# VTK manipulation of image in memory.

**URL:** https://discourse.vtk.org/t/vtk-manipulation-of-image-in-memory/5157
**Category:** Support
**Created:** [February 8, 2021, 8:51pm UTC](https://discourse.vtk.org/t/vtk-manipulation-of-image-in-memory/5157 "2021-02-08T20:51:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.vtk.org/user_avatar/discourse.vtk.org/luis_carlos_carneiro/32/1360_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.vtk.org/u/Luis_Carlos_Carneiro)
#### Post date: [February 8, 2021, 8:51pm UTC](https://discourse.vtk.org/t/vtk-manipulation-of-image-in-memory/5157/1 "2021-02-08T20:51:49Z")

</div>

Dear All,

I have a 3D .mhd file. Then I visualize that file with VTK. I determine a region of that image to crop.  
How I reflect the crop in the visualization.

Have I to crop the .mhd image in memory and redisplay? Are there another ways?  
Which filters to manipulate (crop and other operations) the image in memory?

Thanks,

Luís Gonçalves

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 8, 2021, 9:14pm UTC](https://discourse.vtk.org/t/vtk-manipulation-of-image-in-memory/5157/2 "2021-02-08T21:14:40Z")

</div>

If you use volume rendering then you can set clipping planes based on the ROI. There is no need to modify the volume.

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.vtk.org/user_avatar/discourse.vtk.org/luis_carlos_carneiro/32/1360_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.vtk.org/u/Luis_Carlos_Carneiro)
#### Post date: [February 8, 2021, 9:38pm UTC](https://discourse.vtk.org/t/vtk-manipulation-of-image-in-memory/5157/3 "2021-02-08T21:38:50Z")

</div>

But in the final I want to save to file the clipped volume.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 8, 2021, 9:44pm UTC](https://discourse.vtk.org/t/vtk-manipulation-of-image-in-memory/5157/4 "2021-02-08T21:44:08Z")

</div>

You can use vtkImagePadFilter to cut at current voxel boundaries or use vtkImageReslice for cutting at exact position or with a rotated ROI.
