I have an image and divide this image into blocks, I apply connected component function called "bwconncomp" to each block, I need to store the PixelIdxList field of the structure produced from function "bwconncomp" for each block?
the function bwconncomp returns a structure with 4 fields :
- Connectivity: connectivity of the connected components (can be defined with an input variable)
- ImageSize: size of the image
- NumObjects: number of connected objects found in the image
- PixelIdxList: a cell array which contains the linear indices of the objects (the indices of the kth object are in PixelIdxList{k}).
If you want to acces to an object of a specific block, and find it in the whole image, you "just" have to add the x and y offset that define the position of the block in the whole image. Take care with the indices in PixelIdxList: linear indices, not row-column indices!
We see that 2 objects have been found. "CC.PixelIdxList{1}" gives the linear indices of the first object, and "CC.PixelIdxList{2}" the linear indices of the second object.
For example, I create the variable L1 which contains the linear indices of the first object:
L1 = CC.PixelIdxList{1};
I also can transform the linear indices L1 in row-colomn indices (X1,Y1):