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
.Scalar
;
13 public class IsolateImage
extends Panel
{
16 public static final Scalar LOWER_BOUNDS
= new Scalar(103, 164, 169);
17 public static final Scalar UPPER_BOUNDS
= new Scalar(125, 229, 255);
20 System
.loadLibrary(Core
.NATIVE_LIBRARY_NAME
);
23 public IsolateImage() {
28 URL input
= this.getClass().getResource(("imgs/testpicture.png"));
29 // this will read the image to save
30 // into a BufferedImage variable
31 image
= ImageIO
.read(input
);
32 } catch (IOException ie
) {
38 System
.out
.println("Error: " + ie
.getMessage());
42 public void paint(Graphics g
) {
43 // This is to actually draw the image out,
46 // Input of a bufferedimage, x, y, then
47 // an observer in this case null.
48 g
.drawImage(image
, 0, 0, null);
51 public static void main(String args
[]) throws Exception
{
52 // Creates a window to
54 JFrame frame
= new JFrame("Display image");
56 // Gets the image from ShowImage() method
57 Panel panel
= new IsolateImage();
59 // Adds the image to the new window
61 frame
.getContentPane().add(panel
);
63 // sets the size of the panel
64 frame
.setSize(500, 500);
66 frame
.setVisible(true);