diff --git a/modules/photo/src/arrays.hpp b/modules/photo/src/arrays.hpp index c1c4e5f97..0d86cb6e3 100644 --- a/modules/photo/src/arrays.hpp +++ b/modules/photo/src/arrays.hpp @@ -67,7 +67,7 @@ template struct Array2d { ~Array2d() { if (needToDeallocArray) { - delete a; + delete[] a; } } @@ -96,7 +96,7 @@ template struct Array3d { ~Array3d() { if (needToDeallocArray) { - delete a; + delete[] a; } } @@ -138,7 +138,7 @@ template struct Array4d { ~Array4d() { if (needToDeallocArray) { - delete a; + delete[] a; } } diff --git a/modules/photo/src/denoising.cpp b/modules/photo/src/denoising.cpp index 39643e33d..b980b407b 100644 --- a/modules/photo/src/denoising.cpp +++ b/modules/photo/src/denoising.cpp @@ -103,7 +103,7 @@ static void fastNlMeansDenoisingMultiCheckPreconditions( int imgToDenoiseIndex, int temporalWindowSize, int templateWindowSize, int searchWindowSize) { - int src_imgs_size = srcImgs.size(); + int src_imgs_size = (int)srcImgs.size(); if (src_imgs_size == 0) { CV_Error(CV_StsBadArg, "Input images vector should not be empty!"); } @@ -176,7 +176,7 @@ void cv::fastNlMeansDenoisingColoredMulti( const std::vector& srcImgs, temporalWindowSize, templateWindowSize, searchWindowSize ); - int src_imgs_size = srcImgs.size(); + int src_imgs_size = (int)srcImgs.size(); if (srcImgs[0].type() != CV_8UC3) { CV_Error(CV_StsBadArg, "Type of input images should be CV_8UC3!"); diff --git a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp index 58e4a45e1..6724e8272 100644 --- a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp @@ -62,6 +62,10 @@ struct FastNlMeansDenoisingInvoker { void operator() (const BlockedRange& range) const; + void operator= (const FastNlMeansDenoisingInvoker& invoker) { + CV_Error(CV_StsNotImplemented, "Assigment operator is not implemented"); + } + private: const Mat& src_; Mat& dst_; @@ -102,6 +106,8 @@ FastNlMeansDenoisingInvoker::FastNlMeansDenoisingInvoker( int search_window_size, const double h) : src_(src), dst_(dst) { + CV_Assert(src.channels() <= 3); + template_window_half_size_ = template_window_size / 2; search_window_half_size_ = search_window_size / 2; template_window_size_ = template_window_half_size_ * 2 + 1; @@ -153,16 +159,12 @@ void FastNlMeansDenoisingInvoker::operator() (const BlockedRange& range) cons int row_from = range.begin(); int row_to = range.end() - 1; - int dist_sums_array[search_window_size_ * search_window_size_]; - Array2d dist_sums(dist_sums_array, search_window_size_, search_window_size_); + Array2d dist_sums(search_window_size_, search_window_size_); // for lazy calc optimization - int col_dist_sums_array[template_window_size_ * search_window_size_ * search_window_size_]; - Array3d col_dist_sums(&col_dist_sums_array[0], - template_window_size_, search_window_size_, search_window_size_); + Array3d col_dist_sums(template_window_size_, search_window_size_, search_window_size_); int first_col_num = -1; - Array3d up_col_dist_sums(src_.cols, search_window_size_, search_window_size_); for (int i = row_from; i <= row_to; i++) { @@ -233,7 +235,7 @@ void FastNlMeansDenoisingInvoker::operator() (const BlockedRange& range) cons // calc weights int weights_sum = 0; - int estimation[src_.channels()]; + int estimation[3]; for (int channel_num = 0; channel_num < src_.channels(); channel_num++) { estimation[channel_num] = 0; } diff --git a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp index cb08c7e43..02185d13d 100644 --- a/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp +++ b/modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp @@ -63,6 +63,10 @@ struct FastNlMeansMultiDenoisingInvoker { void operator() (const BlockedRange& range) const; + void operator= (const FastNlMeansMultiDenoisingInvoker& invoker) { + CV_Error(CV_StsNotImplemented, "Assigment operator is not implemented"); + } + private: int rows_; int cols_; @@ -111,6 +115,9 @@ FastNlMeansMultiDenoisingInvoker::FastNlMeansMultiDenoisingInvoker( int search_window_size, const double h) : dst_(dst), extended_srcs_(srcImgs.size()) { + CV_Assert(srcImgs.size() > 0); + CV_Assert(srcImgs[0].channels() <= 3); + rows_ = srcImgs[0].rows; cols_ = srcImgs[0].cols; channels_count_ = srcImgs[0].channels(); @@ -175,16 +182,11 @@ void FastNlMeansMultiDenoisingInvoker::operator() (const BlockedRange& range) int row_from = range.begin(); int row_to = range.end() - 1; - int dist_sums_array[temporal_window_size_ * search_window_size_ * search_window_size_]; - Array3d dist_sums(dist_sums_array, - temporal_window_size_, search_window_size_, search_window_size_); + Array3d dist_sums(temporal_window_size_, search_window_size_, search_window_size_); // for lazy calc optimization - int col_dist_sums_array[ - template_window_size_ * temporal_window_size_ * search_window_size_ * search_window_size_]; - - Array4d col_dist_sums(col_dist_sums_array, - template_window_size_, temporal_window_size_, search_window_size_, search_window_size_); + Array4d col_dist_sums( + template_window_size_, temporal_window_size_, search_window_size_, search_window_size_); int first_col_num = -1; @@ -263,7 +265,7 @@ void FastNlMeansMultiDenoisingInvoker::operator() (const BlockedRange& range) // calc weights int weights_sum = 0; - int estimation[channels_count_]; + int estimation[3]; for (int channel_num = 0; channel_num < channels_count_; channel_num++) { estimation[channel_num] = 0; }