Fix integer overflow in NL-Means denoising on white input

Issues #2646
pull/343/head
Andrey Kamaev 12 years ago
parent 7e92826efc
commit 7374445398
  1. 2
      modules/photo/src/fast_nlmeans_denoising_invoker.hpp
  2. 2
      modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp

@ -257,7 +257,7 @@ void FastNlMeansDenoisingInvoker<T>::operator() (const BlockedRange& range) cons
}
for (size_t channel_num = 0; channel_num < sizeof(T); channel_num++)
estimation[channel_num] = (estimation[channel_num] + weights_sum/2) / weights_sum;
estimation[channel_num] = ((unsigned)estimation[channel_num] + weights_sum/2) / weights_sum;
dst_.at<T>(i,j) = saturateCastFromArray<T>(estimation);
}

@ -287,7 +287,7 @@ void FastNlMeansMultiDenoisingInvoker<T>::operator() (const BlockedRange& range)
}
for (size_t channel_num = 0; channel_num < sizeof(T); channel_num++)
estimation[channel_num] = (estimation[channel_num] + weights_sum / 2) / weights_sum;
estimation[channel_num] = ((unsigned)estimation[channel_num] + weights_sum / 2) / weights_sum;
dst_.at<T>(i,j) = saturateCastFromArray<T>(estimation);

Loading…
Cancel
Save