/*========================================================================= Program: GIFT Weight Generators Test Module: giftTestWeightGenerators.cxx Language: C++ Date: 2005/11/23 Version: 0.1 Author: Dan Mueller [d.mueller@qut.edu.au] Copyright (c) 2005 Queensland University of Technology. All rights reserved. See giftCopyright.txt 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) //Warning about: identifier was truncated to '255' characters in the debug information (MVC6.0 Debug) #pragma warning( disable : 4786 ) #endif //General includes #include //ITK includes #include #include "itkNumericTraits.h" #include "itkImage.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkCastImageFilter.h" #include "itkRescaleIntensityImageFilter.h" //GIFT includes #include "giftSelectMaximumFeature.h" ///////////////////////////////////////////////////////////// //Test gift::SelectMaximumFeature int giftTestSelectMaximumFeature( int argc, char* argv[] ) { bool success = true; //ARGUMENTS: //argv[0] = Executable name //argv[1] = FeatureMap1 file name and path (eg. "C:\temp\feature1.png") //argv[2] = FeatureMap2 file name and path (eg. "C:\temp\feature2.png") //argv[3] = FilenameWeightMapPattern file name and path pattern (eg. "C:\temp\weight_{0}.png") //Set input variables char* FilenameFeatureMap1 = argv[1]; char* FilenameFeatureMap2 = argv[2]; char* FilenameWeightMapPattern = argv[3]; //Typedefs const unsigned int Dimension = 2; typedef float InternalPixelType; typedef unsigned char WritePixelType; //Declare types typedef itk::Image InternalImageType; typedef itk::Image WriteImageType; typedef itk::ImageFileReader ReaderType; typedef itk::ImageFileWriter WriterType; typedef itk::RescaleIntensityImageFilter RescaleFilterType; typedef gift::SelectMaximumFeature WeightGeneratorType; //Read FeatureMap1 ReaderType::Pointer readerFeatureMap1 = ReaderType::New(); readerFeatureMap1->SetFileName(FilenameFeatureMap1); readerFeatureMap1->Update(); //Read FeatureMap2 ReaderType::Pointer readerFeatureMap2 = ReaderType::New(); readerFeatureMap2->SetFileName(FilenameFeatureMap2); readerFeatureMap2->Update(); //Create weight generator WeightGeneratorType::Pointer weightGenerator = WeightGeneratorType::New(); weightGenerator->SetNumberOfFeatureMaps(2); weightGenerator->SetNumberOfWeightMaps(2); weightGenerator->SetInputByImageLevelBand(0, 0, 0, readerFeatureMap1->GetOutput()); weightGenerator->SetInputByImageLevelBand(1, 0, 0, readerFeatureMap2->GetOutput()); weightGenerator->Update(); for (unsigned int index=0; indexGetNumberOfWeightMaps(); index++) { //Rescale RescaleFilterType::Pointer filterRescale = RescaleFilterType::New(); filterRescale->SetOutputMinimum(0); filterRescale->SetOutputMaximum(255); filterRescale->SetInput(weightGenerator->GetOutput(index)); //Construct output weight filename char strIndex[5]; sprintf(strIndex, "%02d", index); std::string weightMapFilename = FilenameWeightMapPattern; itksys::SystemTools::ReplaceString(weightMapFilename, "{0}", strIndex); //Write WriterType::Pointer writer = WriterType::New(); writer->SetFileName(weightMapFilename.c_str()); writer->SetInput(filterRescale->GetOutput()); writer->Update(); } //Return if (success){return EXIT_SUCCESS;} else {return EXIT_FAILURE;} }