[vtkusers] vtkImageReslice and vtkImageViewer vs. vtkImageViewer2
Todd Baker
tbaker at claritysolutionsllc.com
Tue Jun 17 21:52:03 EDT 2003
Hello All:
Thanks for a toolkit that seems to have tons of useful
functionality... once I learn how to use it:)
I have set up a pipeline to show three orthogonal views of a dataset. I
know this question is on the list many times, but I've tried many of the
solutions to no avail.
If I just use a vtkImageViewer I get all three views and can slice
through the dataset fine. If I use a vtkImageViewer2 with the same
pipeline I get nothing. But in reality, neither of them really suits my
need so I've set up the following pipeline so that I can use a
vtkImageBlend at the end to show the results of two registered datasets.
The result of the pipeline below is the ability to get a few partial
slices of the transverse view that are in the top right corner (not the
bottom left as with the same spacing and origin using a vtkImageViewer).
I get no visible slices in the coronal or sagittal view. Any hints on
what I've missed? I think that I have a misunderstanding of when the 3D
dataset is actually "sliced" into a 2D dataset... should this be in the
reslicer or in the image actor?
Thanks in advance for your help.
Todd Baker
tbaker at claritysolutionsllc.com
// function importing a pointer to an imported data array
GetFixedVolumeData(PFixedVolumeData);
NativeDim[0] = PFixedVolumeSpecs->XDim;
NativeDim[1] = PFixedVolumeSpecs->YDim;
NativeDim[2] = PFixedVolumeSpecs->ZDim;
VolumeImportFilter->SetImportPointer( PFixedVolumeData,
NativeDim[0] *
NativeDim[1] *
NativeDim[2], false);
// set up size
NativeSize[0] = NativeDim[0];
NativeSize[1] = NativeDim[1];
NativeSize[2] = NativeDim[2];
// set up start
NativeStart.Fill(0);
// set default region
NativeRegion.SetIndex( NativeStart);
NativeRegion.SetSize ( NativeSize );
VolumeImportFilter->SetRegion( NativeRegion );
NativeSpacing[0] = PFixedVolumeSpecs->XSpacing;
NativeSpacing[1] = PFixedVolumeSpecs->YSpacing;
NativeSpacing[2] = PFixedVolumeSpecs->ZSpacing;
VolumeImportFilter->SetSpacing ( NativeSpacing );
NativeOrigin[0] = - PFixedVolumeSpecs->XDim *
PFixedVolumeSpecs->XSpacing * 0.5;
NativeOrigin[1] = - PFixedVolumeSpecs->YDim *
PFixedVolumeSpecs->YSpacing * 0.5;
NativeOrigin[2] = - PFixedVolumeSpecs->ZDim *
PFixedVolumeSpecs->ZSpacing * 0.5;
VolumeImportFilter->SetOrigin( NativeOrigin );
VolumeImportFilter->UpdateLargestPossibleRegion();
// connect the itkImportFilter to an itkVtkAdaptor
ivAdaptor->SetInput(VolumeImportFilter->GetOutput());
ReslicerTrans->SetInput(MapperTrans1->GetOutput());
ReslicerTrans->SetResliceAxesOrigin(NativeOrigin);
ReslicerTrans->SetOutputExtent(0, NativeDim[0] - 1, 0, NativeDim[1] - 1,
0, NativeDim[2] - 1);
ReslicerTrans->SetOutputOrigin(NativeOrigin[0], NativeOrigin[1],
NativeOrigin[2]);
ReslicerTrans->InterpolateOn();
ReslicerCor->SetInput(MapperCor1->GetOutput());
ReslicerCor->InterpolateOn();
ReslicerCor->SetResliceAxesOrigin(NativeOrigin);
ReslicerCor->SetOutputExtent(0, NativeDim[0] - 1, 0, NativeDim[1] - 1,
0, NativeDim[2] - 1);
ReslicerCor->SetOutputOrigin(NativeOrigin[0], NativeOrigin[1],
NativeOrigin[2]);
ReslicerSag->SetInput(MapperSag1->GetOutput());
ReslicerSag->InterpolateOn();
ReslicerSag->SetResliceAxesOrigin(NativeOrigin);
ReslicerSag->SetOutputExtent(0, NativeDim[0] - 1, 0, NativeDim[1] - 1,
0, NativeDim[2] - 1);
ReslicerSag->SetOutputOrigin(NativeOrigin[0], NativeOrigin[1],
NativeOrigin[2]);
ReslicerCor->SetResliceAxesDirectionCosines(1, 0, 0, 0, 0, -1, 0, 1, 0);
ReslicerSag->SetResliceAxesDirectionCosines(0, 1, 0, 0, 0, -1, 1, 0, 0);
ReslicerTrans->SetOutputSpacing(NativeSpacing[0], NativeSpacing[1],
NativeSpacing[2]);
ReslicerCor->SetOutputSpacing(NativeSpacing[0], NativeSpacing[1],
NativeSpacing[2]);
ReslicerSag->SetOutputSpacing(NativeSpacing[0], NativeSpacing[1],
NativeSpacing[2]);
MapperTrans1->SetInput(ivAdaptor->GetOutput());
MapperTrans1->UpdateWholeExtent();
ActorTrans1->SetInput(ReslicerTrans->GetOutput());
ActorTrans1->SetDisplayExtent(0, PFixedVolumeSpecs->XDim - 1, 0,
PFixedVolumeSpecs->YDim - 1, 0, PFixedVolumeSpecs->ZDim - 1);
RenderTrans1->AddActor(ActorTrans1);
ActorTrans1->SetZSlice((ActorTrans1->GetWholeZMax() -
ActorTrans1->GetWholeZMin()) * 0.5);
MapperCor1->SetInput(ivAdaptor->GetOutput());
MapperCor1->UpdateWholeExtent();
ActorCor1->SetInput(ReslicerCor->GetOutput());
ActorCor1->SetDisplayExtent(0, PFixedVolumeSpecs->XDim - 1, 0,
PFixedVolumeSpecs->YDim - 1, 0, PFixedVolumeSpecs->ZDim - 1);
RenderCor1->AddActor(ActorCor1);
ActorCor1->SetZSlice((ActorCor1->GetWholeZMax() -
ActorCor1->GetWholeZMin()) * 0.5);
MapperSag1->SetInput(ivAdaptor->GetOutput());
MapperSag1->UpdateWholeExtent();
ActorSag1->SetInput(ReslicerSag->GetOutput());
ActorSag1->SetDisplayExtent(0, PFixedVolumeSpecs->YDim - 1, 0,
PFixedVolumeSpecs->YDim - 1, 0, PFixedVolumeSpecs->ZDim - 1);
RenderSag1->AddActor(ActorSag1);
ActorSag1->SetZSlice((ActorSag1->GetWholeZMax() -
ActorSag1->GetWholeZMin()) * 0.5);
ReslicerTrans->UpdateWholeExtent();
ReslicerCor->UpdateWholeExtent();
ReslicerSag->UpdateWholeExtent();
vtkTextActor * lblPatientName = vtkTextActor::New();
vtkTextProperty * lblPatientNameProps =
lblPatientName->GetTextProperty();
lblPatientName->SetInput("Head, SQ\n12\\20\\2002");
lblPatientNameProps->SetFontFamilyToCourier();
lblPatientName->GetPositionCoordinate()->SetCoordinateSystemToNormalized
Viewport();
lblPatientName->GetPositionCoordinate()->SetValue(0.1, 0.75);
RenderSag1->AddActor(lblPatientName);
RenderWindow->Render();
RenderInt->Initialize();
RenderInt->Start();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030617/5a9fa3a0/attachment.htm>
More information about the vtkusers
mailing list