[vtkusers] vtkimagereslicemapper to get exact slice

David Gobbi david.gobbi at gmail.com
Fri Mar 7 14:24:27 EST 2014


You see the ROI on two slices because vtkImageResliceMapper is
performing interpolation between the slices (the mapper does
trilinear interpolation).

To ensure out-of-plane interpolation doesn't happen, you need to do
two things:

1) Do not use SetSlabThickness().

2) Use JumpToNearestSliceOn().

The "JumpToNearesetSlice" causes it to display the image slice
that is closest to your chosen plane, rather than interpolating between
the two closest slices.

Let me know if this solves the issue.

  David


On Fri, Mar 7, 2014 at 9:05 AM, chasank <chasank at gmail.com> wrote:
> Hi,
>
> I coded to draw and save rectangle roi as a nifti file. I have no problem of
> drawing and saving rectangle roi. After I draw roi on an axial (xy plane)
> slice and save it as nifti file with range [0, 1], when I try to display the
> saved roi file on renderer, the roi is displayed not only on the slice I
> drew but also on the previous slice. In other words, it is displayed on two
> consecutive slices. A piece of code that I wrote to display the saved roi:
>
> void Display(vtkImageData *imageData, vtkRenderer *renderer, vtkImageStack
> *imageStack, int layerIndex, ORIENTATION_TYPE orientationType)
> {
>     double spacing[3];
>     imageData->GetSpacing(spacing);
>
>     imageResliceMapper->SetInputData(imageData);
>     imageResliceMapper->SliceFacesCameraOff();
>     imageResliceMapper->SliceAtFocalPointOff();
>     imageResliceMapper->SetImageSampleFactor(2);
>     imageResliceMapper->BorderOn();
>     imageResliceMapper->BackgroundOn();
>
>     double *center = imageData->GetCenter();
>     vtkPlane *plane = this->imageResliceMapper->GetSlicePlane();
>     plane->SetOrigin(center);
>
>     if(orientationType == ORIENTATION_TYPE::AXIAL)
>     {
>         plane->SetNormal(0.0, 0.0, 1.0);
>         imageResliceMapper->SetSlabThickness(spacing[2]);
>     }
>     else if(orientationType == ORIENTATION_TYPE::CORONAL)
>     {
>         plane->SetNormal(0.0, 1.0, 0.0);
>         imageResliceMapper->SetSlabThickness(spacing[1]);
>     }
>     else if(orientationType == ORIENTATION_TYPE::SAGITTAL)
>     {
>         plane->SetNormal(1.0, 0.0, 0.0);
>         imageResliceMapper->SetSlabThickness(spacing[0]);
>     }
>
>     imageResliceMapper->UpdateInformation();
>     imageResliceMapper->Modified();
>
>     double windowLevel[2];
>     histogramRepresentation->SetRenderer(renderer);
>     histogramRepresentation->SetImageData(imageData);
>     histogramRepresentation->BuildRepresentation();
>     histogramRepresentation->GetOptimumWindowLevel(windowLevel);
>
>     imageProperty->SetLayerNumber(layerIndex);
>     imageProperty->SetColorLevel(windowLevel[1]);
>     imageProperty->SetColorWindow(windowLevel[0]);
>     imageProperty->SetLookupTable(lookupTable);
>     imageProperty->SetInterpolationTypeToLinear();
>     imageProperty->SetAmbient(1.0);
>     imageProperty->SetDiffuse(1.0);
>     imageProperty->SetOpacity(1.0);
>
>     imageSlice->SetMapper(imageResliceMapper);
>     imageSlice->SetProperty(imageProperty);
>     imageSlice->Update();
>
>     imageStack->AddImage(imageSlice);
>     imageStack->Update();
> }
>
> I also tried to display saved roi with Osirix and it is displayed well. The
> roi is displayed on the slice I drew it. So, there is no problem in creating
> roi and saving roi data. Probably, I could not configure
> vtkImageResliceMapper with using its necessary methods. So, please guide me
> to find where I did the mistake.


More information about the vtkusers mailing list