ITK/Examples/ImageProcessing/MergeLabelMapFilter: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
Daviddoria (talk | contribs) (Created page with "Demo text - permissions problem.") |
No edit summary |
||
Line 1: | Line 1: | ||
Demo text - permissions problem. | Demo text - permissions problem. | ||
#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; | |||
} |
Revision as of 00:48, 6 January 2012
Demo text - permissions problem.
- 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;
}