[vtkusers] Intersection of two vtkImageData
David Gobbi
david.gobbi at gmail.com
Fri Nov 29 11:24:42 EST 2013
Hi Tony,
If you are using VTK 5.10 or later, you should be able to use
vtkImageReslice to generate a stencil for the overlap. It has a flag,
GenerateOuptutStencilOn(), that will generate a stencil that gives the
overlap region between its input and its output. I use this feature
when I do image registration in VTK, i.e. I use the stencil from
vtkImageReslice as the region over which I compute the image
similarity metric.
Here is roughly what the reslice code looks like:
reslice = vtkImageReslice()
reslice.SetInput(image1) # the image that you want to resample
reslice.SetInformationInput(image2) # the other image
reslice.SetResliceTransform(transform) # transform, if any
reslice.GenerateOutputStencilOn()
reslice.Update()
image3 = reslice.GetOutput() # image1 resampled like image2
stencil = reslice.GetStencilOutput() # stencil for overlap region
Even if you don't use a stencil, vtkImageReslice is a good way of
changing the extent, origin, and spacing of one image so that it
matches another image.
David
On Fri, Nov 29, 2013 at 8:54 AM, Tony <bowler0_uk at yahoo.com> wrote:
> Dear list,
>
> I have two vtkImageData objects. They each show data in the same 3D space each have different spacing, origins, extents and dimensionality, although they do overlap and often one is entirely within the other. I am trying to create a further two images, with the same spacing and dimensionality, containing the contents of the first two images that lie in the region intersected by the two images for quantitative comparison. I have tried using the imagestencil methods without much luck so far. Is this is the right approach? If not is there a better one?
>
> Thanks.
More information about the vtkusers
mailing list