# Extract all 2D slices from Binary labelMap

**URL:** <https://discourse.slicer.org/t/extract-all-2d-slices-from-binary-labelmap/12417>\
**Category:** Development\
**Created:** [July 7, 2020, 2:46pm UTC](https://discourse.slicer.org/t/extract-all-2d-slices-from-binary-labelmap/12417 "2020-07-07T14:46:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![loubna](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@loubna](https://discourse.slicer.org/u/loubna)\
**Post date:** [July 7, 2020, 2:46pm UTC](https://discourse.slicer.org/t/extract-all-2d-slices-from-binary-labelmap/12417/1 "2020-07-07T14:46:20Z")

</div>

Hi,

I have 3D vtkImageData (binarylabelMap) from which, I want extract all 2D slices. How can I do that

thank’s in advance

---

<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 8, 2020, 12:19pm UTC](https://discourse.slicer.org/t/extract-all-2d-slices-from-binary-labelmap/12417/2 "2020-07-08T12:19:03Z")

</div>

Probably the simplest is to get the voxels as numpy array using `a=slicer.util.arrayFromVolume(volumeNode)`. Then you can extract a slice using numpy array indexing, for example the 6th slice is `a[:,:,5]`.

---

<div class="post-metadata">

**Author:** ![loubna](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@loubna](https://discourse.slicer.org/u/loubna)\
**Post date:** [July 9, 2020, 6:46pm UTC](https://discourse.slicer.org/t/extract-all-2d-slices-from-binary-labelmap/12417/3 "2020-07-09T18:46:51Z")

</div>

Thank you very much Mr for reply
