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

yasser salman yass71 at yahoo.com
Sat May 29 04:44:37 EDT 2004


hi Luis ,
i sent this message without my result coz the result
size exceeds the limitation of 40K , i'm still wait
the approval but any way if u can help me to fix my
problem without result here is my message without
result.., 
i rescale (as u suggested) the volume and it works :) 
but i still stucked at the colored region :( the
attchment file represents my results , all i need  (as
seen in fig 1 lower part) to color the segmented
region , i try to color it using :
1- itkRelabelComponentImageFilter the color segmented
region displayed but using the saved file only !!! Fig
2.  
2-itkFunctorScalarToRGBPixelFunctor same as itkRelable
the output Direct from the filter represented by fig 1
, from saved file represented from fig 2., 
3- vtkImageMapToColor the output seems as Grids,
sorry Luis for these extented details , but i stucked
for a long time solving this problem ,i posted below
my modified code ,,


--- Luis Ibanez <luis.ibanez at kitware.com> wrote:
> 
> Hi Yasser,
> 
> The Relabel image filter assigns values like :
> 1,2,3....
> 
> to the pixels in the image.  Those values will
> appear very dark in any viewer unless you rescale
> them before attempting to visualize them.
> 
>
http://www.itk.org/Insight/Doxygen/html/classitk_1_1RelabelComponentImageFilter.html
> 
> 
> Since you are using VTK for visualization, you
> simply
> need to adjust the parameters of intensity windowing
> in your viewer.
> 
> 
> 
>    Regards,
> 
> 
>      Luis
> 
> 
> ----------------------
> yasser salman wrote:
> > 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 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();
  RescaleType:: Pointer rescale= RescaleType::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();


area = calculator->GetTotalMass()/255;
char b[10];
sprintf(b,"%f",area);
AfxMessageBox(b);
  
SegmentedImageType::ConstPointer image  =
connectedThreshold->GetOutput();
SegmentedImageType::RegionType   region =
connectedThreshold->GetBufferedRegion();
SegmentedImageType::SizeType     size   =
region.GetSize();




  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();  
///Uranr Code--------------
  typedef itk::RGBPixel<unsigned char>   RGBPixelType;
  typedef itk::Image<RGBPixelType, 3>    RGBImageType;
  typedef itk::Image<unsigned short, 3>  
LabeledImageType;
  typedef itk::Image<float, 3>          
ScalarImageType;
  typedef itk::ImageFileWriter<RGBImageType>
FileWriterType;

  typedef
itk::Functor::ScalarToRGBPixelFunctor<unsigned short>
    ColorMapFunctorType;
  typedef
itk::UnaryFunctorImageFilter<LabeledImageType,
    RGBImageType, ColorMapFunctorType>
ColorMapFilterType;
  ColorMapFilterType::Pointer colormapper =
ColorMapFilterType::New();
  
  FileWriterType::Pointer writer =
FileWriterType::New();
  writer->SetFileName("c:/rr.vtk");

 
colormapper->SetInput(connectedThreshold->GetOutput());
  writer->SetInput(colormapper->GetOutput());
writer->Update();
//_____________End of Urany Code
		
	
rescale->SetInput(rcfilter->GetOutput());
rescale->SetOutputMinimum(0);
rescale->SetOutputMaximum(255);
rescale->Update();
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( relabellerMetaWriterIO
);
	relabellerWriter->Write();
rcfilter->Update();

  ITK2VTKconnector->SetInput(rescale->GetOutput());
 
ITK2VTKconnector->GetImporter()->SetDataScalarTypeToUnsignedChar();
  
  //----------------------------------
  //           VTK Pipeline
  //----------------------------------

 
 GaussianRegion->SetStandardDeviations (5, 2, 1);
     GaussianRegion-> SetRadiusFactors (1.0, 1.0,
1.0);
GaussianRegion
->SetInput(ITK2VTKconnector->GetOutput());
  
vtkLookupTable *hueLut0 = vtkLookupTable::New();
    hueLut0->SetTableRange (0,2000);
    hueLut0->SetAlphaRange(0,1);
    hueLut0->SetSaturationRange (0,0);
    hueLut0->SetValueRange (0, 5);
    
	hueLut0->Build();
	
	hueLut0->SetHueRange (0, 0);
	
	vtkLookupTable *hueLut1 = vtkLookupTable::New();
	hueLut1->SetTableRange (0,2000);
    hueLut1->SetAlphaRange(0,1);
    hueLut1->SetSaturationRange (1,1);
    hueLut1->SetValueRange (1, 1);
	
	hueLut1->Build();
	
	hueLut1->SetHueRange (0, 1);

  vtkImageMapToColors *alpha0 =
vtkImageMapToColors::New();
    alpha0->SetInput(gaussian->GetOutput());
    alpha0->SetLookupTable(hueLut0);
  vtkImageMapToColors *alpha1 =
vtkImageMapToColors::New();
    alpha1->SetInput(GaussianRegion->GetOutput());
   alpha1->SetLookupTable(hueLut1);

  vtkImageBlend *blend=vtkImageBlend::New();
    blend-> SetInput(0,alpha0->GetOutput());
    blend-> SetInput(1,alpha1->GetOutput());// end of
1
   blend->SetOpacity(1,.7);



mcTumor->SetInput(GaussianRegion->GetOutput());  // to
display Tumor only it works!!
	mc->SetInput( blend->GetOutput());  // to display
Both tumor and head but nosiy displayed.., 
	
	
.... to visualiztion pipes..,




	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 


More information about the Insight-users mailing list