/// <summary> /// Fills a connected component with the given color. /// Input/output 1- or 3-channel, 8-bit, or floating-point image. /// It is modified by the function unless the FLOODFILL_MASK_ONLY flag is set in the /// second variant of the function. See the details below. /// </summary> /// <param name="mask">(For the second function only) Operation mask that should be a single-channel 8-bit image, /// 2 pixels wider and 2 pixels taller. The function uses and updates the mask, so you take responsibility of /// initializing the mask content. Flood-filling cannot go across non-zero pixels in the mask. For example, /// an edge detector output can be used as a mask to stop filling at edges. It is possible to use the same mask /// in multiple calls to the function to make sure the filled area does not overlap.</param> /// <param name="seedPoint">Starting point.</param> /// <param name="newVal">New value of the repainted domain pixels.</param> /// <param name="rect">Optional output parameter set by the function to the /// minimum bounding rectangle of the repainted domain.</param> /// <param name="loDiff">Maximal lower brightness/color difference between the currently /// observed pixel and one of its neighbors belonging to the component, or a seed pixel /// being added to the component.</param> /// <param name="upDiff">Maximal upper brightness/color difference between the currently /// observed pixel and one of its neighbors belonging to the component, or a seed pixel /// 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> /// <returns></returns> public int FloodFill(InputOutputArray mask, Point seedPoint, Scalar newVal, out Rect rect, Scalar? loDiff = null, Scalar? upDiff = null, FloodFillFlag flags = FloodFillFlag.Link4) { return Cv2.FloodFill(this, mask, seedPoint, newVal, out rect, loDiff, upDiff, flags); }
/// <summary> /// 連結成分を指定した色で塗りつぶす /// </summary> /// <param name="image">入力画像.1チャンネルあるいは3チャンネル,8ビットあるいは浮動小数点型.CV_FLOODFILL_MASK_ONLYフラグがセットされたとき以外は,データが書き換えられる.</param> /// <param name="seedPoint">連結成分の開始点.シードピクセル. </param> /// <param name="newVal">塗りつぶされる領域の新しいピクセル値(塗りつぶす値).</param> /// <param name="loDiff">現在の観測対象ピクセルと,その連結成分に属する隣接ピクセル, またはそのピクセルを連結成分に追加するためのシードピクセルとの,輝度値/色の差(違い)の許容下限値. 8ビットカラー画像のときは,パックされた値. </param> /// <param name="upDiff">現在の観測対象ピクセルと,その連結成分に属する隣接ピクセル, またはそのピクセルを連結成分に追加するためのシードピクセルとの,輝度値/色の差(違い)の許容上限値. 8ビットカラー画像のときは,パックされた値. </param> /// <param name="comp">構造体へのポインタ.この関数は,塗りつぶされた領域の情報を構造体に代入する. </param> /// <param name="flags">操作フラグ.下位ビットは関数内で用いられる連結性に関する値4(デフォルト)または8が入っている. /// 連結性は,どのピクセルを隣接ピクセルと見なすかを定義する.上位ビットは0,あるいはCv.FLOODFILL_FIXED_RANGE, Cv.FLOODFILL_MASK_ONLY との組み合わせである.</param> /// <param name="mask">処理用マスク</param> #else /// <summary> /// Fills a connected component with given color. /// </summary> /// <param name="image">Input 1- or 3-channel, 8-bit or floating-point image. It is modified by the function unless CV_FLOODFILL_MASK_ONLY flag is set. </param> /// <param name="seedPoint">The starting point. </param> /// <param name="newVal">New value of repainted domain pixels. </param> /// <param name="loDiff">Maximal lower brightness/color difference between the currently observed pixel and one of its neighbor belong to the component or seed pixel to add the pixel to component. In case of 8-bit color images it is packed value. </param> /// <param name="upDiff">Maximal upper brightness/color difference between the currently observed pixel and one of its neighbor belong to the component or seed pixel to add the pixel to component. In case of 8-bit color images it is packed value. </param> /// <param name="comp">Pointer to structure the function fills with the information about the repainted domain. </param> /// <param name="flags">The operation flags. Lower bits contain connectivity value, 4 (by default) or 8, used within the function. Connectivity determines which neighbors of a pixel are considered. Upper bits can be 0 or combination of the flags</param> /// <param name="mask">Operation mask</param> #endif public static void FloodFill(CvArr image, CvPoint seedPoint, CvScalar newVal, CvScalar loDiff, CvScalar upDiff, out CvConnectedComp comp, FloodFillFlag flags, CvArr mask) { if (image == null) { throw new ArgumentNullException("image"); } IntPtr maskPtr = (mask == null) ? IntPtr.Zero : mask.CvPtr; comp = new CvConnectedComp(); NativeMethods.cvFloodFill(image.CvPtr, seedPoint, newVal, loDiff, upDiff, comp.CvPtr, (int)flags, maskPtr); }
/// <summary> /// Fills a connected component with the given color. /// </summary> /// <param name="image">Input/output 1- or 3-channel, 8-bit, or floating-point image. /// It is modified by the function unless the FLOODFILL_MASK_ONLY flag is set in the /// second variant of the function. See the details below.</param> /// <param name="mask">(For the second function only) Operation mask that should be a single-channel 8-bit image, /// 2 pixels wider and 2 pixels taller. The function uses and updates the mask, so you take responsibility of /// initializing the mask content. Flood-filling cannot go across non-zero pixels in the mask. For example, /// an edge detector output can be used as a mask to stop filling at edges. It is possible to use the same mask /// in multiple calls to the function to make sure the filled area does not overlap.</param> /// <param name="seedPoint">Starting point.</param> /// <param name="newVal">New value of the repainted domain pixels.</param> /// <param name="rect">Optional output parameter set by the function to the /// minimum bounding rectangle of the repainted domain.</param> /// <param name="loDiff">Maximal lower brightness/color difference between the currently /// observed pixel and one of its neighbors belonging to the component, or a seed pixel /// being added to the component.</param> /// <param name="upDiff">Maximal upper brightness/color difference between the currently /// observed pixel and one of its neighbors belonging to the component, or a seed pixel /// 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> /// <returns></returns> public static int FloodFill(InputOutputArray image, InputOutputArray mask, Point seedPoint, Scalar newVal, out Rect rect, Scalar? loDiff = null, Scalar? upDiff = null, FloodFillFlag flags = FloodFillFlag.Link4) { if (image == null) throw new ArgumentNullException("image"); if (mask == null) throw new ArgumentNullException("mask"); image.ThrowIfNotReady(); mask.ThrowIfNotReady(); Scalar loDiff0 = loDiff.GetValueOrDefault(new Scalar()); Scalar upDiff0 = upDiff.GetValueOrDefault(new Scalar()); CvRect rect0; int ret = NativeMethods.imgproc_floodFill(image.CvPtr, mask.CvPtr, seedPoint, newVal, out rect0, loDiff0, upDiff0, (int)flags); rect = rect0; image.Fix(); mask.Fix(); return ret; }
/// <summary> /// 連結成分を指定した色で塗りつぶす /// </summary> /// <param name="image">入力画像.1チャンネルあるいは3チャンネル,8ビットあるいは浮動小数点型.CV_FLOODFILL_MASK_ONLYフラグがセットされたとき以外は,データが書き換えられる.</param> /// <param name="seedPoint">連結成分の開始点.シードピクセル. </param> /// <param name="newVal">塗りつぶされる領域の新しいピクセル値(塗りつぶす値).</param> /// <param name="loDiff">現在の観測対象ピクセルと,その連結成分に属する隣接ピクセル, またはそのピクセルを連結成分に追加するためのシードピクセルとの,輝度値/色の差(違い)の許容下限値. 8ビットカラー画像のときは,パックされた値. </param> /// <param name="upDiff">現在の観測対象ピクセルと,その連結成分に属する隣接ピクセル, またはそのピクセルを連結成分に追加するためのシードピクセルとの,輝度値/色の差(違い)の許容上限値. 8ビットカラー画像のときは,パックされた値. </param> /// <param name="comp">構造体へのポインタ.この関数は,塗りつぶされた領域の情報を構造体に代入する. </param> /// <param name="flags">操作フラグ.下位ビットは関数内で用いられる連結性に関する値4(デフォルト)または8が入っている. /// 連結性は,どのピクセルを隣接ピクセルと見なすかを定義する.上位ビットは0,あるいはCv.FLOODFILL_FIXED_RANGE, Cv.FLOODFILL_MASK_ONLY との組み合わせである.</param> #else /// <summary> /// Fills a connected component with given color. /// </summary> /// <param name="image">Input 1- or 3-channel, 8-bit or floating-point image. It is modified by the function unless CV_FLOODFILL_MASK_ONLY flag is set. </param> /// <param name="seedPoint">The starting point. </param> /// <param name="newVal">New value of repainted domain pixels. </param> /// <param name="loDiff">Maximal lower brightness/color difference between the currently observed pixel and one of its neighbor belong to the component or seed pixel to add the pixel to component. In case of 8-bit color images it is packed value. </param> /// <param name="upDiff">Maximal upper brightness/color difference between the currently observed pixel and one of its neighbor belong to the component or seed pixel to add the pixel to component. In case of 8-bit color images it is packed value. </param> /// <param name="comp">Pointer to structure the function fills with the information about the repainted domain. </param> /// <param name="flags">The operation flags. Lower bits contain connectivity value, 4 (by default) or 8, used within the function. Connectivity determines which neighbors of a pixel are considered. Upper bits can be 0 or combination of the flags</param> #endif public static void FloodFill(CvArr image, CvPoint seedPoint, CvScalar newVal, CvScalar loDiff, CvScalar upDiff, out CvConnectedComp comp, FloodFillFlag flags) { FloodFill(image, seedPoint, newVal, loDiff, upDiff, out comp, flags, null); }