How to remove boundary from binarized image
Following images are results of a binarization algorithm on an image containing licence plate number in the middle and some noise on boundaries. I am developing an algorithm to remove those black areas, so that image becomes something like second example. (Second one is cropped manually before binarization)
So far I tried to remove black lines (horizontal and vertical) base on 1) how many black pixels they have, 2) how black pixel rate drops moving downward starting from top, or upward starting from down.
Nothing works for all images. Any suggestions?
Manually cropped:
Look at Opencv's contour finding. You should be able to isolate just the digits by finding all the contours and filtering them by aspect ratio and area.