ITK/Examples/ImageProcessing/MergeLabelMapFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(argc/argv not used)
(Deprecated content that is moved to sphinx)
 
Line 1: Line 1:
==MergeLabelMapFilter.cxx==
{{warning|1=The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/*  pages likely require ITK version 4.13 or earlier releases.   In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.
<source lang="cpp">
}}
#include "itkBinaryImageToShapeLabelMapFilter.h"
#include "itkMergeLabelMapFilter.h"
 
int main(int, char*[])
{
  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;
  MergerType::Pointer merger = MergerType::New();
  merger->SetMethod(MergerType::PACK);
 
  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;
}
 
</source>
 
{{ITKCMakeLists|{{SUBPAGENAME}}}}

Latest revision as of 21:01, 4 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.