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


  • $\begingroup$ 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)? $\endgroup$
    – endolith
    Aug 21, 2015 at 20:38
  • 1
    $\begingroup$ @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. $\endgroup$
    – slackbot
    Aug 24, 2015 at 6:05
  • 1
    $\begingroup$ 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? $\endgroup$
    – Moti
    Aug 25, 2015 at 4:37
  • 1
    $\begingroup$ 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? $\endgroup$
    – Moti
    Aug 25, 2015 at 5:07
  • 1
    $\begingroup$ @endolith Thanks. I'll look into it. Much appreciated. $\endgroup$
    – slackbot
    Sep 3, 2015 at 5:52

1 Answer 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.