ImageVerifierCode 换一换
格式:DOC , 页数:20 ,大小:107.50KB ,
资源ID:2283415      下载积分:10 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/2283415.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(matlab特征匹配部分程序整理.doc)为本站上传会员【天****】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

matlab特征匹配部分程序整理.doc

1、Affine function 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

2、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,:)>w-1); X(1,z) = w-1; z = find(X(1,:)<=1); X(1,z) = 1.5; z= find(X(2,:)>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 =

3、 x - floor(x); %calculate alphas and betas for each point beta = y - floor(y); fx = floor(x); fy = floor(y); inw = fy + (fx-1)*h; %create index(索引) for neighboring pixels ine = fy + fx*h; isw = fy+1 + (fx-1)*h; ise = fy+1 + fx*h; img2 = (1-alpha).*(1-beta).*img(inw) + ... %interpolate

4、同样) (1-alpha).*beta.*img(isw) + ... alpha.*(1-beta).*img(ine) + ... alpha.*beta.*img(ise); img2 = reshape(img2,h,w); imagesc(img2); %build_pyramid function [pyr,imp] = build_pyramid(img,levels,scl) img2 = img; img2 = resample_bilinear(img2,1/2); %expand to reta

5、in spatial frequencies %img2 = imresize(img2,2,'bilinear'); %expand to retain spatial frequencies sigma=1.5; %variance for laplacian filter sigma2=1.5; %variance for downsampling sig_delta = (1.6-.6)/levels; for i=1:levels if i==1 img3 = img2; img2 = filte

6、r_gaussian(img2,7,.5); %slightly filter bottom level end imp{i}=img2; A = filter_gaussian(img2,7,sigma); %calculate difference of gaussians B = filter_gaussian(A,7,sigma); pyr{i} = A-B; %store result in cell array if i==1 img2

7、 img3; else B = filter_gaussian(img2,7,sigma2); %anti-alias for downsampling B = filter_gaussian(B,7,sigma2); end img2 = resample_bilinear(B,scl); %downsample for next level end %show_pyramid(pyr) %show pyramid if desired %/////////////////////////

8、////////////////////////////////////////////////////// function show_pyramid(pyr) close all [h,w] = size(pyr); for i=1: figure imagesc(pyr{i}); colormap gray; end 3\ function key = construct_key(px, py, img, sz) pct = .75; [h,w] = size(img);

9、 [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);

10、 y=y(:); x=x(:); t = 0; c = 0; for k=1:size(y,1) if 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

