Skip to content

Commit

Permalink
ENH: Improve warning messages (label numbers as ints instead of chars)
Browse files Browse the repository at this point in the history
This filter is typically instantiated with unsigned char pixel type,
which leads to non-meaningful information being printed, such as:

WARNING: In C:\P\IPP\ITK-source\ITK\Modules\Filtering\ImageStatistics\include\itkLabelOverlapMeasuresImageFilter.hxx, line 233
LabelOverlapMeasuresImageFilter (000001FF7CF72F80): Label � not found.

WARNING: In C:\P\IPP\ITK-source\ITK\Modules\Filtering\ImageStatistics\include\itkLabelOverlapMeasuresImageFilter.hxx, line 233
LabelOverlapMeasuresImageFilter (000001FF7CF72F80): Label � not found.

WARNING: In C:\P\IPP\ITK-source\ITK\Modules\Filtering\ImageStatistics\include\itkLabelOverlapMeasuresImageFilter.hxx, line 233
LabelOverlapMeasuresImageFilter (000001FF7CF72F80): Label � not found.

WARNING: In C:\P\IPP\ITK-source\ITK\Modules\Filtering\ImageStatistics\include\itkLabelOverlapMeasuresImageFilter.hxx, line 233
LabelOverlapMeasuresImageFilter (000001FF7CF72F80): Label not found.
  • Loading branch information
dzenanz committed Sep 15, 2023
1 parent aaa4315 commit 7b74fca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Expand Up @@ -196,13 +196,16 @@ class ITK_TEMPLATE_EXPORT LabelOverlapMeasuresImageFilter : public ImageSink<TLa
protected:
LabelOverlapMeasuresImageFilter();
~LabelOverlapMeasuresImageFilter() override = default;

/** Type to use for printing label values (e.g. in warnings). */
using PrintType = typename NumericTraits<LabelType>::PrintType;

void
PrintSelf(std::ostream & os, Indent indent) const override;

void
BeforeStreamedGenerateData() override;


void
ThreadedStreamedGenerateData(const RegionType &) override;

Expand Down
Expand Up @@ -174,7 +174,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetTargetOverlap(LabelType label)
auto mapIt = this->m_LabelSetMeasures.find(label);
if (mapIt == this->m_LabelSetMeasures.end())
{
itkWarningMacro("Label " << label << " not found.");
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
return 0.0;
}

Expand Down Expand Up @@ -225,7 +225,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetUnionOverlap(LabelType label) c
auto mapIt = this->m_LabelSetMeasures.find(label);
if (mapIt == this->m_LabelSetMeasures.end())
{
itkWarningMacro("Label " << label << " not found.");
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
return 0.0;
}

Expand Down Expand Up @@ -292,7 +292,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetVolumeSimilarity(LabelType labe
auto mapIt = this->m_LabelSetMeasures.find(label);
if (mapIt == this->m_LabelSetMeasures.end())
{
itkWarningMacro("Label " << label << " not found.");
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
return 0.0;
}
RealType value = 2.0 *
Expand Down Expand Up @@ -335,7 +335,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetFalseNegativeError(LabelType la
auto mapIt = this->m_LabelSetMeasures.find(label);
if (mapIt == this->m_LabelSetMeasures.end())
{
itkWarningMacro("Label " << label << " not found.");
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
return 0.0;
}

Expand Down Expand Up @@ -391,7 +391,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetFalsePositiveError(LabelType la
auto mapIt = this->m_LabelSetMeasures.find(label);
if (mapIt == this->m_LabelSetMeasures.end())
{
itkWarningMacro("Label " << label << " not found.");
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
return 0.0;
}

Expand Down Expand Up @@ -446,7 +446,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetFalseDiscoveryRate(LabelType la
auto mapIt = this->m_LabelSetMeasures.find(label);
if (mapIt == this->m_LabelSetMeasures.end())
{
itkWarningMacro("Label " << label << " not found.");
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
return 0.0;
}

Expand Down

0 comments on commit 7b74fca

Please sign in to comment.