<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4134.600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Dear friends,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I want to show volume raycast output.Earlier I used 
vtkVolume16Reader class.Now I am using vtkImageImport to read buffer slice by 
slice and display volume.I have written code as follows.But I am not getting 
exact volume.Please give me suggestion.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>void Raycast(LPSTR FileName,HWND m_hWnd,double 
in_max,double in_min)<BR>{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;<BR>&nbsp;DICOMReader 
TempReader1;<BR>&nbsp;//creating objects <BR>&nbsp;TempReader1.StaticVarInit(); 
<BR>&nbsp;BOOL flag=TempReader1.ReadDicomImage(FileName); <BR>&nbsp;char 
*acquistion=TempReader1.GetDicomInfo(cs_modality); <BR>&nbsp;const char 
&nbsp;*samples=TempReader1.GetDicomInfo(cs_samples_pixel);<BR>&nbsp;char 
*Spacing = TempReader1.GetDicomInfo(cs_pixel_spacing);<BR>&nbsp;char *ChrVDepth 
= TempReader1.GetDicomInfo(cs_slice_thickness);<BR>&nbsp;float VoxelDepth = 
atof(ChrVDepth);<BR>&nbsp;//double in_max,in_min;<BR>&nbsp;double VoxelWidth, 
VoxelHeight;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;GetVoxelSpacing(Spacing,VoxelWidth,VoxelHeight);<BR>&nbsp;<BR>&nbsp;// 
Vtk Class to import the Buffer for furthur operations on 
volume.<BR>&nbsp;unsigned short 
*Buffer=NULL;<BR>&nbsp;if(strcmp(acquistion,"MR")==0)<BR>&nbsp;{<BR>&nbsp;&nbsp;//FindVolumeMaxMin(FileName,&amp;in_max,&amp;in_min);<BR>&nbsp;&nbsp;LPSTR 
File=new char 
[100];<BR>&nbsp;&nbsp;&nbsp;&nbsp;File=IntensityScaleVolume(FileName,in_max,in_min,750,300);<BR>&nbsp;&nbsp;TempReader1.StaticVarInit(); 
<BR>&nbsp;&nbsp;BOOL flag=TempReader1.ReadDicomImage(File); 
<BR>&nbsp;&nbsp;Buffer = (unsigned short *) TempReader1.GetAllImageData();&nbsp; 
<BR>&nbsp;&nbsp;samples=TempReader1.GetDicomInfo(cs_samples_pixel);<BR>&nbsp;}<BR>&nbsp;else<BR>&nbsp;&nbsp;Buffer 
= (unsigned short *) TempReader1.GetAllImageData();&nbsp; </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;int 
spp=atoi(samples);<BR>&nbsp;<BR>&nbsp;renderer1 
=vtkRenderer::New();<BR>&nbsp;renWin1=vtkRenderWindow::New();<BR>&nbsp;<BR>&nbsp;Importer 
= vtkImageImport::New();<BR>&nbsp;<BR>&nbsp;Importer-&gt;SetDataExtent(0, 
TempReader1.width - 1, 0, TempReader1.height- 1, 0, &nbsp;TempReader1.Slices - 
1);<BR>&nbsp;Importer-&gt;SetWholeExtent(0, TempReader1.width - 1, 0, 
TempReader1.height- 1, 0, &nbsp;TempReader1.Slices - 
1);<BR>&nbsp;Importer-&gt;SetDataSpacing((float)VoxelWidth,(float)VoxelHeight,(float)VoxelDepth);<BR>&nbsp;<BR>&nbsp;Importer-&gt;SetNumberOfScalarComponents(spp);<BR>&nbsp;Importer-&gt;SetDataScalarTypeToUnsignedShort();<BR>&nbsp;Importer-&gt;SetImportVoidPointer(Buffer);&nbsp;&nbsp; 
// Importing the Buffer<BR>&nbsp;<BR>&nbsp;//flip the image into z axis 
</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;flip=vtkImageFlip::New();<BR>&nbsp;flip-&gt;SetInput(Importer-&gt;GetOutput());<BR>&nbsp;flip-&gt;SetFilteredAxes(2);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;//to get first image display once again flip 
the 
image<BR>&nbsp;flip1=vtkImageFlip::New();<BR>&nbsp;flip1-&gt;SetInput(flip-&gt;GetOutput());<BR>&nbsp;flip1-&gt;SetFilteredAxes(1);<BR>&nbsp;<BR>&nbsp;//ray 
cast composition function 
<BR>&nbsp;compositeFunction=vtkVolumeRayCastCompositeFunction::New();<BR>&nbsp;volume1=vtkVolume::New();<BR>&nbsp;<BR>&nbsp;//opacity 
transfer 
functio<BR>&nbsp;<BR>&nbsp;opacityTransferFunction=vtkPiecewiseFunction::New();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
opacityTransferFunction-&gt;AddPoint(0,0.0);<BR>&nbsp;opacityTransferFunction-&gt;AddPoint(127,1.0);<BR>&nbsp;opacityTransferFunction-&gt;AddPoint(255,2.0);<BR>&nbsp;opacityTransferFunction-&gt;AddPoint(383,3.0);<BR>&nbsp;opacityTransferFunction-&gt;AddPoint(511,4.0);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;<BR>&nbsp;volumeProperty=vtkVolumeProperty::New();<BR>&nbsp;volumeProperty-&gt;SetScalarOpacity(opacityTransferFunction);<BR>&nbsp;volumeProperty-&gt;SetAmbient(0.10);<BR>&nbsp;volumeProperty-&gt;SetDiffuse(0.50);<BR>&nbsp;volumeProperty-&gt;SetSpecular(0.40);<BR>&nbsp;volumeProperty-&gt;SetSpecularPower(100);<BR>&nbsp;volumeProperty-&gt;SetInterpolationTypeToLinear();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
volumeProperty-&gt;ShadeOn();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;volumeMapper=vtkVolumeRayCastMapper::New();&nbsp;<BR>&nbsp;volumeMapper-&gt;SetVolumeRayCastFunction(compositeFunction);///for 
Raycast 
Technique<BR>&nbsp;volumeMapper-&gt;SetInput(flip1-&gt;GetOutput());<BR>&nbsp;<BR>&nbsp;volume1-&gt;SetMapper(volumeMapper);<BR>&nbsp;volume1-&gt;SetProperty(volumeProperty);<BR>&nbsp;&nbsp;<BR>&nbsp;renderer1-&gt;AddVolume(volume1);<BR>&nbsp;renWin1-&gt;AddRenderer(renderer1);<BR>&nbsp;renWin1-&gt;SetParentId(m_hWnd);<BR>&nbsp;iren1 
=vtkRenderWindowInteractor::New();<BR>&nbsp;iren1-&gt;SetRenderWindow(renWin1);<BR>&nbsp;renWin1-&gt;Render();&nbsp; 
<BR>&nbsp;iren1-&gt;Initialize();<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2>Ramakrishna</FONT></DIV></BODY></HTML>