Java text image recognition (1) [88250 original]__java
Source: Internet
Author: User
SummaryImage recognition is a very popular research field, involving a wide range of knowledge, including information theory, pattern recognition, fuzzy mathematics, Image coding, content classification and so on. This article only uses Java to implement a simple image text binary processing, on the recognition is not implemented.
StepsCreate a text character template two value matrixtwo-valued matrix processing of test charactersCode/*
* @ (#) Stdmodelrepository.java
*
* This are free software; You can redistribute it and/or modify
* It under the terms of the GNU general public License as published by
* the free Software Foundation; Either version 3 of the License, or
* (at your option) any later version.
*
* This are distributed in the hope that it'll be useful,
* but without any WARRANTY; Without even the implied warranty of
* merchantability or FITNESS for A particular purpose. The
* GNU Library general public License for more details.
* You should have received a copy of the GNU general public License
* Along with this program; If not, write to the free Software
* Foundation, Inc., Temple Place-suite, Boston, MA 02111-1307, USA.
*/
Package cn.edu.ynu.sei.recognition.util;
/*
* @ (#) Imageutils.java
*
* This are free software; You can redistribute it and/or modify
* It under the terms of the GNU general public License as published by
* the free Software Foundation; Either version 3 of the License, or
* (at your option) any later version.
*
* This are distributed in the hope that it'll be useful,
* but without any WARRANTY; Without even the implied warranty of
* merchantability or FITNESS for A particular purpose. The
* GNU Library general public License for more details.
* You should have received a copy of the GNU general public License
* Along with this program; If not, write to the free Software
* Foundation, Inc., Temple Place-suite, Boston, MA 02111-1307, USA.
*/
Package cn.edu.ynu.sei.recognition.util;
/**
* Mainipulation of image data.
* @author 88250
* @version 1.0.0.3, Mar 20, 2008
*/
public class Imageutils {
/**
* Return all of the pixel values of sepecified <code>image</code>.
* @param image The sepecified image
* @param width width of the <code>image</code>
* @param height of the <code>image</code>
* @return
*/
public static int [] Getpixels (image image, int width, int height) {
int [] pixels = new int [width * height];
try {
New PixelGrabber (image, 0, 0, width, height, pixels, 0, width). grabpixels ();
catch (Interruptedexception ex) {
Logger.getlogger (Imageutils. class. GetName ()).
Log (Level.severe, NULL, ex);
}
return pixels;
}
/**
* Get a matrix that described the <code>pixels</code>.
* <p>
* For example, the result is the matrix like this:
* <center>
* 0000000000000000<br>
* 0000000000000000<br>
* 0001111111110000<br>
* 0011111111111000<br>
* 0011111111111100<br>
* 0011000000011100<br>
* 0000000000011100<br>
* 0000111111111100<br>
* 0011111111111100<br>
* 0011111110011100<br>
* 0111100000011100<br>
* 0111100000011100<br>
* 0111100000111100<br>
* 0111100001111110<br>
* 0011111111111100<br>
* 0011111111111100<br>
* 0001111111111100<br>
* 0000000000000000<br>
* 0000000000000000<br>
* </center>
* It describes the Alphbet ' a '.
* </p>
* @param pixels the pixel array
* @param sparsefactor sparse factor
* @return A matrix that describes a Alphbet
*/
public static int [] Getsymbolmatrix (int [] pixels, int sparsefactor) {
Final int width = stdmodelrepository.width;
Final int height = stdmodelrepository.height;
int [] [] ret = new int [width][height];
for (int i = 0; i < height; i + +) {
for (int j = 0; J < width; j + +) {
if (pixels[i * width + j] = = 1) {
Ret[j][i] = 0;
} else {
Ret[j][i] = 1;
}
}
}
return ret;
}
/**
* Print the <code>matrix</code> under console.
* @param matrix the sepecified matrix data
*/
public static void Displaymatrix (int [] matrix) {
System.out.println ("");
for (int i = 0; I < matrix[0].length i + +) {
for (int j =
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.