<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Hi Amy <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></DIV>
<DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Thank you for your help. vtkFixedPointVolumeRayCastMapper is well working. Also I have tried keeping vtkVolumeRayCastMapper with the use of vtkImageShiftScale filter but I het the folloing error regarding the statment : shifter->SetInput(vtkImporter->GetOutput());<o:p></o:p></SPAN></DIV>
<DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> <o:p></o:p></SPAN></DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">1>..\test_itk.cxx(129) : error C2664: 'void vtkImageAlgorithm::SetInput(vtkDataObject *)' : cannot convert parameter 1 from 'vtkImageData *' to 'vtkDataObject *'<o:p></o:p></SPAN></DIV>
<DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </SPAN></DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
<DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Please do you know how to resolve this problem. I'm not expert; I’m just doing my first steps in vtk and itk. <o:p></o:p></SPAN></DIV>
<DIV><SPAN lang=FR style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-ansi-language: FR">Thank you<o:p></o:p></SPAN></DIV>
<DIV><SPAN lang=FR style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-ansi-language: FR"> <o:p></o:p></SPAN></DIV>
<DIV><SPAN lang=FR style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-ansi-language: FR"> <o:p></o:p></SPAN></DIV>
<DIV><SPAN lang=FR style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-ansi-language: FR">Sara<o:p></o:p></SPAN></DIV><o:p></o:p></SPAN>
<DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN> </DIV>
<DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">this this the modified code :<o:p></o:p></SPAN></DIV>
<DIV>
<DIV> </DIV>
<DIV> </DIV></DIV><FONT color=#008000 size=2>
<DIV>// The following example illustrates the use of the ConfidenceConnectedImageFilter. The criterion used by the</DIV>
<DIV>// ConfidenceConnectedImageFilter is based on simple statistics of the current region. </DIV>
<DIV>// 3D</DIV>
<DIV>// The following example illustrates the use of the ConfidenceConnectedImageFilter. The criterion used by the</DIV>
<DIV>// ConfidenceConnectedImageFilter is based on simple statistics of the current region. </DIV>
<DIV>// 3D</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkConfidenceConnectedImageFilter.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkImage.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkCastImageFilter.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkCurvatureFlowImageFilter.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkImageFileReader.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkImageFileWriter.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkVTKImageExport.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkVTKImageImport.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkImageImport.h"</FONT><FONT size=2> </DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkImageExport.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkImageReader.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkPiecewiseFunction.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkVolumeProperty.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkVolumeRayCastMapper.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkVolumeTextureMapper3D.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkFixedPointVolumeRayCastMapper.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkVolumeRayCastCompositeFunction.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkVolume.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkRenderer.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkRenderWindow.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkRenderWindowInteractor.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkImageShiftScale.h"</DIV></FONT><FONT color=#0000ff size=2>
<DIV>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"vtkFixedPointVolumeRayCastMapper.h"</DIV></FONT><FONT color=#008000 size=2>
<DIV>// This function will connect the given itk::VTKImageExport filter to the given vtkImageImport filter.</DIV></FONT><FONT color=#0000ff size=2>
<DIV>template</FONT><FONT size=2> <</FONT><FONT color=#0000ff size=2>typename</FONT><FONT size=2> ITK_Exporter, </FONT><FONT color=#0000ff size=2>typename</FONT><FONT size=2> VTK_Importer></DIV></FONT><FONT color=#0000ff size=2>
<DIV>void</FONT><FONT size=2> ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)</DIV>
<DIV>{</DIV>
<DIV>importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());</DIV>
<DIV>importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());</DIV>
<DIV>importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());</DIV>
<DIV>importer->SetSpacingCallback(exporter->GetSpacingCallback());</DIV>
<DIV>importer->SetOriginCallback(exporter->GetOriginCallback());</DIV>
<DIV>importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());</DIV>
<DIV>importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());</DIV>
<DIV>importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());</DIV>
<DIV>importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());</DIV>
<DIV>importer->SetDataExtentCallback(exporter->GetDataExtentCallback());</DIV>
<DIV>importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());</DIV>
<DIV>importer->SetCallbackUserData(exporter->GetCallbackUserData());</DIV>
<DIV>}</DIV></FONT><FONT color=#0000ff size=2>
<DIV>int</FONT><FONT size=2> main( )</DIV>
<DIV>{</DIV>
<DIV></FONT><FONT color=#008000 size=2>//typedef unsigned short InputPixelType;</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>float</FONT><FONT size=2> InputPixelType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2> OutputPixelType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> Dimension = 3;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::Image< InputPixelType, Dimension > InputImageType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::Image< OutputPixelType, Dimension > OutputImageType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::CastImageFilter< InputImageType, OutputImageType > CastingFilterType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::ImageFileReader< InputImageType > ReaderType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::ImageFileWriter< OutputImageType > WriterType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::CurvatureFlowImageFilter< InputImageType, InputImageType > CurvatureFlowImageFilterType; </DIV>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::ConfidenceConnectedImageFilter<InputImageType, InputImageType> ConnectedFilterType;</DIV>
<DIV>CastingFilterType::Pointer caster = CastingFilterType::New(); </DIV>
<DIV>ReaderType::Pointer reader = ReaderType::New();</DIV>
<DIV>WriterType::Pointer writer = WriterType::New();</DIV>
<DIV>CurvatureFlowImageFilterType::Pointer smoothing = CurvatureFlowImageFilterType::New(); </DIV>
<DIV>ConnectedFilterType::Pointer confidenceConnected = ConnectedFilterType::New();</DIV>
<DIV></DIV>
<DIV>reader->SetFileName( </FONT><FONT color=#a31515 size=2>"c:/images/3DImages/Patient01.mhd"</FONT><FONT size=2> );</DIV>
<DIV>writer->SetFileName( </FONT><FONT color=#a31515 size=2>"c:/images/3DConfidenceConnectedSegmImg.mhd"</FONT><FONT size=2> );</DIV>
<DIV>smoothing->SetInput( reader->GetOutput() );</DIV>
<DIV>confidenceConnected->SetInput( smoothing->GetOutput() );</DIV>
<DIV>caster->SetInput( confidenceConnected->GetOutput() );</DIV>
<DIV>writer->SetInput( caster->GetOutput() );</DIV>
<DIV></DIV>
<DIV>smoothing->SetNumberOfIterations( 5 );</DIV>
<DIV>smoothing->SetTimeStep( 0.125 );</DIV>
<DIV></DIV>
<DIV>confidenceConnected->SetMultiplier( 2.5 ); </DIV>
<DIV>confidenceConnected->SetNumberOfIterations( 5);</DIV>
<DIV>confidenceConnected->SetReplaceValue( 255 ); </DIV>
<DIV>InputImageType::IndexType index; </DIV>
<DIV>index[0] = atoi( </FONT><FONT color=#a31515 size=2>"256"</FONT><FONT size=2> );</DIV>
<DIV>index[1] = atoi( </FONT><FONT color=#a31515 size=2>"256"</FONT><FONT size=2> );</DIV>
<DIV>index[2] = atoi( </FONT><FONT color=#a31515 size=2>"16"</FONT><FONT size=2> );</DIV>
<DIV>confidenceConnected->SetSeed( index ); </DIV>
<DIV>confidenceConnected->SetInitialNeighborhoodRadius( 2 );</DIV>
<DIV></FONT><FONT color=#0000ff size=2>try</DIV></FONT><FONT size=2>
<DIV>{</DIV>
<DIV>writer->Update();</DIV>
<DIV>}</DIV>
<DIV></FONT><FONT color=#0000ff size=2>catch</FONT><FONT size=2>( itk::ExceptionObject & excep )</DIV>
<DIV>{</DIV>
<DIV>std::cerr << </FONT><FONT color=#a31515 size=2>"Exception caught !"</FONT><FONT size=2> << std::endl;</DIV>
<DIV>std::cerr << excep << std::endl;</DIV>
<DIV>}</DIV>
<DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::VTKImageExport< InputImageType > ExportFilterType;</DIV>
<DIV>ExportFilterType::Pointer itkExporter = ExportFilterType::New(); </DIV>
<DIV>itkExporter->SetInput(reader->GetOutput()); </DIV>
<DIV></FONT><FONT color=#008000 size=2>// Create the vtkImageImport and connect it to the itk::VTKImageExport instance.</DIV></FONT><FONT size=2>
<DIV>vtkImageImport* vtkImporter = vtkImageImport::New(); </DIV>
<DIV>ConnectPipelines(itkExporter, vtkImporter);</DIV>
<DIV></DIV>
<DIV>vtkImageShiftScale* shifter = vtkImageShiftScale::New();</DIV>
<DIV>shifter->SetInput(vtkImporter->GetOutput());</DIV>
<DIV></FONT><FONT color=#008000 size=2>//shifter->SetScale(256);</DIV></FONT><FONT size=2>
<DIV>shifter->SetOutputScalarTypeToUnsignedChar();</DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#008000 size=2>// Define opacity transfer function</DIV></FONT><FONT size=2>
<DIV>vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New();</DIV>
<DIV>vtkVolume *volume = vtkVolume::New();</DIV>
<DIV>vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();</DIV>
<DIV>vtkVolumeRayCastMapper *VolumeMapper = vtkVolumeRayCastMapper::New();</DIV>
<DIV>vtkVolumeRayCastCompositeFunction *RayCastFunction =vtkVolumeRayCastCompositeFunction::New();</DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#008000 size=2>// Volume property </DIV></FONT><FONT size=2>
<DIV>opacityTransferFunction->AddPoint(0,0.001);</DIV>
<DIV>opacityTransferFunction->AddPoint(255,0.2);</DIV>
<DIV>volumeProperty->SetScalarOpacity(opacityTransferFunction);</DIV>
<DIV>volumeProperty->SetInterpolationTypeToLinear();</DIV>
<DIV>volumeProperty->ShadeOff();</DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#008000 size=2>// Volume mapper</DIV></FONT><FONT size=2>
<DIV>VolumeMapper->SetVolumeRayCastFunction(RayCastFunction);</DIV>
<DIV>VolumeMapper->SetSampleDistance(1.0);</DIV>
<DIV>VolumeMapper->SetBlendModeToMaximumIntensity();</DIV>
<DIV></FONT><FONT color=#008000 size=2>//VolumeMapper->SetInput(vtkImporter->GetOutput() ); </DIV></FONT><FONT size=2>
<DIV>VolumeMapper->SetInput(shifter->GetOutput() ); </DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#008000 size=2>// The volume </DIV></FONT><FONT size=2>
<DIV>volume->SetMapper(VolumeMapper);</DIV>
<DIV>volume->SetProperty(volumeProperty);</DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#008000 size=2>// Create a renderer, render window, and render window interactor to display the results.</DIV></FONT><FONT size=2>
<DIV>vtkRenderer *Renderer = vtkRenderer::New();</DIV>
<DIV>vtkRenderWindow *RenWin = vtkRenderWindow::New();</DIV>
<DIV>vtkRenderWindowInteractor *RenWinInterc = vtkRenderWindowInteractor::New();</DIV>
<DIV>RenWin->AddRenderer(Renderer);</DIV>
<DIV>RenWinInterc->SetRenderWindow(RenWin);</DIV>
<DIV></FONT><FONT color=#008000 size=2>//Renderer->AddActor(volume);</DIV></FONT><FONT size=2>
<DIV>Renderer->AddVolume(volume);</DIV>
<DIV>Renderer->SetBackground(1,1,1);</DIV>
<DIV>RenWin->Render();</DIV>
<DIV>RenWinInterc->Initialize();</DIV>
<DIV>RenWinInterc->Start();</DIV>
<DIV></FONT><FONT color=#008000 size=2>// Release all VTK components</DIV></FONT><FONT size=2>
<DIV>RenWinInterc->Delete();</DIV>
<DIV>RenWin->Delete(); </DIV>
<DIV>Renderer->Delete();</DIV>
<DIV>volume->Delete();</DIV>
<DIV>VolumeMapper->Delete();</DIV>
<DIV>volumeProperty->Delete();</DIV>
<DIV>opacityTransferFunction->Delete();</DIV>
<DIV>std::cout << </FONT><FONT color=#a31515 size=2>"Code end !"</FONT><FONT size=2> << std::endl;</DIV>
<DIV>std::cin.get();</DIV>
<DIV></FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> 0;</DIV>
<DIV>}</DIV></FONT>
<DIV>
<DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN> </DIV>
<DIV><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN> </DIV>
<DIV>
<DIV><SPAN lang=FR style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-ansi-language: FR"><o:p></o:p></SPAN></DIV><BR><BR><BR>--- En date de : <B>Mar 19.8.08, Amy Squillacote <I><ahs@cfdrc.com></I></B> a écrit :<BR></DIV></DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid">De: Amy Squillacote <ahs@cfdrc.com><BR>Objet: Re: [vtkusers] Problem with vtk RayCasting: volume to be of pixel type unsigned char or unsigned short<BR>À: sara_meghellati@yahoo.fr<BR>Cc: vtkusers@vtk.org<BR>Date: Mardi 19 Août 2008, 15h21<BR><BR><PRE>Hi Sara,
The vtkFixedPointVolumeRayCastMapper can handle float data, so try using
it instead of vtkVolumeRayCastMapper. If for some reason you need to use
vtkVolumeRayCastMapper, you should pass your vtkImageData through a
vtkImageShiftScale filter to convert it to unsigned char or unsigned
short, and then pass the output of that filter to the mapper.
- Amy
sara meghellati wrote:
>
> Hi all,
> I have segmented 3D image using region growing method (using itk) and
> I want to display the original volume(float type) using vtk. I got an
> error at run time stating that vtk raycasting requires the volume to
> be of pixel type unsigned char or unsigned short. I'm converting the
> vtkimport that I use to unsigned char using the function
> SetDataScalarTypeToChar() but I still get the error. The code is bellow.
> Any help is very appreciated.
> Thank you for your time
> Sara
>
>
> #include "itkConfidenceConnectedImageFilter.h"
> #include "itkImage.h"
> #include "itkCastImageFilter.h"
> #include "itkCurvatureFlowImageFilter.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkVTKImageExport.h"
> #include "itkVTKImageImport.h"
> #include "vtkImageImport.h"
> #include "vtkImageExport.h"
> #include "vtkImageReader.h"
> #include "vtkPiecewiseFunction.h"
> #include "vtkVolumeProperty.h"
> #include "vtkVolumeRayCastMapper.h"
> #include "vtkVolumeTextureMapper3D.h"
> #include "vtkFixedPointVolumeRayCastMapper.h"
> #include "vtkVolumeRayCastCompositeFunction.h"
> #include "vtkVolume.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> // This function will connect the given itk::VTKImageExport filter to
> the given vtkImageImport filter.
> template <typename ITK_Exporter, typename VTK_Importer>
> void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)
> {
>
importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
>
importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
>
importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
> importer->SetSpacingCallback(exporter->GetSpacingCallback());
> importer->SetOriginCallback(exporter->GetOriginCallback());
> importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
>
importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
>
importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
> importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
> importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
>
importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
> importer->SetCallbackUserData(exporter->GetCallbackUserData());
> }
> int main( )
> {
> //typedef unsigned short InputPixelType;
> typedef float InputPixelType;
> typedef unsigned char OutputPixelType;
> const unsigned int Dimension = 3;
> typedef itk::Image< InputPixelType, Dimension > InputImageType;
> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
> typedef itk::CastImageFilter< InputImageType, OutputImageType >
> CastingFilterType;
> typedef itk::ImageFileReader< InputImageType > ReaderType;
> typedef itk::ImageFileWriter< OutputImageType > WriterType;
> typedef itk::CurvatureFlowImageFilter< InputImageType, InputImageType
> > CurvatureFlowImageFilterType;
> typedef itk::ConfidenceConnectedImageFilter<InputImageType,
> InputImageType> ConnectedFilterType;
> CastingFilterType::Pointer caster = CastingFilterType::New();
> ReaderType::Pointer reader = ReaderType::New();
> WriterType::Pointer writer = WriterType::New();
> CurvatureFlowImageFilterType::Pointer smoothing =
> CurvatureFlowImageFilterType::New();
> ConnectedFilterType::Pointer confidenceConnected =
> ConnectedFilterType::New();
> reader->SetFileName( "c:/images/Patient01.mhd" );
> writer->SetFileName(
"c:/images/3DConfidenceConnectedSegmImg.mhd" );
> smoothing->SetInput( reader->GetOutput() );
> confidenceConnected->SetInput( smoothing->GetOutput() );
> caster->SetInput( confidenceConnected->GetOutput() );
> writer->SetInput( caster->GetOutput() );
> smoothing->SetNumberOfIterations( 5 );
> smoothing->SetTimeStep( 0.125 );
> confidenceConnected->SetMultiplier( 2.5 );
> confidenceConnected->SetNumberOfIterations( 2 );
> confidenceConnected->SetReplaceValue( 255 );
> InputImageType::IndexType index;
> index[0] = atoi( "256" );
> index[1] = atoi( "256" );
> index[2] = atoi( "16" );
> confidenceConnected->SetSeed( index );
> confidenceConnected->SetInitialNeighborhoodRadius( 2 );
> try
> {
> writer->Update();
> }
> catch( itk::ExceptionObject & excep )
> {
> std::cerr << "Exception caught !" << std::endl;
> std::cerr << excep << std::endl;
> }
> //----------------------------------------------
> // -------------------- vtk Display----------------
> //----------------------------------------------
> typedef itk::VTKImageExport< InputImageType > ExportFilterType;
> ExportFilterType::Pointer itkExporter = ExportFilterType::New();
> itkExporter->SetInput(reader->GetOutput());
> vtkImageImport* vtkImporter = vtkImageImport::New();
> ConnectPipelines(itkExporter, vtkImporter);
> vtkImporter->SetDataScalarTypeToUnsignedChar();
> // Define opacity transfer function
> vtkPiecewiseFunction *opacityTransferFunction =
> vtkPiecewiseFunction::New();
> vtkVolume *volume = vtkVolume::New();
> vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
> vtkVolumeRayCastMapper *VolumeMapper = vtkVolumeRayCastMapper::New();
> vtkVolumeRayCastCompositeFunction *RayCastFunction
> =vtkVolumeRayCastCompositeFunction::New();
> // Volume property
> opacityTransferFunction->AddPoint(0,0.001);
> opacityTransferFunction->AddPoint(255,0.2);
> volumeProperty->SetScalarOpacity(opacityTransferFunction);
> volumeProperty->SetInterpolationTypeToLinear();
> volumeProperty->ShadeOff();
> // Volume mapper
> VolumeMapper->SetVolumeRayCastFunction(RayCastFunction);
> VolumeMapper->SetSampleDistance(1.0);
> VolumeMapper->SetBlendModeToMaximumIntensity();
> VolumeMapper->SetInput(vtkImporter->GetOutput() );
> // The volume
> volume->SetMapper(VolumeMapper);
> volume->SetProperty(volumeProperty);
> // Create a renderer, render window, and render window interactor to
> display the results.
> vtkRenderer *Renderer = vtkRenderer::New();
> vtkRenderWindow *RenWin = vtkRenderWindow::New();
> vtkRenderWindowInteractor *RenWinInterc =
> vtkRenderWindowInteractor::New();
> RenWin->AddRenderer(Renderer);
> RenWinInterc->SetRenderWindow(RenWin);
> Renderer->AddVolume(volume);
> Renderer->SetBackground(1,1,1);
> RenWin->Render();
> RenWinInterc->Initialize();
> RenWinInterc->Start();
> // Release all VTK components
> RenWinInterc->Delete();
> RenWin->Delete();
> Renderer->Delete();
> volume->Delete();
> VolumeMapper->Delete();
> volumeProperty->Delete();
> opacityTransferFunction->Delete();
>
> return 0;
> }
>
>
> ------------------------------------------------------------------------
> Envoyé avec Yahoo! Mail
>
<http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52423/*http://fr.docs.yahoo.com/mail/overview/index.html>.
> Une boite mail plus intelligente.
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
Amy Squillacote Phone: (256) 726-4839
Computer Scientist Fax: (256) 726-4806
CFD Research Corporation Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL 35805
</PRE></BLOCKQUOTE></td></tr></table><br>
<hr size="1">
Envoyé avec <a href="http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52423/*http://fr.docs.yahoo.com/mail/overview/index.html">Yahoo! Mail</a>.<br>Une boite mail plus intelligente. </a>