[vtkusers] 2D view with color overlays over grayscale volumes
John Drescher
drescherjm at gmail.com
Wed Jun 17 11:53:34 EDT 2009
> I am using the code from vtkINRIA3D to do this however it has several problems.
>
> http://www-sop.inria.fr/asclepios/software/vtkINRIA3D/dashboard/Doxygen/html/vtkImageBlendWithMask_8cxx-source.html
>
> The main problem is that it blends my grayscale image with another LUT
> based image to form a 3D color volume. At the resolution I am using
> this volume is over 700MB. At first the program was using 3 of these
> one for each of the Coronal, Axial and Sagittal views but I patched my
> code to use only 1 buffer.
>
> Anyways I am thinking that this blending operation does not need to be
> done this way. Can I have multiple image actors with different LUTs
> and place the overlay in a layer above the image I want to view?
>
Yesterday I have solved this issue. I added a the following members to
the vtkViewImage2D class:
/// Overlay image
vtkImageData* FGImage;
vtkImageActor* FGImageActor;
vtkImageMapToColors* FGWindowLevel;
vtkImageReslice* FGImageReslice;
The solution was to handle the FGImage the same as the image.
Performance is good, actually better than with the 3D color volume and
memory usage is less than 1/2 of what it was for my 0.625 CT cases.
void vtkViewImage2D::SetFGImage( vtkImageData* image, vtkLookupTable* lut )
{
vtkImageActor* actor = vtkImageActor::New();
vtkImageMapToColors* windowLevel = vtkImageMapToColors::New();
vtkImageReslice* relsice = vtkImageReslice::New();
// set up the vtk pipeline
relsice->SetOutputDimensionality(2);
relsice->InterpolateOff();
double* spacing = this->GetImage()->GetSpacing();
image->SetSpacing(spacing);
double* origin = this->GetImage()->GetOrigin();
image->SetOrigin(origin);
image->Update();
windowLevel->SetLookupTable(lut);
windowLevel->SetInput(image);
windowLevel->PassAlphaToOutputOn();
relsice->SetInput(windowLevel->GetOutput());
actor->SetInput(relsice->GetOutput());
FGImageActor = actor;
FGWindowLevel = windowLevel;
FGImageReslice = relsice;
this->FGImageActor->SetOpacity(0.95);
Update();
SetupAnnotations();
this->GetRenderer()->AddViewProp(this->FGImageActor);
this->GetRenderer()->Render();
}
/////////////////////////////////////////////////////////////////////////////////////////
void vtkViewImage2D::SetResliceAxesDirectionCosines( double x0, double
x1, double x2,
double y0, double y1, double y2,
double z0, double z1, double z2 )
{
if ( this->ImageReslice != NULL) {
this->ImageReslice->SetResliceAxesDirectionCosines(x0,x1,x2,
y0,y1,y2,
z0,z1,z2);
}
if ( this->FGImageReslice != NULL) {
this->FGImageReslice->SetResliceAxesDirectionCosines(x0,x1,x2,
y0,y1,y2,
z0,z1,z2);
}
}
--
John M. Drescher
More information about the vtkusers
mailing list