MATLAB: Connected component of a given pixel

connected componentimage processingImage Processing Toolbox

i want to find a connected component of a given pixel, and then test if another pixel belong to this component.
Thank you.

Best Answer

% Label the connected components.
labeledImage = bwlabel(binaryImage);
% Check two points to see if they're in the same blob.
if labeledImage(row1, column1) == labeledImage(row2, column2);
% They're the same component.
else
% They're living in different components.
end
Related Question