Commit a2dec6c3 authored by Andrey Pavlenko's avatar Andrey Pavlenko Committed by OpenCV Buildbot

Merge pull request #2493 from ilya-lavrenov:tapi_fnlm

parents b70332d8 6fe71bd2
...@@ -86,7 +86,9 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst, ...@@ -86,7 +86,9 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst,
float h, float hForColorComponents, float h, float hForColorComponents,
int templateWindowSize, int searchWindowSize) int templateWindowSize, int searchWindowSize)
{ {
if (_src.type() != CV_8UC3) int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
if (type != CV_8UC3 && type != CV_8UC4)
{ {
CV_Error(Error::StsBadArg, "Type of input image should be CV_8UC3!"); CV_Error(Error::StsBadArg, "Type of input image should be CV_8UC3!");
return; return;
...@@ -97,7 +99,7 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst, ...@@ -97,7 +99,7 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst,
templateWindowSize, searchWindowSize)) templateWindowSize, searchWindowSize))
Mat src = _src.getMat(); Mat src = _src.getMat();
_dst.create(src.size(), src.type()); _dst.create(src.size(), type);
Mat dst = _dst.getMat(); Mat dst = _dst.getMat();
Mat src_lab; Mat src_lab;
...@@ -113,10 +115,10 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst, ...@@ -113,10 +115,10 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst,
fastNlMeansDenoising(ab, ab, hForColorComponents, templateWindowSize, searchWindowSize); fastNlMeansDenoising(ab, ab, hForColorComponents, templateWindowSize, searchWindowSize);
Mat l_ab_denoised[] = { l, ab }; Mat l_ab_denoised[] = { l, ab };
Mat dst_lab(src.size(), src.type()); Mat dst_lab(src.size(), CV_MAKE_TYPE(depth, 3));
mixChannels(l_ab_denoised, 2, &dst_lab, 1, from_to, 3); mixChannels(l_ab_denoised, 2, &dst_lab, 1, from_to, 3);
cvtColor(dst_lab, dst, COLOR_Lab2LBGR); cvtColor(dst_lab, dst, COLOR_Lab2LBGR, cn);
} }
static void fastNlMeansDenoisingMultiCheckPreconditions( static void fastNlMeansDenoisingMultiCheckPreconditions(
......
...@@ -149,10 +149,10 @@ static bool ocl_fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst, ...@@ -149,10 +149,10 @@ static bool ocl_fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst,
fastNlMeansDenoising(l_ab[0], l_ab_denoised[0], h, templateWindowSize, searchWindowSize); fastNlMeansDenoising(l_ab[0], l_ab_denoised[0], h, templateWindowSize, searchWindowSize);
fastNlMeansDenoising(l_ab[1], l_ab_denoised[1], hForColorComponents, templateWindowSize, searchWindowSize); fastNlMeansDenoising(l_ab[1], l_ab_denoised[1], hForColorComponents, templateWindowSize, searchWindowSize);
UMat dst_lab(src.size(), src.type()); UMat dst_lab(src.size(), CV_8UC3);
mixChannels(l_ab_denoised, std::vector<UMat>(1, dst_lab), from_to, 3); mixChannels(l_ab_denoised, std::vector<UMat>(1, dst_lab), from_to, 3);
cvtColor(dst_lab, dst, COLOR_Lab2LBGR); cvtColor(dst_lab, dst, COLOR_Lab2LBGR, src.channels());
return true; return true;
} }
......
...@@ -72,9 +72,9 @@ OCL_TEST_P(FastNlMeansDenoising, Mat) ...@@ -72,9 +72,9 @@ OCL_TEST_P(FastNlMeansDenoising, Mat)
} }
} }
typedef FastNlMeansDenoisingTestBase fastNlMeansDenoisingColored; typedef FastNlMeansDenoisingTestBase FastNlMeansDenoisingColored;
OCL_TEST_P(fastNlMeansDenoisingColored, Mat) OCL_TEST_P(FastNlMeansDenoisingColored, Mat)
{ {
for (int j = 0; j < test_loop_times; j++) for (int j = 0; j < test_loop_times; j++)
{ {
...@@ -88,7 +88,7 @@ OCL_TEST_P(fastNlMeansDenoisingColored, Mat) ...@@ -88,7 +88,7 @@ OCL_TEST_P(fastNlMeansDenoisingColored, Mat)
} }
OCL_INSTANTIATE_TEST_CASE_P(Photo, FastNlMeansDenoising, Combine(Values(1, 2), Bool())); OCL_INSTANTIATE_TEST_CASE_P(Photo, FastNlMeansDenoising, Combine(Values(1, 2), Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Photo, fastNlMeansDenoisingColored, Combine(Values(Channels(3)), Bool())); OCL_INSTANTIATE_TEST_CASE_P(Photo, FastNlMeansDenoisingColored, Combine(Values(3, 4), Bool()));
} } // namespace cvtest::ocl } } // namespace cvtest::ocl
......
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