]> Creatis software - clitk.git/blobdiff - filters/clitkImageArithmGenericFilter.txx
Changed mVtkImageReslice strategy: one filter per vtkImage
[clitk.git] / filters / clitkImageArithmGenericFilter.txx
index 6d406810ae972b0237cdb9d537a23f94f3f33dfc..9679d028e4ffa1cd5dd4f846954b79a2c999371d 100644 (file)
@@ -1,18 +1,22 @@
-/*-------------------------------------------------------------------------
-                                                                                
-  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.
-                                                                                
+/*=========================================================================
+  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://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 above copyright notices for more information.
-                                                                             
-  -------------------------------------------------------------------------*/
+  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
+======================================================================-====*/
 #ifndef CLITKIMAGEARITHMGENERICFILTER_TXX
 #define CLITKIMAGEARITHMGENERICFILTER_TXX
-
 namespace clitk
 {
   
@@ -33,9 +37,7 @@ namespace clitk
   template<class args_info_type>
   template<unsigned int Dim>
   void ImageArithmGenericFilter<args_info_type>::InitializeImageType() {      
-    ADD_IMAGE_TYPE(Dim, char);
-    ADD_IMAGE_TYPE(Dim, short);
-    ADD_IMAGE_TYPE(Dim, float);
+    ADD_DEFAULT_IMAGE_TYPES(Dim);
   }
   //--------------------------------------------------------------------
 
@@ -91,7 +93,6 @@ namespace clitk
   void ImageArithmGenericFilter<args_info_type>::UpdateWithInputImageType() {
     // Read input1
     typename ImageType::Pointer input1 = this->template GetInput<ImageType>(0);
-    typename ImageType::PixelType PixelType;
 
     // Set input image iterator
     typedef itk::ImageRegionIterator<ImageType> IteratorType;
@@ -109,7 +110,7 @@ namespace clitk
     }
 
     // Check if overwrite and outputisfloat and pixeltype is not float -> do not overwrite
-    if (mOverwriteInputImage && mOutputIsFloat && (typeid(PixelType) != typeid(float))) {
+    if (mOverwriteInputImage && mOutputIsFloat && (typeid(typename ImageType::PixelType) != typeid(float))) {
       // std::cerr << "Warning. Could not use both mOverwriteInputImage and mOutputIsFloat, because input is " 
       //                     << typeid(PixelType).name()
       //                     << std::endl;
@@ -205,7 +206,7 @@ namespace clitk
       break;
     case 5: // Absolute difference
       while (!ito.IsAtEnd()) {
-        ito.Set(PixelTypeDownCast<double, PixelType>(fabs(it2.Get()-it1.Get()))); 
+        ito.Set(PixelTypeDownCast<double, PixelType>(fabs((double)it2.Get()-(double)it1.Get()))); 
         ++it1; ++it2; ++ito;
       }
       break;
@@ -269,12 +270,14 @@ namespace clitk
     case 3: // Max 
       while (!it.IsAtEnd()) {
         if (it.Get() < mScalar) ito.Set(PixelTypeDownCast<double, PixelType>(mScalar)); 
+        else ito.Set(PixelTypeDownCast<double, PixelType>(it.Get()));
         ++it; ++ito;
       }
       break;
     case 4: // Min
       while (!it.IsAtEnd()) {
         if (it.Get() > mScalar) ito.Set(PixelTypeDownCast<double, PixelType>(mScalar)); 
+        else ito.Set(PixelTypeDownCast<double, PixelType>(it.Get()));
         ++it; ++ito;
       }
       break;
@@ -282,6 +285,7 @@ namespace clitk
       while (!it.IsAtEnd()) {
         if (it.Get() <= 0) ito.Set(PixelTypeDownCast<double, PixelType>(-it.Get())); 
         // <= zero to avoid warning for unsigned types
+        else ito.Set(PixelTypeDownCast<double, PixelType>(it.Get()));
         ++it; ++ito;
       }
       break;