How do I perform edge detection of a bitmap using MFC? I have searched, but I found processes that contained matrices which I could not understand.
+1
A:
sobel operator .....the simplest differentiator: http://en.wikipedia.org/wiki/Sobel_operator
Egon
2010-06-28 05:11:23
i have learned from a site. see is it correct? find the difference for calculating gradient A(x,y)=A(x+1,y)-(x-1,y) thenA(x,y)=((A(x,y)-Amin)/(Amax-Amin))*255where Amin and Amax is the min and max value in the image.
Sweety Khan
2010-06-28 08:15:51
i code this but doest not get the required result.i code A(x,y) as COLORREF rgb = dc.GetPixel(x, y); BYTE A = rgb;
Sweety Khan
2010-06-28 08:20:48
@Sweety Khan: `COLORREF` contains three parts, one for each color component. You can't just convert that to a single byte. Try `BYTE A = BYTE(int(GetRValue(rgb)) + int(GetGValue(rgb)) + int(GetBValue(rgb)) / 3)` . This is effectively a very simple greyscale conversion. As a result, you might not find a red-blue edge.
MSalters
2010-06-28 08:48:40
ok should i do the same or finding Amin and Amax?
Sweety Khan
2010-06-28 09:07:34
i tried to code n i m so near to it. it displays a black background and edges with red color but its not so prominent, i m so near to it, please see n help.
Sweety Khan
2010-06-28 10:17:29
COLORREF rgb = dc.GetPixel(x, y);A =(r+g+b)/3;min = A < min ? A: min;max = A > max ? A: max;
Sweety Khan
2010-06-28 10:18:19
COLORREF rgb = dc.GetPixel(x, y);A =(r+g+b)/3;COLORREF rgb1 = dc.GetPixel(x,y+1);A1 =(r1+g1+b1)/3;COLORREF rgb2 = dc.GetPixel(x,y-1);A2 =(r+g+b2)/3;A = A1-A2;A=((A-min)/(max-min))*255; dc.SetPixel(x,y, A);
Sweety Khan
2010-06-28 10:19:25
both of the codes r in separate loops. waiting for someones response..........
Sweety Khan
2010-06-28 10:20:01
I would strongly suggest that you see the implementation present in openCV http://opencv.willowgarage.com/documentation/cpp/image_filtering.html#index-205you can download the openCV libraries for free and can see the code inside the header files.
Egon
2010-06-29 01:11:08
A:
You don't. Link to an actual cv library, then read up on the canny edge detector
Terry Mahaffey
2010-06-28 07:22:04
i have learned from a site. see is it correct? find the difference for calculating gradient A(x,y)=A(x+1,y)-(x-1,y) thenA(x,y)=((A(x,y)-Amin)/(Amax-Amin))*255where Amin and Amax is the min and max value in the image.
Sweety Khan
2010-06-28 08:16:06
i code this but doest not get the required result.i code A(x,y) as COLORREF rgb = dc.GetPixel(x, y); BYTE A = rgb;
Sweety Khan
2010-06-28 08:21:16