<!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> </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> </DIV>
<DIV><FONT face=Arial size=2>void Raycast(LPSTR FileName,HWND m_hWnd,double
in_max,double in_min)<BR>{</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> <BR> DICOMReader
TempReader1;<BR> //creating objects <BR> TempReader1.StaticVarInit();
<BR> BOOL flag=TempReader1.ReadDicomImage(FileName); <BR> char
*acquistion=TempReader1.GetDicomInfo(cs_modality); <BR> const char
*samples=TempReader1.GetDicomInfo(cs_samples_pixel);<BR> char
*Spacing = TempReader1.GetDicomInfo(cs_pixel_spacing);<BR> char *ChrVDepth
= TempReader1.GetDicomInfo(cs_slice_thickness);<BR> float VoxelDepth =
atof(ChrVDepth);<BR> //double in_max,in_min;<BR> double VoxelWidth,
VoxelHeight;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> GetVoxelSpacing(Spacing,VoxelWidth,VoxelHeight);<BR> <BR> //
Vtk Class to import the Buffer for furthur operations on
volume.<BR> unsigned short
*Buffer=NULL;<BR> if(strcmp(acquistion,"MR")==0)<BR> {<BR> //FindVolumeMaxMin(FileName,&in_max,&in_min);<BR> LPSTR
File=new char
[100];<BR> File=IntensityScaleVolume(FileName,in_max,in_min,750,300);<BR> TempReader1.StaticVarInit();
<BR> BOOL flag=TempReader1.ReadDicomImage(File);
<BR> Buffer = (unsigned short *) TempReader1.GetAllImageData();
<BR> samples=TempReader1.GetDicomInfo(cs_samples_pixel);<BR> }<BR> else<BR> Buffer
= (unsigned short *) TempReader1.GetAllImageData(); </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> int
spp=atoi(samples);<BR> <BR> renderer1
=vtkRenderer::New();<BR> renWin1=vtkRenderWindow::New();<BR> <BR> Importer
= vtkImageImport::New();<BR> <BR> Importer->SetDataExtent(0,
TempReader1.width - 1, 0, TempReader1.height- 1, 0, TempReader1.Slices -
1);<BR> Importer->SetWholeExtent(0, TempReader1.width - 1, 0,
TempReader1.height- 1, 0, TempReader1.Slices -
1);<BR> Importer->SetDataSpacing((float)VoxelWidth,(float)VoxelHeight,(float)VoxelDepth);<BR> <BR> Importer->SetNumberOfScalarComponents(spp);<BR> Importer->SetDataScalarTypeToUnsignedShort();<BR> Importer->SetImportVoidPointer(Buffer);
// Importing the Buffer<BR> <BR> //flip the image into z axis
</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> flip=vtkImageFlip::New();<BR> flip->SetInput(Importer->GetOutput());<BR> flip->SetFilteredAxes(2);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> //to get first image display once again flip
the
image<BR> flip1=vtkImageFlip::New();<BR> flip1->SetInput(flip->GetOutput());<BR> flip1->SetFilteredAxes(1);<BR> <BR> //ray
cast composition function
<BR> compositeFunction=vtkVolumeRayCastCompositeFunction::New();<BR> volume1=vtkVolume::New();<BR> <BR> //opacity
transfer
functio<BR> <BR> opacityTransferFunction=vtkPiecewiseFunction::New();<BR>
opacityTransferFunction->AddPoint(0,0.0);<BR> opacityTransferFunction->AddPoint(127,1.0);<BR> opacityTransferFunction->AddPoint(255,2.0);<BR> opacityTransferFunction->AddPoint(383,3.0);<BR> opacityTransferFunction->AddPoint(511,4.0);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> <BR>
<BR> <BR> volumeProperty=vtkVolumeProperty::New();<BR> volumeProperty->SetScalarOpacity(opacityTransferFunction);<BR> volumeProperty->SetAmbient(0.10);<BR> volumeProperty->SetDiffuse(0.50);<BR> volumeProperty->SetSpecular(0.40);<BR> volumeProperty->SetSpecularPower(100);<BR> volumeProperty->SetInterpolationTypeToLinear();<BR>
volumeProperty->ShadeOn();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> volumeMapper=vtkVolumeRayCastMapper::New(); <BR> volumeMapper->SetVolumeRayCastFunction(compositeFunction);///for
Raycast
Technique<BR> volumeMapper->SetInput(flip1->GetOutput());<BR> <BR> volume1->SetMapper(volumeMapper);<BR> volume1->SetProperty(volumeProperty);<BR> <BR> renderer1->AddVolume(volume1);<BR> renWin1->AddRenderer(renderer1);<BR> renWin1->SetParentId(m_hWnd);<BR> iren1
=vtkRenderWindowInteractor::New();<BR> iren1->SetRenderWindow(renWin1);<BR> renWin1->Render();
<BR> iren1->Initialize();<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2>Ramakrishna</FONT></DIV></BODY></HTML>