[Insight-users] Bug in OtsuThresholdImageFilter?

Roman Grothausmann roman.grothausmann at helmholtz-berlin.de
Thu Aug 19 08:45:54 EDT 2010


Dear mailing list members,


GetThreshold() from OtsuThresholdImageFilter in the code below does not 
return any value. Is that a bug?

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