Skip to content

Commit

Permalink
Update comments and add method to CV Helper class
Browse files Browse the repository at this point in the history
  • Loading branch information
hirshagarwal committed Feb 15, 2018
1 parent 8574152 commit f92b3a0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
Binary file modified TheiaJava/bin/com/hirshagarwal/theia/Main/ImagePanel.class
Binary file not shown.
Binary file modified TheiaJava/bin/com/hirshagarwal/theia/Main/Main.class
Binary file not shown.
25 changes: 25 additions & 0 deletions TheiaJava/src/com/hirshagarwal/theia/Main/CVHelper.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.hirshagarwal.theia.Main;

import java.awt.FlowLayout;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.ByteArrayInputStream;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import org.opencv.core.CvType;
import org.opencv.core.Mat;
Expand Down Expand Up @@ -42,5 +46,26 @@ public BufferedImage matToBufferedImage(Mat inputImage) {
return new BufferedImage(0, 0, 0);
}
}

/**
* Use a JFrame to display a buffered image
* @param imageToShow
*/
public void showBufferedImage(BufferedImage imageToShow) {
JFrame f = new JFrame();
f.getContentPane().setLayout(new FlowLayout());
f.getContentPane().add(new JLabel(new ImageIcon(imageToShow.getScaledInstance(700, 500, 0))));
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

/***
* Pipelined operation for displaying an OpenCV matrix
* @param image
*/
public void showMat(Mat image) {
showBufferedImage(matToBufferedImage(image));
}

}
6 changes: 5 additions & 1 deletion TheiaJava/src/com/hirshagarwal/theia/Main/ImagePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
* @author Hirsh R. Agarwal
*
*/
@SuppressWarnings("serial")

public class ImagePanel extends JPanel{

/**
*
*/
private static final long serialVersionUID = -6534569916418284351L;
private Image image;

public void paintComponent(Graphics g){
Expand Down
4 changes: 4 additions & 0 deletions TheiaJava/src/com/hirshagarwal/theia/Main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ public static void clearExportTitles() {
Main.exportTitles.clear();
}

/**
* Clear all of the static data held in the Main class
* Useful for freeing memory and restarting the display class
*/
public static void clearData() {
Main.stacksToCrop.clear();
Main.exportDirectories.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public class ThresholdImageStack {

// Private Fields
private ImageStack rawImage;
private ImageStack thresholdImageStack;
private CVHelper cvHelper = new CVHelper();
Expand Down

0 comments on commit f92b3a0

Please sign in to comment.