]> Creatis software - clitk.git/blobdiff - tools/clitkImageArithmGenericFilter.txx
Add another operation -ln(I/IO)
[clitk.git] / tools / clitkImageArithmGenericFilter.txx
index 1316fc145c7caf0a524a9a77f3cf9255498f2c90..4abb43343463652f899748d818f7d5bea3682d20 100644 (file)
@@ -393,6 +393,18 @@ void clitk::ImageArithmGenericFilter<args_info_type>::ComputeImage(Iter1 it, Ite
       ++ito;
     }
     break;
+  case 13: // -ln I/I0
+    while (!it.IsAtEnd()) {
+      if (it.Get() == 0) { // special case for fluence image with 0 value in a pixel -> consider 0.5
+        ito.Set(-log(0.5 / mScalar) );
+      }
+      else {
+        ito.Set(-log(PixelTypeDownCast<double, PixelType>((double)it.Get() / mScalar)) );
+      }
+      ++it;
+      ++ito;
+    }
+    break;
   default: // error ?
     std::cerr << "ERROR : the operation number (" << mTypeOfOperation << ") is not known." << std::endl;
     exit(-1);