11、 t/c; key(i) = t; end key = key/sum(key); 4\detect_features function [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('thresh') thresh

12、 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; e

13、nd if ~exist('disp_flag') disp_flag = 0; end if size(img,3) > 1 img = rgb2gray(img); end % Computation of the maximum number of levels: Lmax = floor(min(log(2*size(img)/12)/log(scl))); %build image pyramid and difference of gaussians filter

14、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 create sub-pixel and sub-scale adjustments [features,keys] = refine_features(img,pyr,scl,imp,pts,radi

15、us3,min_sep,edgeratio); 5\drawbox function 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; plot(b(:,2),b(:,1),'color',clr); 6\ eliminate_edges

16、 function [f2,k2] = eliminate_edges( features,keys);%消除边缘 f2 = features(find(features(:,5)>0),:); k2 = keys(find(features(:,5)>0),:); 7\ f_class function [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(1,length(r)).*(b(

17、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 < .3*(max(r)-min(r))); cl = length(i); or = (m(i,2)-1)*pi/length(r)*2; 8/ filter_gaussian function image_out = filter_gaussian(img,o

18、rder,sig) img2 = img; for i=1:floor(order/2) %pad image borders with enough for filter order [h,w] = size(img2); img2 = [img2(1,1) img2(1,:) img2(1,w); img2(:,1) img2 img2(:,w); img2(h,1) img2(h,:) img2(h,w)]; end f = gauss1d(order,sig); %create

19、 filter coefficient matrix%创建滤波器系数矩阵 image_out = conv2(img2,f,'valid'); % do the filtering image_out = conv2(image_out,f','valid'); % do the filtering function f = gauss1d(order,sig) f=0; i=0; j=0; %generate gaussian coefficients %产生高斯系数 for x = -fix(order/2):1:fix(order/2) i = i

20、 1; f(i) = 1/2/pi*exp(-((x^2)/(2*sig^2))); end f = f / sum(sum(f)); %normalize filter%正常化滤波 function f = gauss2d(order,sig) f=0; i=0; j=0; %generate gaussian coefficients %产生高斯系数 for x = -fix(order/2):1:fix(order/2) j=j+1; i=0; for y = -fix(order/2):1:fix(order/2)

21、 i=i+1; f(i,j) = 1/2/pi*exp(-((x^2+y^2)/(2*sig^2))); end end f = f / sum(sum(f)); %normalize filter%正常化滤波 9/ filter_laplacian function image_out = filter_gaussian(img,order,sig) h1 = gauss1d(order,sig); %create filter coefficient matrix h2 = conv2(h1, [.5 0 -.5]); h3 = conv

22、2(h2,h2); h3 = h3/sum(abs(h3)); order = length(h3); img2 = img; for i=1:floor(order/2) %pad image borders with enough for filter order [h,w] = size(img2); img2 = [img2(1,1) img2(1,:) img2(1,w); img2(:,1) img2 img2(:,w); img2(h,1) img2(h,:) img2(h,w

23、)]; end image_out = conv2(img2,h3','valid'); % do the filtering image_out = image_out(:,floor(order/2)+1:end-floor(order/2)); image_out2 = conv2(img2,h3,'valid'); % do the filtering image_out2 = image_out2(floor(order/2)+1:end-floor(order/2),:); image_out = -image_out-image_out2; function f

24、 gauss1d(order,sig) f=0; i=0; j=0; %generate gaussian coefficients for x = -fix(order/2):1:fix(order/2) i = i + 1; f(i) = 1/2/pi*exp(-((x^2)/(2*sig^2))); end f = f / sum(sum(f)); %normalize filter function f = gauss2d(order,sig) f=0; i=0; j=0; %generate gaussian coefficients

25、 for x = -fix(order/2):1:fix(order/2) j=j+1; i=0; for y = -fix(order/2):1:fix(order/2) i=i+1; f(i,j) = 1/2/pi*exp(-((x^2+y^2)/(2*sig^2))); end end f = f / sum(sum(f)); %normalize filter 10/ find_extrema function [mx] = find_extrema(img,thresh,radius) %img

26、 abs(img); [h,w] = size(img); % get interior image subtracting radius pixels from border p = img(radius+1:h-radius, radius+1:w-radius); %get pixels above threshold [yp,xp] = find(p>thresh); yp=yp+radius; xp=xp+radius; pts = yp+(xp-1)*h; %create offset list for immediate neighborhood

27、 z=ones(3,3); z(2,2)=0; [y,x]=find(z); y=y-2; x=x-2; if size(pts,2)>size(pts,1) pts = pts'; end %test for max within immediate neighborhood if size(pts,1)>0 maxima=ones(length(pts),1); for i=1:length(x) pts2 = pts + y(i) + x(i)*h; maxima =

28、maxima & img(pts)>img(pts2); end xp = xp(find(maxima)); %save maxima yp = yp(find(maxima)); pts = yp+(xp-1)*h; %create new index list of good points end %create offset list for radius of pixels [y,x]=meshgrid(-20:20,-20:20

29、); z = (x.^2+y.^2)<=radius^2 & (x.^2+y.^2)>(1.5)^2; %include points within radius without immediate neighborhood [y,x]=find(z); x=x-21; y=y-21; %create offset list for ring of pixels [y2,x2]=meshgrid(-20:20,-20:20); z = (x2.^2+y2.^2)<=(radius)^2 & (x2.^2+y2.^2)>(radius-1)^2; [y2,x2]=

30、find(z); x2=x2-21; y2=y2-21; maxima = ones(length(pts),1); %test within radius of pixels (done after first test for slight speed increase) if size(pts,1)>0 for i = 1:length(x) pts2 = pts + y(i) + x(i)*h; maxima = maxima & img(pts)>img(pts2); %test points end

31、 xp = xp(find(maxima)); %save maxima from immediate neighborhood yp = yp(find(maxima)); pts = yp+(xp-1)*h; %create new index list mx = [yp xp]; else mx = []; end 11\ find_features function maxima = find_features(pyr

32、 img, scl, thresh, radius, radius2, disp_flag, img_flag) % pts = find_features(pyr,img,scl,thresh,radius,radius2,disp_flag,1); levels = size(pyr); levels = levels(2); mcolor = [ 0 1 0; %color array for display of features at different scales 略 [himg,wimg] = size(i

33、mg); %get size of images [h,w] = size(pyr{2}); for i=2:levels-1 [h,w] = size(pyr{i}); [h2,w2] = size(pyr{i+1}); %find maxima mx = find_extrema(pyr{i},thresh,radius); %find maxima at current scale level mx2 =

34、 round((mx-1)/scl) + 1; %find coords in level above mx_above = neighbor_max(pyr{i},pyr{i+1},mx,mx2,radius2); %do neighbor comparison in scale space above if i>1 mx2 = round((mx-1)*scl) + 1; %find coor

35、ds in level below mx_below = neighbor_max(pyr{i},pyr{i-1},mx,mx2,radius2); %do comparison in scale below maxima{i} = plist(mx, mx_below & mx_above); %get coord list for retained maxima and minima else maxima{i} = plist(mx, mx_above); end

36、 %find minima %if i==11, % keyboard; %end; mx = find_extrema(-pyr{i},thresh,radius); %find minima at current scale level mx2 = round((mx-1)/scl) + 1; %find coords in level above mx_above = neighbor_m

37、ax(-pyr{i},-pyr{i+1},mx,mx2,radius2); %do neighbor comparison in scale space above if i>1 mx2 = round((mx-1)*scl) + 1; %find coords in level below mx_below = neighbor_max(-pyr{i},-pyr{i-1},mx,mx2,radius2); %do comparison in scale below

38、 mxtemp = plist(mx, mx_below & mx_above); %get coord list for retained maxima and minima else mxtemp = plist(mx, mx_above); end maxima{i} = [maxima{i}; mxtemp]; %combine maxima and minima into list for return %di

39、splay results if desired if disp_flag > 0 figure if img_flag == 0 tmp=resample_bilinear(img,himg/h); imagesc(tmp); colormap gray; show_plist(maxima{i},mcolor(mod(i-1,7)+1,:),'+'

40、); else imagesc(pyr{i}); colormap gray; show_plist(maxima{i},mcolor(mod(i-1,7)+1,:),'+'); end end end % Compare a vector of pixels with its neighbors in another scale function v = neighbor_max(img1,img2,i,i2,radius)

41、 % i and i2 are column vectors of r,c coords if (size(i2,1))==0 | size(img2,1)<11 | size(img2,2)<11 v=zeros(length(i),1); else [h,w] = size(img1); [h2,w2] = size(img2); [y,x]=meshgrid(-20:20,-20:20); %create set of offs

42、ets within radius z = (x.^2+y.^2)<=radius^2; [y,x]=find(z); x=x-21; y=y-21; radius=ceil(radius); bound = ones(size(i2,1),2)*[h2-radius 0;0 w2-radius]; %create boundary listing i2 = i2 - ((i2 > bound).*(i2-bound+1)); %

43、test bounds to make all points within image i2 = i2 + ((i2 < radius+1).*(radius-i2+1)); i2 = vec(i2,h2); %create indices from x,y coords i = vec(i,h); p = img1(i); res = ones(length(i),1); for j=1:lengt

44、h(x) %check against all points within radius itest = i2 + x(j) + h2*y(j); p2 = img2(itest); res = res & (p>=p2); end v = res; %store results in bina

45、ry vector end function v = vec(points,h) y = points(:,1); x = points(:,2); v = y + (x-1)*h; %create index vectors function p = plist(points, flags) p = points(find(flags),:); 12\ fit_parabola function [c]=fit_parabola(x1, x2, x3, y1, y2, y3) z = [x1^2 x1 1; x2^2 x2 1; x3^2

46、 x3 1]; c = inv(z)*[y1; y2; y3]; 13/ fit_paraboloid function [yctr,xctr] = fit_paraboloid(data) %Create Solution Matrix [yp,xp] = meshgrid(-1:1,-1:1); yp=yp(:); xp=xp(:); M=zeros(9,6); for i=1:length(yp) x=xp(i); y=yp(i); M(i,:) = [x^2 y^2 x*y x y 1]; end g = data'; g = g(:); c

47、f = inv(M'*M)*M'*g; a=cf(1); b=cf(2); c=cf(3); d=cf(4); e=cf(5); xctr = (-2*b*d+e*c)/(4*a*b-c*c); yctr = (-2*a*e-d*c)/(4*a*b-c*c); %A = [a c/2; c/2 b]; %[u,s,v] = svd(A); 14/ fmransac_test2 clear p im hc hcm hcmf hcmfi; % Play with these parameters: keytype = 2; % The type of feature key

48、 to use gdorder = 4; % The highest order Gaussian derivative filters to use gdsigma = 5; % The standard deviation of the Gaussian derivatives steer = 0; % Steer filters in gradient direction for rotational invariance % Create an image with lots of "inside" and "outside" corners in it

49、 im1 = corners('prob', 0.5); [ny, nx] = size(im1); if 0 % Transform the image twice T = maketform('projective', ... [0 0; ny 0; ny nx; 0 nx], ... [0 0; ny 0.3*nx; ny 0.7*nx; 0 nx]); im2 = imtransform(im1, T, 'FillValues', 255); else im2 = affine(im1, pi/2, 1, 1, 0, 0, nx/2, ny/

50、2); end % Run the Harris corner detector on both images p1 = harris_pts(im1, 'smoothing', 1.0, 'nmsrad', 2, 'relthresh', 0.1); % Project the corners in the first image through the transformation p2 = fliplr(tformfwd(fliplr(p1), T)); % Compute the feature keys switch keytype case 0 % Test

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服