Skip to content

Commit 2850fe6

Browse files
authored
Update globalmatting.cpp
1 parent 6eacc41 commit 2850fe6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

modules/ximgproc/src/globalmatting.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ void GlobalMatting::calculateAlphaPatchMatch(const cv::Mat_<cv::Vec3b> &image,
282282
if (r < 1)
283283
break;
284284

285-
int di = r * (rand() / (RAND_MAX + 1.f));
286-
int dj = r * (rand() / (RAND_MAX + 1.f));
285+
int di = int(r * (rand() / (RAND_MAX + 1.f)));
286+
int dj = int(r * (rand() / (RAND_MAX + 1.f)));
287287

288288
int fi = s.fi + di;
289289
int bj = s.bj + dj;
@@ -419,7 +419,7 @@ void GlobalMatting::expansionOfKnownRegions(cv::InputArray _img, cv::InputOutput
419419
CV_Error(CV_StsBadArg, "image and trimap mush have same size");
420420

421421
for (int i = 0; i < niter; ++i)
422-
expansionOfKnownRegionsHelper(img, trimap, i + 1, niter - i);
422+
expansionOfKnownRegionsHelper(img, trimap, i + 1, float(niter - i));
423423
erodeFB(trimap, 2);
424424
}
425425

@@ -470,8 +470,8 @@ void GlobalMatting::globalMattingHelper(cv::Mat _image, cv::Mat _trimap, cv::Mat
470470
break;
471471
case 128:
472472
{
473-
alpha(y, x) = 255 * samples[y][x].alpha;
474-
conf(y, x) = 255 * exp(-samples[y][x].cost / 6);
473+
alpha(y, x) = uchar(255 * samples[y][x].alpha);
474+
conf(y, x) = uchar(255 * exp(-samples[y][x].cost / 6));
475475
cv::Point p = foregroundBoundary[samples[y][x].fi];
476476
foreground(y, x) = image(p.y, p.x);
477477
break;

0 commit comments

Comments
 (0)