[vtkusers] Displaying a 2D image as a volume
Cory Quammen
cquammen at cs.unc.edu
Wed Feb 27 13:43:46 EST 2008
Jeroen,
Does the thickness of the image change across the image? If so, why
not display the image as a height field? You could even distort the
image by a positive factor to get one surface and by a negative factor
to get a back surface. When you place the surfaces back-to-back, you
will get a shape with some thickness. The only problem is that the
edges of the two height fields might not meet if there is non-zero
displacement at the edges, but you could work around that if it
bothers you.
Cory
On Wed, Feb 27, 2008 at 11:06 AM, <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
> _______________________________________________
> 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
>
--
Cory Quammen
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen
More information about the vtkusers
mailing list