net.sourceforge.javaocr.ocrPlugins.mseOCR
Class TrainingImage

java.lang.Object
  extended by net.sourceforge.javaocr.scanner.PixelImage
      extended by net.sourceforge.javaocr.ocrPlugins.mseOCR.TrainingImage

public class TrainingImage
extends PixelImage

Class to hold a training image for a single character. A training image is a representative image for a single character, and is used to determine the likelihood that a given character image is a particular character.

Author:
Ronald B. Cemer

Field Summary
static float ASPECT_RATIO_TOLERANCE
          This is the maximum variance of aspect ratio between a training image and the actual image segment to be decoded.
static float BOTTOM_WHITE_SPACE_FRACTION_TOLERANCE
          This is the maximum variance between the source character's bottom white space fraction and the training image's bottom white space fraction.
 float bottomWhiteSpaceFraction
          Fraction of the row arrayHeight which is occupied by complete whitespace below the character.
private static Logger LOG
           
private  int myMaxX
           
private  int myMaxY
           
static float TOP_WHITE_SPACE_FRACTION_TOLERANCE
          This is the maximum variance between the source character's top white space fraction and the training image's top white space fraction.
 float topWhiteSpaceFraction
          Fraction of the row arrayHeight which is occupied by complete whitespace above the character.
 
Fields inherited from class net.sourceforge.javaocr.scanner.PixelImage
aspectRatio, FILTER_FIR_COEFFS, height, npix, pixels, width
 
Constructor Summary
TrainingImage(int[] pixels, int width, int height, int topWhiteSpacePixels, int bottomWhiteSpacePixels)
          Construct a new TrainingImage object from an array of gray scale pixels.
 
Method Summary
 double calcMSE(int[] theirPixels, int w, int h, int x1, int y1, int x2, int y2)
          Calculate the error factor between a block of pixels and our image.
 
Methods inherited from class net.sourceforge.javaocr.scanner.PixelImage
filter, filter, getPixel, getPixelIndex, grayScaleToRGB, rgbToImage, toGrayScale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASPECT_RATIO_TOLERANCE

public static final float ASPECT_RATIO_TOLERANCE
This is the maximum variance of aspect ratio between a training image and the actual image segment to be decoded. It is expressed as a fraction of the calculated aspect ratios. Any training image which varies by more than this fraction from the aspect ratio of the character to be decoded, is not used to decode that character.

See Also:
Constant Field Values

TOP_WHITE_SPACE_FRACTION_TOLERANCE

public static final float TOP_WHITE_SPACE_FRACTION_TOLERANCE
This is the maximum variance between the source character's top white space fraction and the training image's top white space fraction. Any training image which varies from the source character by more than this tolerance, will not be considered a candidate.

See Also:
Constant Field Values

BOTTOM_WHITE_SPACE_FRACTION_TOLERANCE

public static final float BOTTOM_WHITE_SPACE_FRACTION_TOLERANCE
This is the maximum variance between the source character's bottom white space fraction and the training image's bottom white space fraction. Any training image which varies from the source character by more than this tolerance, will not be considered a candidate.

See Also:
Constant Field Values

topWhiteSpaceFraction

public final float topWhiteSpaceFraction
Fraction of the row arrayHeight which is occupied by complete whitespace above the character.


bottomWhiteSpaceFraction

public final float bottomWhiteSpaceFraction
Fraction of the row arrayHeight which is occupied by complete whitespace below the character.


myMaxX

private int myMaxX

myMaxY

private int myMaxY

LOG

private static final Logger LOG
Constructor Detail

TrainingImage

public TrainingImage(int[] pixels,
                     int width,
                     int height,
                     int topWhiteSpacePixels,
                     int bottomWhiteSpacePixels)
Construct a new TrainingImage object from an array of gray scale pixels.

Parameters:
pixels - An array of pixels in the range 0-255.
width - The arrayWidth of the image.
height - The arrayHeight of the image.
topWhiteSpacePixels - The number of scan lines at the top of this character cell which are all white. These are excluded from the arrayWidth and arrayHeight of the training image.
bottomWhiteSpacePixels - The number of scan lines at the bottom of this character cell which are all white. These are excluded from the arrayWidth and arrayHeight of the training image.
Method Detail

calcMSE

public double calcMSE(int[] theirPixels,
                      int w,
                      int h,
                      int x1,
                      int y1,
                      int x2,
                      int y2)
Calculate the error factor between a block of pixels and our image.

Parameters:
theirPixels - An array of grayscale pixels which contains the block to be compared This should be in binary format, with each pixel having a value of either 0 or 255.
w - The arrayWidth of the pixel array.
h - The arrayHeight of the pixel array.
x1 - The position of the left border of the rectangle to be compared.
y1 - The position of the top border of the rectangle to be compared.
x2 - The position of the right border of the rectangle to be compared. Note that pixels up to, but not including this position, will be compared.
y2 - The position of the bottom border of the rectangle to be compared. Note that pixels up to, but not including this position, will be compared.
Returns:
A double representing the average per-pixel mean square error. Lower numbers indicate a better match.


Copyright © -2012. All Rights Reserved.