[vtkusers] Displaying a 2D image as a volume

J.S.Wijnhout at lumc.nl J.S.Wijnhout at lumc.nl
Fri Feb 29 02:23:56 EST 2008


I've tried vtkImageActor, which works of course, but it doesn't show the thickness of the slice. I need to visualize this because I have multiple intersecting 2D slices with differences thickness.

best,
Jeroen

-----Original Message-----
From: vtkusers-bounces+j.s.wijnhout=lumc.nl at vtk.org [mailto:vtkusers-bounces+j.s.wijnhout=lumc.nl at vtk.org] On Behalf Of Francois Bertel
Sent: Wednesday, February 27, 2008 5:18 PM
To: vtkusers at vtk.org
Subject: Re: [vtkusers] Displaying a 2D image as a volume

Maybe vtkImageActor?

J.S.Wijnhout at lumc.nl wrote:
>> Dimension[i] is the number of points along axis i, not the number of cells. >Number of cells along axis i is Dimension[i]-1. If Dimension[i]=1, number >of cells[i]=0, so no thickness.
> 
> Thanks for clearing that up. Do you have an idea of how to display the slice (which has a thickness in reality), without resorting to padding?
> 
> best,
> Jeroen
> 
> J.S.Wijnhout at lumc.nl wrote:
>> Hi,
>>
>> Thanks for the suggestion, that actually worked! I'm not sure what is
>> wrong with my original approach (a bug perhaps?), but padding the image
>> with transparent voxels work. For those of you who have the same
>> problem:
>>
>>     double minValue = _image->GetScalarTypeMax ();
>>     double maxValue = _image->GetScalarTypeMin ();
>>     // This is a custom function to determine the min/max gray values:
>>     DetermineMinMax ( _image, minValue, maxValue );    
>>     vtkImageShiftScale *scaler = vtkImageShiftScale::New ();
>>     scaler->SetInput ( _image );
>>     scaler->SetOutputScalarTypeToUnsignedChar ();
>>
>>     // Map to [1,255], the value 0 is reserved for a transparency hack:
>>     int delta = maxValue - minValue;
>>     scaler->SetShift ( ( delta / 254.0 ) - minValue );
>>     scaler->SetScale ( 254.0 / delta );
>>
>>
>>     vtkImageConstantPad *padder = vtkImageConstantPad::New ();
>>     int extent [ 6 ];
>>     _image->GetExtent ( extent );
>>     extent [ 2 ] = 3;
>>     extent [ 5 ] = 3;
>>     padder->SetOutputWholeExtent ( extent );
>>     padder->SetInput ( scaler->GetOutput () );
>>     padder->SetConstant ( 0.0 );
>>
>>     // Modify the transfer functions such that pixel value 0 (the 
>>     // value the image is padded with in the z-dimension) corresponds to
>> a
>>     // completely transparent voxel and value 1 to pure black:
>>     vtkPiecewiseFunction *opacityTransferFunction =
>> vtkPiecewiseFunction::New ();
>>     opacityTransferFunction->AddPoint ( 0, 0.0 );
>>     opacityTransferFunction->AddPoint ( 0.5, 1.0 );
>>     opacityTransferFunction->AddPoint ( 1, 1.0 );
>>     opacityTransferFunction->AddPoint ( 255, 1.0 );
>>     vtkColorTransferFunction *colorTransferFunction =
>> vtkColorTransferFunction::New ();
>>     colorTransferFunction->AddRGBPoint ( 0, 0.0, 0.0, 0.0 );
>>     colorTransferFunction->AddRGBPoint ( 1, 0.0, 0.0, 0.0 );
>>     colorTransferFunction->AddRGBPoint ( 255, 1.0, 1.0, 1.0 );
>>
>>     vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New ();
>>     volumeProperty->SetColor ( colorTransferFunction );
>>     volumeProperty->SetScalarOpacity ( opacityTransferFunction );
>>
>>     vtkVolumeRayCastCompositeFunction *rayCastFunction =
>> vtkVolumeRayCastCompositeFunction::New ();
>>  
>>     vtkVolumeRayCastMapper *hiResVolumeMapper =
>> vtkVolumeRayCastMapper::New ();
>>     hiResVolumeMapper->SetInput ( padder->GetOutput () );
>>     hiResVolumeMapper->SetVolumeRayCastFunction ( rayCastFunction );
>>
>>     vtkVolume *volume = vtkVolume::New ();
>>     volume->SetProperty ( volumeProperty );
>>     volume->SetMapper ( hiResVolumeMapper );
>>
>>
>> best,
>> Jeroen
>> _______________________________________________
>> This is the private VTK discussion list. 
>> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
> 
> 


-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                       | Clifton Park NY 12065, USA
_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list