[Insight-users] How to create a LabelImage from RelabelComponentImageFilter

Ella Maria Kadas ella_kadas at yahoo.com
Mon Mar 28 10:08:58 EDT 2011



Hi all,
  I am trying to use compute some morphological operations on a binary image. i first used BinaryThresholdImageFilter, then got the connected components with ConnectedComponentImageFilter, and then relabeled them with RelabelComponentImageFilter     Now i was trying to  use LabelImageToLabelMapFilter but i don't know how to create this LabelImage. In the Examples from the Gaetan Lehmann the LabelImage is always read from input.    I just want somehow to use the output from the RelabeloComponentImageFilter to create a LabelMapFilter.

       Part of the code is:

typedef unsigned long LabelPixelType;
typedef itk::Image< LabelPixelType, Dimension > LabelImageType;
typedef itk::ConnectedComponentImageFilter <OutputType, LabelImageType > ConnectedComponentImageFilterType;
		ConnectedComponentImageFilterType::Pointer labelFilter	= ConnectedComponentImageFilterType::New ();
		labelFilter->SetInput(filter->GetOutput());
		labelFilter->Update();
		
	typedef itk::RelabelComponentImageFilter<LabelImageType,LabelImageType>
		RelabelImageFilter;
		RelabelImageFilter::Pointer relabel = RelabelImageFilter::New();
		relabel->SetInput(labelFilter->GetOutput());
		relabel->Update();
		typedef unsigned long LabelType;
		typedef itk::AttributeLabelObject<unsigned long, Dimension, double> LabelObjectType;
		typedef itk::LabelMap<LabelObjectType> LabelMapType;
		
		
		typedef itk::LabelImageToLabelMapFilter<LabelType, LabelMapType> I2LType;
		I2LType::Pointer i2l = I2LType::New();
//!!!!! This is the part where i can't figure out the proper input, because using relabel->GetOutput() is defenetely wrong
		i2l->SetInput(relabel->GetOutput());
		i2l->SetBackgroundValue(0);
		i2l->Update();

Thanks in advance,   Ella
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110328/c15087f1/attachment.htm>


More information about the Insight-users mailing list