[vtkusers] save slice from vtk image volume
David Gobbi
david.gobbi at gmail.com
Wed Dec 4 09:48:08 EST 2013
On Wed, Dec 4, 2013 at 7:05 AM, Jesse Ross-Jones <jesse.rj at gmail.com> wrote:
> Hi David,
> Thanks for the reply. In that case I would need to render the image to the
> window and set the camera origin and direction to point to the image then
> save that to a file?
If you use vtkImageResliceMapper to get the slice, then yes, the only
way to capture the slice is to render it to a window and then save the
window's contents to a file.
> I have been trying with the vtkProbefilter to extract the image that I want.
> I am using the same plane origin and normal as before.
>
>
> vtkSmartPointer<vtkPlaneSource> PlaneSource =
> vtkSmartPointer<vtkPlaneSource>::New();
> PlaneSource->SetCenter(testpoint2);
> PlaneSource->SetNormal(normal2);
>
> vtkPolyData *Plane = PlaneSource -> GetOutput();
>
> vtkProbeFilter *Probe = vtkProbeFilter::New();
>
> Probe->SetInput(Plane);
> Probe->SetSource(reader->GetOutput());
> //Probe->SetInputConnection(reader->GetOutputPort);
> Probe->SpatialMatchOn();
> Probe->Update();
>
> However, with this method it seems I can only seem to be able to save a
> vtkpolydata file of the plane. Is it possible to use the vtkProbeFilter to
> obtain a slice of an image volume?
A vtkProbeFilter's output is always the same geometry as the input.
So if you want vtkProbeFilter to produce an image, you need to set its
input to a vtkImageData. But then you run into a problem, because you
cannot set the "normal" of a vtkImageData, so you won't be able to
extract an oblique slice.
I suggest that you use vtkImageReslice (the filter, not the mapper) to
extract a slice from your data. The VTK source code contains an
example:
Examples/ImageProcessing/Python/ImageSlicing.py
David
>
> Many thanks,
> Jesse
More information about the vtkusers
mailing list