Fixed bounds checking

pull/3814/head
Erik Karlsson 10 years ago
parent d588c717da
commit 584372bbf2
  1. 6
      modules/photo/src/fast_nlmeans_denoising_invoker.hpp
  2. 6
      modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp

@ -132,7 +132,7 @@ FastNlMeansDenoisingInvoker<T, IT, UIT>::FastNlMeansDenoisingInvoker(
const size_t ALLOC_CHUNK = 65536;
IT max_dist =
(IT)pixelInfo<T>::sampleMax() * (IT)pixelInfo<T>::sampleMax() * (IT)pixelInfo<T>::channels;
int almost_max_dist = 0;
size_t almost_max_dist = 0;
while (true)
{
double dist = almost_max_dist * almost_dist2actual_dist_multiplier;
@ -158,7 +158,7 @@ void FastNlMeansDenoisingInvoker<T, IT, UIT>::operator() (const Range& range) co
int row_from = range.start;
int row_to = range.end - 1;
int almost_max_dist = almost_dist2weight_.size();
size_t almost_max_dist = almost_dist2weight_.size();
// sums of cols anf rows for current pixel p
Array2d<IT> dist_sums(search_window_size_, search_window_size_);
@ -242,7 +242,7 @@ void FastNlMeansDenoisingInvoker<T, IT, UIT>::operator() (const Range& range) co
IT* dist_sums_row = dist_sums.row_ptr(y);
for (int x = 0; x < search_window_size_; x++)
{
int almostAvgDist = (int)(dist_sums_row[x] >> almost_template_window_size_sq_bin_shift_);
size_t almostAvgDist = (size_t)(dist_sums_row[x] >> almost_template_window_size_sq_bin_shift_);
IT weight =
almostAvgDist < almost_max_dist ? almost_dist2weight_[almostAvgDist] : 0;
weights_sum += weight;

@ -143,7 +143,7 @@ FastNlMeansMultiDenoisingInvoker<T, IT, UIT>::FastNlMeansMultiDenoisingInvoker(
const size_t ALLOC_CHUNK = 65536;
IT max_dist =
(IT)pixelInfo<T>::sampleMax() * (IT)pixelInfo<T>::sampleMax() * (IT)pixelInfo<T>::channels;
int almost_max_dist = 0;
size_t almost_max_dist = 0;
while (true)
{
double dist = almost_max_dist * almost_dist2actual_dist_multiplier;
@ -169,7 +169,7 @@ void FastNlMeansMultiDenoisingInvoker<T, IT, UIT>::operator() (const Range& rang
int row_from = range.start;
int row_to = range.end - 1;
int almost_max_dist = almost_dist2weight.size();
size_t almost_max_dist = almost_dist2weight.size();
Array3d<IT> dist_sums(temporal_window_size_, search_window_size_, search_window_size_);
@ -269,7 +269,7 @@ void FastNlMeansMultiDenoisingInvoker<T, IT, UIT>::operator() (const Range& rang
for (int x = 0; x < search_window_size_; x++)
{
int almostAvgDist = (int)(dist_sums_row[x] >> almost_template_window_size_sq_bin_shift);
size_t almostAvgDist = (size_t)(dist_sums_row[x] >> almost_template_window_size_sq_bin_shift);
IT weight =
almostAvgDist < almost_max_dist ? almost_dist2weight[almostAvgDist] : 0;

Loading…
Cancel
Save