Skip to content

Commit 7b74fca

Browse files
committed
ENH: Improve warning messages (label numbers as ints instead of chars)
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.
1 parent aaa4315 commit 7b74fca

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Modules/Filtering/ImageStatistics/include/itkLabelOverlapMeasuresImageFilter.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,16 @@ class ITK_TEMPLATE_EXPORT LabelOverlapMeasuresImageFilter : public ImageSink<TLa
196196
protected:
197197
LabelOverlapMeasuresImageFilter();
198198
~LabelOverlapMeasuresImageFilter() override = default;
199+
200+
/** Type to use for printing label values (e.g. in warnings). */
201+
using PrintType = typename NumericTraits<LabelType>::PrintType;
202+
199203
void
200204
PrintSelf(std::ostream & os, Indent indent) const override;
201205

202206
void
203207
BeforeStreamedGenerateData() override;
204208

205-
206209
void
207210
ThreadedStreamedGenerateData(const RegionType &) override;
208211

Modules/Filtering/ImageStatistics/include/itkLabelOverlapMeasuresImageFilter.hxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetTargetOverlap(LabelType label)
174174
auto mapIt = this->m_LabelSetMeasures.find(label);
175175
if (mapIt == this->m_LabelSetMeasures.end())
176176
{
177-
itkWarningMacro("Label " << label << " not found.");
177+
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
178178
return 0.0;
179179
}
180180

@@ -225,7 +225,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetUnionOverlap(LabelType label) c
225225
auto mapIt = this->m_LabelSetMeasures.find(label);
226226
if (mapIt == this->m_LabelSetMeasures.end())
227227
{
228-
itkWarningMacro("Label " << label << " not found.");
228+
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
229229
return 0.0;
230230
}
231231

@@ -292,7 +292,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetVolumeSimilarity(LabelType labe
292292
auto mapIt = this->m_LabelSetMeasures.find(label);
293293
if (mapIt == this->m_LabelSetMeasures.end())
294294
{
295-
itkWarningMacro("Label " << label << " not found.");
295+
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
296296
return 0.0;
297297
}
298298
RealType value = 2.0 *
@@ -335,7 +335,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetFalseNegativeError(LabelType la
335335
auto mapIt = this->m_LabelSetMeasures.find(label);
336336
if (mapIt == this->m_LabelSetMeasures.end())
337337
{
338-
itkWarningMacro("Label " << label << " not found.");
338+
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
339339
return 0.0;
340340
}
341341

@@ -391,7 +391,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetFalsePositiveError(LabelType la
391391
auto mapIt = this->m_LabelSetMeasures.find(label);
392392
if (mapIt == this->m_LabelSetMeasures.end())
393393
{
394-
itkWarningMacro("Label " << label << " not found.");
394+
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
395395
return 0.0;
396396
}
397397

@@ -446,7 +446,7 @@ LabelOverlapMeasuresImageFilter<TLabelImage>::GetFalseDiscoveryRate(LabelType la
446446
auto mapIt = this->m_LabelSetMeasures.find(label);
447447
if (mapIt == this->m_LabelSetMeasures.end())
448448
{
449-
itkWarningMacro("Label " << label << " not found.");
449+
itkWarningMacro("Label " << static_cast<PrintType>(label) << " not found.");
450450
return 0.0;
451451
}
452452

0 commit comments

Comments
 (0)