reduce a width line to a small line by matrix operation

1 view (last 30 days)
Hey,
I would like to reduce a width line to a smaller line. In the picture the big widh one to the little red one. Therefore I have the following Idea: I is the Image.
% find rows and columns with zeros
[row,col] = find(I~=1);
A=[row,col];
Now I have a Matrix A=[1 2;1 3; 1 4; 2 3; 2 5; 2 7] There I am looking for the A(1,:) values. If they is an value repeating I will take it and calculate the middle of the belonging values A(1,:).
But I am not sure how to do it...
Than I will store just one value of the repeating value of A together with the middle Value in the Matrix an delete the other values.

Answers (1)

Image Analyst
Image Analyst on 22 May 2014
Use bwmorph() with the 'skel' option.
  2 Comments
Image Analyst
Image Analyst on 23 May 2014
Edited: Image Analyst on 23 May 2014
Jana's "Answer" moved here:
Unfortunately I can't use bwmorph(). Because my line is not always looking such idle like this I draw. Sometimes it is more like this. With bwmorph() I would loose a part of my line.
Sry for not describing clear enough the problem
Image Analyst
Image Analyst on 23 May 2014
You would not lose it if it's not broken. If it is broken into multiple pieced you have to decide if you want that, and they're supposed to be multiple pieces, or it you want to try to reconnect the pieces. If you want to reconnect, then use imclose() before using bwmorph().

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!