在matlab中使用互相关的帧之间的对象位移

时间:2016-01-03 16:57:59

标签: image matlab templates

我想估计物体上的位移(此物体是沿图像的曲线),我想知道它在连续帧之间使用互相关移动了多少:

我有一个问题是确定模板的正确尺寸,当我更改模板尺寸时,它会给出不同的结果,你能帮我吗

   a = imread('001.jpg');
   a1 = imread('002.jpg');

  im1 =  imcrop(a,[500 400 200 100]); % Template 
  im2 =  imcrop(a1,[300 300 820 360]);

  c = normxcorr2(im1,im2);
  figure, surf(c), shading flat



  %offset found by correlation
 [max_c, imax] = max(abs(c(:)));
 [ypeak, xpeak] = ind2sub(size(c),imax(1));
 corr_offset = [(xpeak-size(im1,2))
           (ypeak-size(im1,1))];

  % relative offset of position of subimages
   rect_offset = [(rect_a1(1)-rect_a(1))
           (rect_a1(2)-rect_a(2))];

    % total offset
   offset = corr_offset + rect_offset;
    xoffset = offset(1);
   yoffset = offset(2); 

0 个答案:

没有答案