'How to remove noise from a number plate image OpenCV, Python?

I have some cropped numberplates and I need to select the characters from those plates. But due to some noise unable to select all the characters. Please help me out in case I am doing something wrong.

    img_lp = cv2.resize(image, (200, 50))
    img_gray_lp = cv2.cvtColor(img_lp, cv2.COLOR_BGR2GRAY)
    _, img_binary_lp = cv2.threshold(img_gray_lp, 200, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
    img_binary_lp = cv2.erode(img_binary_lp, (3,3))
    img_binary_lp = cv2.dilate(img_binary_lp, (3,3))

Input:

Input

Output:

Output



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source