I have been trying to create a code, but I couldn' t.My idea is an algorithm to find all connected componets using 8 neighbors in a binary image, without using the function "bwlabel". For example, my input matrix is:
a =
1 1 0 0 0 0 0 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0I would to have something like this:
a =
1 1 0 0 0 0 0 1 1 0 0 2 2 0 1 1 0 0 0 2 0 1 1 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0There are 3 connected objects in this image, please Help, anything would be appreciated!
Best Answer