targetmotion.m

来自「ESTIMATION OF AIRCRAFT TRAJECTORY FROM I」· M 代码 · 共 34 行

M
34
字号
for t = 1:num_frames
    % Now let the target move also:
        tpixinx1 = floor((target_velx+.2*randn(1))*delt*t);
        tpixiny1 = floor((target_vely+.2*randn(1))*delt*t);  % Before interpolating extract the number of pixels moved
        txi1 = target_velx*delt*t - tpixinx1;
        tyi1 = target_vely*delt*t - tpixiny1;   % Interpolate on subpixels around the origin only
        [txgrid1 tygrid1] = meshgrid(1:23);     % meshgrid here generates a matrix of grid elements
        [txi1 tyi1] = meshgrid(txi1+1:txi1+23,tyi1+1:tyi1+23); % meshgrid generates 2 matrices with the x and y grids

        % Interpolate the intensity values first using interp2 -- a built in MATLAB command
        temp1 = interp2(txgrid1,tygrid1,tracking1,txi1,tyi1);

        % Insert the target at the location determined by the initial offset, and the number of whole pixels moved
        tx1 = tpixinx1+ target_x_initally-1;
        ty1 = tpixiny1 + target_y_initally-1;
        out(tx1-3:tx1+9,ty1-3:ty1+9,t) =  temp1(18:-1:6,18:-1:6) + out(tx1-3:tx1+9,ty1-3:ty1+9,t);

        % Now let the target move also:
        tpixinx = floor(target_velx*delt*t);
        tpixiny = floor(target_vely*delt*t);  % Before interpolating extract the number of pixels moved
        txi = target_velx*delt*t - tpixinx;
        tyi = target_vely*delt*t - tpixiny;   % Interpolate on subpixels around the origin only
        [txgrid tygrid] = meshgrid(1:11);     % meshgrid here generates a matrix of grid elements
        [txi tyi] = meshgrid(txi+1:txi+11,tyi+1:tyi+11); % meshgrid generates 2 matrices with the x and y grids

        % Interpolate the intensity values first using interp2 -- a built in MATLAB command
        temp = interp2(txgrid,tygrid,target1,txi,tyi);

        % Insert the target at the location determined by the initial offset, and the number of whole pixels moved
        tx = tpixinx + target_x_initally-1;
        ty = tpixiny + target_y_initally-1;
        out(tx:tx+6,ty:ty+6,t) = temp(9:-1:3,9:-1:3) + out(tx:tx+6,ty:ty+6,t);
 end % of loop on t

⌨️ 快捷键说明

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