0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Desktop : OpenCV Flood Fill

Posted at
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)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?