0

I want to find all connected components in a license plate. First, I threshold my image and then use connected component function in opencv to label binary image, but the character in red region and number 10 in blue region are not detected. What can I do to detect a character?

License plate sample:

enter image description here enter image description here

Vega
  • 27,856
  • 27
  • 95
  • 103
sina
  • 331
  • 4
  • 12

2 Answers2

1

Try using Niblack Thresholding. This is what I got with Window Size=5 and k=4.25 enter image description here

I converted the image to grayscale and then did Niblack Thresholding. Here is a sample Python code. (code does not include connected component analysis and masking, which is needed to get the output on the right)

import cv2 
import numpy as np
from skimage.filters import threshold_niblack


image = cv2.imread('IRplate.jpg')
B_Wimage = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)


thresh = threshold_niblack(B_Wimage, window_size=5, k=4.25)
ret,thresh = cv2.threshold(thresh,0,255,cv2.THRESH_BINARY_INV)


cv2.imshow('A1',thresh)
k = cv2.waitKey(0)
cv2.destroyAllWindows()

You will have to do some erosion/dilation and connected component analysis on the Thresholded image to get the clean result on the right.

Hope this helps! :)

Titanoboa
  • 355
  • 1
  • 9
0

I bet you'd probably have problems too, if you would look at the thresholded image.

I assume you've used a single threshold (and possibly a greyscale at that). But you have three effects at play here: the image is made up of several regions, it's in color, and there is a shadow.

You might want to look at Adaptive Thresholding, possibly followed by Grab-cut

MSalters
  • 173,980
  • 10
  • 155
  • 350