【发布时间】:2019-09-03 12:15:12
【问题描述】:
我有几张小图像,我希望它们的像素大小正好为 100x100,无需缩放。为了实现这一点,我正在创建一个白色的 100x100 图像并将小图像复制到其中。
我的代码:
/*Small image*/
Emgu.CV.Mat Char = new Emgu.CV.Mat();
/*...fill small Image with stuff...*/
/*Create black Image (don't know how to create a White Image)*/
FinalChar = Emgu.CV.Mat.Zeros(100, 100, Emgu.CV.CvEnum.DepthType.Cv8U, 1);
/*Invert Image to become white*/
Emgu.CV.CvInvoke.BitwiseNot(FinalChar, FinalChar);
/*Copy small Image to large Image starting at row 5 and column 5*/
Char.CopyTo(FinalChar.Row(5).Col(5)); /*This is NOT working... Image 'Finalchar' is still White.*/
请不要告诉我这个帖子:OpenCV draw an image over another image
我不知道,但 rowRange 和 colRange 不是 Emgu.CV 的一部分。
这里有一个小例子,你可以复制试试看:
/*Create small black image*/
Emgu.CV.Mat Small = Emgu.CV.Mat.Zeros(10, 10, Emgu.CV.CvEnum.DepthType.Cv8U, 1);
/*Create large white image*/
Emgu.CV.Mat Large = Emgu.CV.Mat.Zeros(20, 20, Emgu.CV.CvEnum.DepthType.Cv8U, 1);
Emgu.CV.CvInvoke.BitwiseNot(Large, Large);
/*Copy small, black image to large white image at 5,5 - the large image should
now contain a black rect in its center*/
Small.CopyTo(Large.Row(5).Col(5));
Emgu.CV.CvInvoke.NamedWindow("Output", Emgu.CV.CvEnum.NamedWindowType.AutoSize);
Emgu.CV.CvInvoke.Imshow("Output", Large);
Emgu.CV.CvInvoke.WaitKey();
return;
【问题讨论】:
-
如果您能提供minimal reproducible example,那就太好了。