package analyzer; /*Collect Statistics from an Image Add the Statistics to the Collection Database * * aevans 8/14/2013 */ import java.awt.Color; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import javax.imageio.ImageIO; import jdbc.Jdbcconn; public class Analyzer { private BufferedImage image; private ArrayList<BufferedImage> imageList; public Analyzer() { // TODO empty constructor imageList = new ArrayList<BufferedImage>(); } public Analyzer(byte[] inimage) { // TODO constructor from bytes ByteArrayInputStream bis = new ByteArrayInputStream(inimage); try { image = ImageIO.read(bis); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } imageList = new ArrayList<BufferedImage>(); } public Analyzer(BufferedImage bimage) { // TODO input buffered image image = bimage; imageList = new ArrayList<BufferedImage>(); } public void analyze_image() { // TODO control the pulling of key statistics getOffsets(); } private void getOffsets() { // TODO return an array list of offsets representing potential letters // then try to weed out non-letters int width = image.getWidth(); int height = image.getHeight(); for (int x = 1; x < width - 1; x++) { for (int y = 1; y < height - 1; y++) { System.out.println("\n"); System.out.print(new Color(image.getRGB(x, y)).getBlue()); System.out.print(" " + new Color(image.getRGB(x, y)).getRed()); System.out.print(" " + new Color(image.getRGB(x, y)).getGreen() + "\n"); } } // return list } private void getAverageCurvature(int x0, int x1, int y0, int y1) { // get the average curvature of a suspected letter // return the average curvature } private void getaverageSlope(int x0, int x1, int y0, int y1) { // TODO get the average slope of the suspected letter in a section // return the average slope } private void getskew(int x0, int x1, int y0, int y1) { // TODO deskew an image // get average angle based on furthest width vertically // get top horizontally // get bottom horizontally // get angle to bottom // verify with angle to the horizontal // return the skew angle } private void deskew() { // TODO deskew a found letter // return letter } private void sectionCheck(int x0, int x1, int y0, int y1) { // TODO check for sections of a suspected letter that limit the database // return the appropriate section } private void significantChunk(int x0, int x1, int y0, int y1) { // TODO check if offset represents a significant chunk // return boolean if significant chunk } private void isLetter(int x0, int x1, int y0, int y1) { // TODO check to ensure that significant chunk is a letter // return boolean of whether offsets represent letter } public BufferedImage getImage() { return image; } }