<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=iso-8859-7>
<META content="MSHTML 6.00.6000.16608" name=GENERATOR></HEAD>
<BODY id=MailContainerBody 
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px" 
bgColor=#ffffff leftMargin=0 topMargin=0 CanvasTabStop="true" 
name="Compose message area">
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>I have combined the code found in 
itkReadITKImageShowVTK.cpp file (InsightApplications\Auxiliary\vtk) and the code 
found in DicomSeriesReadImageWrite2.cpp (InsightToolkit\Examples\IO) to read a 
DICOM series and visualize it in VTK. My problem is that the volume is not 
visualized correctly. I believe something's wrong with the opacity. Here is my 
code. </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>this is what i get when i read the dicom series in itk and visualize it in 
vtk</DIV>
<DIV>&nbsp;</DIV>
<DIV><A 
title="http://img385.imageshack.us/img385/6632/itkla0.jpg&#10;CTRL + Click to follow link" 
href="http://img385.imageshack.us/img385/6632/itkla0.jpg">http://img385.imageshack.us/img385/6632/itkla0.jpg</A></DIV>
<DIV>&nbsp;</DIV>
<DIV>and this is what i want the volume to look like (reading dicom series and 
visualizing the volume in vtk)</DIV>
<DIV>&nbsp;</DIV>
<DIV><A 
title="http://img389.imageshack.us/img389/9425/vtkif8.jpg&#10;CTRL + Click to follow link" 
href="http://img389.imageshack.us/img389/9425/vtkif8.jpg">http://img389.imageshack.us/img389/9425/vtkif8.jpg</A></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>template &lt;typename ITK_Exporter, typename 
VTK_Importer&gt;<BR>void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* 
importer)<BR>{<BR>&nbsp; 
importer-&gt;SetUpdateInformationCallback(exporter-&gt;GetUpdateInformationCallback());<BR>&nbsp; 
importer-&gt;SetPipelineModifiedCallback(exporter-&gt;GetPipelineModifiedCallback());<BR>&nbsp; 
importer-&gt;SetWholeExtentCallback(exporter-&gt;GetWholeExtentCallback());<BR>&nbsp; 
importer-&gt;SetSpacingCallback(exporter-&gt;GetSpacingCallback());<BR>&nbsp; 
importer-&gt;SetOriginCallback(exporter-&gt;GetOriginCallback());<BR>&nbsp; 
importer-&gt;SetScalarTypeCallback(exporter-&gt;GetScalarTypeCallback());<BR>&nbsp; 
importer-&gt;SetNumberOfComponentsCallback(exporter-&gt;GetNumberOfComponentsCallback());<BR>&nbsp; 
importer-&gt;SetPropagateUpdateExtentCallback(exporter-&gt;GetPropagateUpdateExtentCallback());<BR>&nbsp; 
importer-&gt;SetUpdateDataCallback(exporter-&gt;GetUpdateDataCallback());<BR>&nbsp; 
importer-&gt;SetDataExtentCallback(exporter-&gt;GetDataExtentCallback());<BR>&nbsp; 
importer-&gt;SetBufferPointerCallback(exporter-&gt;GetBufferPointerCallback());<BR>&nbsp; 
importer-&gt;SetCallbackUserData(exporter-&gt;GetCallbackUserData());<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>/**<BR>&nbsp;* This function will connect the given 
vtkImageExport filter to<BR>&nbsp;* the given itk::VTKImageImport 
filter.<BR>&nbsp;*/<BR>template &lt;typename VTK_Exporter, typename 
ITK_Importer&gt;<BR>void ConnectPipelines(VTK_Exporter* exporter, ITK_Importer 
importer)<BR>{<BR>&nbsp; 
importer-&gt;SetUpdateInformationCallback(exporter-&gt;GetUpdateInformationCallback());<BR>&nbsp; 
importer-&gt;SetPipelineModifiedCallback(exporter-&gt;GetPipelineModifiedCallback());<BR>&nbsp; 
importer-&gt;SetWholeExtentCallback(exporter-&gt;GetWholeExtentCallback());<BR>&nbsp; 
importer-&gt;SetSpacingCallback(exporter-&gt;GetSpacingCallback());<BR>&nbsp; 
importer-&gt;SetOriginCallback(exporter-&gt;GetOriginCallback());<BR>&nbsp; 
importer-&gt;SetScalarTypeCallback(exporter-&gt;GetScalarTypeCallback());<BR>&nbsp; 
importer-&gt;SetNumberOfComponentsCallback(exporter-&gt;GetNumberOfComponentsCallback());<BR>&nbsp; 
importer-&gt;SetPropagateUpdateExtentCallback(exporter-&gt;GetPropagateUpdateExtentCallback());<BR>&nbsp; 
importer-&gt;SetUpdateDataCallback(exporter-&gt;GetUpdateDataCallback());<BR>&nbsp; 
importer-&gt;SetDataExtentCallback(exporter-&gt;GetDataExtentCallback());<BR>&nbsp; 
importer-&gt;SetBufferPointerCallback(exporter-&gt;GetBufferPointerCallback());<BR>&nbsp; 
importer-&gt;SetCallbackUserData(exporter-&gt;GetCallbackUserData());<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>int itkReadDicomSeries (std::string 
directoryPath)<BR>{&nbsp;<BR>&nbsp;typedef unsigned char&nbsp;&nbsp;&nbsp; 
PixelType;<BR>&nbsp;const unsigned int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dimension = 
3;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;typedef itk::OrientedImage&lt; PixelType, 
Dimension &gt; ImageType;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;typedef itk::ImageSeriesReader&lt; ImageType 
&gt; ReaderType;<BR>&nbsp;ReaderType::Pointer reader = 
ReaderType::New();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;typedef 
itk::GDCMImageIO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ImageIOType;<BR>&nbsp;ImageIOType::Pointer dicomIO = 
ImageIOType::New();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;reader-&gt;SetImageIO( dicomIO 
);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;typedef itk::GDCMSeriesFileNames 
NamesGeneratorType;<BR>&nbsp;NamesGeneratorType::Pointer nameGenerator = 
NamesGeneratorType::New();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;nameGenerator-&gt;SetUseSeriesDetails( true 
);<BR>&nbsp;nameGenerator-&gt;AddSeriesRestriction("0008|0021" );</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;nameGenerator-&gt;SetDirectory(directoryPath);<BR>&nbsp;<BR>&nbsp;std::cout 
&lt;&lt; std::endl &lt;&lt; "The directory: " &lt;&lt; 
std::endl;<BR>&nbsp;std::cout &lt;&lt; std::endl &lt;&lt; directoryPath &lt;&lt; 
std::endl &lt;&lt; std::endl;<BR>&nbsp;std::cout &lt;&lt; "Contains the 
following DICOM Series: ";<BR>&nbsp;std::cout &lt;&lt; std::endl &lt;&lt; 
std::endl;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;typedef std::vector&lt; std::string 
&gt;&nbsp;&nbsp;&nbsp; SeriesIdContainer;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;const SeriesIdContainer &amp; seriesUID = 
nameGenerator-&gt;GetSeriesUIDs();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;SeriesIdContainer::const_iterator seriesItr = 
seriesUID.begin();<BR>&nbsp;SeriesIdContainer::const_iterator seriesEnd = 
seriesUID.end();<BR>&nbsp;while( seriesItr != seriesEnd ) 
{<BR>&nbsp;&nbsp;std::cout &lt;&lt; seriesItr-&gt;c_str() &lt;&lt; 
std::endl;<BR>&nbsp;&nbsp;seriesItr++;<BR>&nbsp;}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;std::string 
seriesIdentifier;<BR>&nbsp;&nbsp;&nbsp;&nbsp;seriesIdentifier = 
seriesUID.begin()-&gt;c_str();<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;std::cout 
&lt;&lt; std::endl &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;std::cout 
&lt;&lt; "Now reading series: " &lt;&lt; std::endl &lt;&lt; 
std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; seriesIdentifier 
&lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; std::endl 
&lt;&lt; std::endl;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;typedef std::vector&lt; 
std::string &gt;&nbsp;&nbsp; 
FileNamesContainer;<BR>&nbsp;&nbsp;&nbsp;&nbsp;FileNamesContainer 
fileNames;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;fileNames = 
nameGenerator-&gt;GetFileNames( seriesIdentifier );</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>reader-&gt;SetFileNames( fileNames 
);&nbsp;&nbsp;<BR>reader-&gt;Update();<BR>&nbsp;</FONT><FONT face=Arial 
size=2><BR></FONT><FONT face=Arial size=2>typedef itk::VTKImageExport&lt; 
ImageType &gt; ExportFilterType;<BR>&nbsp;&nbsp;&nbsp; ExportFilterType::Pointer 
itkExporter = ExportFilterType::New();&nbsp;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; itkExporter-&gt;SetInput( 
reader-&gt;GetOutput() );<BR>&nbsp;<BR>// Create the vtkImageImport and connect 
it to the itk::VTKImageExport instance.<BR>&nbsp;&nbsp;&nbsp; vtkImageImport* 
vtkImporter = vtkImageImport::New();&nbsp; <BR>&nbsp;&nbsp;&nbsp; 
ConnectPipelines(itkExporter, vtkImporter);<BR>&nbsp;<BR>vtkPiecewiseFunction* 
opacityTransferFunction = vtkPiecewiseFunction::New();<BR>&nbsp;&nbsp;&nbsp; 
vtkColorTransferFunction* colorTransferFunction = 
vtkColorTransferFunction::New();&nbsp;&nbsp;<BR>&nbsp;<BR>vtkVolume* volume = 
vtkVolume::New();<BR>vtkVolumeProperty* volumeProperty = 
vtkVolumeProperty::New();&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;vtkVolumeTextureMapper3D* 
volumeMapper = vtkVolumeTextureMapper3D::New();<BR>&nbsp;&nbsp;&nbsp; 
vtkFixedPointVolumeRayCastMapper* volumeMapperSoftware = 
vtkFixedPointVolumeRayCastMapper::New();<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;volumeProperty-&gt;SetScalarOpacity(opacityTransferFunction);<BR>&nbsp;&nbsp;&nbsp;&nbsp;volumeProperty-&gt;SetInterpolationTypeToLinear();<BR>&nbsp;&nbsp;&nbsp;&nbsp;volumeProperty-&gt;ShadeOff();&nbsp;<BR>&nbsp;&nbsp;&nbsp; 
volume-&gt;SetProperty(volumeProperty);&nbsp;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;volumeMapperSoftware-&gt;SetInput(vtkImporter-&gt;GetOutput());<BR>&nbsp;volumeMapperSoftware-&gt;SetSampleDistance(1.0);<BR>&nbsp;&nbsp;&nbsp;volume-&gt;SetMapper(volumeMapperSoftware);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
vtkInteractorStyleTrackballCamera * interactorStyle = 
vtkInteractorStyleTrackballCamera::New();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; // Create a renderer, render 
window, and render window interactor to display the 
results.<BR>&nbsp;&nbsp;&nbsp; vtkRenderer* renderer = 
vtkRenderer::New();<BR>&nbsp;&nbsp;&nbsp; vtkRenderWindow* renWin = 
vtkRenderWindow::New();<BR>&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor* iren = 
vtkRenderWindowInteractor::New();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 
renWin-&gt;SetSize(500, 500);<BR>&nbsp;&nbsp;&nbsp; 
renWin-&gt;AddRenderer(renderer);<BR>&nbsp;&nbsp;&nbsp; 
iren-&gt;SetRenderWindow(renWin);<BR>&nbsp;&nbsp;&nbsp; 
iren-&gt;SetInteractorStyle(interactorStyle);<BR>&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp; // Add the vtkImageActor to the renderer for 
display.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;renderer-&gt;AddVolume(volume);<BR>&nbsp;&nbsp;&nbsp; 
</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; // Bring up the render window 
and begin interaction.<BR>&nbsp;&nbsp;&nbsp; 
renWin-&gt;Render();<BR>&nbsp;&nbsp;&nbsp; iren-&gt;Start();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;return 0;<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>If anyone has another working example that does what i am trying to do 
please let me know. I would really appreciate it.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks in advance,</DIV>
<DIV>Polys</DIV></FONT></DIV></BODY></HTML>