Skip to content

Commit

Permalink
Merge pull request #1767 from ANTsX/AtroposDegCase
Browse files Browse the repository at this point in the history
BUG:  Address degenerate case.
  • Loading branch information
ntustison authored Jul 4, 2024
2 parents 6a916f2 + 232fbc5 commit dc336c5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ImageSegmentation/antsAtroposSegmentationImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "itkOtsuMultipleThresholdsCalculator.h"
#include "itkSampleClassifierFilter.h"
#include "itkSignedMaurerDistanceMapImageFilter.h"
#include "itkStatisticsImageFilter.h"
#include "itkVariableSizeMatrix.h"
#include "itkVectorIndexSelectionCastImageFilter.h"
#include "itkWeightedCentroidKdTreeGenerator.h"
Expand Down Expand Up @@ -1306,6 +1307,18 @@ AtroposSegmentationImageFilter<TInputImage, TMaskImage, TClassifiedImage>::Updat
NumericTraits<RealType>::OneValue() / static_cast<RealType>(totalNumberOfClasses);
}
}
// Check to see if the resulting number of classes is equal to the total number of classes.
using StatisticsImageFilterType = itk::StatisticsImageFilter<ClassifiedImageType>;
auto statisticsImageFilter = StatisticsImageFilterType::New();
statisticsImageFilter->SetInput(maxLabels);
statisticsImageFilter->Update();

if (statisticsImageFilter->GetMaximum() != totalNumberOfClasses)
{
itkExceptionMacro("Updating the class labeling resulted in " << statisticsImageFilter->GetMaximum() <<
" non-zero label sets but " << totalNumberOfClasses << " is requested.");
}

auto labelMapFilter = itk::LabelImageToShapeLabelMapFilter<ClassifiedImageType>::New();
labelMapFilter->SetInput(maxLabels);
labelMapFilter->SetComputeOrientedBoundingBox(false);
Expand Down

0 comments on commit dc336c5

Please sign in to comment.