Commit 2f1cc018 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

enabled SSE3 by default; integrated SSE3-optimized bilateral filter (by Grigoriy…

enabled SSE3 by default; integrated SSE3-optimized bilateral filter (by Grigoriy Frolov); modified API of non-local means (use Input/OutputArrays)
parent 9f016da4
......@@ -191,7 +191,7 @@ OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC"
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE "Enable SSE instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE2 "Enable SSE2 instructions" ON IF (MSVC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions" OFF IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions" ON IF (MSVC OR CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSSE3 "Enable SSSE3 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF (CV_ICC OR CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
......
This diff is collapsed.
......@@ -55,23 +55,23 @@
namespace cv
{
CV_EXPORTS void fastNlMeansDenoising( const Mat& src, Mat& dst,
int templateWindowSize, int searchWindowSize, int h);
CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst,
int templateWindowSize, int searchWindowSize, int h);
CV_EXPORTS void fastNlMeansDenoisingColored( const Mat& src, Mat& dst,
int templateWindowSize, int searchWindowSize,
int h, int hForColorComponents);
CV_EXPORTS_W void fastNlMeansDenoisingColored( InputArray src, OutputArray dst,
int templateWindowSize, int searchWindowSize,
int h, int hForColorComponents);
CV_EXPORTS void fastNlMeansDenoisingMulti( const std::vector<Mat>& srcImgs,
int imgToDenoiseIndex, int temporalWindowSize,
Mat& dst,
int templateWindowSize, int searchWindowSize, int h);
CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs,
int imgToDenoiseIndex, int temporalWindowSize,
OutputArray dst,
int templateWindowSize, int searchWindowSize, int h);
CV_EXPORTS void fastNlMeansDenoisingColoredMulti( const std::vector<Mat>& srcImgs,
int imgToDenoiseIndex, int temporalWindowSize,
Mat& dst,
int templateWindowSize, int searchWindowSize,
int h, int hForColorComponents);
CV_EXPORTS_W void fastNlMeansDenoisingColoredMulti( InputArrayOfArrays srcImgs,
int imgToDenoiseIndex, int temporalWindowSize,
OutputArray dst,
int templateWindowSize, int searchWindowSize,
int h, int hForColorComponents);
}
#endif
......
......@@ -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);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment