Commit 12687179 authored by Bellaktris's avatar Bellaktris

-||-

parent cc9fd5af
...@@ -61,6 +61,8 @@ namespace cv ...@@ -61,6 +61,8 @@ namespace cv
Mat_<float> res( src.size(), 0.0f ), Mat_<float> res( src.size(), 0.0f ),
num( src.size(), 0.0f ); num( src.size(), 0.0f );
double threshold = 2.0*log(psize)*sigma;
for (int i = 0; i <= src.rows - psize; ++i) for (int i = 0; i <= src.rows - psize; ++i)
for (int j = 0; j <= src.cols - psize; ++j) for (int j = 0; j <= src.cols - psize; ++j)
{ {
...@@ -69,7 +71,7 @@ namespace cv ...@@ -69,7 +71,7 @@ namespace cv
dct(patch, patch); dct(patch, patch);
float * ptr = (float *) patch.data; float * ptr = (float *) patch.data;
for (int k = 0; k < psize*psize; ++k) for (int k = 0; k < psize*psize; ++k)
if (fabs(ptr[k]) < 3.0f*sigma) if (fabs(ptr[k]) < threshold)
ptr[k] = 0.0f; ptr[k] = 0.0f;
idct(patch, patch); idct(patch, patch);
......
...@@ -14,13 +14,14 @@ namespace cvtest ...@@ -14,13 +14,14 @@ namespace cvtest
for (int i = 0; i < nTests; ++i) for (int i = 0; i < nTests; ++i)
{ {
cv::String srcName = dir + cv::format( "sources/%02d.png", i + 1); cv::String srcName = dir + cv::format( "sources/%02d.png", i + 1);
cv::Mat src = cv::imread( srcName ); cv::Mat src = cv::imread( srcName, 1 );
cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 ); cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 );
cv::Mat previousResult = cv::imread( previousResultName, 1 ); cv::Mat previousResult = cv::imread( previousResultName, 1 );
cv::Mat currentResult; cv::Mat currentResult, fastNlMeansResult;
cv::dctDenoising(src, currentResult, sigma, psize); cv::dctDenoising(src, currentResult, sigma, psize);
cv::fastNlMeansDenoising(src, fastNlMeansResult);
cv::Mat sqrError = ( currentResult - previousResult ) cv::Mat sqrError = ( currentResult - previousResult )
.mul( currentResult - previousResult ); .mul( currentResult - previousResult );
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/types_c.h" #include "opencv2/imgproc/types_c.h"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/photo.hpp"
#include "opencv2/xphoto.hpp" #include "opencv2/xphoto.hpp"
#include "opencv2/ts.hpp" #include "opencv2/ts.hpp"
#include <iostream> #include <iostream>
......
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