Algorithm:
1)Scan the entire image by moving sequentially along the rows from top to bottom.
2)Whenever we arrive at a foreground pixel p we examine the four neighbours of p which have already been encountered thus far in the scan. These are the neighbours (i) to the left of p, (ii) above p, (iii) the upper left diagonal and (iv) the upper right diagonal.
3)The labelling of p occurs as follows:
i) if all four neighbours are background (i.e. have value 0), assign a new label to p; else
ii) if only one neighbour is foreground (i.e. has value 1), assign its label to p; else
iii) if more than one of the neighbours is foreground, assign one of the labels to p and resolve the equivalences.
#DigitalImageProcessing #MATLAB #ComputerVision
21 авг 2024