2023年11月28日发(作者:为什么都不建议买gs4plus)
车牌识别(?)-车牌定位
在对车牌识别过程中,常?的?法有:基于形状、基于?调、基于纹理、基于?字特征等?法。?先基于形状,在车
牌中因为车牌为形状规格的矩形,所以?的转化为寻找矩形特征,常常是利?车牌长宽?例特征、占据图像的?例等。基于
?调,国内的车牌往往是蓝底?字,可以采?图像的?调或者饱和度特征,进??成?值图,定位车牌位置。基于纹理特征
??还没有基础到。基于?字特征往往是根据?字轮廓特征进?识别,原理是基于相邻?字轮廓特征、?例进?定位车牌位
置。
?、图像?值化
正如前??章所?,?先进?获取图像?值化特征,本?采取了根据图像亮度特征,提?对?度,进?可以清晰获取?
字的图像,为下?步的?字轮廓识别打好基础。
1.1 算法流程
伪代码
1、图像转化为HSV图像,获取V通道图像
2、提?对?度
3、V图像?斯滤波,去除噪声
4、图像?值化
程序源码:
def get_colorvalue(image):
height, width, shape =
image_hsv = ((height,width), 8)
image_hsv = or(image, _RGB2HSV)
image_hue, image_saturation, image_value = (image_hsv)
return image_value
def enhance_contrast(image):
kernel = ucturingElement(_RECT, (3,3))
img_tophat = logyEx(image, _TOPHAT,kernel)
img_blackhat = logyEx(image, _BLACKHAT, kernel)
image_plus_tophat = (image, img_tophat)
image_plus_blackhat_minus_blackhat = ct(image_plus_tophat, img_blackhat)
return image_plus_blackhat_minus_blackhat
def preprocess(srcimage):
image_value = get_colorvalue(srcimage)
image_enhance = enhance_contrast(image_value)
image_hsv = or(image, _RGB2HSV)
image_hue, image_saturation, image_value = (image_hsv)
上?分别为src、hue、saturation、value四副图像,在其中saturatio中可以清晰获取车牌相对于背景的饱和度?,则提取较
value图像则可视为灰度图像,能保留图像?部分图像特征。
关于hsv的介绍可以参考这篇?章:?章简单介绍hsv体系内容。
2、图像对?度增强
kernel = ucturingElement(_RECT, (3,3))
img_tophat = logyEx(image, _TOPHAT,kernel)
img_blackhat = logyEx(image, _BLACKHAT, kernel)
image_plus_black = (image, img_blackhat)
image_plus_blackhat_minus_blackhat = ct(image_plus_black, img_tophat)
(img_tophat) (img_blackhat)
(ima_plus_top_hat) (img_plus_black_top_hat)
图像增强的?的是提?图像的对?度,亮度地?更亮,暗的地?更暗。在形态学处理中,顶帽操作往往?来分离?邻近点亮?些的板块,在
?幅图像具有?幅背景?微?物品?较有规律的情况下,可以使?顶帽运算进?背景提取。?帽运算后的效果图突出了?原图轮廓周围的区
域更暗的区域,这?操作也与选择的核尺?有关。
流程就是,加上?帽,减去顶冒,其实通过实验结果发现,貌似作?不?。
形态学处理详细介绍可以参考::对形态学各种操作和理论进?了详细的介绍
3.?值化
在获取单通道图像后,进?了图像?值化操作,其中?上有个?章推荐使?adaptiveThreshold,其实真的不好?,我也采?
了ostu算法,经过试验验证也不是很好?,经过多次验证,初步定阈值为80,效果?较良好。
?、图像位置初步定位
由于车辆图像背景?较复杂,所以应该根据车牌的特征进?初次筛选,其特征还是根据中国车牌??、?例等关系进?
筛选。
上图是??找的关于车牌的标准,我们可以清晰知道宽:? = 3.5 所以程序设置的最??例是2,最?是5,然后就是根据图
像??设定的?积,长宽等??。
2.1、算法源码
#contants for plate contour
MIN_CONTOUR_RATIO = 1.5
MAX_CONTOUR_RATIO = 5
MIN_CONTOURL_AREA = 1500
def get_external_contours(image_thresh):
# Construct display images and display contours in images
height, width = image_
image_contour1 = ((height, width),8)
image_contour2 = ((height, width),8)
## Custom 3*3 nuclei undergo expansion corrosion in the X direction
kernel = ucturingElement(_RECT, (3, 3))
image_dilate= (image_thresh,kernel,iterations =2)
image_erode= (image_dilate, kernel, iterations = 4)
image_dilate= (image_erode,kernel,iterations = 2)
#
_, contours, hierarchy = ntours(image_dilate, _EXTERNAL, _APPROX_SIMPLE)
contour_filter = []
ntours(image_contour1, contours, -1,(255, 255, 255 ),3)
# choose the suite contour by the feature of special scence
for contour in contours:
contour_possible = PossibleContour(contour)
if(check_external_contour(contour_possible)):
gle(image_contour2, (contour_, contour_),
(contour_ + contour_dth, contour_ + contour_ight),255)
contour_(contour_possible)
print(\"the length of origin contours is %d \" %len(contour_filter))
e(\"1_\",image_contour1)
e(\"1_\",image_contour2)
return contour_filter
# #According to the license plate area size, length and width ratio, the primary screening is carried out
def check_external_contour(contour):
if ( > MIN_CONTOURL_AREA and dth > MIN_CONTOUR_WIDTH and ight >
def chack_plate_blueHue(contour_list, image_src):
if len(contour_list) == 0:
print(\'cannot find the plate contours\')
return None
mean_list = []
# calculate the mean of each blue image and choose the max one,get the index
for contour in contour_list:
image = tSubPix(image_src, ( dth, ight),(X, Y))
b , g, r = (image)
sum_pix = [0] * [1]
b_mean = ((b))/sum_pix
mean_(b_mean)
index = ((mean_list))
contour_final = contour_list[index]
return contour_final
3.2 算法分析
1、
遍历轮廓数组,根据前期获取的候选车牌区域,通过getRectSubPix获取其图像
2、分离图像,获取blue通道图像
3、计算图像均值,并添加到list
4、寻找list的argmax,获取其index
5、返回list中准确的contour
更多推荐
车牌识别
发布评论