how to find the width of edges in matlab?

I am able to find the edges of an image using sobel or canny filter. But I cant calculate the width of the edges.
Actually I want to do the following:
find the width of all horizontal and vertical edges and sum up altogether and store in a variable, say W1
Then find the width of other (non horizontal and vertical) edges. Then multiply each edge width by a factor sqrt(2). After sum up altogether and store in a variable say w2.
Finally perform (w1+w2)/N where N is the no of total edges in the image.

5 Comments

Did you manager to complete your work? I appreciate if you could show me how you accomplished this. I too have an edge map, as a result of applying the Canny edge detector to a grey-scaled image. I now want to scan each pixel in the image (row-wise), and if I come across an edge, I need to find its local min and max. I need to find the total number of edges + the local min and max values of each and every edge. Can you help please?
I'll tell you how when you ask your own, new question.
Looks like I responded to that 3 weeks ago and you never replied.
Oh, I'm really sorry, I just saw your response. I will reply in that thread. Thanks.

Sign in to comment.

 Accepted Answer

First I'd threshold ats some desired edge strength. Then I'd use bwmorph() to get the skeleton of the edges and call sum() to get the length. Then I'd call bwarea() on the thresholded image to get the area. Divide the area by the length to get the average width of all the edges.

8 Comments

But I want to separate the horizontal and vertical edges from the others edges. As I want to multiply the non horizontal and non vertical edge-width with a factor.
How can I accomplish this. However may I have the code of the technique you have just mentioned above Sir.
Thanks
I suggested bwarea instead of sum because it takes into account the angle of the edge.
Sorry I am unable to find the length for the skeletonized image using the sum(). I have tried this way, is it okay :
X = imread('sample1.jpg');
BW = im2bw(X,0.8);
figure(1),imshow(BW),title('Binary image');
BW2 = bwmorph(BW,'remove'); figure(2), imshow(BW2),title('Interior removed image');
BW3 = bwmorph(BW2,'skel',Inf); figure(3), imshow(BW3),title('skeleton image');
I don't see any edge filtering going on there! Next, why did you call the remove option? I didn't tell you to do that. Then do
skelLength = sum(BW3(:));
shimul
shimul on 25 Aug 2013
Edited: shimul on 25 Aug 2013
Thanks once again. I am getting the value 1.2148e-004 after dividing the area by length and getting the average width of all edges. I think this small value indicate that the input image is sharp. The will be high if the input image is blur. Am I right? The code is like that:
X = imread('sample1.jpg');
BW = im2bw(X,0.8);
figure(1),imshow(BW),title('Binary image');
BW3 = bwmorph(BW,'skel',Inf); figure(3), imshow(BW3),title('skeleton image');
skelLength = sum(BW3(:));
res=bwarea(skelLength);
final=res/skelLength;
disp(final);
But I want to process the (horizontal,vertical) and other edges (non horizontal and non vertical) separately. I want to multiply only the non horizontal and non vertical edges with a factor. And then calculate the average altogether.
How can I do so.
Do you feel like showing us the image? It's customary to provide an image for people to look at when asking advice on images.
This is the image named as sample1.jpg --> http://tinypic.com/view.php?pic=1250um8&s=5
And this is the image named as sample2.jpg --> http://tinypic.com/view.php?pic=2qdaibc&s=5
I am using these two image for my work. My main intention is to calculate the sharpness index according to the paper "Referenceless image quality evaluation for whole sliding imaging" By Mashahiro Yamaguchi et al.
Hello Sir, am I following right way or anything wrong. Actually I very much new on this way. Please provide me with some more suggestions

Sign in to comment.

More Answers (0)

Asked:

on 25 Aug 2013

Commented:

on 5 Jun 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!