MATLAB: Break an image file into multiple image files in matlab

image processingImage Processing Toolboxocr

I need to process a source file(in .jpg). It contains a paragraph of text. I want to separate each line and produce it into separate files.
for eg I have an image file which contains:
Chicken Sandwich
Heavy Motor
Sign Language
I want to create 3 files. Each should contain one line. I want to break the file w.r.t the line spacing. How should I proceed ?

Best Answer

Try collapsing the image horizontally:
verticalProfile = sum(grayImage, 2);
then look for bright and dark regions that indicate where the lines of text start and stop.