案例2:识别车牌号
方法流程:采集->图像预处理(滤波、二值化处理、形态学处理)->特征提取->仿射变换->定位->截取->字符识别
程序代码:
dev_close_window()
dev_open_window(0, 0, -1, -1, 'black', WindowHandle)
dev_open_file_dialog('read_image', 'default', 'default', Selection)
read_image (Image,Selection)
mean_image (Image,ImageMean, 5, 5)
decompose3(ImageMean, Image1, Image2, Image3)
trans_from_rgb(Image1, Image2, Image3, ImageResult1, ImageResult2,ImageResult3, 'hsv')
threshold(ImageResult2, Regions, 144, 251)
fill_up (Regions,RegionFillUp)
closing_rectangle1(RegionFillUp, RegionClosing, 10, 10)
connection(RegionClosing, ConnectedRegions)
select_shape(ConnectedRegions, SelectedRegions, 'area', 'and', 8788.99, 13009.2)
shape_trans(SelectedRegions, RegionTrans, 'rectangle2')
orientation_region(RegionTrans, Phi)
hom_mat2d_identity(HomMat2DIdentity)
area_center(RegionTrans, Area, Row, Column)
*vector_angle_to_rigid
(Row, Column, Phi, Row, Column, 0, HomMat2D)
hom_mat2d_rotate(HomMat2DIdentity, -Phi, Row, Column, HomMat2DRotate)
affine_trans_region(RegionTrans, RegionAffineTrans, HomMat2DRotate, 'nearest_neighbor')
affine_trans_image(Image, ImageAffinTrans, HomMat2DRotate, 'constant', 'false')
reduce_domain(ImageAffinTrans, RegionAffineTrans, ImageReduced)
rgb1_to_gray(ImageReduced, GrayImage)
invert_image(GrayImage, ImageInvert)
threshold(GrayImage, Regions1, 175, 241)
opening_circle(Regions1, RegionOpening, 1)
connection(RegionOpening, ConnectedRegions1)
select_shape(ConnectedRegions1, SelectedRegions1, 'area', 'and', 95.87, 500)
closing_circle(SelectedRegions1, RegionClosing1, 2)
sort_region(RegionClosing1, SortedRegions, 'character', 'false', 'column')
read_ocr_class_mlp('Industrial_0-9A-Z_NoRej.omc', OCRHandle)
do_ocr_multi_class_mlp(RegionClosing1, ImageInvert, OCRHandle, Class, Confidence)
disp_message(WindowHandle, Class, 'window', 0, 0, 'black', 'true')
实验结果:
图2