[Insight-users] Bug in OtsuThresholdCalculator
Adrian Friebel Work
friebel at izbi.uni-leipzig.de
Thu Jul 26 12:43:59 EDT 2012
Hello,
I just discovered a bug in the OtsuThresholdCalculator class.
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)
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.
Can anyone reproduce this issue?
Best regards,
Adrian.
PS: Below the pipeline I used:
typedef unsigned char CScalarPixelType;
typedef itk::Image<CScalarPixelType, 2> CScalarImageType;
typedef itk::ImageFileReader<CScalarImageType> ScalarReaderType;
typedef itk::ImageFileWriter<CScalarImageType> ScalarWriterType;
typedef itk::OtsuThresholdImageFilter<CScalarImageType,
CScalarImageType> OtsuThresholdImageFilterType;
ScalarReaderType::Pointer reader;
OtsuThresholdImageFilterType::Pointer otsuFilter;
ScalarWriterType::Pointer writer;
reader = ScalarReaderType::New();
reader->SetFileName("myfile.tif");
otsuFilter = OtsuThresholdImageFilterType::New();/
/otsuFilter->SetInput(reader->GetOutput());
otsuFilter->Update();
std::cout << (int)(otsuFilter->GetThreshold()) << std::endl;
writer = ScalarWriterType::New();
writer->SetFileName("myfile_bin.tif");
writer->SetInput(otsuFilter->GetOutput());
writer->Update();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120726/5a2337ba/attachment.htm>
More information about the Insight-users
mailing list