/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMultiScaleHessianBasedMeasureImageFilterTest.cxx,v $ Language: C++ Date: $Date: 2007/07/27 21:19:46 $ Version: $Revision: 1.5 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "itkHessianToObjectnessMeasureImageFilter.h" #include "itkMultiScaleHessianBasedMeasureImageFilter.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkRescaleIntensityImageFilter.h" #include "itkImage.h" int main( int argc, char *argv[] ) { if ( argc < 5 ) { std::cerr << "Missing Parameters: " << argv[0] << " Input_Image" << " Enhanced_Output_Image" << " Scales_Output_Image" << " [SigmaMin SigmaMax NumberOfScales ObjectDimension]" << std::endl; return EXIT_FAILURE; } // Define the dimension of the images const unsigned char Dim = 2; typedef float PixelType; // Declare the types of the images typedef itk::Image ImageType; typedef itk::ImageFileReader FileReaderType; typedef itk::ImageFileWriter FileWriterType; typedef itk::RescaleIntensityImageFilter RescaleFilterType; // Declare the type of enhancement filter typedef itk::HessianToObjectnessMeasureImageFilter ObjectnessFilterType; // Declare the type of multiscale enhancement filter typedef itk::MultiScaleHessianBasedMeasureImageFilter MultiScaleEnhancementFilterType; FileReaderType::Pointer imageReader = FileReaderType::New(); imageReader->SetFileName(argv[1]); try { imageReader->Update(); } catch (itk::ExceptionObject &ex) { std::cout << ex << std::endl; return EXIT_FAILURE; } MultiScaleEnhancementFilterType::Pointer multiScaleEnhancementFilter = MultiScaleEnhancementFilterType::New(); multiScaleEnhancementFilter->SetInput(imageReader->GetOutput()); ObjectnessFilterType* objectnessFilter = multiScaleEnhancementFilter->GetHessianToMeasureFilter(); objectnessFilter->SetScaleObjectnessMeasure(false); objectnessFilter->SetBrightObject(false); objectnessFilter->SetGamma(5.0); if ( argc >= 5 ) { multiScaleEnhancementFilter->SetSigmaMin( atof(argv[4]) ); } if ( argc >= 6 ) { multiScaleEnhancementFilter->SetSigmaMax( atof(argv[5]) ); } if ( argc >= 7 ) { multiScaleEnhancementFilter->SetNumberOfSigmaSteps( atoi(argv[6]) ); } if ( argc >= 8 ) { objectnessFilter->SetObjectDimension( atoi(argv[7]) ); } try { multiScaleEnhancementFilter->Update(); } catch (itk::ExceptionObject &e) { std::cerr << e << std::endl; } RescaleFilterType::Pointer rescale = RescaleFilterType::New(); rescale->SetInput(multiScaleEnhancementFilter->GetOutput()); rescale->SetOutputMinimum(0); rescale->SetOutputMaximum(255); FileWriterType::Pointer writer = FileWriterType::New(); writer->SetFileName(argv[2]); writer->SetInput(rescale->GetOutput()); try { writer->Update(); } catch (itk::ExceptionObject &e) { std::cerr << e << std::endl; } RescaleFilterType::Pointer rescale2 = RescaleFilterType::New(); rescale2->SetInput(multiScaleEnhancementFilter->GetScalesOutput()); rescale2->SetOutputMinimum(0); rescale2->SetOutputMaximum(255); FileWriterType::Pointer writer2 = FileWriterType::New(); writer2->SetFileName(argv[3]); writer2->SetInput(rescale2->GetOutput()); try { writer2->Update(); } catch (itk::ExceptionObject &e) { std::cerr << e << std::endl; } }