# 边缘图像特征提取就是求取图像的梯度和特征幅值。

• 虫虫123456
了解作者
• matlab
开发工具
• 1.1KB
文件大小
• rar
文件格式
• 0
收藏次数
• 5 积分
下载积分
• 0
下载次数
• 2022-06-27 22:27
上传日期

TX_TD_PP_CORR2.rar
• TX_TD_PP_CORR2.m
3.8KB

function TX_TD_PP_CORR2 disp('请输入图象'); pause(1) [filename, pathname] = uigetfile( ... {'*.bmp','MATLAB Files (*.jpg)'; '*.m', 'M-files (*.m)'; ... '*.fig','Figures (*.fig)'; ... '*.mat','MAT-files (*.mat)'; ... '*.mdl','Models (*.mdl)'; ... '*.*', 'All Files (*.*)'}, ... '请输入图象'); [q,qq]=size(pathname); S='\'; [q1,qq1]=size(filename); RNAME=pathname; RNAME(qq+1)=S(1); RNAME(qq+2:qq+1+qq1)=filename(1:qq1); [Q,QN]=size(RNAME); FMT=RNAME(QN-2:QN); AA=imread(RNAME,FMT); %figure(1),imshow(dh1); AA1=rgb2gray(AA); AA=double(AA1)/255; figure(1),imshow(AA); [X,Y]=getpts; X(1)=min(X); X(2)=max(X); Y(1)=min(Y); Y(2)=max(Y); AAX=AA(Y(1):Y(2),X(1):X(2)); figure(2),imshow(AAX); [MM,NN]=size(AAX); YZ_AA=graythresh(AAX); AA_YZFG=(AAX<YZ_AA); figure(3),imshow(AA_YZFG); AA_YZFG=double(AA_YZFG); AA_EDGE=edge(AA_YZFG,'canny'); figure(4),imshow(AA_EDGE); %IDX_AA_EDGE=find(AA_EDGE); TD_AA=gradient(AAX); %TD_AA=gradient(AA); %AA_EDGE_XX_BYTD=TD_AA(IDX_AA_EDGE); disp('请输入图象'); pause(1) [filename, pathname] = uigetfile( ... {'*.bmp','MATLAB Files (*.jpg)'; '*.m', 'M-files (*.m)'; ... '*.fig','Figures (*.fig)'; ... '*.mat','MAT-files (*.mat)'; ... '*.mdl','Models (*.mdl)'; ... '*.*', 'All Files (*.*)'}, ... '请输入图象'); [q,qq]=size(pathname); S='\'; [q1,qq1]=size(filename); RNAME=pathname; RNAME(qq+1)=S(1); RNAME(qq+2:qq+1+qq1)=filename(1:qq1); [Q,QN]=size(RNAME); FMT=RNAME(QN-2:QN); BB=imread(RNAME,FMT); BB1=rgb2gray(BB); BB=double(BB1)/255; figure(5),imshow(BB); TD_BB=gradient(BB); [M,N]=size(BB); YZ_BB=graythresh(BB); BB_YZFG=(BB<YZ_BB); figure(6),imshow(BB_YZFG); BB_YZFG=double(BB_YZFG); BB_EDGE=edge(BB_YZFG,'canny'); figure(7),imshow(BB_EDGE); LM=fix(Y(1))-50; if LM<=0; LM=1; end HM=fix(Y(2))+50; if HM>M HM=M; end LN=fix(X(1))-50; if LN<=1 LN=1; end HN=fix(X(2))+50; if HN>N HN=N; end for i=LM:HM-MM+1 for j=LN:HN-NN+1 BB_XX=BB(i:i+MM-1,j:j+NN-1); %IDX_BB_EDGE_XX=find(BB_EDGE_XX); TD_BB=gradient(BB_XX); %BB_EDGE_XX_BYTD=TD_BB(IDX_BB_EDGE_XX); %[MB,NB]=size(BB_EDGE_XX_BYTD); %[MA,NA]=size(AA_EDGE_XX_BYTD); %C(i-LM+1,j-LN+1)=corr2(TD_AA,TD_BB); PX=i-LM+1; PY=j-LN+1; C(PX,PY)=corr2(TD_AA,TD_BB); end end CM=max(max(C)); [XC,YC]=size(C); figure(8),imshow(C); figure(9),mesh(C); for p=1:XC for q=1:YC if C(p,q)==CM pM=p; qN=q; end end end pMz=pM+LM-1; qNz=qN+LN-1; pMzz=pMz+MM-1; qNzz=qNz+NN-1; BBX=BB(pMz:pMzz,qNz:qNzz); %BB_YZFG_PP=BB_YZFG(pMz:pMzz,qNz:qNzz); %BB_EDGE_PP=BB_EDGE(pMz:pMzz,qNz:qNzz); figure(10),imshow(BBX); BBX_YZ=graythresh(BBX); BBX_YZFG=(BBX<BBX_YZ); BBX_YZFG=double(BBX_YZFG); BBX_EDGE=edge(BBX_YZFG,'canny'); figure(11),imshow(BBX_YZFG); figure(12),imshow(BBX_EDGE); pMz,pMzz qNz,qNzz CM

相关推荐