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