2

Input Demo Image

The task I am facing is extraction of rotated text (any angle) from a scanned image(attached Image). The image contains a blue sticker on it and need means in extracting the text (printed text) from it. The pattern of the sticker will remain the same for all the time.

As you can see the orientation is not stable and i would be really grateful if anyone could suggest a manner in which i could extract the text.

Reference to the question can be found here, or the technique How to remove text region in a document image? or extract image from a document image

Thanks

slackbot
  • 21
  • 5
  • So you're extracting text from the sticker, not the document? It will always have the same shape, with text in the same relative position, rotated and shifted but not perspective distorted or skewed (image is from a flatbed scanner, not a camera)? – endolith Aug 21 '15 at 20:38
  • What are you interested in? taking out the blue areas? Rotate them? Identify their content? Is the content fix for all stickers? Do you want to straighten them in the scanned? Are the stickers covering other text? Are they embedded (as in the picture) in text? You are really not clear with what your task is. – Moti Aug 21 '15 at 22:08
  • @endolith Yes i am interested in extracting only the text from the sticker. It will always have same shape and size, the text on sticker will be always have same relative position, only thing which will differ is orientation of the sticker on the page.

    Yes, the image will be from a flatbed scanner and not a camera.

    – slackbot Aug 24 '15 at 06:00
  • 1
    @Moti Yes i am interested in extracting text from sticker only. The sticker is covering other text. Imagine something pasted on a printed document. Need to ocr/extract what's on the sticker. – slackbot Aug 24 '15 at 06:05
  • 1
    It seems the stickers are well defined - you straiten them and use an off the shelf OCR. What is it that you need to develop? Are the steps involved clear to you? Could you use open-source solutions? – Moti Aug 25 '15 at 04:37
  • @moti how do i straighten them, cos this is a sample document, the position of the sticker may vary from doc 2 doc. My ultimate goal is extraction of text from sticker, if i get that i am a happy man. yes i can use open source solutions, but matlab is preferred. – slackbot Aug 25 '15 at 04:41
  • 1
    Assuming the color as a differentiator, start with identifying a closed continuous area of same color. Identify the corners and apply a rotation algorithm to straighten a rectangle. What assumption may be made about the stickers? – Moti Aug 25 '15 at 05:07
  • @Moti is there a MATLAB code you could provide me with? The stickers are the same size and all have same pattern. The type of text font is always similar on it. – slackbot Aug 25 '15 at 06:14
  • Do you know how to identify a rectangle and the relative corners of the stickers on the image? – Moti Aug 25 '15 at 06:18
  • @Moti I dont think I do. I am fairly new to MATLAB. – slackbot Aug 25 '15 at 06:21
  • These are similar but the original images have been lost: http://dsp.stackexchange.com/q/2975/29 http://stackoverflow.com/q/1817442/125507 http://opencv-code.com/tutorials/detecting-simple-shapes-in-an-image/ – endolith Aug 30 '15 at 13:32
  • 1
    @endolith Thanks. I'll look into it. Much appreciated. – slackbot Sep 03 '15 at 05:52

1 Answers1

1

I think your workflow should be something like this:

1) Detect the rectangle.

2) Find the rectangle's orientation.

3) Rotate the rectangle and place it in a new image.

4) Feed the rectangle twice to an OCR (one time with the calculated orientation, and the other with the rectangle rotated 180 degrees, because you are not sure if it's oriented correctly).

5) Find which OCR output makes more sense.

6) Voila!

More Details:

1) Check this OpenCV tutorial to detect simple shapes (in your case the rectangle) http://opencv-code.com/tutorials/detecting-simple-shapes-in-an-image/

2) if you use the previous tutorial, you have the four edges of the rectangle. calculate the angle between the longest edge and the x-axis.

3) I don't know the level of your image processing skills, but rotating a rectangle's pixels and putting it in another image should be straight forward (I suggest using linear interpolation).

4) I don't have much experience in OCR, but according to many answers here on the exchange, I guess you can use an off-the-shelf OCR.

yasserhtd
  • 11
  • 2