<!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 frineds,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I am working volumerendering.All three techniques 
are working perfectly.But It is very slow when I drag 120 slices in one image.I 
want to make it fast .I have written code as follows.Please give me 
suggestion&nbsp; to make it fast.</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=Arial size=2>
<DIV><BR>void Composite(LPSTR FileName,HWND m_hWnd)<BR>{</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;DICOMReader DCMReader;<BR>&nbsp;DCMReader.StaticVarInit(); 
<BR>&nbsp;///Read the Dicom file<BR>&nbsp;BOOL 
flag=DCMReader.ReadDicomImage(FileName); <BR>&nbsp;//samples per 
pixel<BR>&nbsp;const char 
*samples=DCMReader.GetDicomInfo(cs_samples_pixel);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;float VoxelDepth = 1;<BR>&nbsp;double VoxelWidth = 1,VoxelHeight = 
1;<BR>&nbsp;//dataspacing in x,y direction <BR>&nbsp;char *Spacing = 
DCMReader.GetDicomInfo(cs_pixel_spacing);<BR>&nbsp;//dataspacing in z 
direction<BR>&nbsp;char *ChrVDepth = 
DCMReader.GetDicomInfo(cs_slice_thickness);<BR>&nbsp;<BR>&nbsp;if(strcmp(ChrVDepth," 
") != 0)<BR>&nbsp;&nbsp;VoxelDepth = atof(ChrVDepth);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;if(strcmp(Spacing," ") != 
0)<BR>&nbsp;&nbsp;GetVoxelSpacing(Spacing,VoxelWidth,VoxelHeight);<BR>&nbsp;<BR>&nbsp;///get 
image data pointer<BR>&nbsp;unsigned char* Buffer = (unsigned char *) 
DCMReader.GetAllImageData();&nbsp; <BR>&nbsp;int 
spp=atoi(samples);<BR>&nbsp;&nbsp;///calculating the volume size<BR>&nbsp;long 
ImageSz = DCMReader.width&nbsp; * DCMReader.height 
*DCMReader.Slices;<BR>&nbsp;long in_max,in_min;<BR>&nbsp;<BR>&nbsp;renderer1 
=vtkRenderer::New();<BR>&nbsp;renWin1=vtkRenderWindow::New();<BR>&nbsp;<BR>&nbsp;// 
Vtk Class to import the Buffer for furthur operations on 
volume.<BR>&nbsp;<BR>&nbsp;vtkImageImport *Importer = 
vtkImageImport::New();<BR>&nbsp;<BR>&nbsp;Importer-&gt;SetDataExtent(0, 
DCMReader.width - 1, 0, DCMReader.height- 1, 0, DCMReader.Slices - 
1);<BR>&nbsp;Importer-&gt;SetWholeExtent(0, DCMReader.width - 1, 0, 
DCMReader.height- 1, 0, DCMReader.Slices - 
1);<BR>&nbsp;Importer-&gt;SetDataSpacing((float)VoxelWidth,(float)VoxelHeight,(float)VoxelDepth);<BR>&nbsp;Importer-&gt;SetNumberOfScalarComponents(spp);<BR>&nbsp;// 
Set the Appropriate Data Type to the Importer 
Object<BR>&nbsp;if(DCMReader.DataType==DCMUShort) 
<BR>&nbsp;{<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;//Find the max,min values of Input 
Images<BR>&nbsp;&nbsp;FindMinMax((unsigned 
short*)Buffer,ImageSz,&amp;in_max,&amp;in_min);<BR>&nbsp;&nbsp;Importer-&gt;SetDataScalarTypeToUnsignedShort();<BR>&nbsp;&nbsp;<BR>&nbsp;}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;if(DCMReader.DataType==DCMShort) 
<BR>&nbsp;{<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;//Find the max,min values of Input 
Images<BR>&nbsp;&nbsp;FindMinMax((short 
*)Buffer,ImageSz,&amp;in_max,&amp;in_min);<BR>&nbsp;&nbsp;Importer-&gt;SetDataScalarTypeToUnsignedShort();<BR>&nbsp;}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;if(DCMReader.DataType==DCMUChar) <BR>&nbsp;{<BR>&nbsp;&nbsp;//Find 
the max,min values of Input Images<BR>&nbsp;&nbsp;FindMinMax((unsigned char 
*)Buffer,ImageSz,&amp;in_max,&amp;in_min);<BR>&nbsp;&nbsp;Importer-&gt;SetDataScalarTypeToUnsignedChar();<BR>&nbsp;}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;if(DCMReader.DataType==DCMChar) <BR>&nbsp;{<BR>&nbsp;&nbsp;//Find the 
max,min values of Input Images <BR>&nbsp;&nbsp;FindMinMax((char 
*)Buffer,ImageSz,&amp;in_max,&amp;in_min);<BR>&nbsp;&nbsp;Importer-&gt;SetDataScalarTypeToUnsignedChar();<BR>&nbsp;}</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;Importer-&gt;SetImportVoidPointer(Buffer);&nbsp;&nbsp; // 
Importing the Buffer<BR>&nbsp;<BR>&nbsp;//to get first image display once again 
flip the image<BR>&nbsp;vtkImageFlip 
*upsidedownflip=vtkImageFlip::New();<BR>&nbsp;upsidedownflip-&gt;SetInput(Importer-&gt;GetOutput());<BR>&nbsp;upsidedownflip-&gt;SetFilteredAxes(2);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;vtkImageFlip 
*fronttobackflip=vtkImageFlip::New();<BR>&nbsp;fronttobackflip-&gt;SetInput(upsidedownflip-&gt;GetOutput());<BR>&nbsp;fronttobackflip-&gt;SetFilteredAxes(1);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;//Create a transfer function mapping scalar value to 
opacity<BR>&nbsp;vtkPiecewiseFunction *oTFun = 
vtkPiecewiseFunction::New();<BR>&nbsp;oTFun-&gt;AddPoint(0, 
0.0);<BR>&nbsp;oTFun-&gt;AddPoint(in_max, 0.2);<BR>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; //Create a transfer function mapping scalar value to color 
(grey)<BR>&nbsp; vtkPiecewiseFunction *cTFun = 
vtkPiecewiseFunction::New();<BR>&nbsp; cTFun-&gt;AddSegment(0, 0.5, in_max, 
1);<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; &nbsp;// Create a property for the 
volume and set the transfer functions.<BR>&nbsp; // Turn shading on and use 
trilinear interpolation<BR>&nbsp;&nbsp; vtkVolumeProperty *volumeProperty = 
vtkVolumeProperty::New();<BR>&nbsp;&nbsp; 
volumeProperty-&gt;SetColor(cTFun);<BR>&nbsp;&nbsp; 
volumeProperty-&gt;SetScalarOpacity(oTFun);<BR>&nbsp;&nbsp; 
volumeProperty-&gt;SetAmbient(0.10);<BR>&nbsp;&nbsp; 
volumeProperty-&gt;SetDiffuse(0.40);<BR>&nbsp;&nbsp; 
volumeProperty-&gt;SetSpecular(0.50);<BR>&nbsp;&nbsp; 
volumeProperty-&gt;SetSpecularPower(1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
volumeProperty-&gt;SetInterpolationTypeToLinear();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
volumeProperty-&gt;ShadeOn();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;<BR>&nbsp;vtkVolumeRayCastMapper 
*volumeMapper=vtkVolumeRayCastMapper::New();&nbsp;<BR>&nbsp;vtkVolumeRayCastCompositeFunction 
*Composite=vtkVolumeRayCastCompositeFunction::New(); 
<BR>&nbsp;Composite-&gt;SetCompositeMethodToClassifyFirst();<BR>&nbsp;volumeMapper-&gt;SetInput(fronttobackflip-&gt;GetOutput());</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;volumeMapper-&gt;SetVolumeRayCastFunction(Composite);///for Composite 
Technique</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;vtkVolume 
*volume1=vtkVolume::New();&nbsp;<BR>&nbsp;volume1-&gt;SetMapper(volumeMapper);<BR>&nbsp;volume1-&gt;SetProperty(volumeProperty);<BR>&nbsp;//Set 
the volume to Volume to renderer&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;vtkLODProp3D 
*lod=vtkLODProp3D::New();<BR>&nbsp;lod-&gt;AddLOD(volumeMapper,volumeProperty,0.0);<BR>&nbsp;lod-&gt;SetPosition(0,1,2);<BR>&nbsp;lod-&gt;SetScale(3,3,3);<BR>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;renderer1-&gt;AddProp(lod);<BR>&nbsp;//renderer1-&gt;AddVolume(volume1);<BR>&nbsp;renWin1-&gt;AddRenderer(renderer1);<BR>&nbsp;<BR>&nbsp;///Client 
window handle to vtk Render 
window<BR>&nbsp;renWin1-&gt;SetParentId(m_hWnd);<BR>&nbsp;//set the render 
window 
size<BR>&nbsp;renWin1-&gt;SetSize(DCMReader.width+10,DCMReader.height+10); 
<BR>&nbsp;iren1 
=vtkRenderWindowInteractor::New();<BR>&nbsp;iren1-&gt;SetRenderWindow(renWin1);<BR>&nbsp;//Render 
the Volume<BR>&nbsp;renWin1-&gt;Render();&nbsp; <BR>&nbsp;//mouse interact the 
render window<BR>&nbsp;iren1-&gt;Initialize();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;//clean the vtk 
objects<BR>&nbsp;<BR>&nbsp;Importer-&gt;Delete();<BR>&nbsp;fronttobackflip-&gt;Delete();<BR>&nbsp;upsidedownflip-&gt;Delete();<BR>&nbsp;Composite-&gt;Delete();<BR>&nbsp;oTFun-&gt;Delete();<BR>&nbsp;cTFun-&gt;Delete();<BR>&nbsp;volumeProperty-&gt;Delete();<BR>&nbsp;volumeMapper-&gt;Delete();<BR>&nbsp;volume1-&gt;Delete();<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>thanking you,</DIV>
<DIV>&nbsp;</DIV>
<DIV>regards,<BR>ramakrishna</FONT></DIV></BODY></HTML>