Grepper Logo

How to detect multiple blocks of text from an image of a document?

1. First you need to convert the image into grayscale 

2. Perform otsu'threshold which does better binarization in removing the background. 

3. Specify structure shape and kernel size. Kernel size increases or decreases the area of the rectangle to be detected. 

4. Applying dilation on the threshold image with the kernel when you dilated it gets thicker. 

5. Finding contours Looping through the identified contours Then the rectangular part is can be drawn using cv2.rectangle method


Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.