matlab bmp hsi,Matlab关于HSI的理解,车牌提取的程序

关于基于彩色的车牌定位,适应性都不强啊

下面的这个代码共参考,但它也是只针对一副图像有效。

怎样才能找到适应性强的“蓝色区域”,定位出车牌?

讨论加我,注明Matlab,QQ:471968026

% license plate recognition - car plate location based on color model

% modified by ZHAO Hui, April 30th,2005

I=imread('Car.jpg');

[y,x,z]=size(I);

myI=double(I);

%%%%%%%%%%% RGB to HSI  %%%%%%%%

tic   % 测定算法执行的时间,开始计时

%%%%%%%%%%% 统计分析 %%%%%%%%%%%%%%%

%%%%%%%% Y 方向 %%%%%%%%%%

Blue_y=zeros(y,1);

for i=1:y

for j=1:x

if((myI(i,j,1)<=121)&&myI(i,j,1)>=110&&((myI(i,j,2)<=155)&&(myI(i,j,2)>=141))&&((myI(i,j,3)<=240)&&(myI(i,j,3)>=210)))

% 蓝色RGB的灰度范围

Blue_y(i,1)= Blue_y(i,1)+1;     % 蓝色象素点统计

end

end

end

[temp MaxY]=max(Blue_y);        % Y方向车牌区域确定

PY1=MaxY;  %存放BLUE-Y列向量中的最大值,即整付图象中行中符合IF 条件的灰度范围的元素的最大个数

while ((Blue_y(PY1,1)>=5)&&(PY1>1))

PY1=PY1-1;

end

PY2=MaxY;

while ((Blue_y(PY2,1)>=5)&&(PY2

PY2=PY2+1;

end

IY=I(PY1:PY2,:,:);

%%%%%%%% X 方向 %%%%%%%%%%

Blue_x=zeros(1,x);             % 进一步确定X方向的车牌区域

for j=1:x

for i=PY1:PY2

if((myI(i,j,1)<=121)&&myI(i,j,1)>=110&&((myI(i,j,2)<=155)&&(myI(i,j,2)>=141))&&((myI(i,j,3)<=240)&&(myI(i,j,3)>=210)))

Blue_x(1,j)= Blue_x(1,j)+1;

end

end

end

PX1=1;

while ((Blue_x(1,PX1)<3)&&(PX1

PX1=PX1+1;%从前往后取符合(Blue_x(1,PX1)<3)条件的列,止到中间有一列断开为止

end

PX2=x;

while ((Blue_x(1,PX2)<3)&&(PX2>PX1))

PX2=PX2-1;%从后往前取符合(Blue_x(1,PX2)<3)条件的列,止到中间有一列断开为止

end

PX1=PX1-2; % 对车牌区域的修正    这里还不是很明白为什么要修正以及修正就要+2??不修正会怎么样?希望大虾们解释下

PX2=PX2+2;

Plate=I(PY1:PY2,PX1-2:PX2,:);

t=toc % 读取计时

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

figure,imshow(I);

figure,plot(Blue_y);grid

figure,plot(Blue_x);grid

figure,imshow(IY);

figure,imshow(Plate);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值