fb96b49b2888f8deea618cd4c935cd74ccac1680
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
;
14 public class IsolateImage
extends Panel
{
17 public static Mat matOriginal
;
19 public static final Scalar LOWER_BOUNDS
= new Scalar(103, 164, 169);
20 public static final Scalar UPPER_BOUNDS
= new Scalar(125, 229, 255);
23 System
.loadLibrary(Core
.NATIVE_LIBRARY_NAME
);
26 public IsolateImage() {
31 URL input
= this.getClass().getResource(("imgs/testpicture.png"));
32 // this will read the image to save
33 // into a BufferedImage variable
34 image
= ImageIO
.read(input
);
35 } catch (IOException ie
) {
41 System
.out
.println("Error: " + ie
.getMessage());
45 public void paint(Graphics g
) {
46 // This is to actually draw the image out,
49 // Input of a bufferedimage, x, y, then
50 // an observer in this case null.
51 g
.drawImage(image
, 0, 0, null);
54 public static void main(String args
[]) throws Exception
{
56 matOriginal
= new Mat();
58 // Creates a window to
60 JFrame frame
= new JFrame("Display image");
62 // Gets the image from ShowImage() method
63 Panel panel
= new IsolateImage();
65 // Adds the image to the new window
67 frame
.getContentPane().add(panel
);
69 // sets the size of the panel
70 frame
.setSize(500, 500);
72 frame
.setVisible(true);