Adrian Friebel Work | 26 Jul 2012 18:43
Picon

Bug in OtsuThresholdCalculator

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();
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users

Gmane