partshiftz0.m

来自「基于matlab写的对人体的分割程序」· M 代码 · 共 40 行

M
40
字号
function Y = partshiftZ0(D,len,wid)%D = partshiftZ0(D,len,wid)%Pads the matrix with zeros%Assumes D is 0-degree alignedif nargin < 3,    wid = 0;end%if nargin > 3,    %Circularly shift the array so that the u,v, aligns up    %ie, if respIm(:,:,1,parent) has the canonical alignment, the most    %likely kid orientation should be shifted to be respIm(:,:,1,kid)%    [uu,vv] = pol2cart(([0:stepo:360+stepo]+90) * pi/180,1);%    [dummy,I] = max(uu*u + vv*v);%    D = circshift(D,[0 0 -(I-1)]);%end [imy, imx, imo] = size(D);stepo = 360/imo; %stepo = 15 degrees%[ux,vx] = pol2cart(([stepo:stepo:360]+180) * pi/180,wid); %Width offset%[uy,vy] = pol2cart(([stepo:stepo:360]+90) * pi/180,len); %Length offset[ux,vx] = pol2cart(([stepo:stepo:360]+180-stepo+180) * pi/180,wid); %Width offset[uy,vy] = pol2cart(([stepo:stepo:360]+90-stepo+180) * pi/180,len); %Length offsetvx = -vx;vy = -vy;xvec = round(ux+uy);yvec = round(vx+vy);maxv = round(max(abs([xvec yvec])));Y = zeros([imy imx imo]);;D = padarray(D,[maxv maxv 0],'both');for i = 1:imo,    Y(:,:,i) = D(maxv+yvec(i)+1:imy+maxv+yvec(i),maxv+xvec(i)+1:imx+maxv+xvec(i),i);end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?