<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
I just discovered a bug in the OtsuThresholdCalculator class.<br>
<br>
The Otsu calculator outputs a threshold of 1, if the frequencies of
the first two bins in the histogram are zero. (Regardless of the
frequencies of the other bins)<br>
<br>
I tested this with an image that contains no pixel with intensity
values of 0 and 1. The Otsu threshold is always 1. When I reset the
intensity of one arbitrary pixel to 0 or 1, the Otsu calculator
finds a reasonable threshold value.<br>
<br>
Can anyone reproduce this issue?<br>
<br>
<br>
Best regards,<br>
Adrian.<br>
<br>
<br>
PS: Below the pipeline I used:<br>
<br>
<br>
typedef unsigned char
CScalarPixelType;<br>
<br>
typedef itk::Image<CScalarPixelType, 2>
CScalarImageType;<br>
<br>
typedef itk::ImageFileReader<CScalarImageType>
ScalarReaderType;<br>
typedef itk::ImageFileWriter<CScalarImageType>
ScalarWriterType;<br>
<br>
typedef itk::OtsuThresholdImageFilter<CScalarImageType,
CScalarImageType> OtsuThresholdImageFilterType;<br>
<br>
ScalarReaderType::Pointer reader;<br>
OtsuThresholdImageFilterType::Pointer otsuFilter;<br>
ScalarWriterType::Pointer writer;<br>
<br>
reader = ScalarReaderType::New();<br>
reader->SetFileName("myfile.tif");<br>
<br>
otsuFilter = OtsuThresholdImageFilterType::New();<i><br>
</i>otsuFilter->SetInput(reader->GetOutput());<br>
otsuFilter->Update();<br>
std::cout << (int)(otsuFilter->GetThreshold()) <<
std::endl;<br>
<br>
writer = ScalarWriterType::New();<br>
writer->SetFileName("myfile_bin.tif");<br>
writer->SetInput(otsuFilter->GetOutput());<br>
writer->Update();<br>
</body>
</html>