# Slicer.util.array: format, grayscale and RGB

**URL:** <https://discourse.slicer.org/t/slicer-util-array-format-grayscale-and-rgb/4312>\
**Category:** Development\
**Tags:** python\
**Created:** [October 7, 2018, 10:57pm UTC](https://discourse.slicer.org/t/slicer-util-array-format-grayscale-and-rgb/4312 "2018-10-07T22:57:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![virginia\_fgc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/virginia_fgc/32/3309_2.png) [@virginia\_fgc](https://discourse.slicer.org/u/virginia_fgc)\
**Post date:** [October 7, 2018, 10:57pm UTC](https://discourse.slicer.org/t/slicer-util-array-format-grayscale-and-rgb/4312/1 "2018-10-07T22:57:48Z")

</div>

Hello,

I am using the Python console to create a script that handles my imported image as an array thanks to:  
`image = slicer.util.array('T2IMAGE')`

The image is in an ‘nrrd’ format, and it’s a T2 weighted MR acquisition. When I use the above clause, I get a 4x256x256 array (dimensions are correct: there are 4 slices with a 256x256 resolution), but I do not understand the values themselves.

I have noticed that the minimum value is 0 and the maximum value is 32767 (using image.max() and image.min()). How does Slicer reads ‘nrrd’ files?

In addition to that doubt, I have the following issue: the image is supposed to be a grayscale image, but I need to change the value of some pixels to a **color**. Hence, is there a way to handle that grayscale image as an RGB?

Thank you very much for any suggestion.  
Kind regards,

Virginia

---

<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:** [October 8, 2018, 4:03am UTC](https://discourse.slicer.org/t/slicer-util-array-format-grayscale-and-rgb/4312/2 "2018-10-08T04:03:13Z")

</div>

> [@virginia\_fgc](#):
>
> I have noticed that the minimum value is 0 and the maximum value is 32767 (using image.max() and image.min()).

This behavior is probably incorrect. Most likely the software that created this nrrd image used incorrect byte ordering (endianness). How did you create the nrrd file?

> [@virginia\_fgc](#):
>
> In addition to that doubt, I have the following issue: the image is supposed to be a grayscale image, but I need to change the value of some pixels to a **color**.

When you segment a volume by “painting” voxels you don’t change voxels of the original volume node but you modify segmentation node overlaid on the original volume, using [Segment Editor module](https://slicer.readthedocs.io/en/latest/user_guide/module_segmenteditor.html).
