5f573721adb0f593c4a64247e1f31a28e0480133
[3501/OpenCVShowImage] / IsolateImage.java
1 import org.opencv.core.Core;
2 import org.opencv.core.Mat;
3 import org.opencv.core.Scalar;
4 import org.opencv.imgcodecs.Imgcodecs;
5
6 public class IsolateImage {
7
8 public static Mat matOriginal;
9 public static Mat filtered;
10
11 public static final Scalar LOWER_BOUNDS = new Scalar(169, 164, 103);
12 public static final Scalar UPPER_BOUNDS = new Scalar(255, 229, 140);
13 // public static final Scalar LOWER_BOUNDS = new Scalar(255, 0, 0);
14 // public static final Scalar UPPER_BOUNDS = new Scalar(0, 255, 255);
15
16 static {
17 System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
18 }
19
20 public static void main(String args[]) throws Exception {
21
22 matOriginal = new Mat();
23 filtered = new Mat();
24
25 processImage();
26 }
27
28 public static void processImage() {
29 matOriginal = Imgcodecs.imread("imgs/testpicture.png"); // convert image
30 // into matrix
31
32 Core.inRange(matOriginal, LOWER_BOUNDS, UPPER_BOUNDS, filtered);
33
34 Imgcodecs.imwrite("output.png", filtered);
35
36 }
37 }