[JAVA] Desktop: OpenCV Flood Fill

Goal
Test OpenCV flood fill.

OpenCV_FloodFill.java


import org.opencv.core.*;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class OpenCV_FloodFill {

    public static void main(String[] args){
        try{
            System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
            Mat src = Imgcodecs.imread("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\test-floodFill.jpg ");
            System.out.println("Imgproc.FLOODFILL_FIXED_RANGE="+Imgproc.FLOODFILL_FIXED_RANGE);
            System.out.println("Imgproc.FLOODFILL_MASK_ONLY="+ Imgproc.FLOODFILL_MASK_ONLY);
            Point seedPoint = new Point(85,89);
            Mat mask = new Mat();
            Rect rect = new Rect();
            Imgproc.floodFill(src, mask, seedPoint, new Scalar(0,130,120), rect, new Scalar(20,20,20),new Scalar(20,20,20), 4);
            Imgcodecs.imwrite("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\test-floodFill_do.jpg ", src);


        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
Result
![test-floodFill_do.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/276243/44a6140d-0713-edb6-dd59-82033a901799.jpeg)

Recommended Posts

Desktop: OpenCV Flood Fill
Desktop: OpenCV Flood Fill For Fun
Desktop: OpenCV Fill Poly
Desktop: OpenCV BilateralFilterBlur
Desktop: OpenCV Dilate
Desktop: OpenCV Expand
Desktop: OpenCV Affine
Desktop: OpenCV Emboss
Desktop: OpenCV CLAHE
Desktop: OpenCV Ellipse2Poly
Desktop: OpenCV HDR
Desktop: OpenCV Polylines
Desktop: OpenCV Denoise
Desktop: OpenCV Sharpness
Desktop: OpenCV OpenCV_SalonUseBlurAddWeighted
Desktop: OpenCV Mosaic
Desktop: OpenCV Rectangle
Desktop: OpenCV Watershed
Desktop: OpenCV Text
Desktop: OpenCV Inpaint
Desktop: OpenCV NormalizeBlur
Desktop: OpenCV StereoSGBM
Desktop: OpenCV Spot
Desktop: OpenCV Canny
Desktop: OpenCV Denoise3
Desktop: OpenCV Histogram
Desktop: OpenCV Dft
Desktop: OpenCV Decolor
Desktop: OpenCV FaceDetector
Desktop: OpenCV Denoise2
Desktop: OpenCV StereoBM
Desktop: OpenCV Fill Poly With Mouse Control
Desktop: OpenCV Kirsch Filter
Desktop: OpenCV Laplacian Filter 2
Desktop: OpenCV Illumination Change
Desktop: OpenCV Add WaterMark
Desktop: OpenCV Sharpness Gui
Desktop: OpenCV Color Change
Desktop: OpenCV Freichennel Filter
Desktop: OpenCV Adaptive Threshold
Desktop: OpenCV Draw Circle
Desktop: OpenCV Mean Filter
Desktop: OpenCV Java Repository
Desktop: OpenCV Sobel Filter2
Desktop: OpenCV pyrMeanShift Filter
Desktop: OpenCV OpticalFlow PyrLK
Desktop: OpenCV Virtual Piano
Desktop: OpenCV merge Picture
Desktop: OpenCV Scharr Filter
Desktop: Opencv webcam preview
Desktop: OpenCV Laplacian Filter
Desktop: OpenCV Median Blur
Desktop: OpenCV Robinson Filter
Desktop: OpenCV record video
Desktop: OpenCV Texture Flatting
Desktop: OpenCV color space
Desktop: OpenCV SqrBox Filter
Desktop: OpenCV resize image
Desktop: OpenCV Pencil Sketch
Desktop: OpenCV Color Map
Desktop: OpenCV Seamless Clone