MATLAB: How to find the margin in an image of the text document

counting pixelscursiveedge detectionhandwritingimage analysisimage processingImage Processing Toolboxocr

I have a sample of handwriting. And I want to find the left, right and top margin[i.e., the space between the starting of the writing and the edge of the paper to the left is the left margin]. Please help me with the code.

Best Answer

Did you try to threshold and then use regionprops(L, 'BoundingBox')?
If the shadows on the paper are a problem then call edge() first and then get the bounding box from the edge image.