vtkImageReslice usage

Dear all,
I am having some doubts on vtkImageReslice. I am working in python. I would like not just to resample the image but also to crop the result to a box of size (10,10,20) centered in the origin (the box is much smaller than the original image). I could move and rotate as I wanted, but I could not manage to crop the final image (I guess by using something like reslice.SetOutputExtent(-5,5,-5,5,-10,10) but this does not work)

I am making a downsample and need to conserve the integral of the scalars. The original image has a spacing that depends on the run but in general is of (0.9,0.9,3) and the output of the reslice is (4,4,4), I need that the output image values of the reslice have the integral of the resampled scalars . Is that possible? How vtkImageReslice does interpolate while downsampling?

I do not only need to show the resulting image, but also get the output values for processing.

I am working with an image data named imdata, and the translation and rotation I need for the image is in a 4x4 numpy array named affineMatrix. The relevant part of the code is:

    reslice = vtk.vtkImageReslice()
    matrix = vtk.vtkMatrix4x4()

kind regards,

I could find a solution, so I reply to myself just in case someone has the same issue.

My problem was that after the reslice, the output image will have a different extent (size in pixels) and a different origin (in my case milimeters, and this is the position of voxel 0,0,0 ). I have extracted that data, and computed the voxel range that should be extracted and used a vtkImageClip:


range=computeRange(origin, extent)   # just (Xmin-origin[0])/spacing[0], (Xmax-origin[0])/spacing[0], (Ymin....
                                     # where the output box has coordinates range (Xmin,Xmax,Ymin, Ymax, Zmin, Zmax)
                                     # and check that the range is within imdata extent
clipping.ClipDataOn() # get rid of data outside the region of interest

and the output of clipping is what I need, just the data within an arbitrary transformed box.

I could not find the way to integrate instead of interpolating for the downsampling. I will make fine voxels and join them in bigger voxels integrating with numpy for my calculations.