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.
John Williams answered .
2025-11-20
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;