From cada7d33a84b2588c26217b16473dcb4ccd3831d Mon Sep 17 00:00:00 2001 From: Philip Manke Date: Tue, 21 May 2024 16:59:48 +0200 Subject: [PATCH] Fix overflow for large selections --- auxiliary/include/cuvis_spectral.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auxiliary/include/cuvis_spectral.hpp b/auxiliary/include/cuvis_spectral.hpp index a5aa350..3105122 100644 --- a/auxiliary/include/cuvis_spectral.hpp +++ b/auxiliary/include/cuvis_spectral.hpp @@ -163,9 +163,9 @@ namespace cuvis::aux::spectral //binary mask //using nearest neighbor - cv::fillPoly(mask, vpts, cv::Scalar(255,255,255)); + cv::fillPoly(mask, vpts, cv::Scalar(255)); - std::uint16_t n = 0; //counter variable + std::uint64_t n = 0; //counter variable std::vector sum_v(img._channels, 0.0); //growing sum std::vector sq_sum_v(img._channels, 0.0); //growing square sum @@ -180,7 +180,7 @@ namespace cuvis::aux::spectral for (int z = 0; z < img._channels; z++) { //reading out value - auto loc_val = img._data[((y)*img._width + (x)) * img._channels + (z)]; + auto loc_val = img._data[((y) * img._width + (x)) * img._channels + (z)]; //adding up values sum_v[z] += loc_val; sq_sum_v[z] += loc_val * loc_val;