EmguCV图像旋转 [英] EmguCV image rotation

查看:536
本文介绍了EmguCV图像旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码

i use this code

private void button12_Click(object sender, EventArgs e)
{
    Bitmap bm = new Bitmap(pictureBox1.Image);
   Image<Gray, byte> img = new Image<Gray, byte>(bm);
    double x = 20;
    img.Rotate(x, new Gray(255));
    pictureBox9.Image = img.ToBitmap();

}


用于图像旋转的


但它不起作用,

为什么????


for image rotation
but it doesn't work ,
why????

推荐答案

点击此链接:http://www.emgu.com/wiki/files/1.4.0.0/html/ae9c1603-5135-1a2f-bd46-1dd736d4d7a8.htm [ ^ ]



您会看到Rotate方法也有一个名为 crop 的参数,将此参数设置为false以及您的所有信息图像将被保留。



我认为你的代码应改为:

follow this link: http://www.emgu.com/wiki/files/1.4.0.0/html/ae9c1603-5135-1a2f-bd46-1dd736d4d7a8.htm[^]

You will see the Rotate method also has an argument called crop, set this argument false and all information of your image will be preserved.

I think your code should be changed into:
img = img.Rotate(x, new Gray(255),false);



希望这会对你有帮助!


Hope this will help you!


你可能需要试试这个:

图像<灰色,字节> imgOut = img.Rotate(x,new Gray(255));

pictureBox9.Image = imgOut.ToBitmap();



I没有编译,即使我的机器上有emgucv,但我查看了他们的libray。我相信你应该像我上面所说的那样打电话。



看看他们的实现:

public Image< TColor,TDepth> WarpAffine< TMapDepth>(矩阵< TMapDepth> mapMatrix,int width,int height,INTER interpolationType,WARP warpType,TColor backgroundColor)其中TMapDepth:new()

{

Image< ; TColor,TDepth> image = new Image< TColor,TDepth>(宽度,高度);

//此调用externs c函数

CvInvoke.cvWarpAffine(base.Ptr,image.Ptr, mapMatrix.Ptr,(int)(interpolationType |((INTER)((int)warpType))),backgroundColor.MCvScalar);

返回图片;

}
You may have to try this:
Image<Gray,Byte> imgOut= img.Rotate(x, new Gray(255));
pictureBox9.Image= imgOut.ToBitmap();

I did not compile, even though i have emgucv on my machine, but I looked into their libray. I believe you should call like I said above.

see their implementation:
public Image<TColor, TDepth> WarpAffine<TMapDepth>(Matrix<TMapDepth> mapMatrix, int width, int height, INTER interpolationType, WARP warpType, TColor backgroundColor) where TMapDepth: new()
{
Image<TColor, TDepth> image = new Image<TColor, TDepth>(width, height);
//this call externs c function
CvInvoke.cvWarpAffine(base.Ptr, image.Ptr, mapMatrix.Ptr, (int) (interpolationType | ((INTER) ((int) warpType))), backgroundColor.MCvScalar);
return image;
}


嗯,如果它不起作用。

问题不是那个问题。



改变这一行

img.Rotate(x,new Gray(255));



to

img = img.Rotate(x,new Gray(255));
Well, in case of "it doesn't work".
The problem is not that complected.

change this line
img.Rotate(x, new Gray(255));

to
img = img.Rotate(x, new Gray(255));


这篇关于EmguCV图像旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