/*========================================================================= Program: GIFT Weight Combiner Test Module: giftTestWeightCombiners.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 "itkNumericTraits.h" #include "itkImage.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkCastImageFilter.h" #include "itkRescaleIntensityImageFilter.h" //GIFT includes #include "giftLinearWeightCombiner.h" ///////////////////////////////////////////////////////////// //Test gift::LinearWeightCombiner int giftTestLinearWeightCombiner( int argc, char* argv[] ) { bool success = true; //ARGUMENTS: //argv[0] = Executable name //argv[1] = Input1 file name and path (eg. "C:\temp\input1.png") //argv[2] = Input2 file name and path (eg. "C:\temp\input2.png") //argv[3] = Input3 file name and path (eg. "C:\temp\input3.png") //argv[4] = WeightInput1 file name and path (eg. "C:\temp\weight_input1.png") //argv[5] = WeightInput2 file name and path (eg. "C:\temp\weight_input2.png") //argv[6] = WeightInput3 file name and path (eg. "C:\temp\weight_input3.png") //argv[7] = Final output file and path (eg. "C:\temp\output.png") //Set input variables char* Input1Filename = argv[1]; char* Input2Filename = argv[2]; char* Input3Filename = argv[3]; char* WeightInput1Filename = argv[4]; char* WeightInput2Filename = argv[5]; char* WeightInput3Filename = argv[6]; char* OutputFilename = argv[7]; //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::LinearWeightCombiner WeightCombinerType; //Read input1 ReaderType::Pointer readerInput1 = ReaderType::New(); readerInput1->SetFileName(Input1Filename); //Read input2 ReaderType::Pointer readerInput2 = ReaderType::New(); readerInput2->SetFileName(Input2Filename); //Read input3 ReaderType::Pointer readerInput3 = ReaderType::New(); readerInput3->SetFileName(Input3Filename); //Read weightInput1 ReaderType::Pointer readerWeight1 = ReaderType::New(); readerWeight1->SetFileName(WeightInput1Filename); //Read weightInput2 ReaderType::Pointer readerWeight2 = ReaderType::New(); readerWeight2->SetFileName(WeightInput2Filename); //Read weightInput3 ReaderType::Pointer readerWeight3 = ReaderType::New(); readerWeight3->SetFileName(WeightInput3Filename); //Create weight combiner WeightCombinerType::Pointer weightCombiner = WeightCombinerType::New(); weightCombiner->SetNumberOfImages(3); weightCombiner->SetNumberOfLevels(1); weightCombiner->SetNumberOfBands(1); weightCombiner->SetInputByImageLevelBand(0, 0, 0, readerInput1->GetOutput()); weightCombiner->SetInputByImageLevelBand(1, 0, 0, readerInput2->GetOutput()); weightCombiner->SetInputByImageLevelBand(2, 0, 0, readerInput3->GetOutput()); weightCombiner->SetInputByImageLevelBand(3, 0, 0, readerWeight1->GetOutput()); weightCombiner->SetInputByImageLevelBand(4, 0, 0, readerWeight2->GetOutput()); weightCombiner->SetInputByImageLevelBand(5, 0, 0, readerWeight3->GetOutput()); weightCombiner->Update(); //Rescale RescaleFilterType::Pointer filterRescale = RescaleFilterType::New(); filterRescale->SetOutputMinimum(0); filterRescale->SetOutputMaximum(255); filterRescale->SetInput(weightCombiner->GetOutput()); //Write WriterType::Pointer writer = WriterType::New(); writer->SetFileName(OutputFilename); writer->SetInput(filterRescale->GetOutput()); writer->Update(); //Return if (success){return EXIT_SUCCESS;} else {return EXIT_FAILURE;} }