Skip to content

Commit

Permalink
Fix wrong default mask value in floodFill
Browse files Browse the repository at this point in the history
(cherry picked from commit f5592fd)
  • Loading branch information
sovrasov authored and Ubiquite committed Dec 8, 2016
1 parent e91796b commit 6bae9fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/imgproc/src/floodfill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ int cv::floodFill( InputOutputArray _image, InputOutputArray _mask,
else
CV_Error( CV_StsUnsupportedFormat, "" );

uchar newMaskVal = (uchar)((flags & ~0xff) == 0 ? 1 : ((flags >> 8) & 255));
uchar newMaskVal = (uchar)((flags & 0xff00) == 0 ? 1 : ((flags >> 8) & 255));

if( type == CV_8UC1 )
floodFillGrad_CnIR<uchar, uchar, int, Diff8uC1>(
Expand Down
14 changes: 14 additions & 0 deletions modules/imgproc/test/test_floodfill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,4 +528,18 @@ void CV_FloodFillTest::prepare_to_validation( int /*test_case_idx*/ )

TEST(Imgproc_FloodFill, accuracy) { CV_FloodFillTest test; test.safe_run(); }

TEST(Imgproc_FloodFill, maskValue)
{
const int n = 50;
Mat img = Mat::zeros(n, n, CV_8U);
Mat mask = Mat::zeros(n + 2, n + 2, CV_8U);

circle(img, Point(n/2, n/2), 20, Scalar(100), 4);

int flags = 4 + CV_FLOODFILL_MASK_ONLY;
floodFill(img, mask, Point(n/2 + 13, n/2), Scalar(100), NULL, Scalar(), Scalar(), flags);

ASSERT_TRUE(norm(mask.rowRange(1, n-1).colRange(1, n-1), NORM_INF) == 1.);
}

/* End of file. */

0 comments on commit 6bae9fa

Please sign in to comment.