📄 huoxing.m
字号:
function [ output_args ] = huoxing( input_args )%HUOXING Summary of this function goes here% Detailed explanation goes hereI=imread('车牌3.bmp');% G=rgb2gray(I);% result=imhist(G);% [a, b1]=max(result);% if(b1==1)% b1=2;% end% result(b1)=0;% [a, b2]=max(result);%(b1+b2)/2/255%说明 默认的背景色是黑色 如果是反的要自己处理BW=im2bw(I,0.4);%注意这个域值要设好 可采用自适应的方式 这个受光线影响很大的,可以考虑先进行预处理figure,imshow(BW);[height, width]=size(BW);isStart=1;boundary=[];isIn=0;start=0;%算法说明:这是一种基于扫描线的算法,我写的这个程序只是呈现一个基本的算法,因此%稳定性和抗干扰性并不好,需要改进的。%注意:本算法不保证对‘浙’'沪'这类可能分成两部分的字能处理成功%注意这种算法应保证在最后一个字符后加一个黑边factor=0.1;for j=1:width hasWhite=0; for i=1+round(factor*height):round(height*(1-factor)) if(BW(i, j)==1)%如果遇到一个白点 if(isStart==1)%本次应为开始 isStart=0; start=j; end hasWhite=1; isIn=1; break; end end if(hasWhite==0) if(isIn) if(j-start>height/4)%去噪 isStart=1; isIn=0; boundary=[boundary start j]; else isStart=0; start=j; end end endendnum=size(boundary)/2;fprintf('车牌中一共有%d个字符\n', num(2));for i=1:num(2) imshow(BW(1:height, boundary(2*i-1):boundary(2*i)) ); pause,end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -