Following is the result of a binarized 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: