[vtkusers] 3D volume problem with vtkImageReader reading RAW file

Sercani sercanimailgroups at gmail.com
Mon Jun 29 10:05:31 EDT 2009


dk-80 at gmx.de wrote:
> Hi all,
>
> I want to read a 3D raw file (512x512x151) of a head with vtkImageReader. 
> But the result is a cube and this is wrong. It should be a 3D volume.
> Please look at the attached picture.
>
> information about this raw file:
> 	16bits unsigned 
>         BigEndian
>         min 0 max 4096 (12 bits)
> 	Dimensions: 512x512x151
> 	voxel size: 0.4863 0.4863 1 (mm)
>
> My java-code is following:
> 	vtkImageReader reader = new vtkImageReader();
> 	reader.SetFileName(file);
> 	reader.SetFileDimensionality(3);
> 	reader.SetDataExtent(0,511,0,511,0,150);
> 	reader.SetDataSpacing(0.4863, 0.4863, 1);
> 	reader.SetDataByteOrderToBigEndian();
> 	reader.SetDataScalarTypeToUnsignedChar();
> 	reader.Update(); 
>
> 	vtkDataSetMapper map = new vtkDataSetMapper();
> 	map.SetInputConnection(reader.GetOutputPort());
>
>
> what's wrong in my code? and how I can create a volume?
> thanks in advance,
>
> Daniel
>
>   
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   
Hi Daniel;
You must use vtkPiecewiseFunction to set the opacity of voxels in your 
volume and vtkColorTransferFunction to set the color of these 
voxels...here is an example for you which is written for dicom images in 
java...

vtkDICOMImageReader reader = new vtkDICOMImageReader();
reader.SetDirectoryName(path);
reader.SetDataScalarTypeToUnsignedChar();
reader.Update();

vtkPiecewiseFunction opacityFunction = new vtkPiecewiseFunction();
opacityFunction.AddPoint(this.getScalarRangeMin(), 0);
opacityFunction.AddPoint(40, 1);
opacityFunction.AddPoint(1250, 0);
opacityFunction.AddPoint(this.getScalarRangeMax(), 0);
opacityFunction.Update();

vtkColorTransferFunction colorFunction = new vtkColorTransferFunction();
colorFunction.AddRGBPoint(1278, 174/255,55/255,25/255);
colorFunction.AddRGBPoint(1345, 197/255,176/255,116/255);
colorFunction.AddRGBPoint(2900, 242/255,214/255,214/255);

vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
volumeProperty.SetColor(colorFunction);
volumeProperty.SetScalarOpacity(opacityFunction);
volumeProperty.SetInterpolationTypeToLinear();
volumeProperty.ShadeOn();

vtkVolumeTextureMapper3D textureMapper = new vtkVolumeTextureMapper3D();
textureMapper.SetInputConnection(reader.GetOutputPort());
textureMapper.SetBlendModeToComposite();
textureMapper.SetPreferredMethodToNVidia();
textureMapper.SetSampleDistance(0.1);

vtkVolume volume = new vtkVolume();
volume.SetMapper(textureMapper);
volume.SetProperty(volumeProperty);

this.GetRenderer().AddVolume(volume);
this.GetRenderer().ResetCamera();






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090629/43490b22/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 68906 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090629/43490b22/attachment.jpeg>


More information about the vtkusers mailing list