文件名称:MATLAB车牌汉字识别
文件大小:129KB
文件格式:RAR
更新时间:2012-05-15 19:05:42
MATLAB
function result = letter_compare(ocr_letters, document_letter)
% LETTER_COMPARE.M
%
% function result = letter_compare(ocr_letters, document_letter)
%
% Parameters: ocr_letters is an array (1..4) of structures
% with fields: Mean, Covariance
% Subscripts of array mean 1=O 2=E 3=A 4=U
% document_letter fields is a structure which has
% with fields: Image, EulerNumber, Area, BoundingBox
%
% This function compares a letter extracted from the image paragraph
% to each of the four vowels. Returns the index of the vowel
% which the letter from the paragraph matches, if any.
% If no vowels match up, return 0.
%
% Assumptions:
% - the letter form the document/paragraph is properly oriented
% Calculate the data necessary for the matching
perImg = bwperim(document_letter.Image);
perArea = bwarea(perImg);
compactness = perArea^2/document_letter.Area;
moments = invmoments(document_letter.Image);
% Calculate the top/bottom area ratio
midpoint = floor(document_letter.BoundingBox(4)/2);
topPart = document_letter.Image(1:midpoint,:);
bottomPart = document_letter.Image((midpoint+1):end,:);
partRatio = bwarea(topPart)/bwarea(bottomPart);
% Final vector for the doucment image which will be used for comparison
vector = [ moments(1) moments(2) moments(3) compactness partRatio ];
% Go through all four letters
for i = 1: 4,
% Closeness will be Mahalanobis distance without the log term
closeness(i) = (vector - ocr_letters(i).Mean)*...
inv(ocr_letters(i).Covariance)*...
(vector - ocr_letters(i).Mean)';
% Distance is Mahalanobis distance with the log term
% The log term equalizes the distance space so that
% we can compare which one of the four letters
% is closer to the letter extracted from the paragraph
distance(i) = closeness(i) + log(det(ocr_letters(i).Covariance));
end
% Find one of the vowels with the smallest distance to the document letter
minimumDistance = distance(1);
closestMatch = 1;
for j = 1:4,
if distance(j)
【文件预览】:
www.pudn.com.txt
简易OCR程序
----centralmoment.m(1021B)
----e.mat(488B)
----invmoments.m(1KB)
----vowel.m(5KB)
----a.mat(488B)
----ncmoment.m(1KB)
----CS585 Fall 1998 Project One by Stanislav Rost.files()
--------background.jpg(395B)
--------title.jpg(15KB)
--------par1result.gif(8KB)
--------u2.gif(900B)
--------program.jpg(3KB)
--------results.jpg(3KB)
--------tilted.gif(9KB)
--------mahalanobis.gif(1KB)
--------tiltedresult.gif(8KB)
--------code.jpg(2KB)
--------goals.jpg(2KB)
--------par2result.gif(19KB)
--------Thumbs.db(36KB)
--------istilted.gif(4KB)
--------scaledresult.gif(12KB)
--------split.gif(581B)
--------method.jpg(3KB)
--------n2.gif(1KB)
--------readme.txt(83B)
----o.mat(488B)
----u.mat(488B)
----CS585 Fall 1998 Project One by Stanislav Rost.htm(18KB)
----gravcenters.m(1KB)
----train.m(3KB)
----letter_compare.m(5KB)