From 4b938208800abc14e4515d71c85cfcc091a48534 Mon Sep 17 00:00:00 2001 From: sajarindider Date: Thu, 19 Dec 2019 00:46:46 -0500 Subject: [PATCH] Fixed small inefficiency in seamless clone init --- modules/photo/src/seamless_cloning_impl.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/modules/photo/src/seamless_cloning_impl.cpp b/modules/photo/src/seamless_cloning_impl.cpp index 1b87e86..8fd4bc7 100644 --- a/modules/photo/src/seamless_cloning_impl.cpp +++ b/modules/photo/src/seamless_cloning_impl.cpp @@ -57,12 +57,8 @@ void Cloning::computeGradientX( const Mat &img, Mat &gx) } else if (img.channels() == 1) { - Mat tmp[3]; - for(int chan = 0 ; chan < 3 ; ++chan) - { - filter2D(img, tmp[chan], CV_32F, kernel); - } - merge(tmp, 3, gx); + filter2D(img, gx, CV_32F, kernel); + cvtColor(gx, gx, COLOR_GRAY2BGR); } } @@ -78,12 +74,8 @@ void Cloning::computeGradientY( const Mat &img, Mat &gy) } else if (img.channels() == 1) { - Mat tmp[3]; - for(int chan = 0 ; chan < 3 ; ++chan) - { - filter2D(img, tmp[chan], CV_32F, kernel); - } - merge(tmp, 3, gy); + filter2D(img, gy, CV_32F, kernel); + cvtColor(gy, gy, COLOR_GRAY2BGR); } } -- 2.7.4