vector<Mat> &masks)\r
{\r
LOGLN("Finding seams...");\r
- if (src.size() == 0) \r
+ if (src.size() == 0)\r
return;\r
\r
+#if ENABLE_LOG\r
int64 t = getTickCount();\r
+#endif\r
\r
images_ = src;\r
sizes_.resize(src.size());\r
vector<Mat> &masks)\r
{\r
LOGLN("Finding seams...");\r
- if (sizes.size() == 0) \r
+ if (sizes.size() == 0)\r
return;\r
\r
+#if ENABLE_LOG\r
int64 t = getTickCount();\r
+#endif\r
\r
sizes_ = sizes;\r
corners_ = corners;\r
void DpSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners, vector<Mat> &masks)\r
{\r
LOGLN("Finding seams...");\r
+#if ENABLE_LOG\r
int64 t = getTickCount();\r
+#endif\r
\r
if (src.size() == 0)\r
return;\r
{\r
CV_Assert(states_[comp] & INTERS);\r
\r
- // compute costs \r
+ // compute costs\r
\r
float (*diff)(const Mat&, int, int, const Mat&, int, int) = 0;\r
if (image1.type() == CV_32FC3 && image2.type() == CV_32FC3)\r
void findInPair(size_t first, size_t second, Rect roi);\r
\r
private:\r
- void setGraphWeightsColor(const Mat &img1, const Mat &img2, \r
+ void setGraphWeightsColor(const Mat &img1, const Mat &img2,\r
const Mat &mask1, const Mat &mask2, GCGraph<float> &graph);\r
- void setGraphWeightsColorGrad(const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2, \r
- const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2, \r
+ void setGraphWeightsColorGrad(const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,\r
+ const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,\r
GCGraph<float> &graph);\r
\r
vector<Mat> dx_, dy_;\r
\r
\r
void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(\r
- const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2, \r
- const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2, \r
+ const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,\r
+ const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,\r
GCGraph<float> &graph)\r
{\r
const Size img_size = img1.size();\r
float grad = dx1.at<float>(y, x) + dx1.at<float>(y, x + 1) +\r
dx2.at<float>(y, x) + dx2.at<float>(y, x + 1) + weight_eps;\r
float weight = (normL2(img1.at<Point3f>(y, x), img2.at<Point3f>(y, x)) +\r
- normL2(img1.at<Point3f>(y, x + 1), img2.at<Point3f>(y, x + 1))) / grad + \r
+ normL2(img1.at<Point3f>(y, x + 1), img2.at<Point3f>(y, x + 1))) / grad +\r
weight_eps;\r
if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y, x + 1) ||\r
!mask2.at<uchar>(y, x) || !mask2.at<uchar>(y, x + 1))\r
}\r
if (y < img_size.height - 1)\r
{\r
- float grad = dy1.at<float>(y, x) + dy1.at<float>(y + 1, x) + \r
+ float grad = dy1.at<float>(y, x) + dy1.at<float>(y + 1, x) +\r
dy2.at<float>(y, x) + dy2.at<float>(y + 1, x) + weight_eps;\r
- float weight = (normL2(img1.at<Point3f>(y, x), img2.at<Point3f>(y, x)) + \r
- normL2(img1.at<Point3f>(y + 1, x), img2.at<Point3f>(y + 1, x))) / grad + \r
+ float weight = (normL2(img1.at<Point3f>(y, x), img2.at<Point3f>(y, x)) +\r
+ normL2(img1.at<Point3f>(y + 1, x), img2.at<Point3f>(y + 1, x))) / grad +\r
weight_eps;\r
if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y + 1, x) ||\r
!mask2.at<uchar>(y, x) || !mask2.at<uchar>(y + 1, x))\r
setGraphWeightsColor(subimg1, subimg2, submask1, submask2, graph);\r
break;\r
case GraphCutSeamFinder::COST_COLOR_GRAD:\r
- setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2, \r
+ setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2,\r
submask1, submask2, graph);\r
break;\r
default:\r
}\r
}\r
}\r
- \r
+\r
Mat terminals, leftT, rightT, top, bottom;\r
\r
switch (cost_type_)\r
{\r
case GraphCutSeamFinder::COST_COLOR:\r
- setGraphWeightsColor(subimg1, subimg2, submask1, submask2, \r
+ setGraphWeightsColor(subimg1, subimg2, submask1, submask2,\r
terminals, leftT, rightT, top, bottom);\r
break;\r
case GraphCutSeamFinder::COST_COLOR_GRAD:\r
- setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2, \r
+ setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2,\r
submask1, submask2, terminals, leftT, rightT, top, bottom);\r
break;\r
default:\r
}\r
\r
\r
-void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img2, const Mat &mask1, const Mat &mask2, \r
+void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img2, const Mat &mask1, const Mat &mask2,\r
Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)\r
{\r
const Size img_size = img1.size();\r
\r
void GraphCutSeamFinderGpu::setGraphWeightsColorGrad(\r
const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,\r
- const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2, \r
+ const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,\r
Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)\r
{\r
const Size img_size = img1.size();\r