Skip to content

Commit 5220a9f

Browse files
quadtree init operation
1 parent a9a0919 commit 5220a9f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Diff for: poisson_solver.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ cv::Mat buildPixelToIndexLookup(cv::InputArray mask, cv::InputArray quadtree, in
6868

6969
cv::Mat_<int> pixelToIndex(mask.size());
7070
npixel = 0;
71-
71+
7272
int *pixelToIndexPtr = pixelToIndex.ptr<int>();
7373
const uchar *maskPtr = m.ptr<uchar>();
7474
const float *quadPtr = quad.ptr<float>();
@@ -78,9 +78,13 @@ cv::Mat buildPixelToIndexLookup(cv::InputArray mask, cv::InputArray quadtree, in
7878
if(maskPtr[id] == DIRICHLET_BD)
7979
pixelToIndexPtr[id] = -1;
8080
else if(quadPtr[id] > 0)
81+
{
8182
pixelToIndexPtr[id] = npixel++;
83+
}
8284
else
85+
{
8386
pixelToIndexPtr[id] = -1;
87+
}
8488
}
8589

8690
return pixelToIndex;
@@ -145,6 +149,7 @@ void initquad(cv::InputArray f_,
145149
cv::OutputArray seamoutresult,
146150
cv::OutputArray seam)
147151
{
152+
148153
cv::Mat seamin,seamout;
149154
cv::Mat bdseamout;
150155
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_,
155160
cv::threshold(bdMask_, bdseamout, 0, 1, cv::THRESH_BINARY_INV);
156161

157162
seamout.copyTo(seamoutresult, bdseamout);
158-
163+
159164
seam.getMat() = seaminresult.getMat() + seamoutresult.getMat();
160165
//seamoutresult.getMat().copyTo(seam.getMat());
161166

167+
162168
cv::Mat ones(seam.getMat().rows, seam.getMat().cols, CV_32F);
163169
ones.setTo(1);
164170
cv::Rect rect1(0,ones.rows - 1,ones.cols,1);
165171
cv::Rect rect2(ones.cols - 1,0,1,ones.rows);
166172
ones(rect1).copyTo(seam.getMat()(rect1));
167173
ones(rect2).copyTo(seam.getMat()(rect2));
174+
168175
}
169176

170177

@@ -365,6 +372,7 @@ void solvePoissonEquationsFast( //f means source value
365372

366373
int pow2_size = std::max(nearest_powerof2(seam.cols), nearest_powerof2(seam.rows));
367374
cv::Mat quadtree(pow2_size, pow2_size, CV_32F);
375+
quadtree.setTo(0);
368376
cv::Mat quadseam(pow2_size, pow2_size, CV_32F);
369377
cv::Rect quadrect(0, 0, seam.cols, seam.rows);
370378
seam.copyTo(quadseam(quadrect));
@@ -401,7 +409,7 @@ void solvePoissonEquationsFast( //f means source value
401409
bv.copyTo(composed, bm == DIRICHLET_BD);
402410

403411
cv::Mat r = result_.getMat();
404-
412+
405413
int nUnknowns = 0;
406414
cv::Mat_<int> unknownIdx = buildPixelToIndexLookup(bm, quadtree, nUnknowns);
407415

0 commit comments

Comments
 (0)