I am converting a large invoice image in to pieces line by line to get text using ocr. I am using sobel egde detection and it is working perfectly fine. I am cutting image where sum of edges = 0
EI = edge(im,'Sobel',([]),'Vertical');
histy = sum(EI,2);
Now, issue arises when the source image is not vertically at 90 degree. Images are scanned through scanner and orientation might not correct and given technique get fail. Below is a sample image which is failing as every row has edges. As, now row has zero edges as rows are not horizontally aligned. Below is the image that is causing problem.