
During the 80/90 the IT society was inundated and buried by a sudden Tsunami which was triggered and caused by Apple and Co. It was the WYSIWYG. What is it? It stands for What You See Is What You Get, Or in today's parlance: the ICONS. The icons were brand-new for that time when people had to struggle with cryptic texts and weird menus. They, the icons, were the "ground-breaking" revolution of that time of the IT text-oriented world. A world of boffins and eggheads. A computer without graphical icons -regardless of what kind of computer- is today practically unsellable. Could you imagine that your iPhone or Android smartphone were driven by only "texts" and "menus" ? Even an ancient Chinese man with the name Confucius had to admit that a picture was better to memorize than a narrative.
I am not a revolutionary, nor a dictator in order to shuffle the IT society like Steve Jobs with his WYSIWYG. But what I want to show is a little wave ITOC-ICAW (If The Other Can - I Can As Well). What is OCR really? Instead of trying to explain OCR to you I took the freedom to cite a text from Wikipedia:
Optical character recognition
More HERE. In short: getting a corrigible text out of an image.or optical character reader (OCR) is the electronic or mechanical conversion of images of typed, handwritten or printed text into machine-encoded text, whether from a scanned document, a photo of a document, a scene-photo (for example the text on signs and billboards in a landscape photo) or from subtitle text superimposed on an image
And like Master Confucius said that if he did it he would understand it. So, I show you the way how to implement an OCR in JAVA and let you try to implement it so that you remember and understand OCR. I have showed you how to process Images and Pixels in JAVA and mentioned about the OCR in relationship with the Fonts. Let refresh our memory:
Java:
public static BufferedImage createFontImage(String string, String fontName, int fontAtt, int size) {
// create a BufferImage with width = 1 and height = 1
BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = image.createGraphics();
// create a font with the given fontName (e.g. TimesRoman), attribute (e.g. Font.BOLD) and size (e.g. 15)
Font font = new Font(fontName, fontAtt, size);
// convert to FontMetrics
FontMetrics metrics = g.getFontMetrics(font);
int height = metrics.getHeight();
int width = metrics.stringWidth(string);
// create an image with this width and height
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
// draw or write the given letter (or String) in BLACK with the background WHITE
g = image.createGraphics();
g.setFont(font);
g.setColor(Color.WHITE);
g.fillRect(0, 0, width, height);
g.setColor(Color.BLACK);
g.drawString(string, 0, height);
//
// eliminate the "void"
//
int y = 0;
int white = Color.WHITE.getRGB();
LOOP: for (; y < height; ++y)
for (int x = 0; x < width; ++x)
if (image.getRGB(x, y) != white) {
if (y == 0) return image; // no need to rectify
break LOOP;
}
int H = height - y;
int[] pixels = image.getRGB(0, y, width, H, null, 0, width);
BufferedImage img = new BufferedImage(width, H, BufferedImage.TYPE_INT_ARGB);
img.setRGB(0, 0, width, H, pixels, 0, width);
return img;
}

The Image is based on black pixels that are on a white background. Hard to recognize the "special features" as we know about Facial Recognition, for example, like this:

(source: click HERE)
As you see, there is an algorithm that leads you to the right direction. Not so complicated like Optical Face Recognition, OCR is simpler if you know how and where to start with. As I have showed you how the pixels of an image could be processed and altered. For example: to change the color of an image sentence from black to cyan

The problem of OCR from an image is the "ghosting" (or to be more precise: fogging) between the letters and the background. Modern cars (e.g. AUDI, BMW, Mercedes, etc.) allow their users to write a destination address on a little screen, or the cars can "recognize" the traffic signs. All that bases on a very distinctive segregation between the letters and the background environment (i.e. color). The little screen acts as a transparent background. Example: a traffic sign.

The OCR is here a lot easier to work with. To achieve the same result of Optical Face Recognition we need to create a similar and distinctive environment for the letters out of an image like the OCR of modern cars with their (preconditioned) environments.
- Focusing on the sentence to reduce the unnecessary scanning work and Removing the interfering colors by "Translucentifying" the background
- Isolating letter by letter
- "DOTifying" the letter
- Fixing the distinctive features (like Facial features)
Step 1
Focused on the Image

and extracted

Step 2: pick letter by letter

Step 3: dotifying the letter

Step 4: set the distinctive features:

Sửa lần cuối: