matlab特征匹配部分程序整理.doc
《matlab特征匹配部分程序整理.doc》由会员分享,可在线阅读,更多相关《matlab特征匹配部分程序整理.doc(20页珍藏版)》请在咨信网上搜索。
1、Affinefunction img2 = affine(img, r, sx, sy, a, b, xo, yo)R = cos(r) -sin(r) 0; sin(r) cos(r) 0; 0 0 1;S = sx a 0; b sy 0; 0 0 1;T2 = 1 0 -xo; 0 1 -yo; 0 0 1;T1 = 1 0 xo; 0 1 yo; 0 0 1;A = T1*R*S*T2;h,w=size(img);x,y = meshgrid(1:h,1:w);x=x(:);y=y(:);XP = x;y;ones(1,length(x);X = A*XP;z = find(X(1,:
2、)w-1);X(1,z) = w-1;z = find(X(1,:)h-1);X(2,z) = h-1;z= find(X(2,:)1.5);X(2,z) = 1.5;x = X(1,:);y = X(2,:);alpha = x - floor(x); %calculate alphas and betas for each pointbeta = y - floor(y);fx = floor(x); fy = floor(y);inw = fy + (fx-1)*h; %create index(索引) for neighboring pixelsine = fy + fx*h;isw
3、= fy+1 + (fx-1)*h;ise = fy+1 + fx*h;img2 = (1-alpha).*(1-beta).*img(inw) + . %interpolate(同样) (1-alpha).*beta.*img(isw) + . alpha.*(1-beta).*img(ine) + . alpha.*beta.*img(ise);img2 = reshape(img2,h,w);imagesc(img2);%build_pyramidfunction pyr,imp = build_pyramid(img,levels,scl)img2 = img;img2 = resam
4、ple_bilinear(img2,1/2); %expand to retain spatial frequencies%img2 = imresize(img2,2,bilinear); %expand to retain spatial frequenciessigma=1.5; %variance for laplacian filtersigma2=1.5; %variance for downsamplingsig_delta = (1.6-.6)/levels;for i=1:levels if i=1 img3 = img2; img2 = filter_gaussian(im
5、g2,7,.5); %slightly filter bottom level end impi=img2; A = filter_gaussian(img2,7,sigma); %calculate difference of gaussians B = filter_gaussian(A,7,sigma); pyri = A-B; %store result in cell array if i=1 img2 = img3; else B = filter_gaussian(img2,7,sigma2); %anti-alias for downsampling B = filter_ga
6、ussian(B,7,sigma2); end img2 = resample_bilinear(B,scl); %downsample for next levelend%show_pyramid(pyr) %show pyramid if desired%/function show_pyramid(pyr) close all h,w = size(pyr); for i=1: figure imagesc(pyri); colormap gray;end3 function key = construct_key(px, py, img, sz) pct = .75; h,w = si
7、ze(img); yoff,xoff = meshgrid(-1:1,-1:1); yoff = yoff(:)*pct; xoff = xoff(:)*pct; for i = 1:size(yoff,1) ctrx = px + xoff(i)*sz*2; %method using interpolated values ctry = py + yoff(i)*sz*2; y,x = meshgrid(ctry-sz:sz/3:ctry+sz,ctrx-sz:sz/3:ctrx+sz); y=y(:); x=x(:); t = 0; c = 0; for k=1:size(y,1) if
8、 x(k)1 & y(k)1 t = t + interp(img,x(k),y(k); c=c+1; end end if c=0 c end t = t/c; key(i) = t; end key = key/sum(key);4detect_featuresfunction features,pyr,imp,keys = detect_features(img, scl, disp_flag, thresh, radius, radius2, radius3, min_sep, edgeratio) if exist(scl) scl = 1.5; end if exist(thres
9、h) thresh = 3; end if exist(radius) radius = 4; end if exist(radius2) radius2 = 4; end if exist(radius3) radius3 = 4; end if exist(min_sep) min_sep = .04; end if exist(edgeratio) edgeratio = 5; end if exist(disp_flag) disp_flag = 0; end if size(img,3) 1 img = rgb2gray(img); end % Computation of the
10、maximum number of levels: Lmax = floor(min(log(2*size(img)/12)/log(scl); %build image pyramid and difference of gaussians filter response pyramid pyr,imp = build_pyramid(img,Lmax,scl); %get the feature points pts = find_features(pyr,img,scl,thresh,radius,radius2,disp_flag,1); %classify points and cr
11、eate sub-pixel and sub-scale adjustments features,keys = refine_features(img,pyr,scl,imp,pts,radius3,min_sep,edgeratio);5drawboxfunction drawbox(ang,sz,xc,yc,clr) ang=-ang; b = 1 1; -1 1; -1 -1; 1 -1; 1 1 * sz; t = sin(ang) cos(ang);cos(ang) -sin(ang); b = (t*b); b(:,2)=b(:,2)+xc; b(:,1)=b(:,1)+yc;
12、plot(b(:,2),b(:,1),color,clr); 6 eliminate_edgesfunction f2,k2 = eliminate_edges( features,keys);%消除边缘f2 = features(find(features(:,5)0),:);k2 = keys(find(features(:,5)0),:); 7 f_classfunction cl, or=f_class(r)a = r(length(r) r r(1) r(2);b = (a(1:length(r)+1)-a(2:length(r)+2);b = b./abs(b);d = ones(
13、1,length(r).*(b(1:length(r)b(2:length(r)+1);c = find(d);m = (r(c) c;m = sortrows(m,1);or(1) = (m(1,2)-1)*pi/length(r)*2;cl = 2;dst = m(:,1)-m(1,1);i=find(dst thresh); yp=yp+radius; xp=xp+radius;pts = yp+(xp-1)*h;%create offset list for immediate neighborhoodz=ones(3,3); z(2,2)=0;y,x=find(z);y=y-2; x
14、=x-2;if size(pts,2)size(pts,1) pts = pts;end%test for max within immediate neighborhoodif size(pts,1)0 maxima=ones(length(pts),1); for i=1:length(x) pts2 = pts + y(i) + x(i)*h; maxima = maxima & img(pts)img(pts2); end xp = xp(find(maxima); %save maxima yp = yp(find(maxima); pts = yp+(xp-1)*h; %creat
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- matlab 特征 匹配 部分 程序 整理
1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前自行私信或留言给上传者【天****】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时私信或留言给本站上传会员【天****】,需本站解决可联系【 微信客服】、【 QQ客服】,若有其他问题请点击或扫码反馈【 服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【 版权申诉】”(推荐),意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:4008-655-100;投诉/维权电话:4009-655-100。