时间:2015-04-03 来源:

《数字图像处理原理与实践(MATLAB版)》一书之代码Part9 【系统运维】

function ipts=FastHessian_getIpoints(FastHessianData,1,3;    1,4,5,7;    5,8,9,11]+1;np=0; ipts=struct;% Build the response mapresponseMap=FastHessian_buildResponseMap(FastHessianData);% Find the maxima acrros scale and spacefor o = 1:FastHessianData.octaves    for i = 1:2        b = responseMap{filter_map(o,i+1)};        t = responseMap{filter_map(o, to find maxima across scale and space        [c,0:t.height-1);        r=r(:); c=c(:);                p=find(FastHessian_isExtremum(r, t, b,np]=FastHessian_interpolateExtremum(r(ind), t, b,np);        end    endend% Show laplacian and response maps with found interest-pointsif(verbose)    % Show the response map    if(verbose)        fig_h=ceil(length(responseMap)/3);        h=figure;  set(h,'Laplacian');        for i=1:length(responseMap),[responseMap{i}.width responseMap{i}.height]);            subplot(3,i); imshow(pic,'name',length(responseMap));        for i=1:length(responseMap),[responseMap{i}.width responseMap{i}.height]);            h_res(i)=subplot(3,i); imshow(pic,length(responseMap));    scaley=zeros(1,length(responseMap));    for i=1:length(responseMap)        scales(i)=responseMap{i}.filter*(2/15);        scalex(i)=responseMap{i}.width/size(FastHessianData.img,1);    end    for i=1:np        [t,ipts(i).y*scaley(ind)+1,'o',rand(1,%    I : An 2D image color or greyscale%  %  outputs,3)==3)    cR = .2989; cG = .5870; cB = .1140;    I=I(:,1)*cR+I(:,2)*cG+I(:,3)*cB;end% Make the integral imagepic = cumsum(cumsum(I,2);================================================================================

================================================================================

================================================================================

function orientation=SurfDescriptor_GetOrientation(ip,verbose)% This function SurfDescriptor_GetOrientation will ..%% [orientation] = SurfDescriptor_GetOrientation( ip,%    ip :  InterestPoint data,y, show additional information%  %  outputs,i]=ndgrid(-6:6, 5, 3, 1, 1, 3, 5, X + i * S, img);resY = gauss .* IntegralImage_HaarY(Y + j * S, 4 * S, resX),2*pi);% Repmat is used to check for all angles (x direction) and % all responses (y direction) without for-loops.cx=length(Ang); cy=length(ang1);ang1=repmat(ang1,[cx 1]);Ang =repmat(Ang,[1 cy]);resY =repmat(resY,1);sumY =  sum(resY.*check,ind]=max(R);orientation =  mod(atan2(sumY(ind),2*pi);if(verbose)    pica=zeros(13,1);    imshow(pica,辑录该书第431至第438页之代码网页切图制作,供有需要读者下载研究使用.至此全书代码发布已经接近尾声,网页切图制作希望这些源码能够对有需要的读者有所帮助.代码执行结果请参见原书配图div+css+js切图, np]=FastHessian_interpolateExtremum(r,  t,  b, np)% This function FastHessian_interpolateExtremum will ..%% [ipts,c,m,ipts,%    r : %    c : %    t : %    m : %    b : %    ipts : %    np : %  %  outputs, c, m, c, m, 1), 1), 1) ];%get the step distance between filtersfilterStep = fix((m.filter - b.filter));%If point is sufficiently close to the actual extremumif (abs(O(1)) < 0.5 && abs(O(2)) < 0.5 && abs(O(3)) < 0.5)    np=np+1;    ipts(np).x = double(((c + O(1))) * t.step);    ipts(np).y = double(((r + O(2))) * t.step);    ipts(np).scale = double(((2/15) * (m.filter + O(3) * filterStep)));    ipts(np).laplacian = fix(FastHessian_getLaplacian(m,c,c,m,r, t) - FastHessian_getResponse(m, c - 1,r + 1, t) - FastHessian_getResponse(m, c,r,r, t)) / 2;D = [dx;dy;ds];function H=FastHessian_BuildHessian(r, t, b)v = FastHessian_getResponse(m, c,r, t) + FastHessian_getResponse(m, c - 1,r + 1, t) + FastHessian_getResponse(m, c,r,r, t) - 2 * v;dxy = (FastHessian_getResponse(m, c + 1,r + 1, t) - FastHessian_getResponse(m, c + 1,r - 1, t)) / 4;dxs = (FastHessian_getResponse(t, c + 1) - FastHessian_getResponse(t, c - 1) - FastHessian_getResponse(b, c + 1,r, t)) / 4;dys = (FastHessian_getResponse(t, c) - FastHessian_getResponse(t, c) - FastHessian_getResponse(b, c,r - 1, t)) / 4;H = zeros(3, 1) = dxx;H(1, 3) = dxs;H(2, 2) = dyy;H(2, 1) = dxs;H(3, 3) = dss;

