[vtkusers] Rescaling the voxelised Grid

David Gobbi david.gobbi at gmail.com
Tue May 19 18:15:43 EDT 2015


Hi Nick,

If you want to shrink an image with interpolation and antialiasing, then I
recommend vtkImageResize:

    resize = vtkImageResize()
    resize.SetInputConnection(reader->GetOutputPort())
    resize.SetResizeMethodToOutputDimensions()
    resize.SetOutputDimensions(128, 128, 1)
    resize.Update()

Note that you have to give three output dimensions, so if you have a volume
with 40 slices, you would set the third dimension to 40.  Or, you could use
resize.SetOutputDimensions(128, 128, -1) to tell the filter to leave the
third dimension alone (output number of slices will be the same as the
input number of slices).

I used vtkImageShrink3D before, but like you, I found that I had to shift
the images afterwards (e.g. if I shrunk the image by a factor of 4, then I
had to shift by 1.5 voxels... by inspecting the code, I found that I needed
a shift of 0.5*(N-1) where "N" was my shrink factor.

 - David


On Sat, May 16, 2015 at 1:12 PM, Nick Patterson <pattersonnp.work at gmail.com>
wrote:

> VTK Users,
>
> What would be the appropriate way of resampling a DICOM image from 512x512
> to something like 128x128? I though I had this worked out, but I generated
> a test DICOM image (a number of different sized boxes) and noticed that
> there is some slight offset of the boxes. Is it appropriate to use
> something like vtkImageResample or vtkImageShrink3D to perform this
> operation?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150519/8f457bd4/attachment.html>


More information about the vtkusers mailing list