X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkImageArithmGenericFilter.txx;h=eecbbccda4a9d83c16cec524efb9c0fb4eeb2497;hb=01a0dd7b79c5e5d5b82878d9e64dcba12891b53d;hp=1316fc145c7caf0a524a9a77f3cf9255498f2c90;hpb=faf73a151b8b24e5590a39d58dd69040f0ff1303;p=clitk.git diff --git a/tools/clitkImageArithmGenericFilter.txx b/tools/clitkImageArithmGenericFilter.txx index 1316fc1..eecbbcc 100644 --- a/tools/clitkImageArithmGenericFilter.txx +++ b/tools/clitkImageArithmGenericFilter.txx @@ -45,8 +45,6 @@ template void ImageArithmGenericFilter::InitializeImageType() { ADD_DEFAULT_IMAGE_TYPES(Dim); - ADD_VEC_IMAGE_TYPE(3u,3u,float); - ADD_VEC_IMAGE_TYPE(3u,3u,double); } //-------------------------------------------------------------------- @@ -220,7 +218,7 @@ void ImageArithmGenericFilter::ComputeImage(Iter1 it1, Iter2 it break; case 2: // Divide while (!ito.IsAtEnd()) { - if (it1.Get() != 0) + if (it2.Get() != 0) ito.Set(PixelTypeDownCast((double)it1.Get() / (double)it2.Get())); else ito.Set(mDefaultPixelValue); ++it1; @@ -271,7 +269,7 @@ void ImageArithmGenericFilter::ComputeImage(Iter1 it1, Iter2 it case 8: // Relative Difference while (!ito.IsAtEnd()) { if (it1.Get() != 0) ito.Set(PixelTypeDownCast(((double)it1.Get()-(double)it2.Get()))/(double)it1.Get()); - else ito.Set(0.0); + else ito.Set(mDefaultPixelValue); ++it1; ++it2; ++ito; @@ -351,7 +349,7 @@ void clitk::ImageArithmGenericFilter::ComputeImage(Iter1 it, Ite ++ito; } break; - case 7: // Log + case 7: // ln while (!it.IsAtEnd()) { if (it.Get() > 0) ito.Set(PixelTypeDownCast(log((double)it.Get()))); @@ -393,6 +391,18 @@ void clitk::ImageArithmGenericFilter::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(PixelTypeDownCast(-log((double)it.Get() / mScalar)) ); + } + ++it; + ++ito; + } + break; default: // error ? std::cerr << "ERROR : the operation number (" << mTypeOfOperation << ") is not known." << std::endl; exit(-1);