# How to Crop vtkImageData using vtkBoxWidget that can living inside or outside?

**URL:** https://discourse.vtk.org/t/how-to-crop-vtkimagedata-using-vtkboxwidget-that-can-living-inside-or-outside/9115
**Category:** Support
**Tags:** code, proposal
**Created:** [August 9, 2022, 11:18am UTC](https://discourse.vtk.org/t/how-to-crop-vtkimagedata-using-vtkboxwidget-that-can-living-inside-or-outside/9115 "2022-08-09T11:18:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wulicheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wulicheng/32/1990_2.png) [@wulicheng](https://discourse.vtk.org/u/wulicheng)
#### Post date: [August 9, 2022, 11:18am UTC](https://discourse.vtk.org/t/how-to-crop-vtkimagedata-using-vtkboxwidget-that-can-living-inside-or-outside/9115/1 "2022-08-09T11:18:03Z")

</div>

I cropped the vtkImageData using vtkBoxWidget (inside), but now I want to crop it outside. How can i do?

auto clippingPlanes = vtkSmartPointer::New();  
clip\_box\_widget\_-\>GetPlanes(clippingPlanes);  
double \*bounds = clippingPlanes-\>GetPoints()-\>GetBounds();

//Cropping  
auto volumeMapper = vtkVolumeMapper::SafeDownCast(clipVolumeData-\>GetMapper());  
volumeMapper-\>CroppingOn();//Enable Crobing  
volumeMapper-\>SetCroppingRegionPlanes(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);  
volumeMapper-\>SetCroppingRegionFlagsToSubVolume();

 ![image](https://discourse.vtk.org/uploads/default/original/2X/8/8b2b600838da49fe910abf313d8f170e09c6a0a0.jpeg)  
  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/2/2c9400caf71107a191631c71501a616e965be83c.png)  

But how should i crop that outside.
