# Segmentation of warped text lines

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:

• 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. – Marcus Müller Dec 18 '16 at 23:29
• Too hard for me (as I am a newbie coder). If anyone is willing to give it a go, it would be greatly appreciated! – John Dec 19 '16 at 3:10
• 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. – 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:

http://www.pyimagesearch.com/2014/09/01/build-kick-ass-mobile-document-scanner-just-5-minutes/

https://mzucker.github.io/2016/08/15/page-dewarping.html

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)