[Insight-users] RelabelComponentImageFilter nothing at rendered window..,

yasser salman yass71@yahoo.com
Sun May 9 21:33:55 EDT 2004


Hi All..,

when i'm using  itkRelabelComponentImageFilter as the
input to the writer the file saved and i can display
it clearly also GetSizeOfObjectsInPixels() works good,
but when i'm using it as the input of of
itk2vtkconnector nothing displayed in the render
window can u find out why?


 typedef unsigned short   InputPixelType;
  typedef float        InternalPixelType;
  
  typedef unsigned short   SegmentedPixelType;

  typedef itk::Image< InputPixelType, 3 >        
InputImageType;
  typedef itk::Image< InternalPixelType, 3>      
InternalImageType;

  typedef itk::Image< SegmentedPixelType, 3 >    
SegmentedImageType;

  typedef   itk::CastImageFilter< 
                 InputImageType, 
                 InternalImageType >    
CastImageFilterType;

  typedef   itk::CurvatureFlowImageFilter< 
                 InternalImageType, 
                 InternalImageType >    
CurvatureFlowImageFilterType;

  typedef   itk::ConfidenceConnectedImageFilter< 
                         InternalImageType, 
                         SegmentedImageType >     
				 ConfidenceConnectedImageFilterType;

  typedef itk::ConnectedThresholdImageFilter< 
			InternalImageType, SegmentedImageType >
ConnectedFilterType;
  

  typedef itk::ImageToVTKImageFilter<
SegmentedImageType >  
			ITK2VTKConnectorFilterType;

  typedef itk::VTKImageToImageFilter< InputImageType  
  >  
            VTK2ITKConnectorFilterType;
	   typedef itk::ImageSeriesReader< InputImageType >  
  ReaderType;
  typedef std::vector<std::string> seriesIdContainer;
  typedef std::vector<std::string> fileNamesContainer;
  typedef ConnectedFilterType::IndexType IndexType;	
  typedef
itk::ImageMomentsCalculator<SegmentedImageType>
ImageMomentsType;
typedef itk::ImageSeriesReader< InputImageType >    
ReaderType;

  itk::DICOMImageIO2::Pointer dicomIO =
itk::DICOMImageIO2::New();

  // Get the DICOM filenames from the directory
  itk::DICOMSeriesFileNames::Pointer nameGenerator =
itk::DICOMSeriesFileNames::New();
 CString  directoryname(VolData_FName);

  std::string    stringdirectory =
directoryname.GetBuffer(200);

 // nameGenerator->SetDirectory(  stringdirectory );
it works!!!!!

  nameGenerator->SetDirectory(
"D:/imagedata/Dicom/shy4" );

  typedef std::vector<std::string> seriesIdContainer;
  const seriesIdContainer & seriesUID =
nameGenerator->GetSeriesUIDs();
seriesIdContainer::const_iterator seriesItr =
seriesUID.begin();
  seriesIdContainer::const_iterator seriesEnd =
seriesUID.end();
  while( seriesItr != seriesEnd )
    {
    std::cout << seriesItr->c_str() << std::endl;
    seriesItr++;
    }
  
  typedef
itk::RelabelComponentImageFilter<SegmentedImageType,SegmentedImageType>
RelabelImageFilter;
  typedef std::vector<std::string> fileNamesContainer;
  fileNamesContainer fileNames;
   fileNames = nameGenerator->GetFileNames();
  
  
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileNames( fileNames );
  reader->SetImageIO( dicomIO );

    reader->Update();
  

  CastImageFilterType::Pointer cast =
CastImageFilterType::New();

  CurvatureFlowImageFilterType::Pointer smoothing = 
CurvatureFlowImageFilterType::New();

  ConfidenceConnectedImageFilterType::Pointer
confidence = 
ConfidenceConnectedImageFilterType::New();

  ConnectedFilterType::Pointer connectedThreshold = 
ConnectedFilterType::New();
  RelabelImageFilter::Pointer rcfilter=
RelabelImageFilter::New();
  VTK2ITKConnectorFilterType::Pointer VTK2ITKconnector
= 
VTK2ITKConnectorFilterType::New();

  

  cast->SetInput( reader->GetOutput() );

  smoothing->SetInput(  cast->GetOutput() );
  confidence->SetInput( smoothing->GetOutput());

  smoothing->SetTimeStep( 0.0625 );
 smoothing->SetNumberOfIterations( 2 );
    connectedThreshold->SetInput(
smoothing->GetOutput() );
  connectedThreshold->SetLower(  L_threshold  );
  connectedThreshold->SetUpper(  H_threshold);
  connectedThreshold->SetReplaceValue(
SegmentedRegionColor );


  typedef ConnectedFilterType::IndexType IndexType;
  IndexType seed;
  seed[0] = axi;
  seed[1] = cron;
  seed[2] = sag;

  connectedThreshold->SetSeed( seed );
  ImageMomentsType::Pointer
calculator=ImageMomentsType::New();
connectedThreshold->Update();
  calculator->SetImage(
connectedThreshold->GetOutput());
 calculator->Compute();


  ITK2VTKConnectorFilterType::Pointer ITK2VTKconnector
= 
ITK2VTKConnectorFilterType::New();
rcfilter->SetInput(connectedThreshold->GetOutput());
rcfilter->Update();
	unsigned long nObjects =
rcfilter->GetNumberOfObjects();
	const std::vector<unsigned long> sizeOfObjects =
rcfilter->GetSizeOfObjectsInPixels();
	std::vector<unsigned long>::const_iterator it;

	int i;
	 it =  sizeOfObjects.begin();  	
	typedef itk::ImageFileWriter<SegmentedImageType>		
itkWriterType;
	typedef itk::DICOMImageIO2									
itkMetaImageIOType;
	itkMetaImageIOType::Pointer		labellerMetaWriterIO  =
itkMetaImageIOType::New();
	 itkWriterType::Pointer				relabellerWriter				=
itkWriterType::New();
	itkMetaImageIOType::Pointer		relabellerMetaWriterIO 
= itkMetaImageIOType::New();
	relabellerWriter->SetInput( rcfilter->GetOutput() );
	relabellerWriter->SetFileName(
"c:/Shapes_relabelled.vtk" );
	relabellerWriter->SetImageIO( labellerMetaWriterIO );
	relabellerWriter->Write();



  ITK2VTKconnector->SetInput(connectedThreshold
->GetOutput());  //the region displayed ok but if
rcfilter instead of connectedtehreshold nothing
displayed..
 
ITK2VTKconnector->GetImporter()->SetDataScalarTypeToUnsignedChar();

/////To the Vtk pipeline...



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 



More information about the Insight-users mailing list