mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
enabled SSE3 by default; integrated SSE3-optimized bilateral filter (by Grigoriy Frolov); modified API of non-local means (use Input/OutputArrays)
This commit is contained in:
@@ -45,9 +45,13 @@
|
||||
#include "fast_nlmeans_denoising_invoker.hpp"
|
||||
#include "fast_nlmeans_multi_denoising_invoker.hpp"
|
||||
|
||||
void cv::fastNlMeansDenoising( const cv::Mat& src, cv::Mat& dst,
|
||||
void cv::fastNlMeansDenoising( InputArray _src, OutputArray _dst,
|
||||
int templateWindowSize, int searchWindowSize, int h)
|
||||
{
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
_dst.create(src.size(), src.type());
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
switch (src.type()) {
|
||||
case CV_8U:
|
||||
parallel_for(cv::BlockedRange(0, src.rows),
|
||||
@@ -70,10 +74,14 @@ void cv::fastNlMeansDenoising( const cv::Mat& src, cv::Mat& dst,
|
||||
}
|
||||
}
|
||||
|
||||
void cv::fastNlMeansDenoisingColored( const cv::Mat& src, cv::Mat& dst,
|
||||
void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst,
|
||||
int templateWindowSize, int searchWindowSize,
|
||||
int h, int hForColorComponents)
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
_dst.create(src.size(), src.type());
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
if (src.type() != CV_8UC3) {
|
||||
CV_Error(CV_StsBadArg, "Type of input image should be CV_8UC3!");
|
||||
return;
|
||||
@@ -130,15 +138,20 @@ static void fastNlMeansDenoisingMultiCheckPreconditions(
|
||||
}
|
||||
}
|
||||
|
||||
void cv::fastNlMeansDenoisingMulti( const std::vector<Mat>& srcImgs,
|
||||
void cv::fastNlMeansDenoisingMulti( InputArrayOfArrays _srcImgs,
|
||||
int imgToDenoiseIndex, int temporalWindowSize,
|
||||
cv::Mat& dst,
|
||||
OutputArray _dst,
|
||||
int templateWindowSize, int searchWindowSize, int h)
|
||||
{
|
||||
{
|
||||
vector<Mat> srcImgs;
|
||||
_srcImgs.getMatVector(srcImgs);
|
||||
|
||||
fastNlMeansDenoisingMultiCheckPreconditions(
|
||||
srcImgs, imgToDenoiseIndex,
|
||||
temporalWindowSize, templateWindowSize, searchWindowSize
|
||||
);
|
||||
_dst.create(srcImgs[0].size(), srcImgs[0].type());
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
switch (srcImgs[0].type()) {
|
||||
case CV_8U:
|
||||
@@ -165,16 +178,22 @@ void cv::fastNlMeansDenoisingMulti( const std::vector<Mat>& srcImgs,
|
||||
}
|
||||
}
|
||||
|
||||
void cv::fastNlMeansDenoisingColoredMulti( const std::vector<Mat>& srcImgs,
|
||||
void cv::fastNlMeansDenoisingColoredMulti( InputArrayOfArrays _srcImgs,
|
||||
int imgToDenoiseIndex, int temporalWindowSize,
|
||||
cv::Mat& dst,
|
||||
OutputArray _dst,
|
||||
int templateWindowSize, int searchWindowSize,
|
||||
int h, int hForColorComponents)
|
||||
{
|
||||
vector<Mat> srcImgs;
|
||||
_srcImgs.getMatVector(srcImgs);
|
||||
|
||||
fastNlMeansDenoisingMultiCheckPreconditions(
|
||||
srcImgs, imgToDenoiseIndex,
|
||||
temporalWindowSize, templateWindowSize, searchWindowSize
|
||||
);
|
||||
|
||||
_dst.create(srcImgs[0].size(), srcImgs[0].type());
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
int src_imgs_size = (int)srcImgs.size();
|
||||
|
||||
|
||||
@@ -270,9 +270,9 @@ void FastNlMeansMultiDenoisingInvoker<T>::operator() (const BlockedRange& range)
|
||||
estimation[channel_num] = 0;
|
||||
}
|
||||
for (int d = 0; d < temporal_window_size_; d++) {
|
||||
const Mat& esrc_d = extended_srcs_[d];
|
||||
for (int y = 0; y < search_window_size_; y++) {
|
||||
const T* cur_row_ptr =
|
||||
extended_srcs_[d].ptr<T>(border_size_ + search_window_y + y);
|
||||
const T* cur_row_ptr = esrc_d.ptr<T>(border_size_ + search_window_y + y);
|
||||
|
||||
int* dist_sums_row = dist_sums.row_ptr(d, y);
|
||||
|
||||
@@ -298,7 +298,8 @@ void FastNlMeansMultiDenoisingInvoker<T>::operator() (const BlockedRange& range)
|
||||
dst_.at<T>(i,j) = saturateCastFromArray<T>(estimation);
|
||||
|
||||
} else { // weights_sum == 0
|
||||
dst_.at<T>(i,j) = extended_srcs_[temporal_window_half_size_].at<T>(i,j);
|
||||
const Mat& esrc = extended_srcs_[temporal_window_half_size_];
|
||||
dst_.at<T>(i,j) = esrc.at<T>(i,j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user