function rl=FastHessian_buildResponseLayer(rl,FastHessianData )%  %  inputs,%    rl : %  % Function is written by D.Kroon University of Twente ()step = fix( rl.step);                      % step size for this filterb = fix((rl.filter - 1) / 2 + 1);         % border for this filterl = fix(rl.filter / 3);                   % lobe for this filter (filter size / 3)w = fix(rl.filter);                       % filter sizeinverse_area = 1 / double(w * w);          % normalisation factorimg=FastHessianData.img;[ac,0:rl.height-1);ar=ar(:); ac=ac(:);% get the image coordinatesr = int32(ar * step);c = int32(ac * step);% Compute response componentsDxx =   IntegralImage_BoxIntegral(r - l + 1, 2 * l - 1,img) - IntegralImage_BoxIntegral(r - l + 1, 2 * l - 1, img) * 3;Dyy =   IntegralImage_BoxIntegral(r - b, w,img) - IntegralImage_BoxIntegral(r - fix(l / 2), l,img) * 3;Dxy = + IntegralImage_BoxIntegral(r - l, l,img) + IntegralImage_BoxIntegral(r + 1, l,img) ...      - IntegralImage_BoxIntegral(r - l, l,img) - IntegralImage_BoxIntegral(r + 1, l,img);% Normalise the filter responses with respect to their sizeDxx = Dxx*inverse_area;Dyy = Dyy*inverse_area;Dxy = Dxy*inverse_area;% Get the determinant of hessian response & laplacian signrl.responses = (Dxx .* Dyy - 0.81 * Dxy .* Dxy);rl.laplacian = (Dxx + Dyy) >= 0;

