<!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> </DIV>
<DIV>this is what i get when i read the dicom series in itk and visualize it in
vtk</DIV>
<DIV> </DIV>
<DIV><A
title="http://img385.imageshack.us/img385/6632/itkla0.jpg 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> </DIV>
<DIV>and this is what i want the volume to look like (reading dicom series and
visualizing the volume in vtk)</DIV>
<DIV> </DIV>
<DIV><A
title="http://img389.imageshack.us/img389/9425/vtkif8.jpg 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> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>template <typename ITK_Exporter, typename
VTK_Importer><BR>void ConnectPipelines(ITK_Exporter exporter, VTK_Importer*
importer)<BR>{<BR>
importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());<BR>
importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());<BR>
importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());<BR>
importer->SetSpacingCallback(exporter->GetSpacingCallback());<BR>
importer->SetOriginCallback(exporter->GetOriginCallback());<BR>
importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());<BR>
importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());<BR>
importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());<BR>
importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());<BR>
importer->SetDataExtentCallback(exporter->GetDataExtentCallback());<BR>
importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());<BR>
importer->SetCallbackUserData(exporter->GetCallbackUserData());<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>/**<BR> * This function will connect the given
vtkImageExport filter to<BR> * the given itk::VTKImageImport
filter.<BR> */<BR>template <typename VTK_Exporter, typename
ITK_Importer><BR>void ConnectPipelines(VTK_Exporter* exporter, ITK_Importer
importer)<BR>{<BR>
importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());<BR>
importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());<BR>
importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());<BR>
importer->SetSpacingCallback(exporter->GetSpacingCallback());<BR>
importer->SetOriginCallback(exporter->GetOriginCallback());<BR>
importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());<BR>
importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());<BR>
importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());<BR>
importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());<BR>
importer->SetDataExtentCallback(exporter->GetDataExtentCallback());<BR>
importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());<BR>
importer->SetCallbackUserData(exporter->GetCallbackUserData());<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>int itkReadDicomSeries (std::string
directoryPath)<BR>{ <BR> typedef unsigned char
PixelType;<BR> const unsigned int Dimension =
3;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> typedef itk::OrientedImage< PixelType,
Dimension > ImageType;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> typedef itk::ImageSeriesReader< ImageType
> ReaderType;<BR> ReaderType::Pointer reader =
ReaderType::New();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> typedef
itk::GDCMImageIO
ImageIOType;<BR> ImageIOType::Pointer dicomIO =
ImageIOType::New();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> reader->SetImageIO( dicomIO
);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> typedef itk::GDCMSeriesFileNames
NamesGeneratorType;<BR> NamesGeneratorType::Pointer nameGenerator =
NamesGeneratorType::New();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> nameGenerator->SetUseSeriesDetails( true
);<BR> nameGenerator->AddSeriesRestriction("0008|0021" );</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> nameGenerator->SetDirectory(directoryPath);<BR> <BR> std::cout
<< std::endl << "The directory: " <<
std::endl;<BR> std::cout << std::endl << directoryPath <<
std::endl << std::endl;<BR> std::cout << "Contains the
following DICOM Series: ";<BR> std::cout << std::endl <<
std::endl;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> typedef std::vector< std::string
> SeriesIdContainer;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> const SeriesIdContainer & seriesUID =
nameGenerator->GetSeriesUIDs();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> SeriesIdContainer::const_iterator seriesItr =
seriesUID.begin();<BR> SeriesIdContainer::const_iterator seriesEnd =
seriesUID.end();<BR> while( seriesItr != seriesEnd )
{<BR> std::cout << seriesItr->c_str() <<
std::endl;<BR> seriesItr++;<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> std::string
seriesIdentifier;<BR> seriesIdentifier =
seriesUID.begin()->c_str();<BR> <BR> std::cout
<< std::endl << std::endl;<BR> std::cout
<< "Now reading series: " << std::endl <<
std::endl;<BR> std::cout << seriesIdentifier
<< std::endl;<BR> std::cout << std::endl
<< std::endl;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> typedef std::vector<
std::string >
FileNamesContainer;<BR> FileNamesContainer
fileNames;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> fileNames =
nameGenerator->GetFileNames( seriesIdentifier );</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>reader->SetFileNames( fileNames
); <BR>reader->Update();<BR> </FONT><FONT face=Arial
size=2><BR></FONT><FONT face=Arial size=2>typedef itk::VTKImageExport<
ImageType > ExportFilterType;<BR> ExportFilterType::Pointer
itkExporter = ExportFilterType::New(); </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> itkExporter->SetInput(
reader->GetOutput() );<BR> <BR>// Create the vtkImageImport and connect
it to the itk::VTKImageExport instance.<BR> vtkImageImport*
vtkImporter = vtkImageImport::New(); <BR>
ConnectPipelines(itkExporter, vtkImporter);<BR> <BR>vtkPiecewiseFunction*
opacityTransferFunction = vtkPiecewiseFunction::New();<BR>
vtkColorTransferFunction* colorTransferFunction =
vtkColorTransferFunction::New(); <BR> <BR>vtkVolume* volume =
vtkVolume::New();<BR>vtkVolumeProperty* volumeProperty =
vtkVolumeProperty::New(); <BR> vtkVolumeTextureMapper3D*
volumeMapper = vtkVolumeTextureMapper3D::New();<BR>
vtkFixedPointVolumeRayCastMapper* volumeMapperSoftware =
vtkFixedPointVolumeRayCastMapper::New();<BR> <BR> volumeProperty->SetScalarOpacity(opacityTransferFunction);<BR> volumeProperty->SetInterpolationTypeToLinear();<BR> volumeProperty->ShadeOff(); <BR>
volume->SetProperty(volumeProperty); </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> volumeMapperSoftware->SetInput(vtkImporter->GetOutput());<BR> volumeMapperSoftware->SetSampleDistance(1.0);<BR> volume->SetMapper(volumeMapperSoftware);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
vtkInteractorStyleTrackballCamera * interactorStyle =
vtkInteractorStyleTrackballCamera::New();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // Create a renderer, render
window, and render window interactor to display the
results.<BR> vtkRenderer* renderer =
vtkRenderer::New();<BR> vtkRenderWindow* renWin =
vtkRenderWindow::New();<BR> vtkRenderWindowInteractor* iren =
vtkRenderWindowInteractor::New();<BR> <BR>
renWin->SetSize(500, 500);<BR>
renWin->AddRenderer(renderer);<BR>
iren->SetRenderWindow(renWin);<BR>
iren->SetInteractorStyle(interactorStyle);<BR>
<BR> // Add the vtkImageActor to the renderer for
display.<BR> renderer->AddVolume(volume);<BR>
</FONT></DIV>
<DIV><FONT face=Arial size=2> // Bring up the render window
and begin interaction.<BR>
renWin->Render();<BR> iren->Start();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> return 0;<BR>}</FONT></DIV>
<DIV> </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> </DIV>
<DIV>Thanks in advance,</DIV>
<DIV>Polys</DIV></FONT></DIV></BODY></HTML>