Skip to content Skip to sidebar Skip to footer

Segment Each Character From Noisy Number Plate

I am doing a project on Nepali Number Plate Detection where I have detected my number plate from the vehicle ani skewed the number plate but the result is a noisy image of number p

Solution 1:

Suppose you have the ratio of the plate and you can cut the plate by half by y-axis. From left to right, thresh image, morphologyEx image, contours. Apply the same with the other half.

thresh img

morphologyEx img

Contours

image = cv2.imread("1.PNG")

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
_,thresh = cv2.threshold(gray,127,255,cv2.THRESH_TOZERO)
cv2.imshow("thresh",thresh)

element = cv2.getStructuringElement(shape=cv2.MORPH_RECT, ksize=(5, 11))

morph_img = thresh.copy()
cv2.morphologyEx(src=thresh, op=cv2.MORPH_CLOSE, kernel=element, dst=morph_img)
cv2.imshow("morph_img",morph_img)


_,contours,_ = cv2.findContours(morph_img,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)
for c in contours:
    r = cv2.boundingRect(c)
    cv2.rectangle(image,(r[0],r[1]),(r[0]+r[2],r[1]+r[3]),(0,0,255),2)

cv2.imshow("img",image)

cv2.waitKey(0)
cv2.destroyAllWindows()

Another way to segment the characters is to find sum of gray values along x-axis and y-axis. You can easily see there are 3 peaks in x-axis which are 3 characters and 1 peak in y-axis that is where your characters located.

enter image description here

enter image description here

Post a Comment for "Segment Each Character From Noisy Number Plate"