ITK  5.2.0
Insight Toolkit
SphinxExamples/src/Filtering/LabelMap/MergeLabelMaps/Code.cxx
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
int
main(int, char *[])
{
using ImageType = itk::Image<int, 3>;
// Binary Image to Shape Label Map.
using LabelMapType = BI2SLMType::OutputImageType;
using LabelObjectType = BI2SLMType::LabelObjectType;
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;
}
itkMergeLabelMapFilter.h
itk::BinaryImageToShapeLabelMapFilter
Converts a binary image to a label map and valuate the shape attributes.
Definition: itkBinaryImageToShapeLabelMapFilter.h:63
itkBinaryImageToShapeLabelMapFilter.h
itk::MergeLabelMapFilterEnums::ChoiceMethod::PACK
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::MergeLabelMapFilter
Merges several Label Maps.
Definition: itkMergeLabelMapFilter.h:102