[vtk-developers] vtkImageReslice with the problem of slice original

David Gobbi david.gobbi at gmail.com
Fri May 1 00:22:47 EDT 2015


Hi Jason,

This approach does not work well because AutoCropOutputOn() changes
the extent of the output depending on the direction cosines.

In general, it is not possible to do what you are trying to do with a simple
VTK pipeline.  Callbacks or some similar mechanism must be used to
properly update the the slice position every time the direction changes.
Position changes can be accomplished in two ways:
1) by changing the fourth column of the ResliceAxes matrix (this modifies
the position in the "x" coordinate system, i.e. your 3D coordinate system)
2) by changing the OutputOrigin (this modifies the position in x' coords)

As an example, see the UpdatePlane() method of vtkImagePlaneWidget:
http://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Interaction/Widgets/vtkImagePlaneWidget.cxx#l1550

For VTK 5.10 and VTK 6, you can try using the vtkImageResliceMapper.

 - David


On Thu, Apr 30, 2015 at 12:19 PM, Jason <2130220212 at email.szu.edu.cn> wrote:

> Hi, David
>
> I cannot set the parameters like SetOutputOrigin, SetOutputSpacing,and
> SetOutputExtent for vtkImageReslice, as I get a slice image by the cosin
> value and one point's position.It will get a wrong slice if I set these
> paremeters for vtkImageReslice
> static double axialElements[16] = {
>         1, 0, 0, 0,
>         0, 0.866025, -0.5, 0,
>         0, 0.5, 0.866025, 0,
>         0, 0, 0, 1 };
>
> vtkSmartPointer<vtkMatrix4x4> resliceAxes =
> vtkSmartPointer<vtkMatrix4x4>::New();
> resliceAxes->DeepCopy(axialElements);
> resliceAxes->SetElement(0, 3, 10);
> resliceAxes->SetElement(1, 3, 10);
> resliceAxes->SetElement(2, 3, 10);
>
> vtkSmartPointer<vtkImageReslice> reslice =
> vtkSmartPointer<vtkImageReslice>::New();
> reslice->SetInput(connector->GetOutput());
> reslice->SetOutputDimensionality(2);
> reslice->SetResliceAxes(resliceAxes);
> reslice->SetInterpolationModeToLinear();
> reslice->AutoCropOutputOn();
>
> vtkSmartPointer<vtkLookupTable> colorTable =
> vtkSmartPointer<vtkLookupTable>::New();
> colorTable->SetRange(0, 1000);
> colorTable->SetValueRange(0.0, 1.0);
> colorTable->SetSaturationRange(0.0, 0.0);
> colorTable->SetRampToLinear();
> colorTable->Build();
>
> My purpose is to calculate the origin of image(2D) in 3D volume
> position,and
> I can only get the bounds of the slice image through vtkImageActor :
> vtkSmartPointer<vtkImageMapToColors> colorMap =
> vtkSmartPointer<vtkImageMapToColors>::New();
> colorMap->SetLookupTable(colorTable);
> colorMap->SetInputConnection(reslice->GetOutputPort());
>
> vtkSmartPointer<vtkImageActor> imgActor =
> vtkSmartPointer<vtkImageActor>::New();
> imgActor->SetInput(colorMap->GetOutput());
> double extent[6]={0};
> imgActor->GetBounds(extent);
>
> Can I take point'(extent[0],extet[2]) as the original position of the slice
> image ?
> And calculate its corresponding position in 3D volume by  point = M*point'
> ?
>
> I'm not so sure if this is right or not. Maybe there is a way to get the
> original position(2D) by vtkImageReslice itself.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20150430/879b61a8/attachment.html>


More information about the vtk-developers mailing list