# How to export number of voxels for different colors in CT images after segmentation?

**URL:** <https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [November 20, 2018, 2:44pm UTC](https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813 "2018-11-20T14:44:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sali](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sali](https://discourse.slicer.org/u/sali)\
**Post date:** [November 20, 2018, 2:44pm UTC](https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813/1 "2018-11-20T14:44:39Z")

</div>

Dear experts

I segmented the human Brain with the editor modules for 100 slices of CT images, manually, now, I need to extract the number of voxels for each color with python or …, how can I do that?  
Thanks

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 20, 2018, 3:37pm UTC](https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813/2 "2018-11-20T15:37:35Z")

</div>

Are you interested in the volume of a segment?

---

<div class="post-metadata">

**Author:** ![sali](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sali](https://discourse.slicer.org/u/sali)\
**Post date:** [November 20, 2018, 4:15pm UTC](https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813/3 "2018-11-20T16:15:04Z")

</div>

Dear Andras,  
I exactly need to know the number of voxels(row and column) of each color(segmented parts in each slice), because, I used these CTs as geometry and I have the distributed energy in each voxel of each slice in a text file. Now,I want to calculate the energy distributed in each part.

---

<div class="post-metadata">

**Author:** ![mag](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@mag](https://discourse.slicer.org/u/mag)\
**Post date:** [November 20, 2018, 7:36pm UTC](https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813/4 "2018-11-20T19:36:24Z")

</div>

Have you tried Segment Statistics already? It returns a lot of information including number of voxels of each segment in a segmentation. You can find it under “Quantification” and all you have to do is select which volume you are working on and which segmentation and it will produce a table with the results.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 21, 2018, 12:11am UTC](https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813/5 "2018-11-21T00:11:31Z")

</div>

> [@sali](#):
>
> I used these CTs as geometry and I have the distributed energy in each voxel of each slice in a text file

If you can save this information in nrrd file format (a plain binary volume and a text file that describes size, position, spacing, etc.) then you can nicely visualize it in Slicer and if you set that as input for Segment Statistics module then you’ll get statistics, such as mean/max/average energy per segment.

---

<div class="post-metadata">

**Author:** ![sali](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sali](https://discourse.slicer.org/u/sali)\
**Post date:** [November 26, 2018, 10:35am UTC](https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813/6 "2018-11-26T10:35:09Z")

</div>

Thanks for your help and sorry for the late reply,  
but the “Quantification” just gave me the volume of that segment, not the number of voxels !!! which one should I use? segment statistic?

---

<div class="post-metadata">

**Author:** ![sali](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sali](https://discourse.slicer.org/u/sali)\
**Post date:** [November 26, 2018, 10:41am UTC](https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813/7 "2018-11-26T10:41:00Z")

</div>

Thanks for your help,  
yes, I save these segments in .nrrd file format, and I converted these binary files as .png file with python, but i could not get good result, is there another way to analyze these data which can find the number of voxels for each segment in each slice?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 26, 2018, 2:30pm UTC](https://discourse.slicer.org/t/how-to-export-number-of-voxels-for-different-colors-in-ct-images-after-segmentation/4813/8 "2018-11-26T14:30:54Z")

</div>

Segment statistics gives you the number of voxels. If you need number of voxels (cross-section area by slice) then you can find a readily usable solution here: [Using numpy reslice to get slices of segment](https://discourse.slicer.org/t/using-numpy-reslice-to-get-slices-of-segment/2257/3)
