I have a set of binary images from which I need to scan their pixel values by column. If there's exactly "x" number of non-zero pixels in a row, the algorithm needs to recognize this in order to draw a line or completely convert all pixels to "1" in the rows where this "x" non-zero pixels were identified. This is in order to close a region of the image and then calculate the area enclosed by it.
I started looping through the image and then saved the pixel values in a variable. Then I added a counter so as to count the total number of non-zero pixels from the column it's analyzing. However I'm having trouble with this loop for the part where it needs to count 5 non-zero pixels in a row. If it's followed by a zero pixel, then it's where the closing should happen, but if it's followed by yet another non-zero pixel, it means it isn't the region of interest. This is what I have so far, but it's doing nothing to the image:
[rows,columns] = size(I3);
Thanks in advance. My matlab skills are just basic and so I have trouble with these kinds of loops.
Any help is greatly appreciated.