# How to crop 3D image from a 2D free-hand ROI?

**URL:** https://discourse.vtk.org/t/how-to-crop-3d-image-from-a-2d-free-hand-roi/2468
**Category:** Support
**Created:** [January 21, 2020, 1:45pm UTC](https://discourse.vtk.org/t/how-to-crop-3d-image-from-a-2d-free-hand-roi/2468 "2020-01-21T13:45:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [January 21, 2020, 1:45pm UTC](https://discourse.vtk.org/t/how-to-crop-3d-image-from-a-2d-free-hand-roi/2468/1 "2020-01-21T13:45:02Z")

</div>

When analysis 3D image data by rendering, some tissue is unconcerned and it would distrub the analysis. Thus, I want to crop the image by a free-hand ROI just like RadiAnt:

 ![捕获](https://discourse.vtk.org/uploads/default/original/2X/d/dd9440c60ee4effc90a2b949c236114e80c1d2e0.png)

In the above picture, the green polygon is the ROI, and I want to crop the outside image. The result would be:

 ![1](https://discourse.vtk.org/uploads/default/original/2X/4/49808593a5d5eda28a0899dc34bed88f74a82d1d.png)

And we can focus on the intrested arteries.

If I have the vtkImageData and the 2D coordiante of ROI, how can I crop the image? Does anybody implement the similar function?

---

<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: [January 21, 2020, 3:57pm UTC](https://discourse.vtk.org/t/how-to-crop-3d-image-from-a-2d-free-hand-roi/2468/2 "2020-01-21T15:57:33Z")

</div>

This feature is implemented in 3D Slicer (Segment Editor / Scissors effect). You can use it as is, or use the [source code](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/EditorEffects/qSlicerSegmentEditorScissorsEffect.cxx) in your application, or customize Slicer to do exactly what you need.

---

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [January 27, 2020, 10:23am UTC](https://discourse.vtk.org/t/how-to-crop-3d-image-from-a-2d-free-hand-roi/2468/3 "2020-01-27T10:23:21Z")

</div>

It is a little hard for me to retrive the correct pipeline to crop the image by 2D ROI. Could you please tell me briefly about the pipelien so that I can find the details from the source code.

---

<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: [January 27, 2020, 7:26pm UTC](https://discourse.vtk.org/t/how-to-crop-3d-image-from-a-2d-free-hand-roi/2468/4 "2020-01-27T19:26:49Z")

</div>

You may add a few breakpoints and step through the code using the debugger to see how it works exactly.

If you find this too complicated and you are implementing a medical imaging application then probably it would make more sense to create your application by customizing/extending Slicer. It has been developed exactly for this purpose for decades, and for tens of millions of dollars.

---

<div class="post-metadata">

### Author: ![Linfeng\_Song](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linfeng_song/32/2247_2.png) [@Linfeng\_Song](https://discourse.vtk.org/u/Linfeng_Song)
#### Post date: [August 28, 2020, 2:50am UTC](https://discourse.vtk.org/t/how-to-crop-3d-image-from-a-2d-free-hand-roi/2468/5 "2020-08-28T02:50:49Z")

</div>

Hello,have you implemented this feature yet

---

<div class="post-metadata">

### Author: ![yuxing55555](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yuxing55555/32/2234_2.png) [@yuxing55555](https://discourse.vtk.org/u/yuxing55555)
#### Post date: [August 28, 2020, 5:48am UTC](https://discourse.vtk.org/t/how-to-crop-3d-image-from-a-2d-free-hand-roi/2468/6 "2020-08-28T05:48:46Z")

</div>

> **[VTK体切割动画](https://zhuanlan.zhihu.com/p/121444689)**
>
> 对体进行任性形状的切割 体切割原理：

---

<div class="post-metadata">

### Author: ![NeuZhangQiang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/neuzhangqiang/32/2248_2.png) [@NeuZhangQiang](https://discourse.vtk.org/u/NeuZhangQiang)
#### Post date: [August 28, 2020, 5:58am UTC](https://discourse.vtk.org/t/how-to-crop-3d-image-from-a-2d-free-hand-roi/2468/7 "2020-08-28T05:58:33Z")

</div>

Is the code available?
