X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=filters%2FclitkGuerreroVentilationGenericFilter.cxx;h=04c1e93da814454c172252d3bd21d20445513a06;hb=e6add2e56013846bcf4368013c4aaf4eb36991ec;hp=426765ba89397249030e918a6260c17fa5bcfea2;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/filters/clitkGuerreroVentilationGenericFilter.cxx b/filters/clitkGuerreroVentilationGenericFilter.cxx index 426765b..04c1e93 100644 --- a/filters/clitkGuerreroVentilationGenericFilter.cxx +++ b/filters/clitkGuerreroVentilationGenericFilter.cxx @@ -1,15 +1,20 @@ /*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de - l'Image). All rights reserved. See Doc/License.txt or - http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html 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. - -=========================================================================*/ + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ /** ------------------------------------------------------------------- * @file clitkGuerreroVentilationGenericFilter.cxx @@ -22,66 +27,40 @@ #include "clitkGuerreroVentilationGenericFilter.h" #include #include -//-------------------------------------------------------------------- -clitk::GuerreroVentilationGenericFilter::GuerreroVentilationGenericFilter() -{ - blood_mass_factor=1.; -} -//-------------------------------------------------------------------- +#include //-------------------------------------------------------------------- -void clitk::GuerreroVentilationGenericFilter::Update () { - - // Determine dim, pixel type, number of components - this->GetInputImageDimensionAndPixelType(mDim,mPixelTypeName,mNbOfComponents); - - // Switch by dimension - if (mDim == 3) { Update_WithDim<3>(); return; } - if (mDim == 2) { Update_WithDim<2>(); return; } - std::cerr << "Error, dimension of input image is " << mDim << ", but I only work with 2 or 3." << std::endl; - exit(0); +clitk::GuerreroVentilationGenericFilter::GuerreroVentilationGenericFilter() + :ImageToImageGenericFilter("GuerreroVentilationGenericFilter") { + blood_mass_factor=1.; + InitializeImageType<2>(); + InitializeImageType<3>(); } //-------------------------------------------------------------------- -//This is where you put the actual implementation - -#include -#include - - //-------------------------------------------------------------------- template -void clitk::GuerreroVentilationGenericFilter::Update_WithDim() { -#define TRY_TYPE(TYPE) \ - if (IsSameType(mPixelTypeName)) { Update_WithDimAndPixelType(); return; } - // TRY_TYPE(signed char); - // TRY_TYPE(uchar); - TRY_TYPE(short); - //TRY_TYPE(ushort); - // TRY_TYPE(int); -// TRY_TYPE(unsigned int); - //TRY_TYPE(float); - // TRY_TYPE(double); -#undef TRY_TYPE - - std::string list = CreateListOfTypes(); - std::cerr << "Error, I don't know the type '" << mPixelTypeName << "' for the input image '" - << mInputFilenames[0] << "'." << std::endl << "Known types are " << list << std::endl; - exit(0); +void clitk::GuerreroVentilationGenericFilter::InitializeImageType() { + ADD_IMAGE_TYPE(Dim, short); } //-------------------------------------------------------------------- + //-------------------------------------------------------------------- -template -void clitk::GuerreroVentilationGenericFilter::Update_WithDimAndPixelType() { +template +void clitk::GuerreroVentilationGenericFilter::UpdateWithInputImageType() { - // Read input + // Input should be 2 assert(mInputFilenames.size() == 2); - typedef itk::Image ImageType; - typedef itk::Image OutputImageType; - typename ImageType::Pointer input = clitk::readImage(mInputFilenames[0], mIOVerbose); - typename ImageType::Pointer ref = clitk::readImage(mInputFilenames[1], mIOVerbose); + // Reading input + typedef ImageType InputImageType; + typename InputImageType::Pointer input = this->template GetInput(0); + typename InputImageType::Pointer ref = this->template GetInput(1); + + typedef itk::Image OutputImageType; + // typename ImageType::Pointer input = clitk::readImage(mInputFilenames[0], mIOVerbose); + //typename ImageType::Pointer ref = clitk::readImage(mInputFilenames[1], mIOVerbose); typedef itk::BinaryGuerreroFilter GFilterType; typename GFilterType::Pointer filter = GFilterType::New(); @@ -90,6 +69,7 @@ void clitk::GuerreroVentilationGenericFilter::Update_WithDimAndPixelType() { filter->SetBloodCorrectionFactor(blood_mass_factor); filter->SetUseCorrectFormula(use_correct_formula); filter->Update(); + this->SetNextOutput(filter->GetOutput()); //clitk::writeImage(filter->GetOutput(), mOutputFilename, mIOVerbose); //std::cout << "Warning: removed " << filter->GetFunctor().aberant_voxels << " aberant voxels from the ventilation image"