例题:使用MATLAB编程对图中的车牌号码进行识别
MATLAB程序源代码
clear all
clc
PS=imread('1.jpg');
subplot(1,2,1);
imshow(PS)
title('原图')
p=rgb2gray(PS);
subplot(1,2,2)
imshow(p)
title('原灰度图')
[m,n]=size(p);
GP=zeros(1,256);
for k=0:255
GP(k+1)=length(find(p==k))/(m*n);
end
figure
bar(0:255,GP,'g')
title('原灰度直方图')
max_index=[];
for i=3:length(GP)-2
if((GP(i)>=GP(i+1))&(GP(i)>=GP(i-1)))&((GP(i+1)>=GP(i+2))&(GP(i-1)>=GP(i-2)))
max_index(end+1)=i-1;
end
end
possible=GP(max_index);
[max_value,index]=max(possible);
TT=max_index(inde