<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hey,<br><br>Were you able to try it successfully in java?<br>I am trying to do volume rendering of dicom images in java, and am runnning into lot of problems.<br><br><br><br>--- On <b>Mon, 10/26/09, baliki2@freemail.gr <i>&lt;baliki2@freemail.gr&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: baliki2@freemail.gr &lt;baliki2@freemail.gr&gt;<br>Subject: Re: [vtkusers] x-ray effect in volume rendering<br>To: vtkusers@vtk.org<br>Date: Monday, October 26, 2009, 6:59 AM<br><br><div class="plainMail"><br>It works just great! I'll try it in Java, too.<br><br>Thanks a lot Mr. Gasteiger!<br><br>&gt; Hi "Baliki",<br>&gt; <br>&gt; Below I have inserted a VTK-example program, which reads a raw volume<br>&gt; dataset and performs normal volume rendering, X-ray and MIP projection. I<br>&gt; use
 it for my students to illustrate these different approaches. The samples<br>&gt; on each ray are interpolated with nearest neighbor (not the best, tri-linear<br>&gt; is much better but expansive in computation time. It inFollowing steps you<br>&gt; have to do:<br>&gt; 1. Define "fname" (in main(...)) with the file name of you dataset<br>&gt; 2&nbsp; Specify your raw dataset for the vtkImageReader2 reader (In the example I<br>&gt; use a volume version(!) of the foot dataset of the VTK distribution)<br>&gt; 3. Turn on one of the render modes by uncomment one of the<br>&gt; "currentRenderMode" line at the beginning of the example<br>&gt; <br>&gt; I have included some comments which hopefully helps you to understand each<br>&gt; step.<br>&gt; <br>&gt; Best regards, Rocco<br>&gt; <br>&gt; //--------------------------------------------------------------------------<br>&gt; ------------<br>&gt; //<br>&gt; // This example reads a volume dataset and then
 displays it.<br>&gt; //<br>&gt; #include "vtkRenderer.h"<br>&gt; #include "vtkRenderWindow.h"<br>&gt; #include "vtkRenderWindowInteractor.h"<br>&gt; #include "vtkCamera.h"<br>&gt; #include "vtkInteractorStyleSwitch.h"<br>&gt; #include "vtkImageReader2.h"<br>&gt; #include "vtkActor.h"<br>&gt; <br>&gt; #include "vtkColorTransferFunction.h"<br>&gt; #include "vtkPiecewiseFunction.h"<br>&gt; #include "vtkVolumeProperty.h"<br>&gt; #include "vtkVolumeRayCastCompositeFunction.h"<br>&gt; #include "vtkVolumeRayCastMapper.h"<br>&gt; #include "vtkVolume.h"<br>&gt; <br>&gt; <br>&gt; #define mode_MIP&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 0<br>&gt; #define mode_XRay&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 1<br>&gt; #define mode_Full&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 2<br>&gt; <br>&gt; static int currentRenderMode = mode_XRay;<br>&gt; <br>&gt; // Necessary for correct MIP and XRay scaling (0-1)<br>&gt; static float globalMaximumScalarValue = 0;<br>&gt; ////////////////////////////////////////////////////////////////<br>&gt; // Definition and implementation of our own ray cast composite function<br>&gt; ----------------------------------<br>&gt; class MyVolumeRayCastCompositeFunction : public<br>&gt; vtkVolumeRayCastCompositeFunction<br>&gt; {<br>&gt; <br>&gt; public:<br>&gt; &nbsp;&nbsp;&nbsp; static MyVolumeRayCastCompositeFunction *New()<br>&gt; &nbsp;&nbsp;&nbsp; { return new MyVolumeRayCastCompositeFunction; }<br>&gt; <br>&gt; protected:<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; ////////////////////////////////////////////////////////////////<br>&gt; &nbsp;&nbsp;&nbsp; // Do not change this code<br>&gt; &nbsp;&nbsp;&nbsp; //<br>&gt; &nbsp;&nbsp;&nbsp; // This is called from
 RenderAnImage (in vtkDepthPARCMapper.cxx)<br>&gt; &nbsp;&nbsp;&nbsp; // It uses the integer data type flag that is passed in<br>&gt; &nbsp;&nbsp;&nbsp; // to determine what type of ray needs to be cast (which is handled<br>&gt; &nbsp;&nbsp;&nbsp; // by a template function.&nbsp; It also uses the shading and<br>&gt; &nbsp;&nbsp;&nbsp; // interpolation types to determine which template function<br>&gt; &nbsp;&nbsp;&nbsp; // to call.<br>&gt; &nbsp;&nbsp;&nbsp; void MyVolumeRayCastCompositeFunction::CastRay(<br>&gt; vtkVolumeRayCastDynamicInfo *dynamicInfo,<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkVolumeRayCastStaticInfo *staticInfo )<br>&gt; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void *data_ptr;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; data_ptr = staticInfo-&gt;ScalarDataPointer;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; switch ( staticInfo-&gt;ScalarDataType ) {<br>&gt; case VTK_UNSIGNED_CHAR:<br>&gt;
 &nbsp;&nbsp;&nbsp; vtkCastRay_OwnWork( (unsigned char *)data_ptr, dynamicInfo,<br>&gt; staticInfo );<br>&gt; &nbsp;&nbsp;&nbsp; break;<br>&gt; case VTK_UNSIGNED_SHORT:<br>&gt; &nbsp;&nbsp;&nbsp; vtkCastRay_OwnWork( (unsigned short *)data_ptr, dynamicInfo,<br>&gt; staticInfo );<br>&gt; &nbsp;&nbsp;&nbsp; break;<br>&gt; default:<br>&gt; &nbsp;&nbsp;&nbsp; vtkWarningMacro ( &lt;&lt; "Unsigned char and unsigned short are the only<br>&gt; supported datatypes for rendering" );<br>&gt; &nbsp;&nbsp;&nbsp; break;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&gt; &nbsp;&nbsp;&nbsp; }<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; // This is the template function that actually casts a ray and<br>&gt; computes<br>&gt; &nbsp;&nbsp;&nbsp; // the composite value.&nbsp; This version uses nearest neighbor<br>&gt; interpolation, and performs shading.<br>&gt; &nbsp;&nbsp;&nbsp; template &lt;class T&gt;<br>&gt; &nbsp;&nbsp;&nbsp; void vtkCastRay_OwnWork(T *data_ptr,
 vtkVolumeRayCastDynamicInfo<br>&gt; *dynamicInfo, vtkVolumeRayCastStaticInfo *staticInfo )<br>&gt; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unsigned char&nbsp;&nbsp;&nbsp;*gmptr = NULL;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;accum_red_intensity, accum_green_intensity,<br>&gt; accum_blue_intensity, accum_opacity;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;opacity;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;xinc, yinc, zinc;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;voxel[3];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;ray_position[3];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; T&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp;&nbsp;&nbsp;*dptr;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;*ScalarToOpacityTF;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;*ScalarToColorTF;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;*red_d_shade, *green_d_shade, *blue_d_shade;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;*red_s_shade, *green_s_shade, *blue_s_shade;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unsigned short&nbsp; *encoded_normals;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;currentNormalIndex;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;red_shaded_value, green_shaded_value,<br>&gt; blue_shaded_value;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;offset;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;steps_this_ray;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;scalar_value;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;r, g, b;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;num_steps;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;*ray_start, *ray_increment;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; shading = staticInfo-&gt;Shading;<br>&gt; <br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // For each ray some information are fetched which are<br>&gt; needed for color and shading<br>&gt;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // computation.<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Get ray parameters: Number of sample points, ray start<br>&gt; position, and step size on the ray<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; num_steps = dynamicInfo-&gt;NumberOfStepsToTake;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ray_start = dynamicInfo-&gt;TransformedStart;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ray_increment = dynamicInfo-&gt;TransformedIncrement;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Get diffuse shading table pointers. This table is<br>&gt; preprocessed by VTK and stores<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // for different normal directions its diffuse portion of<br>&gt; the phong illumination term.<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; red_d_shade&nbsp;&nbsp;&nbsp;= staticInfo-&gt;RedDiffuseShadingTable;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; green_d_shade =
 staticInfo-&gt;GreenDiffuseShadingTable;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; blue_d_shade&nbsp; = staticInfo-&gt;BlueDiffuseShadingTable;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Get specular shading table pointers. This table is<br>&gt; preprocessed by VTK and stores<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // for specular normal directions its diffuse portion of the<br>&gt; phong illumination term.<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; red_s_shade = staticInfo-&gt;RedSpecularShadingTable;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; green_s_shade = staticInfo-&gt;GreenSpecularShadingTable;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; blue_s_shade = staticInfo-&gt;BlueSpecularShadingTable;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Get a pointer to the encoded normals of this volume. This<br>&gt; table is preprocessed by VTK and stores<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // for each
 voxel its normal.<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; encoded_normals = staticInfo-&gt;EncodedNormals;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Get the scalar opacity transfer function which maps<br>&gt; scalar input values to opacities<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ScalarToOpacityTF =<br>&gt; staticInfo-&gt;Volume-&gt;GetCorrectedScalarOpacityArray();<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Get the color transfer function which maps scalar input<br>&gt; values to RGB values<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ScalarToColorTF =&nbsp; staticInfo-&gt;Volume-&gt;GetRGBArray();<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // store increments (distance between sample points in x, y,<br>&gt; and z direction) in local variables<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; xinc = staticInfo-&gt;DataIncrement[0];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; yinc =
 staticInfo-&gt;DataIncrement[1];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; zinc = staticInfo-&gt;DataIncrement[2];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //cerr&lt;&lt;xinc&lt;&lt;", "&lt;&lt;yinc&lt;&lt;", "&lt;&lt;zinc&lt;&lt;", "&lt;&lt;endl; //constant<br>&gt; for a data set<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Initialize the ray position (in voxel space)<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ray_position[0] = ray_start[0];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ray_position[1] = ray_start[1];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ray_position[2] = ray_start[2];<br>&gt; <br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Nearest neighbor interpolation - get nearest voxel (in<br>&gt; voxel space) - you have to change this for tri-linear interpolation<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; voxel[0] = vtkRoundFuncMacro( ray_position[0] );<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 voxel[1] = vtkRoundFuncMacro( ray_position[1] );<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; voxel[2] = vtkRoundFuncMacro( ray_position[2] );<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // So far we haven't accumulated anything<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_red_intensity&nbsp;&nbsp;&nbsp;= 0.0;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_green_intensity = 0.0;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_blue_intensity&nbsp; = 0.0;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // accumulated opacity<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_opacity&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;= 0.0;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // added for MIP mode rendering<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float maxOpacity&nbsp; &nbsp; &nbsp; = 0.0;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; float maxValue&nbsp; &nbsp; &nbsp; &nbsp; = 0.0;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; currentNormalIndex&nbsp; &nbsp; = 0;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // For each step along the ray do something (accumulate,<br>&gt; find maximum opacity, ...)<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // "accum_opacity &lt; 1.0" means early-ray-termination<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for ( steps_this_ray = 0; steps_this_ray &lt; num_steps &amp;&amp;<br>&gt; accum_opacity &lt; 1.0; steps_this_ray++ ) {<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // get offset position of current voxel in linear<br>&gt; list<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; offset = voxel[2] * zinc + voxel[1] * yinc +<br>&gt; voxel[0];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // get pointer on current voxel in linear list<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dptr = data_ptr + offset;<br>&gt; <br>&gt;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // get scalar value at current location<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; scalar_value&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;= (int) *(dptr);<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (scalar_value &gt; globalMaximumScalarValue)<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; globalMaximumScalarValue = scalar_value;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // get opacity value for this scalar_value out of<br>&gt; the ScalarOpacityTransferFunction<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; opacity = ScalarToOpacityTF[scalar_value];<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // If we have a
 valid opacity value, then compute<br>&gt; the shading<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( opacity ) {<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; switch (currentRenderMode)<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case mode_MIP:<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // MIP - only maximal value or first<br>&gt; local maximum above a threshold is visualized<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // check if current voxel opacity is<br>&gt; above max opacity<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //if (opacity &gt; maxOpacity)<br>&gt; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (scalar_value &gt; maxValue)<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_red_intensity&nbsp;&nbsp;&nbsp;=<br>&gt; opacity * ScalarToColorTF[(scalar_value) * 3&nbsp; &nbsp; ];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_green_intensity =<br>&gt; opacity * ScalarToColorTF[(scalar_value) * 3 + 1];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_blue_intensity&nbsp; =<br>&gt; opacity * ScalarToColorTF[(scalar_value) * 3 + 2];<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //maxOpacity&nbsp; &nbsp; = opacity;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; maxValue&nbsp; &nbsp; = scalar_value;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_opacity = 1.0-opacity;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case mode_XRay:<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // X-ray projection mode:<br>&gt; Accumulation of the scalar values (or opacity values)<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_red_intensity =<br>&gt; accum_green_intensity = accum_blue_intensity = accum_red_intensity +<br>&gt; scalar_value;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case mode_Full:<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // get r, g, and b value for current<br>&gt; scalar value out of the ColorTransferFunction<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; r = ScalarToColorTF[(scalar_value) *<br>&gt; 3&nbsp; &nbsp; ];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g = ScalarToColorTF[(scalar_value) *<br>&gt; 3 + 1];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; b = ScalarToColorTF[(scalar_value) *<br>&gt; 3 + 2];<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; red_shaded_value&nbsp;&nbsp;&nbsp;= opacity * r;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; green_shaded_value = opacity * g;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; blue_shaded_value&nbsp; = opacity * b;<br>&gt; <br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Accumulate color<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // (the color of the current value<br>&gt; is weighted by the remaining opacity of the voxels<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // in front of the current one)<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_red_intensity&nbsp;&nbsp;&nbsp;=<br>&gt; red_shaded_value&nbsp;&nbsp;&nbsp;* (1.0-accum_opacity) + accum_red_intensity;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_green_intensity =<br>&gt; green_shaded_value * (1.0-accum_opacity) + accum_green_intensity;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_blue_intensity&nbsp; =<br>&gt; blue_shaded_value&nbsp; * (1.0-accum_opacity) + accum_blue_intensity;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Accumulate opacity<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_opacity&nbsp;
 =<br>&gt; opacity*(1.0-accum_opacity) + accum_opacity;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; default:<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_red_intensity = 0.0;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_green_intensity = 0.0;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_blue_intensity = 0.0;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_opacity = 1.0;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; }<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Increment our position and compute new voxel<br>&gt; location<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ray_position[0] += ray_increment[0];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ray_position[1] += ray_increment[1];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ray_position[2] += ray_increment[2];<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; voxel[0] = vtkRoundFuncMacro( ray_position[0] );<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; voxel[1] = vtkRoundFuncMacro( ray_position[1] );<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; voxel[2] = vtkRoundFuncMacro( ray_position[2] );<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }// endFor each step along the
 ray<br>&gt; ----------------------------------------------------------------------------<br>&gt; -----------<br>&gt; <br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Now we stored in accum_{red,green,blue}_intensity the<br>&gt; accumulated RGB values along a ray<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // added for XRay mode rendering<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if( currentRenderMode == mode_XRay)<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // divide accumulated scalar values by the number of<br>&gt; steps times maximum scalar value to get the average<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_red_intensity = accum_green_intensity =<br>&gt; accum_blue_intensity = accum_red_intensity /<br>&gt; float(num_steps*globalMaximumScalarValue);<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; accum_opacity =
 1.0-accum_red_intensity;<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Cap the accumulated intensities at 1.0<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( accum_red_intensity &gt; 1.0 )&nbsp;&nbsp;&nbsp; {<br>&gt; accum_red_intensity = 1.0; }<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( accum_green_intensity &gt; 1.0 ){ accum_green_intensity =<br>&gt; 1.0;}<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( accum_blue_intensity &gt; 1.0 )&nbsp;&nbsp;&nbsp; {<br>&gt; accum_blue_intensity = 1.0;}<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Set the return pixel value.<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dynamicInfo-&gt;Color[0] = accum_red_intensity;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dynamicInfo-&gt;Color[1] = accum_green_intensity;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dynamicInfo-&gt;Color[2] = accum_blue_intensity;<br>&gt;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dynamicInfo-&gt;Color[3] = accum_opacity;<br>&gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dynamicInfo-&gt;NumberOfStepsTaken = steps_this_ray;<br>&gt; <br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; }<br>&gt; <br>&gt; };<br>&gt; //<br>&gt; ----------------------------------------------------------------------------<br>&gt; -<br>&gt; <br>&gt; <br>&gt; ////////////////////////////////////////////////////////////////<br>&gt; //<br>&gt; int main (int argc, char **argv)<br>&gt; {<br>&gt; &nbsp;&nbsp;&nbsp; //check for&nbsp; arguments (e.g. a filename)<br>&gt; &nbsp;&nbsp;&nbsp; const char* fname = "foot.raw";<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; // Create the renderer, the render window, and the interactor. The<br>&gt; renderer<br>&gt; &nbsp;&nbsp;&nbsp; // draws into the render window, the interactor enables mouse- and<br>&gt; &nbsp;&nbsp;&nbsp; // keyboard-based interaction with the data within the render<br>&gt; window.<br>&gt;
 &nbsp;&nbsp;&nbsp; vtkRenderer *renderer = vtkRenderer::New();<br>&gt; &nbsp;&nbsp;&nbsp; //renderer-&gt;SetBackground( 0.2, 0.2, 0.4 );<br>&gt; &nbsp;&nbsp;&nbsp; renderer-&gt;SetBackground( 1.0, 1.0, 1.0 );<br>&gt; &nbsp;&nbsp;&nbsp; vtkCamera *camera = renderer-&gt;GetActiveCamera();<br>&gt; &nbsp;&nbsp;&nbsp; camera-&gt;ParallelProjectionOff();<br>&gt; &nbsp;&nbsp;&nbsp; camera-&gt;SetViewUp (0, 0, -1);<br>&gt; &nbsp;&nbsp;&nbsp; camera-&gt;SetPosition (-1, 2, -0.5);<br>&gt; &nbsp;&nbsp;&nbsp; vtkRenderWindow *renderWindow = vtkRenderWindow::New();<br>&gt; &nbsp;&nbsp;&nbsp; renderWindow-&gt;SetSize( 640, 480 );&nbsp; &nbsp;&nbsp;&nbsp;// Set the size of the render<br>&gt; window (in pixel).<br>&gt; &nbsp;&nbsp;&nbsp; renderWindow-&gt;AddRenderer(renderer);<br>&gt; &nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor *interactionRenderer =<br>&gt; vtkRenderWindowInteractor::New();<br>&gt; &nbsp;&nbsp;&nbsp;
 interactionRenderer-&gt;SetRenderWindow(renderWindow);<br>&gt; <br>&gt; reinterpret_cast&lt;vtkInteractorStyleSwitch*&gt;(interactionRenderer-&gt;GetInteract<br>&gt; orStyle())-&gt;SetCurrentStyleToTrackballCamera();<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; vtkImageReader2 *volumeDataset = vtkImageReader2::New();<br>&gt; &nbsp;&nbsp;&nbsp; volumeDataset-&gt;SetFileName(fname);<br>&gt; &nbsp;&nbsp;&nbsp; volumeDataset-&gt;SetFileDimensionality(3);<br>&gt; &nbsp;&nbsp;&nbsp; volumeDataset-&gt;SetDataExtent(0, 127, 0, 127, 0, 63);<br>&gt; &nbsp;&nbsp;&nbsp; volumeDataset-&gt;SetDataSpacing(1.60938, 1.60938, 1.95313);<br>&gt; &nbsp;&nbsp;&nbsp; volumeDataset-&gt;SetDataOrigin(0.0, 0.0, 0.0);<br>&gt; &nbsp;&nbsp;&nbsp; volumeDataset-&gt;SetDataScalarTypeToUnsignedShort();<br>&gt; &nbsp;&nbsp;&nbsp; volumeDataset-&gt;SetDataByteOrderToLittleEndian();<br>&gt; &nbsp;&nbsp;&nbsp; volumeDataset-&gt;UpdateWholeExtent();<br>&gt; <br>&gt; <br>&gt; <br>&gt;
 ////////////////////////////////////////////////////////////////////////////<br>&gt; ///////////<br>&gt; &nbsp;&nbsp;&nbsp; // Feel free to change this code<br>&gt; &nbsp;&nbsp;&nbsp; // adjustments to the following code may be required and should be<br>&gt; explored<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; // Create transfer function - mapping scalar values [0-...] to COLOR<br>&gt; [0-1, 0-1, 0-1]<br>&gt; &nbsp;&nbsp;&nbsp; vtkColorTransferFunction *colorTransferFunction =<br>&gt; vtkColorTransferFunction::New();<br>&gt; &nbsp;&nbsp;&nbsp; colorTransferFunction-&gt;AddRGBPoint(&nbsp;&nbsp;&nbsp;0.0, 0.0,0.0,0.0);<br>&gt; &nbsp;&nbsp;&nbsp; colorTransferFunction-&gt;AddRGBPoint( 500.0, 0.9,0.5,0.3);<br>&gt; &nbsp;&nbsp;&nbsp; colorTransferFunction-&gt;AddRGBPoint(1100.0, 0.8,0.8,0.6);<br>&gt; &nbsp;&nbsp;&nbsp; colorTransferFunction-&gt;AddRGBPoint(1200.0, 0.6,0.6,0.6);<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; vtkPiecewiseFunction *opacityTransferFunction
 =<br>&gt; vtkPiecewiseFunction::New();<br>&gt; &nbsp;&nbsp;&nbsp; opacityTransferFunction-&gt;AddPoint(&nbsp; &nbsp; 0, 0.0);<br>&gt; &nbsp;&nbsp;&nbsp; //opacityTransferFunction-&gt;AddPoint(&nbsp; 980, 0.1);<br>&gt; &nbsp;&nbsp;&nbsp; //opacityTransferFunction-&gt;AddPoint(&nbsp; 1055, 0.2);<br>&gt; &nbsp;&nbsp;&nbsp; opacityTransferFunction-&gt;AddPoint(&nbsp; 1200, 0.05);<br>&gt; &nbsp;&nbsp;&nbsp; opacityTransferFunction-&gt;AddPoint( 1300, 1.0);<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; // The property describes how the data will look<br>&gt; &nbsp;&nbsp;&nbsp; vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();<br>&gt; &nbsp;&nbsp;&nbsp; volumeProperty-&gt;SetColor(colorTransferFunction);<br>&gt; &nbsp;&nbsp;&nbsp; volumeProperty-&gt;SetScalarOpacity(opacityTransferFunction);<br>&gt; &nbsp;&nbsp;&nbsp; //volumeProperty-&gt;ShadeOn(); // request 3d shading (german:<br>&gt; beleuchtungsberechnung anfordern) //has to be implemented in<br>&gt;
 vtkCastRay_OwnWork<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; //vtkVolumeRayCastCompositeFunction *rayCompositeFunction =<br>&gt; vtkVolumeRayCastCompositeFunction::New();<br>&gt; &nbsp;&nbsp;&nbsp; MyVolumeRayCastCompositeFunction *rayCompositeFunction =<br>&gt; MyVolumeRayCastCompositeFunction::New();<br>&gt; &nbsp;&nbsp;&nbsp; // The mapper knows how to render the data<br>&gt; &nbsp;&nbsp;&nbsp; vtkVolumeRayCastMapper *rayCastMapper =<br>&gt; vtkVolumeRayCastMapper::New();<br>&gt; &nbsp;&nbsp;&nbsp; rayCastMapper-&gt;SetInput( volumeDataset-&gt;GetOutput());<br>&gt; &nbsp;&nbsp;&nbsp; rayCastMapper-&gt;SetVolumeRayCastFunction(rayCompositeFunction);<br>&gt; &nbsp;&nbsp;&nbsp; //Feel free to change parameters for<br>&gt; &nbsp;&nbsp;&nbsp; //rayCastMapper-&gt;AutoAdjustSampleDistancesOff();&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //<br>&gt; interactive framerates by lower quality (on/off)<br>&gt; &nbsp;&nbsp;&nbsp;
 //rayCastMapper-&gt;SetSampleDistance(1.0);<br>&gt; // adjust samples per ray rate if AutoAdjustSampleDistances is OFF<br>&gt; &nbsp;&nbsp;&nbsp; //rayCastMapper-&gt;SetImageSampleDistance(1.0);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //<br>&gt; adjust rays per pixel rate (e.g. 0.5 =&gt; 4 rays for each pixel, 2.0 =&gt; 1 ray<br>&gt; for 4 pixel) if AutoAdjustSampleDistances is OFF<br>&gt; &nbsp;&nbsp;&nbsp; //rayCastMapper-&gt;SetMaximumImageSampleDistance(6.0);&nbsp;&nbsp;&nbsp; // max<br>&gt; sample distance if AutoAdjustSampleDistances is ON<br>&gt; &nbsp;&nbsp;&nbsp; //rayCastMapper-&gt;SetMinimumImageSampleDistance(1.0);&nbsp;&nbsp;&nbsp; // min<br>&gt; sample distance if AutoAdjustSampleDistances is ON<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; // The volume holds the mapper and the property and<br>&gt; &nbsp;&nbsp;&nbsp; // can be used to position/orient the volume<br>&gt; &nbsp;&nbsp;&nbsp; vtkVolume *volData= vtkVolume::New();<br>&gt;
 &nbsp;&nbsp;&nbsp; volData-&gt;SetMapper(rayCastMapper);<br>&gt; &nbsp;&nbsp;&nbsp; volData-&gt;SetProperty(volumeProperty);<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; // Actors are added to the renderer.<br>&gt; &nbsp;&nbsp;&nbsp; renderer-&gt;AddVolume(volData);<br>&gt; <br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; // adjust camera for good initial view<br>&gt; &nbsp;&nbsp;&nbsp; renderer-&gt;ResetCamera();<br>&gt; &nbsp;&nbsp;&nbsp; renderer-&gt;GetActiveCamera()-&gt;Dolly(1);<br>&gt; &nbsp;&nbsp;&nbsp; renderer-&gt;ResetCameraClippingRange();<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; // Start the Interactor<br>&gt; &nbsp;&nbsp;&nbsp; interactionRenderer-&gt;Initialize();<br>&gt; &nbsp;&nbsp;&nbsp; interactionRenderer-&gt;Start();<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; // It is important to delete all objects created previously to<br>&gt; prevent<br>&gt; &nbsp;&nbsp;&nbsp; // memory leaks. In this case, since the program is on its way to<br>&gt; &nbsp;&nbsp;&nbsp; //
 exiting, it is not so important. But in applications it is<br>&gt; &nbsp;&nbsp;&nbsp; // essential.<br>&gt; &nbsp;&nbsp;&nbsp; renderer-&gt;Delete();<br>&gt; &nbsp;&nbsp;&nbsp; renderWindow-&gt;Delete();<br>&gt; &nbsp;&nbsp;&nbsp; interactionRenderer-&gt;Delete();<br>&gt; <br>&gt; &nbsp;&nbsp;&nbsp; return 0;<br>&gt; }<br>&gt; <br>&gt; <br>&gt; -----Original Message-----<br>&gt; From: <a ymailto="mailto:baliki2@freemail.gr" href="/mc/compose?to=baliki2@freemail.gr">baliki2@freemail.gr</a> [mailto:<a ymailto="mailto:baliki2@freemail.gr" href="/mc/compose?to=baliki2@freemail.gr">baliki2@freemail.gr</a>]<br>&gt; Sent: Friday, October 23, 2009 2:11 PM<br>&gt; To: <a ymailto="mailto:post@rocco-gasteiger.de" href="/mc/compose?to=post@rocco-gasteiger.de">post@rocco-gasteiger.de</a><br>&gt; Subject: Re: Re: [vtkusers] x-ray effect in volume rendering<br>&gt; <br>&gt; <br>&gt; I don't really understand what you mean by "divide it by<br>&gt; &gt;
 numSteps*globalMaximumScalarValue at the end".<br>&gt; <br>&gt; What i would like to get is something like this:<br>&gt; <a href="http://www.onlinetelemedicine.com/HTML/product/sam_images/X-Ray.jpg" target="_blank">http://www.onlinetelemedicine.com/HTML/product/sam_images/X-Ray.jpg</a><br>&gt; If you look carefully, the bones edges are more bright than the "inside"<br>&gt; bone area.<br>&gt; I've achieved a similar effect, but not this exact one:<br>&gt; <a href="http://img12.imageshack.us/i/sendj.png/" target="_blank">http://img12.imageshack.us/i/sendj.png/</a><br>&gt; Please download it and zoom in to see it better.<br>&gt; <br>&gt; Thanks!<br>&gt; <br>&gt; &gt; Hello,<br>&gt; &gt;<br>&gt; &gt; Yes, you can! ;-)<br>&gt; &gt;<br>&gt; &gt; It is quite simply. In your composite function accumulate all sampled<br>&gt; scalar<br>&gt; &gt; values (or opacity values) on your ray and divide it by<br>&gt; &gt; numSteps*globalMaximumScalarValue at the end (to
 get the average between 0<br>&gt; &gt; and 1). I've implement it and it should work.<br>&gt; &gt;<br>&gt; &gt; Best regards, Rocco<br>&gt; &gt;<br>&gt; &gt; --------------------------------------------------<br>&gt; &gt; Dipl.-Ing. Rocco Gasteiger<br>&gt; &gt; Otto-von-Guericke University<br>&gt; &gt; Faculty of Computer Science<br>&gt; &gt; Department of Simulation and Graphics<br>&gt; &gt; Universit=E4tsplatz 2, 39106 Magdeburg, Germany<br>&gt; &gt;<br>&gt; &gt; Office:&nbsp; G29-223<br>&gt; &gt; Phone:&nbsp;&nbsp;&nbsp;+49 391 67 127 59<br>&gt; &gt; Fax:=A0=A0&nbsp;&nbsp;&nbsp;+49 391 67 111 64<br>&gt; &gt; Website: <a href="http://wwwisg.cs.uni-magdeburg.de/cvcms/" target="_blank">http://wwwisg.cs.uni-magdeburg.de/cvcms/</a>&nbsp; =<br>&gt; &gt;<br>&gt; &gt; --------------------------------------------------<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; -----Original Message-----<br>&gt; &gt; From: <a ymailto="mailto:vtkusers-bounces@vtk.org"
 href="/mc/compose?to=vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a> [mailto:<a ymailto="mailto:vtkusers-bounces@vtk.org" href="/mc/compose?to=vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a>] On Behalf<br>&gt; &gt; Of <a ymailto="mailto:baliki2@freemail.gr" href="/mc/compose?to=baliki2@freemail.gr">baliki2@freemail.gr</a><br>&gt; &gt; Sent: Friday, October 23, 2009 11:30 AM<br>&gt; &gt; To: <a ymailto="mailto:vtkusers@vtk.org" href="/mc/compose?to=vtkusers@vtk.org">vtkusers@vtk.org</a><br>&gt; &gt; Subject: [vtkusers] x-ray effect in volume rendering<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Is there a way that i can achieve an x-ray effect in volume rendering of<br>&gt; &gt; DICOM images?<br>&gt; &gt; I want to see the constructed volume as a 2D xray-like "image".<br>&gt; &gt;<br>&gt; &gt; I've tied the composite function combined with some tranfer and color<br>&gt; &gt; functions, but i didn't take the exact x-ray effect. The images i use
 are<br>&gt; of<br>&gt; &gt; short type.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; _______________________________________________<br>&gt; &gt; Powered by www.kitware.com<br>&gt; &gt;<br>&gt; &gt; Visit other Kitware open-source projects at<br>&gt; &gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt; &gt;<br>&gt; &gt; Please keep messages on-topic and check the VTK FAQ at:<br>&gt; &gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt; &gt;<br>&gt; &gt; Follow this link to subscribe/unsubscribe:<br>&gt; &gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt; &gt;<br>&gt; &gt; _______________________________________________<br>&gt; &gt; Powered by www.kitware.com<br>&gt; &gt;<br>&gt; &gt; Visit other Kitware open-source projects at<br>&gt; <a
 href="http://www.kitware.com/opensour=" target="_blank">http://www.kitware.com/opensour=</a><br>&gt; &gt; ce/opensource.html<br>&gt; &gt;<br>&gt; &gt; Please keep messages on-topic and check the VTK FAQ at:<br>&gt; <a href="http://www.vtk.org/=" target="_blank">http://www.vtk.org/=</a><br>&gt; &gt; Wiki/VTK_FAQ<br>&gt; &gt;<br>&gt; &gt; Follow this link to subscribe/unsubscribe:<br>&gt; &gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt; <br>&gt; _______________________________________________<br>&gt; Powered by www.kitware.com<br>&gt; <br>&gt; Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt; <br>&gt; Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ"
 target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt; <br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br><br><br>_______________________________________________<br>Powered by www.kitware.com<br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></div></blockquote></td></tr></table><br>