ITK/Examples/ImageProcessing/MergeLabelMapFilter

From KitwarePublic
< ITK‎ | Examples
Revision as of 00:48, 6 January 2012 by Ccagataybilgin (talk | contribs)
Jump to navigationJump to search

Demo text - permissions problem.

  1. include "itkBinaryImageToShapeLabelMapFilter.h"
  2. include "itkMergeLabelMapFilter.h"

int main(int argc, char* argv[]) {

 // Input and Output image types
 typedef itk::Image<int, 3> ImageType;
 //Binary Image to Shape Label Map. 
 typedef itk::BinaryImageToShapeLabelMapFilter<ImageType> BI2SLMType;
 typedef BI2SLMType::OutputImageType LabelMapType;
 typedef BI2SLMType::LabelObjectType LabelObjectType;
 typedef itk::MergeLabelMapFilter<LabelMapType> MergerType;
 typename MergerType::Pointer merger = MergerType::New();
 int noObjects = 4;
 for (int i = 1; i <= noObjects; i++)
   {
   LabelMapType::Pointer labelMap = LabelMapType::New();
   LabelObjectType::Pointer labelObject = LabelObjectType::New();
   labelObject->SetLabel(1);
   labelMap->AddLabelObject(labelObject);
   labelMap->Update();
   merger->SetInput(i - 1, labelMap);
   }
 merger->Update();
 std::cout << "number of objects:  "
     << merger->GetOutput()->GetNumberOfLabelObjects() << "\n";
 std::cout << "number of expected objects:  " << noObjects << "\n";
 return EXIT_SUCCESS;

}