How to find width at certain pixel value in an image

I need to find the width at these positions in pixels although these can be found manually I need to compute this in matlab without manual intervention. I had written the code using improfile but the user needs to manually select the points and run the code three times to get the value. Kindly help me with this. Thank you in advance.

 Accepted Answer

Use the edge() command. Then, for each desired x-position, take the y-position of the 3rd edge from the top.

6 Comments

Matt, could you please elaborate. I did not understand the y-position part.
In any desired column of the edge map, you just have to find the 3rd non-zero value, e.g.,
load image
edge_Image=edge(Image);
col = 190; %desired column
nz = find(edge_Image(:,col));
width=nz(3);
imshow(edge_Image);
drawline('Position',[col 1; col width],'Color','c');
Appreciate your help. I understood the point clearly. Thanks again!
I have another doubt Matt, could you please tell me how to convert the jpg image to .mat format.I tried but the value and class is 1*1 cell and double. Please help me with this
Appreciate your help, will try this. Thank you for responding.

Sign in to comment.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!