I have to recognize the text of the hand-filled bank form. The form has a grid as shown in the image. I am new to Image Processing. I read few papers on handwriting recognition and did denoising, binarization as preprocessing tasks. I want to segment the image now and recognize the characters using a Neural Network. To segment the characters I want to get rid of the grid.
Removing grid from scanned image
Asked Answered
SO is not a coding site. Please show some work so that we can help you with making it better. –
Claudelle
@Claudelle I have tried using Denoising, Binarization and Edge detection on the image provided above. I am not understanding how to get rid of the grid. Any insights would be helpful. –
Yerga
try erosion and dilation operators –
Auricle
I have a solution using OpenCV.
First, I inverted the image:
ret,thresh2 = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV)
Now I performed morphological opening operation:
opening = cv2.morphologyEx(thresh2, cv2.MORPH_OPEN, k2)
cv2.imshow('opening', opening)
You can see that the grid lines have disappeared. But there are some gaos in some of the characters as well. So to fill the gaps I performed morphological dilation operation:
dilate = cv2.morphologyEx(opening, cv2.MORPH_DILATE, k1)
cv2.imshow('dilation', dilate)
You can check out THIS LINK for more morphological operations and kernels used.
@Soltius Hey any idea on how to get the characters back to normal as in the original image? –
Maunsell
What does closing give instead of dilatation ? –
Whall
@Whall Closing is generally used to fill some holes/speckles/gaps inside a binary image. SEE HERE –
Maunsell
Sure that's the general way it's used but I think it's useful here. It depends on the size and shape of kernel you use, but I tried it out with a (5,5) rectangular kernel (instead of the dilatation phase) and it closed some of the gaps :) –
Whall
@Whall exactly!!! That is why I chose it. I tried out the different possibilities as well –
Maunsell
@Jeru can we not take AND operation of the final image from your answer and my input image? That will give us the true characters with grid removed right? –
Yerga
@SwapnilB.AND operation of my final image with your inverse input image might work. Give it a try –
Maunsell
@JeruLuke is there a way I can talk to you? –
Marita
@Marita Sure what do you want to talk about? –
Maunsell
@JeruLuke I want to see if you can help me do some stuff and I can pay you by the hours. If so, please send me an email to [email protected] regards –
Marita
@JeruLuke the kink to the kernels is broken, is it anywhere to be found? –
Kaiak
@EzerK Check out this link –
Maunsell
@JeruLuke, Thanks!! –
Kaiak
© 2022 - 2024 — McMap. All rights reserved.