1 import java
.awt
.Graphics
;
3 import java
.awt
.image
.BufferedImage
;
4 import java
.io
.IOException
;
7 import javax
.imageio
.ImageIO
;
8 import javax
.swing
.JFrame
;
10 import org
.opencv
.core
.Core
;
11 import org
.opencv
.core
.Mat
;
12 import org
.opencv
.core
.Scalar
;
13 import org
.opencv
.imgcodecs
.Imgcodecs
;
15 public class IsolateImage
extends Panel
{
18 public static Mat matOriginal
;
19 public static Mat filtered
;
21 public static final Scalar LOWER_BOUNDS
= new Scalar(103, 164, 169);
22 public static final Scalar UPPER_BOUNDS
= new Scalar(125, 229, 255);
25 System
.loadLibrary(Core
.NATIVE_LIBRARY_NAME
);
28 public IsolateImage() {
33 URL input
= this.getClass().getResource(("imgs/testpicture.png"));
34 // this will read the image to save
35 // into a BufferedImage variable
36 image
= ImageIO
.read(input
);
37 } catch (IOException ie
) {
43 System
.out
.println("Error: " + ie
.getMessage());
47 public void paint(Graphics g
) {
48 // This is to actually draw the image out,
51 // Input of a bufferedimage, x, y, then
52 // an observer in this case null.
53 g
.drawImage(image
, 0, 0, null);
56 public static void main(String args
[]) throws Exception
{
58 matOriginal
= new Mat();
61 // Creates a window to
63 JFrame frame
= new JFrame("Display image");
65 // Gets the image from ShowImage() method
66 Panel panel
= new IsolateImage();
68 // Adds the image to the new window
70 frame
.getContentPane().add(panel
);
72 // sets the size of the panel
73 frame
.setSize(500, 500);
75 frame
.setVisible(true);
78 public static void processImage() {
79 matOriginal
= Imgcodecs
.imread("imgs/testpicture.png"); // convert image