# Get Label Number of each pixel

**URL:** https://discourse.itk.org/t/get-label-number-of-each-pixel/575
**Category:** Beginner Questions
**Created:** [January 8, 2018, 3:53am UTC](https://discourse.itk.org/t/get-label-number-of-each-pixel/575 "2018-01-08T03:53:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![arwtyxouymz](https://discourse.itk.org/user_avatar/discourse.itk.org/arwtyxouymz/32/379_2.png) [@arwtyxouymz](https://discourse.itk.org/u/arwtyxouymz)
#### Post date: [January 8, 2018, 3:53am UTC](https://discourse.itk.org/t/get-label-number-of-each-pixel/575/1 "2018-01-08T03:53:28Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![tim-evain](https://discourse.itk.org/user_avatar/discourse.itk.org/tim-evain/32/220_2.png) [@tim-evain](https://discourse.itk.org/u/tim-evain)
#### Post date: [January 8, 2018, 9:44am UTC](https://discourse.itk.org/t/get-label-number-of-each-pixel/575/2 "2018-01-08T09:44:19Z")

</div>

Hi,

Depending on what you want to do, you can acces the pixel’s values of your label image with the [GetPixel(itk::Index)](https://itk.org/Doxygen/html/classitk_1_1Image.html#ad424c945604f339130b4ffe81b99738e) method or if you want to parse the full image, you can use an [iterator](https://itk.org/Doxygen/html/classitk_1_1ImageRegionConstIterator.html) with its Get() method.

HTH,

Tim

---

<div class="post-metadata">

### Author: ![arwtyxouymz](https://discourse.itk.org/user_avatar/discourse.itk.org/arwtyxouymz/32/379_2.png) [@arwtyxouymz](https://discourse.itk.org/u/arwtyxouymz)
#### Post date: [January 9, 2018, 5:07am UTC](https://discourse.itk.org/t/get-label-number-of-each-pixel/575/3 "2018-01-09T05:07:40Z")

</div>

Thanks, @tim-evain

Which one should I use itkConnectedComponentImageFilter output or itkLabelToRGBImageFilter output?

---

<div class="post-metadata">

### Author: ![arwtyxouymz](https://discourse.itk.org/user_avatar/discourse.itk.org/arwtyxouymz/32/379_2.png) [@arwtyxouymz](https://discourse.itk.org/u/arwtyxouymz)
#### Post date: [January 9, 2018, 5:21am UTC](https://discourse.itk.org/t/get-label-number-of-each-pixel/575/4 "2018-01-09T05:21:06Z")

</div>

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