[英]How to apply cvsobel + emgucv
I am having some problems in using the cvsobel function. 我在使用cvsobel函数时遇到了一些问题。 I have read that the cvsobel
increases the image depth from 8 bit to 16bit... 我已经读过cvsobel
将图像深度从8位增加到16位......
Can somebody help me figure out how i can scale it back to 8 bit ... 有人可以帮我弄清楚我怎么能把它缩回到8位......
My code is 我的代码是
Image<Gray, Byte> grayImage = TestImage.Convert<Gray, Byte>().PyrDown().PyrUp(); ;
Image<Gray, Byte> Dest = new Image<Gray, Byte>(grayImage.Size);
Image<Gray, Byte> SobelHorizontal = new Image<Gray, Byte>(grayImage.Size);
CvInvoke.cvCanny(grayImage, Dest, 10, 60, 3);
CvInvoke.cvSobel(Dest, SobelHorizontal, 1, 0, 3); // introduces exception
where TestImage
is a color image I take from the user. 其中TestImage
是我从用户那里TestImage
的彩色图像。
The problem here i think is with the declaration of SobelHorizontal
... How do i give a 16 bit depth here and make the function work.. 我认为这里的问题是SobelHorizontal
的声明...我如何在这里给出16位深度并使功能正常工作..
Well EMGU actually has sobel and canny implementations in C#: 那么EMGU实际上在C#中有sobel和canny实现:
//grayImage.Canny(Gray thresh, Gray threshelinking)
grayImage.Canny(new Gray(10), new Gray(60));
//grayImage.Sobel(int xorder, intyorder, int aptureSize)
grayImage.Sobel(1, 0, 3);
This Should do as you want without the difficulties you face however as vasile mentioned you can declare the data type of your image however you like 这应该按照您的意愿进行,没有您遇到的困难,但是如同提及的那样,您可以根据需要声明图像的数据类型
Image<Gray,short> Image<Gray,double>, or Image<Gray,float>.
Cheers, 干杯,
Chris 克里斯
You can set it directly too. 你也可以直接设置它。
Example: 例:
Image<Emgu.CV.Structure.Gray, byte> objImagemTemplate = new Image<Emgu.CV.Structure.Gray, byte>(objBitmapTemplate); // Image A
objImagemTemplate = (objImagemTemplate.Canny(new Gray(10), new Gray(60)).Sobel(1, 0, 1)).Convert<Gray, Byte>();
Define SobelHoriz as 将SobelHoriz定义为
Image<Gray, short>
, or whatewer is named the 16 bit integer in C#. 或者,whatewer被命名为C#中的16位整数。 Then use the image.convertTo() function to get it back to gray: 然后使用image.convertTo()函数将其恢复为灰色:
Image<gray, byte> sobelDisplay;
sobelHoriz.convertTo(sobelDisplay);
I do not know how you call it in C#. 我不知道你是怎么称它为C#的。 In c++, the image object has a convertTo() member 在c ++中,image对象有一个convertTo()成员
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.