X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkImageToImageGenericFilter.h;h=07ba4928cc7121ceab7173301f0e5eacbd149004;hb=babf100c0d140f6b2525532d001b7794fb47a625;hp=43a62df8aaaabc969842ba388860fe03e6daec20;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/common/clitkImageToImageGenericFilter.h b/common/clitkImageToImageGenericFilter.h index 43a62df..07ba492 100644 --- a/common/clitkImageToImageGenericFilter.h +++ b/common/clitkImageToImageGenericFilter.h @@ -1,107 +1,55 @@ -#ifndef CLITKIMAGETOIMAGEGENERICFILTER_H -#define CLITKIMAGETOIMAGEGENERICFILTER_H +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr -/** - =================================================================== - * @file clitkImageToImageGenericFilter.h - * @author David Sarrut - * @date 05 May 2008 14:40:51 + 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. - * @brief + 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 +===========================================================================**/ -// clitk include -#include "clitkCommon.h" -#include "clitkImageCommon.h" -#include +#ifndef CLITKIMAGETOIMAGEGENERICFILTER_H +#define CLITKIMAGETOIMAGEGENERICFILTER_H -#include -#include -#include -#include +#include "clitkImageToImageGenericFilterBase.h" namespace clitk { - class ImageToImageGenericFilter: public itk::Object { +//-------------------------------------------------------------------- + template + class ImageToImageGenericFilter: public ImageToImageGenericFilterBase { public: - // constructor - destructor - ImageToImageGenericFilter(); - - // Types - typedef ImageToImageGenericFilter Self; - typedef Object Superclass; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; - - // Generic IO - /// Returns the dimension and pixel type of the *first* input - void GetInputImageDimensionAndPixelType(unsigned int& dim, std::string& pixeltype,unsigned int & components); - - // File IO - void SetInputFilename(const std::string & filename); - void AddInputFilename(const std::string & filename); - void SetInputFilenames(const std::vector & filenames); - void SetOutputFilename(const std::string & filename); - void AddOutputFilename(const std::string & filename); - void SetOutputFilenames(const std::vector & filenames); - std::string GetOutputFilename(); - void SetIOVerbose(bool b) { mIOVerbose = b; } - - // VVImage IO - void SetInputVVImage (vvImage::Pointer input); - void SetInputVVImages (std::vector input); - void AddInputVVImage (vvImage::Pointer input); - vvImage::Pointer GetOutputVVImage (); - std::vector GetOutputVVImages (); - - /// Main function to implement - virtual void Update() = 0; - protected: - /// Call this function to dispatch an output towards the correct sink - template - void SetNextOutput(typename ImageType::Pointer output); - /// Call this function to get the nth itk input image, regardless of input source - template - typename ImageType::Pointer GetInput(unsigned int n); - - std::vector mInputFilenames; - std::list mOutputFilenames; + typedef ImageToImageGenericFilter Self; - bool mIOVerbose; - unsigned int mDim; - std::string mPixelTypeName; - unsigned int mNbOfComponents; + // constructor - destructor + ImageToImageGenericFilter(std::string filterName); - std::vector mInputVVImages; - std::vector mOutputVVImages; + // Main function to call for using the filter. + virtual bool Update(); + virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype); + virtual bool CheckImageType(); + virtual std::string GetAvailableImageTypes(); + protected: + // Object that will manage the list of templatized function for + // each image type. + ImageTypesManager mImageTypesManager; + }; // end class clitk::ImageToImageGenericFilter +#include "clitkImageToImageGenericFilter.txx" + } // end namespace -template -void clitk::ImageToImageGenericFilter::SetNextOutput(typename ImageType::Pointer output) -{ - if (mOutputFilenames.size()) - { - clitk::writeImage(output, mOutputFilenames.front(), mIOVerbose); - mOutputFilenames.pop_front(); - } - if (mInputVVImages.size()) //We assume that if a vv image is set as input, we want one as the output - mOutputVVImages.push_back(vvImageFromITK(output)); -} -template -typename ImageType::Pointer clitk::ImageToImageGenericFilter::GetInput(unsigned int n) -{ - if (mInputFilenames.size() > n) - return clitk::readImage(mInputFilenames[n], mIOVerbose); - else if (mInputVVImages.size() > n) - return typename ImageType::Pointer(const_cast(vvImageToITK(mInputVVImages[n]).GetPointer())); - else - assert(false); //No input, this shouldn't happen -} #endif /* end #define CLITKIMAGETOIMAGEGENERICFILTER_H */