- 1.22 MB
- 40页
- 1、本文档共5页,可阅读全部内容。
- 2、本文档内容版权归属内容提供方,所产生的收益全部归内容提供方所有。如果您对本文有版权争议,可选择认领,认领后既往收益都归您。
- 3、本文档由用户上传,本站不保证质量和数量令人满意,可能有诸多瑕疵,付费之前,请仔细先通过免费阅读内容等途径辨别内容交易风险。如存在严重挂羊头卖狗肉之情形,可联系本站下载客服投诉处理。
- 文档侵权举报电话:19940600175。
'《数字图象处理》课程项目实施报告题目:车牌自动定位与字符分割组号:29任课教师:严壮志组长:13122925鲁珅20%成员:13121104王国平20%成员:13123032尹悦20%成员:13120824胡子泉20%成员:13124177杨亨敏20%联系方式:15921611856二零一六年二月二十六日
《数字图像处理》课程项目报告2016年2月27日一、引言图像分割是图像处理的主要目标,本项目综合利用图像采集、图像增强、彩色图像处理、图像分割等知识,根据牌照的色彩和形状、牌照字符的排列规则及形状等特点,设计实现车牌区域的自动分割及字符的自动分割。二、课程项目目的通过该项目,我们旨在了解图像分割的基本原理,能够对图像处理系统及应用有一个整体认识,对图像识别中涉及的关键技术如直方图分析、阈值分割、特征匹配等有更进一步的理解,提高数字图像处理课程的实际应用能力。三、基本原理随着中国车辆的逐渐增多车辆,车牌识别也应用越来越广泛。虽然车牌识别的方法多种多样,但真正能实用的却是不多。我们小组总结下来对于车牌识别最重要的环节——车牌定位,不外乎两种途径。其一中国的车牌无外乎黄、蓝、白等几种颜色的车牌,因此我们可以根据彩色图像的车牌和字体的色彩,对车牌进行定位。其二我们可以通过对车牌的预处理,将图像转换为灰度图像,通过基本的图像处理方法,如膨胀腐蚀来对车牌进行定位。两种或给方法各有优缺点,方法一明显比第二种方法定位的准确率高,但是识别颜色范围有限,而且需要进行较多的数据运算。第二种方法虽然准确率低,但是运算数据量小,比较快速。车牌能准确定位后,接下来就比较好做了。仅统计二值图像的数据即可对车牌进行分割,从而提取出每个字体的特征,与已知的码本进行匹配比较就可以达到识别车牌的目的。本课题先根据色彩对车牌进行了定位,而后进行了一些相应的处理,达到了较好的效果。
四、具体操作步棸如下:4.1彩色车牌定位以蓝色车牌为例,将彩色车牌读入后,采用水平垂直双向投影法,将图像分别投影到X、Y坐标轴,然后分别沿X、Y轴扫描图像。当沿Y轴扫描时,一边扫描一边统计图像中蓝色像素点的个数,第一次扫描到蓝色像素点最多的行时停止扫描,并记录下蓝色像素点最多的行,然后以此行为基点,分别向上、向下扫描,直到统计的像素点小于像素点阈值时,停止扫描,记录上下行的Y轴坐标PY1、PY2,即PY1、PY2之间区域就是Y轴方向的车牌边缘位置。同理进行X轴方向的像素扫描,确定X轴方向的车牌区域。在得到车牌的大概位置I之后,再对I区域扫描,确定该区域内白色像素点个数,然后求出该区域内白色像素点数所占比例,以判断所得的I区域是否为正确的车牌位置。代码如下(以下为Y方向):[y,x,z]=size(I);%I为彩色图像矩阵是三维矩阵myI=double(I);Blue_y=zeros(y,1);%建立矩阵用于储存蓝色像素点数目fori=1:yforj=1:xif((myI(i,j,1)<=48)&&((myI(i,j,2)<=100)&&(myI(i,j,2)>=40))&&((myI(i,j,3)<=200)&&(myI(i,j,3)>=80)))%蓝色像素点判断依据Blue_y(i,1)=Blue_y(i,1)+1;endendend[tempMaxY]=max(Blue_y);PY1=MaxY;%确定上边界PY2=MaxY;while((Blue_y(PY2,1)>=5)&&(PY2=40)&&(myI(i,j,2)<=90)&&(myI(i,j,3)<=220)&&(myI(i,j,3)>=80)if((myI(i,j,1)<=48)&&((myI(i,j,2)<=100)&&(myI(i,j,2)>=40))&&((myI(i,j,3)<=200)&&(myI(i,j,3)>=80)))%if((myI(i,j,1)<=0.7)&&(myI(i,j,1)>=0.6)&&((myI(i,j,2)<=1.8)&&(myI(i,j,2)>=0.6))&&((myI(i,j,3)<=1.7)&&(myI(i,j,3)>=0.45)))Blue_y(i,1)=Blue_y(i,1)+1;%蓝色象素点统计endend
endbaisebili=0;changkuanbi=0;k=0;l=0;while(~((baisebili>=0.06)&&(baisebili<=0.5)&&(changkuanbi>=0.20)&&(changkuanbi<=0.6)))%gaishanqingxieif(k==0)%第一次进来[tempMaxY]=max(Blue_y);%Y方向车牌区域确定temp(最多点数):所有行中,最多的累积像素点MaxY(最多点所在行):该行中蓝点最多iftemp<=20l=1;break;endPY1=MaxY;%有最多蓝点的行付给PY1while((Blue_y(PY1,1)>=Y_threshlow)&&(PY1>1))%找到图片上边界PY1=PY1-1;end%PY1:存储车牌上边界值PY2=MaxY;while((Blue_y(PY2,1)>=Y_threshlow)&&(PY2=30))&&((myI(i,j,3)<=160)&&(myI(i,j,3)>=80)))if((myI(i,j,1)<=65)&&((myI(i,j,2)<=100)&&(myI(i,j,2)>=40))&&((myI(i,j,3)<=160)&&(myI(i,j,3)>=90)))%这里由82修改成90.因为图片20090504809%if((myI(i,j,1)<=0.7)&&(myI(i,j,1)>=0.6)&&((myI(i,j,2)<=1.8)&&(myI(i,j,2)>=0.6))&&((myI(i,j,3)<=1.7)&&(myI(i,j,3)>=0.45)))Blue_x(1,j)=Blue_x(1,j)+1;endendend
[tempMaxX]=max(Blue_x);PX1=MaxX-6*(PY2-PY1);ifPX1<=1PX1=1;endwhile((Blue_x(1,PX1)<=X_threshhigh)&&(PX1=xPX2=x;endwhile((Blue_x(1,PX2)<=X_threshhigh)&&(PX2>PX1))%阈值PX2=PX2-1;end%确定出X方向车牌终点PX1,PX2%=========================================================a=PY2-PY1+1;b=PX2-PX1+1;White=0;fori=PY1:PY2forj=PX1:PX2if(std([myI(i,j,1)myI(i,j,2)myI(i,j,3)],1,2)<=22)&&(myI(i,j,1)>=90)&&(myI(i,j,1)<=255)White=White+1;%白色象素点统计endendendbaisebili=White/(a*b)changkuanbi=a/bk=k+1%===========================蓝色区域不是车牌区域=================elseif(k~=0)Blue_y(PY1:PY2,1)=0;[tempMaxY]=max(Blue_y);iftemp<=20l=1;break;endPY1=MaxY;
while((Blue_y(PY1,1)>=Y_threshlow)&&(PY1>1))%找到图片上边界%阈值为5PY1=PY1-1;end%PY1:存储车牌上边界值PY2=MaxY;while((Blue_y(PY2,1)>=Y_threshlow)&&(PY2=20))&&((myI(i,j,3)<=160)&&(myI(i,j,3)>=80)))Blue_x(1,j)=Blue_x(1,j)+1;endendend%这里修改成了从中间向两边扩展,这个方法不好。因车牌中间某些位置可能出现断层。%采用增强型两边往中间收缩。[tempMaxX]=max(Blue_x);PX1=MaxX-6*(PY2-PY1);ifPX1<=1PX1=1;endwhile((Blue_x(1,PX1)<=X_threshhigh)&&(PX1=xPX2=x;endwhile((Blue_x(1,PX2)<=X_threshhigh)&&(PX2>PX1))%阈值PX2=PX2-1;end%确定出X方向车牌终点%PX1=1;%while((Blue_x(1,PX1)<=X_threshhigh)&&(PX1PX1))%阈值%PX2=PX2-1;%endPX1,PX2%=========================================================a=PY2-PY1+1;b=PX2-PX1+1;White=0;fori=PY1:PY2forj=PX1:PX2if(std([myI(i,j,1)myI(i,j,2)myI(i,j,3)],1,2)<=16)&&(myI(i,j,1)>=90)&&(myI(i,j,1)<=255)White=White+1;%白色象素点统计endendendbaisebili=White/(a*b)changkuanbi=a/bk=k+1endendif(l==1)myI=double(I);Y_threshlow=5;%这个数值很重要。决定了提取的彩图的质量X_firrectify=5;%ganraotransaction%==============黄色车牌识别========Y方向============================Blue_y=zeros(y,1);fori=1:yforj=1:x%if(myI(i,j,1)<=48)&&(myI(i,j,2)>=40)&&(myI(i,j,2)<=90)&&(myI(i,j,3)<=220)&&(myI(i,j,3)>=80)if((myI(i,j,1)>=140)&&(myI(i,j,1)<=250)&&((myI(i,j,2)<=200)&&(myI(i,j,2)>=100))&&((myI(i,j,3)<=50)&&(myI(i,j,3)>=0)))%if((myI(i,j,1)<=0.7)&&(myI(i,j,1)>=0.6)&&((myI(i,j,2)<=1.8)&&(myI(i,j,2)>=0.6))&&((myI(i,j,3)<=1.7)&&(myI(i,j,3)>=0.45)))Blue_y(i,1)=Blue_y(i,1)+1;%蓝色象素点统计endend
endk=0changkuanbi=0;while(~((changkuanbi>=0.20)&&(changkuanbi<=0.6)))%if(k==0)[tempMaxY]=max(Blue_y);%Y方向车牌区域确定temp(最多点数):所有行中,最多的累积像素点MaxY(最多点所在行):该行中蓝点最多iftemp<=20%2048*1536照相msgbox("车牌定位出错","warning");endPY1=MaxY;%有最多蓝点的行付给PY1while((Blue_y(PY1,1)>=Y_threshlow)&&(PY1>1))%找到图片上边界PY1=PY1-1;end%PY1:存储车牌上边界值PY2=MaxY;while((Blue_y(PY2,1)>=Y_threshlow)&&(PY2=30))&&((myI(i,j,3)<=160)&&(myI(i,j,3)>=80)))if((myI(i,j,1)>=140)&&(myI(i,j,1)<=250)&&((myI(i,j,2)<=200)&&(myI(i,j,2)>=100))&&((myI(i,j,3)<=50)&&(myI(i,j,3)>=0)))%这里由82修改成90.因为图片20090504809%if((myI(i,j,1)<=0.7)&&(myI(i,j,1)>=0.6)&&((myI(i,j,2)<=1.8)&&(myI(i,j,2)>=0.6))&&((myI(i,j,3)<=1.7)&&(myI(i,j,3)>=0.45)))Blue_x(1,j)=Blue_x(1,j)+1;endendend[tempMaxX]=max(Blue_x);PX1=MaxX-6*(PY2-PY1);ifPX1<=1
PX1=1;endwhile((Blue_x(1,PX1)<=X_threshhigh)&&(PX1=xPX2=x;endwhile((Blue_x(1,PX2)<=X_threshhigh)&&(PX2>PX1))%阈值PX2=PX2-1;end%确定出X方向车牌终点%PX1=1;%while((Blue_x(1,PX1)<=X_threshhigh)&&(PX1PX1))%阈值%PX2=PX2-1;%end%确定出X方向车牌终点PX1,PX2%=========================================================a=PY2-PY1+1;b=PX2-PX1+1;changkuanbi=a/b;k=k+1;elseif(k~=0)Blue_y(PY1:PY2,1)=0;[tempMaxY]=max(Blue_y);%Y方向车牌区域确定temp(最多点数):所有行中,最多的累积像素点MaxY(最多点所在行):该行中蓝点最多iftemp<=20%2048*1536照相msgbox("车牌定位出错","warning");endPY1=MaxY;%有最多蓝点的行付给PY1while((Blue_y(PY1,1)>=Y_threshlow)&&(PY1>1))%找到图片上边界PY1=PY1-1;end%PY1:存储车牌上边界值PY2=MaxY;while((Blue_y(PY2,1)>=Y_threshlow)&&(PY2=30))&&((myI(i,j,3)<=160)&&(myI(i,j,3)>=80)))if((myI(i,j,1)>=140)&&(myI(i,j,1)<=250)&&((myI(i,j,2)<=200)&&(myI(i,j,2)>=100))&&((myI(i,j,3)<=50)&&(myI(i,j,3)>=0)))%这里由82修改成90.因为图片20090504809%if((myI(i,j,1)<=0.7)&&(myI(i,j,1)>=0.6)&&((myI(i,j,2)<=1.8)&&(myI(i,j,2)>=0.6))&&((myI(i,j,3)<=1.7)&&(myI(i,j,3)>=0.45)))Blue_x(1,j)=Blue_x(1,j)+1;endendend[tempMaxX]=max(Blue_x);PX1=MaxX-6*(PY2-PY1);ifPX1<=1PX1=1;endwhile((Blue_x(1,PX1)<=X_threshhigh)&&(PX1=xPX2=x;endwhile((Blue_x(1,PX2)<=X_threshhigh)&&(PX2>PX1))%阈值PX2=PX2-1;end%确定出X方向车牌终点PX1,PX2%=========================================================a=PY2-PY1+1;b=PX2-PX1+1;changkuanbi=a/b;end
endend%初次修正Y_firrectify=fix((PY2-PY1)/5);%适当扩大这个值可以正确旋转PY1=PY1-Y_firrectify;%对车牌区域的修正,向上PY2=PY2+Y_firrectify;%对车牌区域的修正,向下PX1=PX1-X_firrectify;%对车牌区域的修正PX2=PX2+X_firrectify;%对车牌区域的修正,%二次修正子函数function[PY2,PY1,PX2,PX1,threshold]=xiuzheng(PY2,PY1,PX2,PX1)S=(PY2-PY1)*(PX2-PX1)ifS<=25000threshold=50;Y_secrectify=3;X_secrectify=3;elseifS>25000&&S<=45000threshold=100;Y_secrectify=-3;X_secrectify=3;elseifS>45000&&S<=80000threshold=200;Y_secrectify=-3;X_secrectify=3;elseifS>80000&&S<=150000threshold=300;Y_secrectify=-10;X_secrectify=-10;elseifS>150000&&S<=400000threshold=600;Y_secrectify=-10;X_secrectify=-10;elsethreshold=1800;Y_secrectify=-10;X_secrectify=-10;end%对车牌区域的进一步修正PY1=PY1-Y_secrectify;PY2=PY2+Y_secrectify;
%---Executesonbuttonpressinhuiduhua.functionhuiduhua_Callback(hObject,eventdata,handles)%hObjecthandletohuiduhua(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%---Executesonbuttonpressinhuiduhua.globalbw;bw=rgb2gray(bw);axes(handles.axes1);imshow(bw);set(handles.edit1,"String","车牌灰度处理后图像");%---Executesonbuttonpressinqingxiejiaozheng.functionqingxiejiaozheng_Callback(hObject,eventdata,handles)%hObjecthandletoqingxiejiaozheng(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalbw;globalqingxiejiao;qingxiejiao=rando_bianhuan(bw);bw=imrotate(bw,qingxiejiao,"bilinear","crop");axes(handles.axes1);imshow(bw);set(handles.edit1,"String","倾斜校正后的车牌图像");%倾斜变换子函数用到Rando变换functionqingxiejiao=rando_bianhuan(I)I=edge(I);theta=1:180;[R,xp]=radon(I,theta);[I,J]=find(R>=max(max(R)));%J为倾斜角qingxiejiao=90-J;%-----车牌图像处理部分,与识别无关,纯粹图像处理%---Executesonbuttonpressinhuidubianhuan.functionhuidubianhuan_Callback(hObject,eventdata,handles)%hObjecthandletohuidubianhuan(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalbw;
b1=bw;b1=imadjust(b1,[0.3,0.7],[]);%J=imadjust(I,[low_in;high_in],[low_out;high_out])%将图像I中的亮度值映射到J中的新值,即将low_in至high_in之间的值映射到low_out至high_out之间的值。%low_in以下与high_in以上的值被剪切掉了,也就是说,low_in以下的值映射到low_out,high_in%以上的值映射到high_out。它们都可以使用空的矩阵[],默认值是[01]。axes(handles.axes1);imshow(b1);set(handles.edit1,"String","灰度变换后的车牌图像");%---Executesonbuttonpressinaverage.functionaverage_Callback(hObject,eventdata,handles)%hObjecthandletoaverage(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalbw;b3=bw;b3=filter2(fspecial("average",2),b3)/255;axes(handles.axes1);imshow(b3);set(handles.edit1,"String","均值滤波后的车牌图像");%---Executesonbuttonpressinzhongzhi.functionzhongzhi_Callback(hObject,eventdata,handles)%hObjecthandletozhongzhi(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalbw;b2=bw;b2=medfilt2(b2);axes(handles.axes1);imshow(b2);set(handles.edit1,"String","中值滤波后的车牌图像");%-----以上为车牌图像处理部分,与识别无关,纯粹图像处理%---Executesonbuttonpressincachu.functioncachu_Callback(hObject,eventdata,handles)%hObjecthandletocachu(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)
globalbw;globalthreshold;bw=im2bw(bw,graythresh(bw));%figure,imshow(bw);bw=bwmorph(bw,"hbreak",inf);%figure,imshow(bw);bw=bwmorph(bw,"spur",inf);%figure,imshow(bw);title("擦除之前");bw=bwmorph(bw,"open",5);%figure,imshow(bw);title("开运算");bw=bwareaopen(bw,50);axes(handles.axes1);imshow(bw);set(handles.edit1,"String","擦除黑点后的车牌图像");%---Executesonbuttonpressinfanse.functionfanse_Callback(hObject,eventdata,handles)%hObjecthandletofanse(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalbw;bw=~bw;axes(handles.axes1);imshow(bw);set(handles.edit1,"String","反色后的车牌图像");%---Executesonbuttonpressinjiebian.functionjiebian_Callback(hObject,eventdata,handles)%hObjecthandletojiebian(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalbw;bw=touying(bw);axes(handles.axes1);imshow(bw);set(handles.edit1,"String","上下边界截取后的图片");%截取时用到投影计算黑点的子函数functionbw_fir=touying(image_bw)X_yuzhi=1;[y,x]=size(image_bw);assignin("base","y",y);assignin("base","x",x);Y_touying=(sum((~image_bw)"))";%往左边投影统计黑点assignin("base","Y_touying",Y_touying);X_touying=sum((~image_bw));%往下面投影
assignin("base","X_touying",X_touying);%找黑体边缘Y_up=fix(y/2);Y_yuzhi=mean(Y_touying((fix(y/2)-10):(fix(y/2)+10),1))/2;%由1.6调整为2assignin("base","Y_yuzhi",Y_yuzhi);while((Y_touying(Y_up,1)>=Y_yuzhi)&&(Y_up>1))%找到图片上边界Y_up=Y_up-1;endY_down=fix(y/2);while((Y_touying(Y_down,1)>=Y_yuzhi)&&(Y_down20000&&SS<=30000shedingyuzhi=4;elseifSS>30000&&SS<=50000shedingyuzhi=4;elseifSS>50000&&SS<=80000shedingyuzhi=4;elseshedingyuzhi=4;endganrao=SS/100;%=========================================================%定义数组histogram存储垂直方向的黑点数histogram=sum(~imfenge);%=================文字分割=============================k=1;forh=1:x-1if((histogram(1,h)<=shedingyuzhi)&&(histogram(1,h+1)>shedingyuzhi))||((h==1)&&histogram(1,h)>shedingyuzhi)fenge(1,k)=h;k=k+1;elseif((histogram(1,h)>shedingyuzhi)&&(histogram(1,h+1)<=shedingyuzhi))||((h==x-1)&&histogram(1,h)>shedingyuzhi)fenge(1,k)=h+1;k=k+1;endend
%k记录边界值的个数%fenge记录边界的位置k=k-1;%去掉多产生的一个K值ifk<10msgbox("提取出错","警告");end%==============================================if(sum(histogram(1,fenge(1,1):fenge(1,2)))=max(baifenbi));shibiehanzi=chepai;%在数字中,从0开始所以要减一。这里不用ifshibiehanzi==1shibiehanzi="京";elseifshibiehanzi==2shibiehanzi="津";elseifshibiehanzi==3shibiehanzi="沪";elseifshibiehanzi==4shibiehanzi="渝";elseifshibiehanzi==5shibiehanzi="冀";elseifshibiehanzi==6shibiehanzi="晋";elseifshibiehanzi==7shibiehanzi="辽";elseifshibiehanzi==8shibiehanzi="吉";elseifshibiehanzi==9shibiehanzi="黑";elseifshibiehanzi==10shibiehanzi="苏";elseifshibiehanzi==11shibiehanzi="浙";elseifshibiehanzi==12shibiehanzi="皖";elseifshibiehanzi==13
shibiehanzi="闽";elseifshibiehanzi==14shibiehanzi="赣";elseifshibiehanzi==15shibiehanzi="鲁";elseifshibiehanzi==16shibiehanzi="豫";elseifshibiehanzi==17shibiehanzi="鄂";elseifshibiehanzi==18shibiehanzi="湘";elseifshibiehanzi==19shibiehanzi="粤";elseifshibiehanzi==20shibiehanzi="琼";elseifshibiehanzi==21shibiehanzi="川";elseifshibiehanzi==22shibiehanzi="贵";elseifshibiehanzi==23shibiehanzi="云";elseifshibiehanzi==24shibiehanzi="陕";elseifshibiehanzi==25shibiehanzi="甘";elseifshibiehanzi==26shibiehanzi="青";elseifshibiehanzi==27shibiehanzi="藏";elseifshibiehanzi==28shibiehanzi="桂";elseifshibiehanzi==29shibiehanzi="蒙";elseifshibiehanzi==30shibiehanzi="新";elseifshibiehanzi==31shibiehanzi="宁";elseifshibiehanzi==32shibiehanzi="港";end
functionshibiezimu=shibiezimu(zimu,xiuzhengzimu)[y,x,z]=size(xiuzhengzimu);fork=1:24sum=0;fori=1:yforj=1:xifzimu(i,j,k)==xiuzhengzimu(i,j)%统计黑白sum=sum+1;endendendbaifenbi(1,k)=sum/(x*y);endchepai=find(baifenbi>=max(baifenbi));shibiezimu=chepai;%在数字中,从0开始所以要减一。这里不用ifshibiezimu==1shibiezimu="A";elseifshibiezimu==2shibiezimu="B";elseifshibiezimu==3shibiezimu="C";elseifshibiezimu==4shibiezimu="D";elseifshibiezimu==5shibiezimu="E";elseifshibiezimu==6shibiezimu="F";elseifshibiezimu==7shibiezimu="G";elseifshibiezimu==8shibiezimu="H";elseifshibiezimu==9shibiezimu="J";elseifshibiezimu==10shibiezimu="K";elseifshibiezimu==11shibiezimu="L";elseifshibiezimu==12shibiezimu="M";elseifshibiezimu==13shibiezimu="N";elseifshibiezimu==14shibiezimu="P";
elseifshibiezimu==15shibiezimu="Q";elseifshibiezimu==16shibiezimu="R";elseifshibiezimu==17shibiezimu="S";elseifshibiezimu==18shibiezimu="T";elseifshibiezimu==19shibiezimu="U";elseifshibiezimu==20shibiezimu="V";elseifshibiezimu==21shibiezimu="W";elseifshibiezimu==22shibiezimu="X";elseifshibiezimu==23shibiezimu="Y";elseifshibiezimu==24shibiezimu="Z";endfunctionshibiezm_sz=shibiezm_sz(shuzizimu,xiuzhengzm_sz)[y,x,z]=size(xiuzhengzm_sz);fork=1:34sum=0;fori=1:yforj=1:xifshuzizimu(i,j,k)==xiuzhengzm_sz(i,j)%统计黑白sum=sum+1;endendendbaifenbi(1,k)=double(sum/(x*y));endchepai=find(baifenbi>=max(baifenbi));chepai=chepai(1,1);%===================数字直接返回=========================if(chepai>=1)&&(chepai<=10)zm_sz=chepai-1;zm_sz=num2str(zm_sz);elseif(chepai>=11)&&(chepai<=34)
%==================字母对应序号转字母====================%=========11-15ABCDE16-20FGHIJ21-25KLMNP26-30QRSTU31-35VWXYZifchepai==11zm_sz="A";elseifchepai==12zm_sz="B";elseifchepai==13zm_sz="C";elseifchepai==14zm_sz="D";elseifchepai==15zm_sz="E";elseifchepai==16zm_sz="F";elseifchepai==17zm_sz="G";elseifchepai==18zm_sz="H";elseifchepai==19zm_sz="J";elseifchepai==20zm_sz="K";elseifchepai==21zm_sz="L";elseifchepai==22zm_sz="M";elseifchepai==23zm_sz="N";elseifchepai==24zm_sz="P";elseifchepai==25zm_sz="Q";elseifchepai==26zm_sz="R";elseifchepai==27zm_sz="S";elseifchepai==28zm_sz="T";elseifchepai==29zm_sz="U";elseifchepai==30zm_sz="V";elseifchepai==31
zm_sz="W";elseifchepai==32zm_sz="X";elseifchepai==33zm_sz="Y";elseifchepai==34zm_sz="Z";endendshibiezm_sz=zm_sz;functionedit2_Callback(hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,"String")returnscontentsofedit2astext%str2double(get(hObject,"String"))returnscontentsofedit2asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit2_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,"BackgroundColor"),get(0,"defaultUicontrolBackgroundColor"))set(hObject,"BackgroundColor","white");endfunctionedit3_Callback(hObject,eventdata,handles)%hObjecthandletoedit3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,"String")returnscontentsofedit3astext%str2double(get(hObject,"String"))returnscontentsofedit3asadouble
%---Executesduringobjectcreation,aftersettingallproperties.functionedit3_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,"BackgroundColor"),get(0,"defaultUicontrolBackgroundColor"))set(hObject,"BackgroundColor","white");end%---ExecutesonbuttonpressinDCT.functionDCT_Callback(hObject,eventdata,handles)%hObjecthandletoDCT(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalbw;globalI;I1=I;%setFI=abs((fft2(I1)));NFI=255*mat2gray(FI);%归一化SFI=fftshift(NFI);imgray=rgb2gray(SFI);%灰阶grayImage=rgb2gray(I1);dctgrayImage=dct2(grayImage);colormap(gray(4));colorbar;dctgrayImage(abs(dctgrayImage)<0.1)=0;I2=idct2(dctgrayImage)/255;axes(handles.axes1);subplot(2,2,1),imshow(I1);title("原始图像");subplot(2,2,2),imshow(imgray),title("FFTof原始图像");subplot(2,2,3),imshow(log(abs(dctgrayImage)),[]);title("DCT变换灰度图像");subplot(2,2,4),imshow(I2),title("DCT逆变换的灰度图像");%---Executesonbuttonpressinreset.functionreset_Callback(hObject,eventdata,handles)
%hObjecthandletoreset(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)clear;clc;close'
您可能关注的文档
- cdio三级项目报告书
- 建设项目报告表送审版
- (1doc)河北省衡水市120兆瓦光伏生态农业大棚项目报告表doc_123900
- 生产计划体系和erp系统项目报告
- 土地整理项目报告
- 甘肃省张掖市甘州区年产吨土霉素钙预混剂和吨那西肽预混剂技术改造项目报告书全本
- 安徽合力股份有限公司轮式装载机一期建设项目报告书
- 建设项目报告表送审版
- 黄果树新城酒店及配套设施项目报告书(报批)环境影响评价报告全本
- 甘肃天水传染病医院项目报告书
- 上海某工业园开发有限公司企业战略规划项目报告1
- 特殊教育多方合作探索实践研究项目报告-上海静安区南阳学校
- 项目报告调查报告表格模板实用文档ppt培训课件
- 安徽合力股份有限公司轮式装载机一期建设项目报告书
- 临清市华旭面粉有限公司年产吨面粉项目报告表
- 循迹小车项目报告
- 夏殿村城中村改造项目报告书
- 青海省无电地区都兰县巴隆滩kwp太阳能光伏提水项目报告表(初稿)