Sunday, April 10, 2011

What next?

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


2) Consonant + ascending vowel sign


In summary we need to be able to do the following transformation before sending the image to Tesseract:


Monday, April 4, 2011

Horizontal histogram profiles of consonants with descending vowel signs

#-*- 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 ="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 ="L",(width * 2, height),255)
cumulativeImage.paste (input_image, (0, 0, width, height))
cumulativeImage.paste (histogramImage, (width, 0, width*2, height))"_"+".png","PNG")
def verticalHistogram ():
path = "/home/debayan/code/lower_descender_images/"
dirName = os.listdir (path)
for image_name in dirName:
input_image = + 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 and generates tiny images with horizontal histogram profiles. The generated set can be found at .
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:

Tthri in Bengali

Mu in Bengali

These are the exceptions:

Chhu in Bengali

Du in Bengali

With some fonts the above glyph might now show a local minima in the histogram

Jri in Bengali

Hri in Bengali

Hu in Bengali

Gu in Bengali