1 /*=========================================================================
4 Module: $RCSfile: clitkImageToImageGenericFilter.txx,v $
6 Date: $Date: 2010/01/29 08:48:42 $
7 Version: $Revision: 1.1 $
8 Author : Joel Schaerer <joel.schaerer@creatis.insa-lyon.fr>
9 David Sarrut <david.sarrut@creatis.insa-lyon.fr>
12 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
13 CREATIS-LRMN http://www.creatis.insa-lyon.fr
15 This program is free software: you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation, version 3 of the License.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 =========================================================================*/
29 //--------------------------------------------------------------------
30 template<class ImageType>
31 void clitk::ImageToImageGenericFilterBase::SetNextOutput(typename ImageType::Pointer output) {
32 if (mOutputFilenames.size())
34 clitk::writeImage<ImageType>(output, mOutputFilenames.front(), mIOVerbose);
35 mOutputFilenames.pop_front();
37 if (mInputVVImages.size()) //We assume that if a vv image is set as input, we want one as the output
38 mOutputVVImages.push_back(vvImageFromITK<ImageType::ImageDimension,typename ImageType::PixelType>(output));
40 //--------------------------------------------------------------------
43 //--------------------------------------------------------------------
44 template<class ImageType>
45 typename ImageType::Pointer clitk::ImageToImageGenericFilterBase::GetInput(unsigned int n) {
46 if (mInputFilenames.size() > n) {
47 return clitk::readImage<ImageType>(mInputFilenames[n], mIOVerbose);
49 else if (mInputVVImages.size() > n)
50 return typename ImageType::Pointer(const_cast<ImageType*>(vvImageToITK<ImageType>(mInputVVImages[n]).GetPointer()));
52 assert(false); //No input, this shouldn't happen
54 //--------------------------------------------------------------------
57 //--------------------------------------------------------------------
58 template<class FilterType>
59 clitk::ImageToImageGenericFilter<FilterType>::ImageToImageGenericFilter(std::string filterName)
60 :ImageToImageGenericFilterBase(filterName){
61 // Create main function manager
62 this->mImageTypesManager = new
63 ImageTypesManager<FilterType>(static_cast<FilterType*>(this));
65 //--------------------------------------------------------------------
68 //--------------------------------------------------------------------
69 template<class FilterType>
70 bool clitk::ImageToImageGenericFilter<FilterType>::Update() {
71 GetInputImageDimensionAndPixelType(mDim,mPixelTypeName,mNbOfComponents);
74 if (!CheckImageType()) {
75 if (mFailOnImageTypeError) ImageTypeError();
76 else SetImageTypeError();
80 // Go ! Call the right templatized function
81 mImageTypesManager->DoIt(mDim, mPixelTypeName);
84 //--------------------------------------------------------------------