@@ -68,7 +68,7 @@ cv::Mat buildPixelToIndexLookup(cv::InputArray mask, cv::InputArray quadtree, in
68
68
69
69
cv::Mat_<int > pixelToIndex (mask.size ());
70
70
npixel = 0 ;
71
-
71
+
72
72
int *pixelToIndexPtr = pixelToIndex.ptr <int >();
73
73
const uchar *maskPtr = m.ptr <uchar>();
74
74
const float *quadPtr = quad.ptr <float >();
@@ -78,9 +78,13 @@ cv::Mat buildPixelToIndexLookup(cv::InputArray mask, cv::InputArray quadtree, in
78
78
if (maskPtr[id] == DIRICHLET_BD)
79
79
pixelToIndexPtr[id] = -1 ;
80
80
else if (quadPtr[id] > 0 )
81
+ {
81
82
pixelToIndexPtr[id] = npixel++;
83
+ }
82
84
else
85
+ {
83
86
pixelToIndexPtr[id] = -1 ;
87
+ }
84
88
}
85
89
86
90
return pixelToIndex;
@@ -145,6 +149,7 @@ void initquad(cv::InputArray f_,
145
149
cv::OutputArray seamoutresult,
146
150
cv::OutputArray seam)
147
151
{
152
+
148
153
cv::Mat seamin,seamout;
149
154
cv::Mat bdseamout;
150
155
cv::Mat seamcal = (cv::Mat_<float >(3 , 3 ) << 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 );
@@ -155,16 +160,18 @@ void initquad(cv::InputArray f_,
155
160
cv::threshold (bdMask_, bdseamout, 0 , 1 , cv::THRESH_BINARY_INV);
156
161
157
162
seamout.copyTo (seamoutresult, bdseamout);
158
-
163
+
159
164
seam.getMat () = seaminresult.getMat () + seamoutresult.getMat ();
160
165
// seamoutresult.getMat().copyTo(seam.getMat());
161
166
167
+
162
168
cv::Mat ones (seam.getMat ().rows , seam.getMat ().cols , CV_32F);
163
169
ones.setTo (1 );
164
170
cv::Rect rect1 (0 ,ones.rows - 1 ,ones.cols ,1 );
165
171
cv::Rect rect2 (ones.cols - 1 ,0 ,1 ,ones.rows );
166
172
ones (rect1).copyTo (seam.getMat ()(rect1));
167
173
ones (rect2).copyTo (seam.getMat ()(rect2));
174
+
168
175
}
169
176
170
177
@@ -365,6 +372,7 @@ void solvePoissonEquationsFast( //f means source value
365
372
366
373
int pow2_size = std::max (nearest_powerof2 (seam.cols ), nearest_powerof2 (seam.rows ));
367
374
cv::Mat quadtree (pow2_size, pow2_size, CV_32F);
375
+ quadtree.setTo (0 );
368
376
cv::Mat quadseam (pow2_size, pow2_size, CV_32F);
369
377
cv::Rect quadrect (0 , 0 , seam.cols , seam.rows );
370
378
seam.copyTo (quadseam (quadrect));
@@ -401,7 +409,7 @@ void solvePoissonEquationsFast( //f means source value
401
409
bv.copyTo (composed, bm == DIRICHLET_BD);
402
410
403
411
cv::Mat r = result_.getMat ();
404
-
412
+
405
413
int nUnknowns = 0 ;
406
414
cv::Mat_<int > unknownIdx = buildPixelToIndexLookup (bm, quadtree, nUnknowns);
407
415
0 commit comments