Академический Документы
Профессиональный Документы
Культура Документы
%%
% Locate Licence Plate Bands
%%
% Blobs Analysis
CC = bwconncomp(LPImageBW);
stats = regionprops(CC, 'Area','BoundingBox','Image');
ids = find([stats.Area] > 8 & [stats.Area] < 250);
BW2 = ismember(labelmatrix(CC),ids);
toc
%%
% Blobs Analysis
CC2 = bwconncomp(~LPImageBW);
stats2 = regionprops(CC2,'Area','BoundingBox','Eccentricity');
ids2 = find([stats2.Area] > 20 & [stats2.Eccentricity] > 0.95);
BW3 = ismember(labelmatrix(CC2),ids2);
%BW3 = [];% ismember(labelmatrix(CC2),ids2);
toc
%%
% Pre-OCR
for k=1:length(ids)
imOriginal = stats(ids(k)).Image;
BB = stats(ids(k)).BoundingBox;
NormIm{1,1} = resizem(imOriginal,[60,30]);
NormIm{2,1} = BB(4)/BB(3);
[NormIm{3,1} NormIm{4,1}, NormIm{5,1}] = getMaxCorrelationRate(NormIm{1,1},i
mrefdata);
if(BB(4)/BB(3)>=1.4 && BB(4)/BB(3)<=2 || BB(4)/BB(3)>=3 && BB(4)/BB(3)<=10)
im = [im NormIm];
%imshow(cell2mat(PD(1,:))) %to display all column in first row on NormIm
%output
%imshow(cell2mat(E2(2)))
end
end
toc
%%
% OCR Function
function [Rate,id, Letter] = getMaxCorrelationRate(imOriginal,imrefdata)
for n=1:length(imrefdata)
Rates(n) = corr2(imOriginal,cell2mat(imrefdata(1,n)));
end
[Rate,id] = max(Rates);
if(Rate>0.48)
Letter = imrefdata{2,id};
else
Letter ='';
end;
end
%%
% OCR AlphaNumerical resolution
%%
% LPNumber = 'Hello Plate';
%% Output
end
% It uses correlation instead of ANN.
% All is in AnprSysData.mat file Chars are indexed from 1 to 109