]> Creatis software - clitk.git/blob - filters/clitkImageArithmGenericFilter.cxx
Initial revision
[clitk.git] / filters / clitkImageArithmGenericFilter.cxx
1 /*=========================================================================
2
3   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
4   l'Image). All rights reserved. See Doc/License.txt or
5   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
6                                                                                 
7      This software is distributed WITHOUT ANY WARRANTY; without even
8      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9      PURPOSE.  See the above copyright notices for more information.
10                                                                              
11 =========================================================================*/
12
13 #ifndef CLITKIMAGEARITHMGENERICFILTER_CXX
14 #define CLITKIMAGEARITHMGENERICFILTER_CXX
15
16 /**
17  -------------------------------------------------------------------
18  * @file   clitkImageArithmGenericFilter.cxx
19  * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
20  * @date   23 Feb 2008
21
22  * @brief  
23  -------------------------------------------------------------------*/
24
25 #include "clitkImageArithmGenericFilter.h"
26
27 //--------------------------------------------------------------------
28 clitk::ImageArithmGenericFilter::ImageArithmGenericFilter():mTypeOfOperation(0) {
29   mIsOperationUseASecondImage = false;
30 }
31 //--------------------------------------------------------------------
32
33 //--------------------------------------------------------------------
34 void clitk::ImageArithmGenericFilter::Update () {
35   
36   // Load image header
37   itk::ImageIOBase::Pointer header = clitk::readImageHeader(mInputFilenames[0]);
38   
39   // Determine dim, pixel type, number of components
40   mDim = header->GetNumberOfDimensions();
41   mPixelTypeName = header->GetComponentTypeAsString(header->GetComponentType());  
42   mNbOfComponents = header->GetNumberOfComponents();
43   
44   if (mInputFilenames.size() == 0) {
45     std::cerr << "ERROR : please provide at least a input filename." << std::endl;
46   }
47   if (mInputFilenames.size() == 1) {
48     mIsOperationUseASecondImage = false;
49   }
50   if (mInputFilenames.size() == 2) {
51     mIsOperationUseASecondImage = true;
52   }
53   if (mInputFilenames.size() > 2) {
54     std::cerr << "ERROR : please provide only 1 or 2 input filenames." << std::endl;
55   }
56
57   // Switch by dimension
58   if (mDim == 2) { Update_WithDim<2>(); return; }
59   if (mDim == 3) { Update_WithDim<3>(); return; }
60   if (mDim == 4) { Update_WithDim<4>(); return; }
61
62   std::cerr << "Error, dimension of input image is " << mDim << ", but I only work with 2,3." << std::endl;
63   exit(0);
64 }
65 //--------------------------------------------------------------------
66
67 #endif //define CLITKIMAGEARITHMGENERICFILTER_CXX