How to fill a gap in a single width image?
2 views (last 30 days)
Show older comments
Dear all, I have an 15X1 logical image for example like this:
0 0 0 1 1 0 0 0 1 1 1 1 0 0 0
As we see, the one's are not connected. I want to make a program that connect the gap between the one's similar the the imfill function in matlab but which can be applied in a single width image. In other words, how to get answer like this 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0
I would appreciate it very much to hear some suggestions.
Meshoo
0 Comments
Accepted Answer
Walter Roberson
on 15 Oct 2013
P = find(M, 1, 'first'); %here 1 is number of items to match, not value to match
Q = find(M, 1, 'last');
N = M;
N(P:Q) = 1;
More Answers (0)
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!