How do you segment the image horizontally?

2 views (last 30 days)
Hi guys... I have an image containing a handwritten sentence of four lines... i want to segment the image into 4 segmented parts horizontally, such that each segmented part contain each of the four line... can any one help???... any help is highly appreciated!!!
PS: the image to be segmented is binary image with black background and white handwritten characters on it

Accepted Answer

Image Analyst
Image Analyst on 24 Jun 2015
You could try summing the image horizontally:
verticalProfile = sum(binaryImage, 2);
then look for bright and non-bright rows. Or you could use a long horizontal structuring element and do a morphological closing with imclose() and then look for the big blobs.
I'm sure there are published algorithms that are much better that you can find here: http://www.visionbib.com/bibliography/contentschar.html#OCR,%20Document%20Analysis%20and%20Character%20Recognition%20Systems
  26 Comments
Meghashree G
Meghashree G on 25 Jan 2016
Hello sir,i have many similar forms like this.But segmentation of lines is not correctly achieved .How to modify the code??Please help me with this.
Walter Roberson
Walter Roberson on 25 Jan 2016
As Image Analyst already replied,
"Otherwise, look at the link I gave to the papers of people who study this as their main career. I don't do OCR and I'm sure my algorithms just off the top of my head are not as successful as those from someone whose full time job OCR is. Please see their published papers if you want something better."
OCR is not just a trick that you get the hang of, not just a matter of fixing off-by-one errors in indexing, not just a matter of knowing the right threshold to use. OCR takes a lot of work. There are a lot of different techniques with different strengths and weaknesses. You can find several hundred books and proceedings on Amazon.com on the topic. There are a number of different conferences on the topic. You can find over one million articles about optical character recognition on scholar.google.com . It is a hard topic to do well.
Image Analyst does not have time to read and understand all of those on your behalf. And I know that I have no interest in reading and understanding those on your behalf. Very few of the regular volunteers have expressed interest in OCR. When we need OCR, we use someone else's program instead of trying to design our own. For example we might call http://www.mathworks.com/help/vision/ref/ocr.html
Your situation has exceeded our available resources, so is time for you to start doing your research.

Sign in to comment.

More Answers (1)

Meghashree G
Meghashree G on 6 Apr 2016
Hello sir, i used your code for line segmentation ,but for the below form its not working!! what changes should i make in order to correctly achieve line segmentation ? i have attached your code also.
Please help me..thank you
  5 Comments
Meghashree G
Meghashree G on 8 Apr 2016
Thank you very very much sir :) it worked :)
Divya
Divya on 17 Jan 2017
Hi Image Analyst,
your code says,
??? Undefined function or method 'histogram' for input arguments of type 'uint8'.
What modifications need to be done??

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!