# 2D image on one slice

**URL:** <https://discourse.slicer.org/t/2d-image-on-one-slice/15771>\
**Category:** Development\
**Created:** [February 1, 2021, 12:58pm UTC](https://discourse.slicer.org/t/2d-image-on-one-slice/15771 "2021-02-01T12:58:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikoskot](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nikoskot](https://discourse.slicer.org/u/nikoskot)\
**Post date:** [February 1, 2021, 12:58pm UTC](https://discourse.slicer.org/t/2d-image-on-one-slice/15771/1 "2021-02-01T12:58:37Z")

</div>

Hello,  
I would like to display a 2D image stored in a 3D numpy array (RGB image) only in one of the slices (for example the Red slice).

```
img = np.zeros((50,50,3))
img[10:40,20:30, 0] = 200 # saturate a part of the first channel
new_volume_node = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeNode")
slicer.util.updateVolumeFromArray(new_volume_node, img)
slicer.app.layoutManager().sliceWidget('Red').sliceLogic().GetSliceCompositeNode().SetForegroundVolumeID(new_volume_node.GetID())

```

With the code above each dimension of the array is connected to one of the slices (1st dimension to Red, 2nd to Green, 3rd to Yellow). Is there a way to display the whole image to one 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:** [February 1, 2021, 2:55pm UTC](https://discourse.slicer.org/t/2d-image-on-one-slice/15771/2 "2021-02-01T14:55:23Z")

</div>

To display an RGB volume, you need to create a `vtkMRMLVectorVolumeNode` and array dimensions must be [dimZ, dimY, dimX, 3].
