fixed a dicide by zero potential problem
authorAlexandre Benoit <no@email>
Wed, 25 Apr 2012 13:56:09 +0000 (13:56 +0000)
committerAlexandre Benoit <no@email>
Wed, 25 Apr 2012 13:56:09 +0000 (13:56 +0000)
modules/contrib/src/basicretinafilter.cpp

index f6f1c23..52338af 100644 (file)
@@ -334,7 +334,8 @@ void BasicRetinaFilter::_localLuminanceAdaptation(const float *inputFrame, const
        for (register unsigned int IDpixel=0 ; IDpixel<_filterOutput.getNBpixels() ; ++IDpixel, ++inputFramePTR)
        {
                float X0=*(localLuminancePTR++)*_localLuminanceFactor+_localLuminanceAddon;
-               *(outputFramePTR++) = (_maxInputValue+X0)**inputFramePTR/(*inputFramePTR +X0);
+               // TODO : the following line can lead to a divide by zero ! A small offset is added, take care if the offset is too large in case of High Dynamic Range images which can use very small values...               
+               *(outputFramePTR++) = (_maxInputValue+X0)**inputFramePTR/(*inputFramePTR +X0+0.00000000001);
                //std::cout<<"BasicRetinaFilter::inputFrame[IDpixel]=%f, X0=%f, outputFrame[IDpixel]=%f\n", inputFrame[IDpixel], X0, outputFrame[IDpixel]);
        }
 }