# How to extract the dataArray values within a rectangleWidget or shapewidget in vtk.js?

**URL:** https://discourse.vtk.org/t/how-to-extract-the-dataarray-values-within-a-rectanglewidget-or-shapewidget-in-vtk-js/8679
**Category:** Development
**Created:** [June 8, 2022, 8:41am UTC](https://discourse.vtk.org/t/how-to-extract-the-dataarray-values-within-a-rectanglewidget-or-shapewidget-in-vtk-js/8679 "2022-06-08T08:41:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Sneha-pk](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sneha-pk/32/4216_2.png) [@Sneha-pk](https://discourse.vtk.org/u/Sneha-pk)
#### Post date: [June 8, 2022, 8:41am UTC](https://discourse.vtk.org/t/how-to-extract-the-dataarray-values-within-a-rectanglewidget-or-shapewidget-in-vtk-js/8679/1 "2022-06-08T08:41:52Z")

</div>

I am trying to develop a region of interest/ROI and a histogram(Piecewise Gussian Widget) corresponding to that ROI. Is there a way to extract the vtkImageData within the region or the dataArray within the ROI?

Thanks in advance.

---

<div class="post-metadata">

### Author: ![mau\_igna\_06](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mau_igna_06/32/8064_2.png) [@mau\_igna\_06](https://discourse.vtk.org/u/mau_igna_06)
#### Post date: [June 8, 2022, 12:27pm UTC](https://discourse.vtk.org/t/how-to-extract-the-dataarray-values-within-a-rectanglewidget-or-shapewidget-in-vtk-js/8679/2 "2022-06-08T12:27:09Z")

</div>

I would suggest you try to prototyptñe it on Slicer first

You have labelmaps segmentation tools and filters, all you need

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [June 8, 2022, 2:52pm UTC](https://discourse.vtk.org/t/how-to-extract-the-dataarray-values-within-a-rectanglewidget-or-shapewidget-in-vtk-js/8679/3 "2022-06-08T14:52:46Z")

</div>

@mau_igna_06 except the JS part as slicer is based on VTK C++.

If you ROI is IJK based, you should be able to easily iterate through your array with 3 nested loops to compute the proper 1D array index.
