OCRNeuralNetwork/src/com/conordevilly/ocr/imageprocessing/ImageProcessor.java
public static BufferedImage extractChar(BufferedImage input){
		ArrayList<Pixel> traverseList = new ArrayList<Pixel>();
		int minX = Integer.MAX_VALUE;
		int minY = Integer.MAX_VALUE;
		int maxX = Integer.MIN_VALUE;
		int maxY = Integer.MIN_VALUE;
		int height = 0;
		int width = 0;

		//Create a list of pixels. Also store the min & max pixels in the list
		for(int i = 0; i < input.getWidth(); i++){
			for(int j = 0; j < input.getHeight(); j++){
				//Check if there's a black pixel at i, j
				if(pixelAt(input, i, j)){
					
					//If there is, add it to the traverse list
					Pixel p = new Pixel(i, j);
					if(!traverseList.contains(p)){
						//Add the pixel to the list
						traverseList.add(p);
						
						//Check if the pixel is a min or max value
						minX = (p.x < minX) ? p.x : minX;
						minY = (p.y < minY) ? p.y : minY;
						maxX = (p.x > maxX) ? p.x : maxX;
						maxY = (p.y > maxY) ? p.y : maxY;
					}
				}
			}
		}
		
		width = maxX - minX;
		height = maxY - minY;
		
		//Return a sub image that contains the exact dimensions of the extracted character
		return input.getSubimage(minX, minY, width, height);
	}
//Extracts a character from an image
Extracts a character from an image
Extracts a character from an image
public static BufferedImage extractChar(BufferedImage input){
		ArrayList<Pixel> traverseList = new ArrayList<Pixel>();
		int minX = Integer.MAX_VALUE;
		int minY = Integer.MAX_VALUE;
		int maxX = Integer.MIN_VALUE;
		int maxY = Integer.MIN_VALUE;
		int height = 0;
		int width = 0;
		for(int i = 0; i < input.getWidth(); i++){
			for(int j = 0; j < input.getHeight(); j++){
				if(pixelAt(input, i, j)){
					Pixel p = new Pixel(i, j);
					if(!traverseList.contains(p)){
						traverseList.add(p);
						minX = (p.x < minX) ? p.x : minX;
						minY = (p.y < minY) ? p.y : minY;
						maxX = (p.x > maxX) ? p.x : maxX;
						maxY = (p.y > maxY) ? p.y : maxY;
					}
				}
			}
		}
		width = maxX - minX;
		height = maxY - minY;
		return input.getSubimage(minX, minY, width, height);
	}
public static BufferedImage extractChar ( BufferedImage input ) { ArrayList < Pixel > traverseList = new ArrayList < Pixel > ( ) ; int minX = Integer . MAX_VALUE ; int minY = Integer . MAX_VALUE ; int maxX = Integer . MIN_VALUE ; int maxY = Integer . MIN_VALUE ; int height = 0 ; int width = 0 ; for ( int i = 0 ; i < input . getWidth ( ) ; i ++ ) { for ( int j = 0 ; j < input . getHeight ( ) ; j ++ ) { if ( pixelAt ( input , i , j ) ) { Pixel p = new Pixel ( i , j ) ; if ( ! traverseList . contains ( p ) ) { traverseList . add ( p ) ; minX = ( p . x < minX ) ? p . x : minX ; minY = ( p . y < minY ) ? p . y : minY ; maxX = ( p . x > maxX ) ? p . x : maxX ; maxY = ( p . y > maxY ) ? p . y : maxY ; } } } } width = maxX - minX ; height = maxY - minY ; return input . getSubimage ( minX , minY , width , height ) ; }
Extracts a character from an image
Extracts a character from an image
//Create a list of pixels. Also store the min & max pixels in the list //Check if there's a black pixel at i, j //If there is, add it to the traverse list //Add the pixel to the list //Check if the pixel is a min or max value //Return a sub image that contains the exact dimensions of the extracted character