clc; clear all; close all;
[filename, pathname, filterindex] = uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' }, '选择待处理图像', ...
'images\01.jpg');
file = fullfile(pathname, filename);%文件路径和文件名创建合成完整文件名
id = Get_Id(file);%得到file中的所有对象
Img = imread(file);%根据路径和文件名读取图片到Img
[Plate, bw, Loc] = Pre_Process(Img); % 车牌区域预处理
result = Plate_Process(Plate, id); % 车牌区域二值化处理
% 寻找连续有文字的块,若长度大于某阈值,则认为该块有两个字符组成,需要分割bw = Segmation(result);
words = Main_Process(bw); % 主流程处理
Write_Mask(words, id); % 写出到模板库
str = Pattern_Recognition(words); % 识别
function id = Get_Id(file)
% 获取图像id信息
% 输入参数:
% file——图像路径
% 输出参数:
% id——图像id信息
info = imfinfo(file);
FS = [422227 354169 293184 235413 214202 ...
130938 490061 120297 98686 137193 ...
80558 46208 69947 58110 62115 ...
59072 52168 60457 53979 50223];
id = find(FS == info.FileSize);
if isempty(id)
warndlg('未建立该图像模板库,可能运行出错!', '警告');
id = 1;
end
function R = Cubic_Spline(P)
% 三次样条插值
% 输入参数:
% P——节点矩阵
% 输出参数:
% R——样条节点矩阵