Step one was to get the maatraa clipping code into Tesseract, which has happened. We still have the following issues to resolve before we can have excellent recognition rates:
We need to split the following glyphs into separate consonant and vowel signs.
1) Consonant + descending vowel sign
Example:
2) Consonant + ascending vowel sign
Example:
In summary we need to be able to do the following transformation before sending the image to Tesseract:
FROM
TO
Sunday, April 10, 2011
Monday, April 4, 2011
Horizontal histogram profiles of consonants with descending vowel signs
#!/usr/bin/python
#-*- coding:utf8 -*-
import Image,ImageDraw
import sys, os
def horizontalHistogram (input_image, image_name):
width = input_image.size[0]
height = input_image.size[1]
print "Width = %d and height = %d" %(width,height)
histoGram = []
for i in range (height):
blackPixelCount = 0
for j in range (width):
pixel = input_image.getpixel ((j, i))
if (pixel == 0):
blackPixelCount += 1
histoGram.append (blackPixelCount)
print histoGram
histogramImage = Image.new("L",(width,height),255)
pen = ImageDraw.Draw(histogramImage)
y = 0
for count in histoGram:
pen.line((0, y) + (count, y), fill=128)
y += 1
cumulativeImage = Image.new("L",(width * 2, height),255)
cumulativeImage.paste (input_image, (0, 0, width, height))
cumulativeImage.paste (histogramImage, (width, 0, width*2, height))
cumulativeImage.save(image_name+"_"+".png","PNG")
def verticalHistogram ():
pass
path = "/home/debayan/code/lower_descender_images/"
dirName = os.listdir (path)
for image_name in dirName:
input_image = Image.open(path + image_name)
horizontalHistogram (input_image, image_name)
The piece of code above takes a set of images (consonant + vowel) in the folder /home/debayan/code/lower_descender_images/ generated by http://code.google.com/p/tesseractindic/source/browse/trunk/tesseract_trainer/generate.py and generates tiny images with horizontal histogram profiles. The generated set can be found at https://picasaweb.google.com/debayanin/OCRStuff .
Observing the set thus generated can give us insights as to where the descender vowel sign begins. If we know this, we can separate the consonant and vowel sign. One general observation in this case is that the point where the vowel sign begins causes a local minima in the histogram profile.
Here are some examples. Note the red horizontal lines which mark the minima in the histogram:
These are the exceptions:
Subscribe to:
Posts (Atom)