function D=FastHessian_BuildDerivative(r,t,b)% This function FastHessian_BuildDerivative will ..%% [D] = FastHessian_BuildDerivative( r,t,b )%  %  inputs,%    D : %  % Function is written by D.Kroon University of Twente ()dx = (FastHessian_getResponse(m, c + 1,r, t)) / 2;dy = (FastHessian_getResponse(m, c,r - 1, t)) / 2;ds = (FastHessian_getResponse(t, c) - FastHessian_getResponse(b, c, bUpright, img,bUpright,img )%  %  inputs,y, orientation)%    bUpright : If true not rotation invariant descriptor%    bExtended :  If true make a 128 values descriptor%    img : Integral image%    verbose : If true show additional information%  %  outputs, if coordinate 0, and scale 1[lb,-4:4); lb=lb(:); kb=kb(:);%Calculate descriptor for this interest point[jl,0:3); il=il(:)'; jl=jl(:)';ix = (il*5-8);jx = (jl*5-8);% 2D matrices instead of double for-loops, jlcx=length(lb); cy=length(ix);lb=repmat(lb,[1 cy]); kb=kb(:);ix=repmat(ix,[cx 1]); jx=jx(:);% Coordinates of samples (not rotated)l=lb+jx; k=kb+ix;%Get coords of sample point on the rotated axissample_x = round(X + (-l * S * si + k * S * co)); sample_y = round(Y + (l * S * co + k * S * si));                %Get the gaussian weighted x and y responsesxs = round(X + (-(jx+1) * S * si + (ix+1) * S * co));ys = round(Y + ((jx+1) * S * co + (ix+1) * S * si));gauss_s1 = SurfDescriptor_Gaussian(xs - sample_x, 2.5 * S);rx = IntegralImage_HaarX(sample_y, 2 * S, sample_x,img);                %Get the gaussian weighted x and y responses on the aligned axisrrx = gauss_s1 .* (-rx * si + ry * co);  rrx=reshape(rrx,cy);rry = gauss_s1 .* ( rx * co + ry * si);  rry=reshape(rry,cy);        % Get the gaussian scalingcx = -0.5 + il + 1; cy = -0.5 + jl + 1;gauss_s2 = SurfDescriptor_Gaussian(cx - 2, 1.5);if (bExtended)    % split x responses for different signs of y    check=rry >= 0; rrx_p=rrx.*check;  rrx_n=rrx.*(~check);        dx = sum(rrx_p); mdx = sum(abs(rrx_p),1);    % split y responses for different signs of x    check=(rrx >= 0); rry_p=rry.*check; rry_n=rry.*(~check);    dy = sum(rry_p,1);    dy_xn = sum(rry_n,1);else    dx = sum(rrx,1);    mdx = sum(abs(rrx),1);    dx_yn = 0; mdx_yn = 0;     dy_xn = 0; mdy_xn = 0;endif (bExtended)    descriptor=[dx;dy;mdx;mdy;dx_yn;dy_xn;mdx_yn;mdy_xn].* repmat(gauss_s2,[4 1]);end  len = sum((dx.^2 + dy.^2 + mdx.^2 + mdy.^2 + dx_yn + dy_xn + mdx_yn + mdy_xn) .* gauss_s2.^2);%Convert to Unit Vectordescriptor= descriptor(:) / sqrt(len);if(verbose)    for i=1:size(rrx,i),9]);        p2=reshape(rry(:,[9,9)*0.02;p2];        if(i==1)            pic=p;        else            pic=[pic ones(19,[]);endfunction an= SurfDescriptor_Gaussian(x, sig)an = 1 / (2 * pi * sig^2) .* exp(-(x.^2 + y.^2) / (2 * sig^2));

================================================================================

================================================================================

===========================================================

首先给出的是原书P438所列之程序源码网页切图制作,row,b)% This function FastHessian_getLaplacian will ..%% [an] = FastHessian_getLaplacian( a,column,%    a : %    row : %    column : %    b : %  %  outputs,%    I : An 2D image color or greyscale%  %  outputs,3)==3)    cR = .2989; cG = .5870; cB = .1140;    I=I(:,1)*cR+I(:,2)*cG+I(:,3)*cB;end% Make the integral imagepic = cumsum(cumsum(I,2);

================================================================================

================================================================================

================================================================================

function responseMap=FastHessian_buildResponseMap(FastHessianData)% Calculate responses for the first 4 FastHessianData.octaves:% Oct1: 9, 21, 27, 51% Oct3: 27, 75, 99,195% Oct5: 99,291,2) / FastHessianData.init_sample);h = (size(FastHessianData.img,   h,   9);    j=j+1; responseMap{j}=FastHessian_ResponseLayer(w, s, h, 21);    j=j+1; responseMap{j}=FastHessian_ResponseLayer(w, s, h / 2, 39);    j=j+1; responseMap{j}=FastHessian_ResponseLayer(w / 2, s * 2, h / 4, 75);    j=j+1; responseMap{j}=FastHessian_ResponseLayer(w / 4, s * 4, h / 8, 147);    j=j+1; responseMap{j}=FastHessian_ResponseLayer(w / 8, s * 8, h / 16, 291);    j=j+1; responseMap{j}=FastHessian_ResponseLayer(w / 16, s * 16,FastHessianData);end

================================================================================

function an=FastHessian_isExtremum(r,  t,  b,c,m,FastHessianData )%  %  inputs,%    an : %  % Function is written by D.Kroon University of Twente (July 2010)% bounds checklayerBorder = fix((t.filter + 1) / (2 * t.step));bound_check_fail=(r <= layerBorder | r >= t.height - layerBorder | c <= layerBorder | c >= t.width - layerBorder);% check the candidate point in the middle layer is above thresh candidate = FastHessian_getResponse(m,c,r + rr, t) >= candidate;          check2=FastHessian_getResponse(m, c + cc,r + rr, t) >= candidate;          check4=(rr ~= 0 || cc ~= 0);          an3 = ~(check1 | (check4 & check2) | check3);          an=an&an3;    endendfunction an=FastHessian_getResponse(a, column, doesn't contain this boundary clamp because if you % process one coordinate at the time you already returned on the boundary check)index=fix(scale*row) * a.width + fix(scale*column)+1;index(index<1)=1; index(index>length(a.responses))=length(a.responses);an=a.responses(index);

function an=IntegralImage_HaarY(row, size,column,img )%  %  inputs,%    an : The haar response in y-direction%  % Function is written by D.Kroon University of Twente (July 2010)an= IntegralImage_BoxIntegral(row, size / 2, img) - IntegralImage_BoxIntegral(row - size / 2, size / 2, img);       

function ipts = SurfDescriptor_DecribeInterestPoints(ipts, extended, verbose)% This function SurfDescriptor_DecribeInterestPoints will ..%% [ipts] = SurfDescriptor_DecribeInterestPoints( ipts,extended,%    ipts : Interest Points (x,scale)%    bUpright : If true not rotation invariant descriptor%    bExtended :  If true make a 128 values descriptor%    img : Integral image%    verbose : If true show useful information%  %  outputs,y,descriptor)%  % Function is written by D.Kroon University of Twente (July 2010)if (isempty(fields(ipts))), h_ang=figure; drawnow,'name', h_des=figure; drawnow,'name', verbose=false; end      ip=ipts(i);   % determine descriptor size   if (extended), figure(h_ang),8, end   ip.orientation=SurfDescriptor_GetOrientation(ip,verbose);   % Extract SURF descriptor   if(verbose), subplot(10,i), upright, img, figure(h_ang), ipts)% This function PaintSURF will display the image with the found  Interest points%% [] = PaintSURF( img,%    img : Image 2D color or greyscale%    ipts : The interest points%  % Function is written by D.Kroon University of Twente (July 2010)% Convert Image to doubleswitch(class(I));    case 'uint8'        I=double(I)/255;    case 'uint16'        I=double(I)/65535;    case 'int8'        I=(double(I)+128)/255;    case 'int16'        I=(double(I)+32768)/65535;    otherwise        I=double(I);endfigure, hold on;if (isempty(fields(ipts))), (ip.y)];   ptR = [(R * cos(ip.orientation)), myPen =[0 0 1]; else myPen =[1 0 0]; end      rectangle('Curvature','Position', pt(2)-R, S],myPen);       plot([pt(1),[pt(2),'g');end

function ResponseLayerData=FastHessian_ResponseLayer(width, step,height,filter )%  %  inputs,%    ResponseLayerData : %  % Function is written by D.Kroon University of Twente (July 2010)width=floor(width);height=floor(height);step=floor(step);filter=floor(filter);ResponseLayerData.width = width;ResponseLayerData.height = height;ResponseLayerData.step = step;ResponseLayerData.filter = filter;ResponseLayerData.responses = zeros(width * height,1);

================================================================================

================================================================================

由于上述代码调用的函数所占篇幅过长div+css+js切图,于是以下部分之代码并未辑录于书中,网页重构报价在此详细列出承接网站前端,以供有需要的读者参阅.特别说明,承接网站前端下面的程序源码由荷兰特温特大学的Dirk-Jan Kroon博士提供psd切图html,row,b)% This function FastHessian_getResponse will ..%% [an] = FastHessian_getResponse( a,column,%    a : %    row : %    column : %    b : %  %  outputs,Options)% This function OPENSURF, and describe% the points by a vector which is robust against (a little bit) rotation % , or make 3D reconstructions.%% This Matlab implementation of Surf is a direct translation of the % OpenSurf C# code of Chris Evans, well structured all inclusive SURF % implementations. On his site you can find Evaluations of OpenSURF % and the C# and C++ code. http://www.chrisevansdev.com/opensurf/% Chris Evans gave me permisson to publish this code under the (Mathworks)% BSD license.%% Ipts = OpenSurf(I,%   I : The 2D input image color or greyscale%   (optional)%   Options : A struct with options (see below)%% outputs, ipts.y : The landmark position%     Ipts.scale : The scale of the detected landmark%     Ipts.laplacian : The laplacian of the landmark neighborhood%     Ipts.orientation : Orientation in radians%     Ipts.descriptor : The descriptor for corresponding point matching%% options, Basic Surf Point Detection% % Load image%   I=imread('TestImages/test.png');% % Set this option to true if you want to see more information%   Options.verbose=false; % % Get the Key Points%   Ipts=OpenSurf(I, Ipts);%% Example 2, example2.m%% Example 3, example3.m%% Function is written by D.Kroon University of Twente (July 2010)% Add subfunctions to Matlab Search pathfunctionname='OpenSurf.m';functiondir=which(functionname);functiondir=functiondir(1:end-length(functionname));addpath([functiondir '/SubFunctions'])       % Process inputsdefaultoptions=struct('tresh','octaves','init_sample','upright','extended','verbose','var')),tags{i})),         warning('register_volumes:unknownoption',Options.verbose);% Describe the interest pointsif(~isempty(ipts))    ipts = SurfDescriptor_DecribeInterestPoints(ipts, Options.extended, Options.verbose);end

I1=imread('box.png');I2=imread('box_in_scene.png');Options.upright=true;Options.tresh=0.0001;Ipts1=OpenSurf(I1,Options);D1 = reshape([Ipts1.descriptor],[]); D2 = reshape([Ipts2.descriptor],[]); err=zeros(1,length(Ipts1));for i=1:length(Ipts1),i),1);        [err(i), ind]=sort(err); cor1=cor1(ind); cor2=cor2(ind);I = zeros([max(size(I1,size(I2,size(I1,2)]);I(1:size(I1,1:size(I1,size(I1,2)+size(I2, imshow(I,        c=rand(1,2)],'-',c)        plot([Ipts1(cor1(i)).x Ipts2(cor2(i)).x+size(I1,...            [Ipts1(cor1(i)).y Ipts2(cor2(i)).y],'Color', column, img)% This function IntegralImage_HaarX will ..%% [an] = IntegralImage_HaarX( row,size,%    row : %    column : %    size : %    img : %  %  outputs, column, size / 2, column - size / 2, size / 2, col,cols, size(img, size(img, size(img, size(img,1);A = img(max(r1+(c1-1)*sx,1));C = img(max(r2+(c1-1)*sx,1));% If coordinates are outside at the top or left, A - B - C + D);

================================================================================

================================================================================

================================================================================

点击次数:37705
作者:
web前端行业资讯
Web new NewsList
谷歌发布Tacotron2:能更简单地训练AI学习演讲 ,,2017年12月21日TensorFlow漏洞爆发背后:关于AI安全我们的傻与天真 ,,2017年12月21日Android端Edge浏览器新版发布:常规性能优化和BUG修复 ,,2017年12月21日三星开发出全球最小的DRAM芯片技术领先优势扩大 ,,2017年12月21日腾讯绝艺AI下一步将学习AlphaGozero自对弈训练 ,,2017年12月21日Facebook社交VR应用Spaces扩大覆盖面:入驻HTCVive ,,2017年12月21日设计图曝光:三星双屏折叠手机原来是这样的 ,,2017年12月21日微信支付和支付宝已成为世界移动支付的"老师" ,,2017年12月21日新专利表明FaceID未来有望装备在iPad、MacBook和iMac等设备 ,,2017年12月21日首批九个建议加入EE4J的项目 ,,2017年12月21日这就是SurfacePhone?微软可折叠手机概念图曝光 ,,2017年12月21日继“Angel”开源后,腾讯又开放TDinsight机器学习平台 ,,2017年12月21日谷歌母公司研发“闪光”网络技术无需铺设线缆 ,,2017年12月21日微软投资5千万美元利用人工智能对抗气候变化 ,,2017年12月21日谷歌中国2017:面向开发者的1年AI先行的1年 ,,2017年12月21日GreenKey加入Symphony软件基金会,将开源语音软件 ,,2017年12月21日腾讯发现者揭秘:怎么应对TensorFlow的安全风险,修复有多难 ,,2017年12月21日清华新成立两大交叉研究机构探索智能与未来 ,,2017年12月21日微软将AI融入生产力工具和搜索引擎与其它巨头竞争 ,,2017年12月21日Gfycat将利用机器学习技术创建高分辨率GIF动图 ,,2017年12月21日安全软件公司Avast开源化机器码反编译器RetDec ,,2017年12月21日谷歌开源TFGAN,让训练和评估GAN变得更加简单 ,,2017年12月21日社区对模块化不感兴趣时隔三周经典版FedoraServer27发布 ,,2017年12月21日Windows10加入OpenSSH客户端 ,,2017年12月21日FirefoxQuantum发布一个月安装量1.7亿 ,,2017年12月21日吴恩达宣布创业新项目已与富士康达成战略合作 ,,2017年12月21日Scala入门系列(十二):隐式转换2017年12月20日speedment入门教程2017年12月20日SLAM入门笔记(1):特征点的匹配2017年12月20日深入浅出了解frame和bounds2017年12月20日【ShareREC】ShareREC手游录像分享SDK双版本上线 【编程语言】2015年01月24日flash文件的压缩方法(swf文件压缩瘦身)2014年01月28日HTTP链接的正则表达式 【编程语言】2015年02月09日浏览器兼容问题IE兼容模式下SCRIPT1028:缺少标识符、字符串或数字 【移动开发】2015年06月24日如何获取JQUERYAJAX返回的JSON结果集实现代码2014年01月29日UVALive-4329Pingpong(树状数组)【移动开发】2015年08月14日windows服务创建步骤【编程语言】2014年12月01日手机客户端UI设计规范模版2014年01月28日js动画(animate)简单引擎代码示例2014年01月29日jquery放大镜效果超漂亮噢2014年01月29日CSS反转字符加密邮箱地址2014年01月29日win2008r2AD用户账户的批量导入方法2014年01月30日搭建一个wordpress网站需要做哪些工作【数据库】2015年02月15日【Cocos2d-x】PhysicsEditor的使用【编程语言】2015年01月19日Android短信验证码控件【编程语言】2014年11月10日C#界面之与WinForm自带控件对应的DEV控件(持续更新中...)【综合】2015年05月05日Google组建下一代开源网络 ,,2016年06月23日hdu1878欧拉回路(DFS+欧拉回路) 【综合】2015年08月14日javaScript中call函数的用法说明2014年01月28日如何高效地使用Launcher,如果你还没删的话【编程语言】2015年08月07日response.setContentType()的作用及MIME参数详解2014年01月29日淘宝前端JavaScript库KISSY1.2稳定版发布 ,,2016年06月23日php实现分页工具类分享2014年01月29日python计算最大优先级队列实例2014年01月29日iOSdCateGory类别的扩展---使用+理解 【数据库】2015年05月06日AndroidVolley获取磁盘已有缓存数据【编程语言】2015年05月18日jqgrid表格数据导出实例2014年01月29日感染linux脚本程序技术2014年01月29日Unity3D-图形性能优化:渲染统计窗口 【移动开发】2015年03月30日CentOS系统Squid反向代理【Web前端】2015年04月13日
我们保证
We guarantee
> psd效果文件手工切图,保证图片效果最好体积最小利于传输
> 100%手写的HTML(DIV+CSS)编码,绝对符合W3C标准
> 代码精简、css沉余量小、搜索引擎扫描迅速,网页打开快捷
> 应用Css Sprite能够减少HTTP请求数,提高网页性能
> 跨浏览器兼容(IE6、7、8、9,Firefox火狐,Chrome谷歌)