ITK  5.4.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
*
* https://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()
{
using ImageType = itk::Image<int, 3>;
// Binary Image to Shape Label Map.
using LabelMapType = BI2SLMType::OutputImageType;
using LabelObjectType = BI2SLMType::LabelObjectType;
auto merger = MergerType::New();
int noObjects = 4;
for (int i = 1; i <= noObjects; ++i)
{
auto labelMap = LabelMapType::New();
auto 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:62
itkBinaryImageToShapeLabelMapFilter.h
itk::MergeLabelMapFilterEnums::ChoiceMethod::PACK
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
New
static Pointer New()
itk::MergeLabelMapFilter
Merges several Label Maps.
Definition: itkMergeLabelMapFilter.h:101