<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<a class="moz-txt-link-abbreviated" href="mailto:dk-80@gmx.de">dk-80@gmx.de</a> wrote:
<blockquote cite="mid:20090604133337.50800@gmx.net" type="cite">
  <pre wrap="">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

  </pre>
  <br>
  <hr size="4" width="90%"><br>
  <center><img src="cid:part1.08010707.01070503@gmail.com"></center>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>

Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>

Please keep messages on-topic and check the VTK FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>

Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
  </pre>
</blockquote>
Hi Daniel;<br>
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...<br>
<br>
vtkDICOMImageReader reader = new vtkDICOMImageReader();<br>
reader.SetDirectoryName(path);<br>
reader.SetDataScalarTypeToUnsignedChar();<br>
reader.Update();<br>
<br>
vtkPiecewiseFunction opacityFunction = new vtkPiecewiseFunction();<br>
opacityFunction.AddPoint(this.getScalarRangeMin(), 0);<br>
opacityFunction.AddPoint(40, 1);<br>
opacityFunction.AddPoint(1250, 0);<br>
opacityFunction.AddPoint(this.getScalarRangeMax(), 0);<br>
opacityFunction.Update();<br>
<br>
vtkColorTransferFunction colorFunction = new vtkColorTransferFunction();<br>
colorFunction.AddRGBPoint(1278, 174/255,55/255,25/255);<br>
colorFunction.AddRGBPoint(1345, 197/255,176/255,116/255);<br>
colorFunction.AddRGBPoint(2900, 242/255,214/255,214/255);<br>
<br>
vtkVolumeProperty volumeProperty = new vtkVolumeProperty();<br>
volumeProperty.SetColor(colorFunction);<br>
volumeProperty.SetScalarOpacity(opacityFunction);<br>
volumeProperty.SetInterpolationTypeToLinear();<br>
volumeProperty.ShadeOn();<br>
<br>
vtkVolumeTextureMapper3D textureMapper = new vtkVolumeTextureMapper3D();<br>
textureMapper.SetInputConnection(reader.GetOutputPort());<br>
textureMapper.SetBlendModeToComposite();<br>
textureMapper.SetPreferredMethodToNVidia();<br>
textureMapper.SetSampleDistance(0.1);<br>
<br>
vtkVolume volume = new vtkVolume();<br>
volume.SetMapper(textureMapper);<br>
volume.SetProperty(volumeProperty);<br>
<br>
this.GetRenderer().AddVolume(volume);<br>
this.GetRenderer().ResetCamera();<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>