I am trying to segment warped text lines found in photos taken from a page of a book (from the camera of a smartphone). This is meant as a preprocessing step before running OCR on them.

I have found two relevant papers on this:



I read the papers but they're too hard to implement, can anyone help?

Example input no.1:

Example input no.2:

  • $\begingroup$ What do you mean with "too hard to implement"? Explain what you're having problems with specifically; that will possibly make it possible for us to help. $\endgroup$ – Marcus Müller Dec 18 '16 at 23:29
  • $\begingroup$ Too hard for me (as I am a newbie coder). If anyone is willing to give it a go, it would be greatly appreciated! $\endgroup$ – John Dec 19 '16 at 3:10
  • $\begingroup$ Check out the section on running average binarization in Gonzalez and Woods, assumes your goal is to render the characters black on a white background as a preprocessing step. $\endgroup$ – Rethunk Jun 4 '17 at 13:07

Your question is very broad and I won't go read the papers and implement it for you. If you could show specific problems, we might help you better (or the guys at stackoverflow for programming questions).

Meanwhile, you can have a look at these two resources, which treat a similar problem, including some code:




Your images are quite nice and clean, so it may be possible to do segment the letters using a single function on MATLAB. In fact this is the kind of image which MATLAB uses as examples in its documentation for this function, imbinarize.

Try reading the image in and running this line of code
bin = ~imbinarize(im, 'adaptive', 'ForegroundPolarity', 'dark');
where im is the image matrix (converted to grayscale) and bin is your output binary image (~ inverts the image, making the letters white)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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