Get Label Number of each pixel

Hi, all
I’m using itkConnectedComponentImageFilter for labeling image and itkLabelToRGBImageFilter for convert from binary image to rgb image based on labeling.
I want to get labels of each pixels, but i don’t know how to do.

In detail, each pixel are image coordinates, for example, {30, 20}, {0, 0}, and so on, and i want to get label of that pixel.

How should i do?

Hi,

Depending on what you want to do, you can acces the pixel’s values of your label image with the GetPixel(itk::Index) method or if you want to parse the full image, you can use an iterator with its Get() method.

HTH,

Tim

1 Like

Thanks, @tim-evain

Which one should I use itkConnectedComponentImageFilter output or itkLabelToRGBImageFilter output?

I solved this problem.
Thank you @tim-evain!!

1 Like