Message Boards Message Boards

0
|
3557 Views
|
6 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Character Recognition

Posted 9 years ago

Dear all, Currently I am working on character recognition in a natural scene image. As it is an academic project, so following assumptions are fixed for an input image.

1- Font Family & size is fixed.

2- Only color can vary.

While the characters are embedded inside of some random natural image. So we need to localize characters in an image first followed by its recognition. I was planning to use co-relation between the template and test image but it works fine only for binary images. For an RGB image i did segmentation but after that co-relation is not working. So please can any one share a simple mechanism to implement this project?

Regards

POSTED BY: Muhammad Khizar
6 Replies

Hi Henrik, Thanks for your feedback. I will give it a try.

Regards

POSTED BY: Muhammad Khizar

Hello Muhammad,

from your post I could not find out whether the characters have a fixed specific color or not. If they do have a specific color, then a solution might be (let img be your original image):

red = {.93, .1, .15};
letterImg = ImageApply[If[EuclideanDistance[#, red] < .2, 0, 1] &, img]

giving: enter image description here

which can be treated with TextRecognize. If one uses the documentation the result is frustrating: It simply does not work! Only when choosing a non-documented (!) option, things appear to work a bit:

enter image description here

I myself learned about this valuable option (and more) from another interesting post of Marco Thiel (thanks Marco!). I do not understand why those details are undocumented. (In case it is documented meanwhile (v10.3.1), then just ignore my last remark.)

Regards -- Henrik

POSTED BY: Henrik Schachner

Hello Henrik,

Thanks for your response. I already did segmentation based on character color but the issue is color is not fixed. So right now I don't know which characteristics shall i use for alphabet segmentation. If you know other method kindly share it.

Regards

POSTED BY: Muhammad Khizar

Hello Muhammad,

I am afraid I did not read you first post careful enough, sorry! OK, here comes another try:

Let img be your original image, then I construct and apply a sort of an "edge mask":

img1 = ColorQuantize[img, 15];
edgeMask = ColorNegate@Dilation[EdgeDetect[img1], 2];
img2 = ImageMultiply[img1, edgeMask]

which gives:

enter image description here

Having done this preparation we can convince ourself that MorphologicalComponents does the trick:

(mc = MorphologicalComponents[img2]) // Colorize

enter image description here

This results in more than 1000 components, which are represented in their own part of the image (using automated crop). Since the font size is fixed, one can have a rough idea about the expected size of those images which contain letters:

{min, max} = MinMax[mc]
(* Out:  {0, 1029} *)

levelImages = ParallelTable[{n, i = Function[{level}, ImageCrop@Image@Map[If[# == level, 0, 1] &, mc, {2}]][n], 
    ImageDimensions[i]}, {n, min, max}];

letterCandidats = Select[levelImages, With[{xdim = #[[3, 1]], ydim = #[[3, 2]]}, (40 < xdim < 70) && (40 < ydim < 70)] &];

{#1, #2, TextRecognize[#2, "SegmentationMode" -> 6]} & @@@ letterCandidats

The result then looks like:

enter image description here

Maybe this might be a way for an approach . Regards -- Henrik

POSTED BY: Henrik Schachner

Target Image

This is the image, what I want to do is to extract letters from this image followed by recognition. Well code is simple correlation between a template image (containing a letter to detect) and test image (containing all alphabets -- binary image). So for binary version this approach is perfectly working but as soon as I implement same strategy to this image it doesn't work. So kindly share your thoughts on it, is there any other better way to do it. I want to keep things simple as i have to implement it in java without using any external lib.

POSTED BY: Muhammad Khizar

You should post sample images and some initial CODE that you wrote.

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract