cv图像翻转,EmguCV图像旋转「建议收藏」

iusethiscodeprivatevoidbutton12_Click(objectsender,EventArgse){Bitmapbm=newBitmap(pictureBox1.Image);Imageimg=newImage(bm);doublex=20;img.Rotate(x,newGray(255));pictureBox9.Image…

大家好,又见面了,我是你们的朋友全栈君。

cv图像翻转,EmguCV图像旋转「建议收藏」

i use this codeprivate void button12_Click(object sender, EventArgs e)

{

Bitmap bm = new Bitmap(pictureBox1.Image);

Image img = new Image(bm);

double x = 20;

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

pictureBox9.Image = img.ToBitmap();

}

for image rotation

but it doesn’t work ,

why????

解决方案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!

You may have to try this:

Image 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 WarpAffine(Matrix mapMatrix, int width, int height, INTER interpolationType, WARP warpType, TColor backgroundColor) where TMapDepth: new()

{

Image image = new Image(width, height);

//this call externs c function

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

return image;

}

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));

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/127844.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号