3

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

CC = bwconncomp(BW);
numPixels = cellfun(@numel,CC.PixelIdxList);
...

how to loop for all CC, and for each one, and test if a given pixels belong to it!

1
  • 3
    Share the code you have tried? Commented Mar 26, 2014 at 12:59

1 Answer 1

6

I think you'd be better off representing the connected components as a labeled image

lb = bwlabel( BW );

Now, each pixel in BW has a label (1..N) while background pixels remains 0.
You can test for pixel x,y what is its label:

 lb( y, x )

You can compare the labels of two pixels

 lb( y1, x1 ) == lb( y2, x2 )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.