[Insight-users] Bug in OtsuThresholdImageFilter?

Roman Grothausmann roman.grothausmann at helmholtz-berlin.de
Thu Aug 19 09:04:51 EDT 2010


Thanks a lot Frederic Perez! That was my problem. It made me remember 
the warning of my old teacher who encouraged us to use printf...

Thanks again.
Roman

Frederic Perez wrote:
> Hello Roman,
> 
> On Thu, Aug 19, 2010 at 2:45 PM, Roman Grothausmann <
> roman.grothausmann at helmholtz-berlin.de> wrote:
> 
>> Dear mailing list members,
>>
>>
>> GetThreshold() from OtsuThresholdImageFilter in the code below does not
>> return any value. Is that a bug?
>>
> 
> According to the documentation (
> http://www.itk.org/Doxygen320/html/classitk_1_1OtsuThresholdImageFilter.html#a7c5fd26660c92354986d61ff8770cf86
> ),
> 
> template<class TInputImage , class TOutputImage >
> virtual InputPixelType<http://www.itk.org/Doxygen320/html/classitk_1_1OtsuThresholdImageFilter.html#a3495c875550c2ae4ed950ef5e54567a1>
>  itk::OtsuThresholdImageFilter<http://www.itk.org/Doxygen320/html/classitk_1_1OtsuThresholdImageFilter.html><
> TInputImage, TOutputImage >::GetThreshold (  ) const [virtual]
> 
> you should get an InputPixelType. Since you have instantiated unsigned chars,
> perhaps you are getting a character that doesn't "show up."
> 
> Try debugging, or do something like
> 
> std::cout << "Threshold: " << static_cast<unsigned
> int>(filter->GetThreshold()) << std::endl;
> 
> 
> Regards,
> 
> Frederic Perez
> 
> 
>> Any help is very much appreciated
>> Roman
>>
>>
>> ________________________________________
>>
>> #include <itkImageFileReader.h>
>> #include <itkImageFileWriter.h>
>>
>> #include <itkOtsuThresholdImageFilter.h>
>> #include "itkFilterWatcher2.h"
>>
>> int main( int argc, char * argv[] )
>>    {
>>    if( argc != 4 )
>>        {
>>        std::cerr << "Usage: " << argv[0];
>>        std::cerr << " inputImage";
>>        std::cerr << " outputImage";
>>        std::cerr << " #_of_hist-bins";
>>        std::cerr << std::endl;
>>        return EXIT_FAILURE;
>>        }
>>
>>    typedef  unsigned char InputPixelType;
>>    typedef  unsigned char OutputPixelType;
>>
>>    const unsigned int Dimension = 3;
>>
>>    typedef itk::Image<InputPixelType,  Dimension>   InputImageType;
>>    typedef itk::Image<OutputPixelType,  Dimension>   OutputImageType;
>>
>>    typedef itk::ImageFileReader<InputImageType>  ReaderType;
>>    typedef itk::ImageFileWriter<OutputImageType>  WriterType;
>>    WriterType::Pointer writer = WriterType::New();
>>
>>    ReaderType::Pointer reader = ReaderType::New();
>>    reader->SetFileName(argv[1]);
>>
>>    typedef itk::OtsuThresholdImageFilter<InputImageType, OutputImageType>
>> FilterType;
>>    FilterType::Pointer filter = FilterType::New();
>>
>>
>>    filter->SetNumberOfHistogramBins(atoi(argv[3]));
>>
>>    filter->SetInput(reader->GetOutput());
>>    FilterWatcher watcher(filter, "filter");
>>    filter->Update();
>>
>>    std::cout << "Threshold: " << filter->GetThreshold() << std::endl;
>>
>>    writer->SetFileName(argv[2]);
>>    writer->SetInput(filter->GetOutput());
>>    writer->Update();
>>
>>    return EXIT_SUCCESS;
>>    }
>>



-- 
Roman Grothausmann

Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
Bereich Funktionale Materialien
Institut für angewandte Materialforschung
Hahn-Meitner-Platz 1
D-14109 Berlin	

Tel.: +49-(0)30-8062-2816
Fax.: +49-(0)30-8062-3059

Vorsitzender des Aufsichtsrats: Prof. Dr. Dr. h.c. mult. Joachim Treusch
Stellvertretende Vorsitzende: Dr. Beatrix Vierkorn-Rudolph
Geschäftsführer: Prof. Dr. Anke Rita Kaysser-Pyzalla, Prof. Dr. Dr. h.c. 
Wolfgang Eberhardt, Dr. Ulrich Breuer
Sitz der Gesellschaft: Berlin
Handelsregister: AG Charlottenburg, 89 HRB 5583



More information about the Insight-users mailing list