[Insight-users] itkMergeLabelMapFilter bug or misunderstanding

cagatay bilgin bilgincc at gmail.com
Thu Jan 5 14:47:53 EST 2012


Hello and happy new years ITK community,

I am having trouble understanding the output of
itkMergeLabelMapFilter. I am attaching a
simple program that creates 4 labelmaps
each holding one label object. After running
the mergelabelmapfilter, I expect to see
a labelmap with 4 labelobjects in it, but for
some reason there are 7 objects. When I look
at the objects in the map, I see that some of
them are repeated (not illustrated in the attached
code). Could this be a bug or I am missing something
here?

Thank you,
Cagatay


#include "itkBinaryImageToShapeLabelMapFilter.h"
#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;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120105/23fbacdf/attachment.htm>


More information about the Insight-users mailing list