静止ウェブカメラでは、各フレーム内で移動している物体を連続して撮影しています。私は各フレームのサブピクセルシフトを推定しようとしていますが、見積もりはオフです。私の最初の試行で間違った見積もりがあったので、私はオブジェクトのマスクを作成し、背景を取り除いている間に動くオブジェクトだけでシフトを推定しようとしました。しかし、画素シフトの推定値は同じであった。Matlabの移動物体のサブピクセルシフト推定
function delta_est = estimate_shift(s,n)
h = waitbar(0, 'Shift Estimation');
set(h, 'Name', 'Please wait...');
nr = length(s);
delta_est=zeros(nr,2);
p = [n n] % only the central (aliasing-free) part of NxN pixels is used for shift estimation
p(1)
sz = size(s{1});
S1 = fftshift(fft2(s{1})); % Fourier transform of the reference image
for i=2:nr
waitbar(i/nr, h, 'Shift Estimation');
S2 = fftshift(fft2(s{i})); % Fourier transform of the image to be registered
S2(S2==0)=1e-10;
Q = S1./S2;
A = angle(Q); % phase difference between the two images
% determine the central part of the frequency spectrum to be used
beginy = floor(sz(1)/2)-p(1)+1;
endy = floor(sz(1)/2)+p(1)+1;
beginx = floor(sz(2)/2)-p(2)+1;
endx = floor(sz(2)/2)+p(2)+1;
% compute x and y coordinates of the pixels
x = ones(endy-beginy+1,1)*[beginx:endx];
x = x(:);
y = [beginy:endy]'*ones(1,endx-beginx+1);
y = y(:);
v = A(beginy:endy,beginx:endx);
v = v(:);
% compute the least squares solution for the slopes of the phase difference plane
M_A = [x y ones(length(x),1)];
r = M_A\v;
delta_est(i,:) = -[r(2) r(1)].*sz/2/pi;
end
close(h);
正しいサブピクセル推定に移行するためには、どのような変更が必要ですか?
あなたは本当にこれらの虚弱な画像から良い測定を期待していますか? [非公式に申し訳ありません] –
@ Yves Daoust超解像度のためにサブピクセルシフトを見つけようとしているので、意味があります。私がそれをベースにしている作品は、レンズレスカメラを使用し、彼の写真はこれらよりもはるかに悪いです。サブピクセルシフトを取得する方法はありますか? –
では、SNRが低いので、標準偏差がピクセルより大きく変動し、サブピクセル推定が幻想的になることが予想されます。 –