# Convert voxels to grayscale

**URL:** <https://discourse.slicer.org/t/convert-voxels-to-grayscale/12376>\
**Category:** Development\
**Created:** [July 5, 2020, 1:12am UTC](https://discourse.slicer.org/t/convert-voxels-to-grayscale/12376 "2020-07-05T01:12:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![talmazov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/talmazov/32/3966_2.png) [@talmazov](https://discourse.slicer.org/u/talmazov)\
**Post date:** [July 5, 2020, 1:12am UTC](https://discourse.slicer.org/t/convert-voxels-to-grayscale/12376/1 "2020-07-05T01:12:26Z")

</div>

Hey,  
I am using  
slicer.util.arrayFromVolume  
to obtain an array of my slice widget view. However, the array contains voxel data, how can i convert that to RGB grayscale?

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:** [July 5, 2020, 1:56am UTC](https://discourse.slicer.org/t/convert-voxels-to-grayscale/12376/2 "2020-07-05T01:56:46Z")

</div>

I don’t know what you mean by “RGB grayscale”.

If your volume is a scalar volume (i.e., each voxel of the volume is a scalar, not a vector) then `slicer.util.arrayFromVolume` returns a 3D array.

If you want the displayed slice, with current window/level, opacity settings, all the overlays then you can get the 24-bit RGB image using [Screen Capture module’s logic](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Capture). This is intended for presentations, slide shows, etc., not for computation, because all the display settings (window/level, overlays, etc.) are burnt into the displayed image.

---

<div class="post-metadata">

**Author:** ![talmazov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/talmazov/32/3966_2.png) [@talmazov](https://discourse.slicer.org/u/talmazov)\
**Post date:** [July 30, 2020, 9:57pm UTC](https://discourse.slicer.org/t/convert-voxels-to-grayscale/12376/3 "2020-07-30T21:57:18Z")

</div>

the screen capture module is what i needed!  
Thanks!
