# Downsampling a 3D image by 2 in all dimensions

**URL:** https://discourse.vtk.org/t/downsampling-a-3d-image-by-2-in-all-dimensions/7255
**Category:** Support
**Created:** [November 23, 2021, 9:55am UTC](https://discourse.vtk.org/t/downsampling-a-3d-image-by-2-in-all-dimensions/7255 "2021-11-23T09:55:51Z")
**Posts on this page:** 2
**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: [November 23, 2021, 9:55am UTC](https://discourse.vtk.org/t/downsampling-a-3d-image-by-2-in-all-dimensions/7255/1 "2021-11-23T09:55:51Z")

</div>

Dear All,

I want to downsample a MHD (3D, RGB) image by 2 in all dimensions. But because the image is a surface the resulting image is sparse. Has VTK some function to do that with some king of filter (Raised Cosine (??)) that do not have that problem?

Thanks,

Luís Gonçalves.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [November 23, 2021, 2:23pm UTC](https://discourse.vtk.org/t/downsampling-a-3d-image-by-2-in-all-dimensions/7255/2 "2021-11-23T14:23:10Z")

</div>

Try vtkImageResize. It allows you to choose what filter (interpolator) to use.

```auto
  vtkNew<vtkImageSincInterpolator> interpolator;
  // Hann is another name for Raised Cosine
  interpolator->SetWindowFunctionToHann();
  // Perform antialiasing when downsampling
  interpolator->AntialiasingOn();

  vtkNew<vtkImageResize> resize;
  resize->SetInputData(imageData);
  resize->InterpolateOn();
  resize->SetInterpolator(interpolator);
  resize->SetResizeMethodToOutputDimensions();
  resize->SetOutputDimensions(newSize[0], newSize[1], newSize[2]);

```
