projects
/
3501
/
OpenCVShowImage
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7a245e8
)
remove unnecessary methods to display image
author
EvanYap
<evanyap.14@gmail.com>
Tue, 18 Oct 2016 02:37:04 +0000
(19:37 -0700)
committer
EvanYap
<evanyap.14@gmail.com>
Tue, 18 Oct 2016 02:37:04 +0000
(19:37 -0700)
IsolateImage.java
patch
|
blob
|
blame
|
history
diff --git
a/IsolateImage.java
b/IsolateImage.java
index 0ee66c3ba9bdc752c9d7f80ac1675d2bc3ffc1ab..d9de95edfb609567c40f9f548c1e70e0917e911d 100644
(file)
--- a/
IsolateImage.java
+++ b/
IsolateImage.java
@@
-1,11
+1,5
@@
-import java.awt.Graphics;
import java.awt.Panel;
import java.awt.image.BufferedImage;
import java.awt.Panel;
import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.net.URL;
-
-import javax.imageio.ImageIO;
-import javax.swing.JFrame;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Core;
import org.opencv.core.Mat;
@@
-13,7
+7,8
@@
import org.opencv.core.Scalar;
import org.opencv.imgcodecs.Imgcodecs;
public class IsolateImage extends Panel {
import org.opencv.imgcodecs.Imgcodecs;
public class IsolateImage extends Panel {
- BufferedImage image;
+ BufferedImage filteredImage;
+ BufferedImage origImage;
public static Mat matOriginal;
public static Mat filtered;
public static Mat matOriginal;
public static Mat filtered;
@@
-26,31
+21,7
@@
public class IsolateImage extends Panel {
}
public IsolateImage() {
}
public IsolateImage() {
- try {
- // image file
- // name is
- // testpicture.png
- URL input = this.getClass().getResource(("imgs/testpicture.png"));
- // this will read the image to save
- // into a BufferedImage variable
- image = ImageIO.read(input);
- } catch (IOException ie) {
- // this is to spill
- // out a message
- // saying
- // something
- // doesn't work
- System.out.println("Error: " + ie.getMessage());
- }
- }
- public void paint(Graphics g) {
- // This is to actually draw the image out,
- // necessary.
-
- // Input of a bufferedimage, x, y, then
- // an observer in this case null.
- g.drawImage(image, 0, 0, null);
}
public static void main(String args[]) throws Exception {
}
public static void main(String args[]) throws Exception {
@@
-58,26
+29,16
@@
public class IsolateImage extends Panel {
matOriginal = new Mat();
filtered = new Mat();
matOriginal = new Mat();
filtered = new Mat();
- // Creates a window to
- // display the image
- JFrame frame = new JFrame("Display image");
-
- // Gets the image from ShowImage() method
- Panel panel = new IsolateImage();
-
- // Adds the image to the new window
- // panel
- frame.getContentPane().add(panel);
-
- // sets the size of the panel
- frame.setSize(500, 500);
- // makes it visible
- frame.setVisible(true);
+ processImage();
}
public static void processImage() {
matOriginal = Imgcodecs.imread("imgs/testpicture.png"); // convert image
// into matrix
}
public static void processImage() {
matOriginal = Imgcodecs.imread("imgs/testpicture.png"); // convert image
// into matrix
+ Core.inRange(matOriginal, LOWER_BOUNDS, UPPER_BOUNDS, filtered);
+
+ Imgcodecs.imwrite("output.png", filtered);
+
}
}
}
}