提交 6fe71bd2 编写于 作者: I Ilya Lavrenov

added 4 channels support to fnlm

上级 ae2b0b00
......@@ -86,7 +86,9 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst,
float h, float hForColorComponents,
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!");
return;
......@@ -97,7 +99,7 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst,
templateWindowSize, searchWindowSize))
Mat src = _src.getMat();
_dst.create(src.size(), src.type());
_dst.create(src.size(), type);
Mat dst = _dst.getMat();
Mat src_lab;
......@@ -113,10 +115,10 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst,
fastNlMeansDenoising(ab, ab, hForColorComponents, templateWindowSize, searchWindowSize);
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);
cvtColor(dst_lab, dst, COLOR_Lab2LBGR);
cvtColor(dst_lab, dst, COLOR_Lab2LBGR, cn);
}
static void fastNlMeansDenoisingMultiCheckPreconditions(
......
......@@ -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[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);
cvtColor(dst_lab, dst, COLOR_Lab2LBGR);
cvtColor(dst_lab, dst, COLOR_Lab2LBGR, src.channels());
return true;
}
......
......@@ -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++)
{
......@@ -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, fastNlMeansDenoisingColored, Combine(Values(Channels(3)), Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Photo, FastNlMeansDenoisingColored, Combine(Values(3, 4), Bool()));
} } // namespace cvtest::ocl
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册