Skip to content

Commit

Permalink
Merge pull request #1456 from jacob-m-nash/floodfill-maskonly-set-color
Browse files Browse the repository at this point in the history
Encoded white grey value into maskonly flag
  • Loading branch information
shimat committed Aug 16, 2022
2 parents 16342ee + 3dc0687 commit cf9c448
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/OpenCvSharp/Cv2/Cv2_imgproc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,8 @@ public static int FloodFill(InputOutputArray image, Point seedPoint, Scalar newV
/// being added to the component.</param>
/// <param name="flags">Operation flags. Lower bits contain a connectivity value,
/// 4 (default) or 8, used within the function. Connectivity determines which
/// neighbors of a pixel are considered. </param>
/// neighbors of a pixel are considered. Using FloodFillFlags.MaskOnly will
/// fill in the mask using the grey value 255 (white). </param>
/// <returns></returns>
public static int FloodFill(InputOutputArray image,
Point seedPoint, Scalar newVal, out Rect rect,
Expand All @@ -2287,6 +2288,11 @@ public static int FloodFill(InputOutputArray image, Point seedPoint, Scalar newV
var loDiff0 = loDiff.GetValueOrDefault(new Scalar());
var upDiff0 = upDiff.GetValueOrDefault(new Scalar());

if (flags.HasFlag(FloodFillFlags.MaskOnly))
{
flags |= (FloodFillFlags)(255 << 8);
}

NativeMethods.HandleException(
NativeMethods.imgproc_floodFill1(
image.CvPtr, seedPoint, newVal, out rect,
Expand Down Expand Up @@ -2340,7 +2346,8 @@ public static int FloodFill(InputOutputArray image, Point seedPoint, Scalar newV
/// being added to the component.</param>
/// <param name="flags">Operation flags. Lower bits contain a connectivity value,
/// 4 (default) or 8, used within the function. Connectivity determines which
/// neighbors of a pixel are considered. </param>
/// neighbors of a pixel are considered. Using FloodFillFlags.MaskOnly will
/// fill in the mask using the grey value 255 (white). </param>
/// <returns></returns>
public static int FloodFill(InputOutputArray image, InputOutputArray mask,
Point seedPoint, Scalar newVal, out Rect rect,
Expand All @@ -2356,6 +2363,11 @@ public static int FloodFill(InputOutputArray image, Point seedPoint, Scalar newV
var loDiff0 = loDiff.GetValueOrDefault(new Scalar());
var upDiff0 = upDiff.GetValueOrDefault(new Scalar());

if (flags.HasFlag(FloodFillFlags.MaskOnly))
{
flags |= (FloodFillFlags)(255 << 8);
}

NativeMethods.HandleException(
NativeMethods.imgproc_floodFill2(
image.CvPtr, mask.CvPtr, seedPoint,
Expand Down

0 comments on commit cf9c448

Please sign in to comment.