[vtkusers] vtkImageReslice and clip

David Gobbi dgobbi at irus.rri.ca
Mon Jul 2 11:34:43 EDT 2001


On Mon, 2 Jul 2001, Peter Böttcher wrote:

> Dear vtk users
>
> I would like to clip a vtkImageData with
> vtkImageReslice->SetOutputExtent(...) or
> vtkImageClip->SetOuputWholeExtent(...)
>
> With values 0,x,y1,y2,z1,z2 every thing works fine. The image is resized
> at the
> right side. When I apply a bigger value than 0 for the min-value
> vtkImageReslice and
> also vtkImageClip produces a black offset instead of resizing the image
> at the left side.

Hi Peter,

The problem isn't with vtkImageClip or vtkImageReslice, but with
vtkImageWindow (or vtkImageViewer, same thing).  The lower-left
corner of the window always corresponds to (0,0,ZSlice), regardless
of where the image extent actually starts.

You can follow vtkImageClip with vtkImageTranslateExtent to shift
the extent back to (0,whatever) after you do the clip.  Or
you can use vtkImageReslice like so:

reslice->SetOutputExtent(0,width-1,0,height-1,0,depth-1)
reslice->SetOutputOrigin(xoffset,yoffset,zoffset)

The above assumes that the image spacing is (1,1,1).  If it is not,
you will have to use the slightly more complicated

reslice->SetOutputExtent(0,width-1,0,height-1,0,depth-1)
reslice->SetOutputOrigin(xoffset*spacing[0],yoffset*spacing[1],...)

 - David





More information about the vtkusers mailing list