上記のリンクに基づいて、クロスポイントを取得することはできましたが、2 つ以上の結果が得られることもあります。フレームごとに十字がわずかに移動した10枚の同様の画像があります。最初の画像のクロスポイントと比較することで、他の 9 枚の画像から非常に離れている残りの余分なピクセルを削除する方法はありますか? 動きが非常に小さいので、得られた2つ以上の結果から選択すべきピクセルは、前の画像のピクセルに最も近い値を持つピクセルであると言えますか? これを行う方法はありますか?ありがとう!
2 に答える
1
1つの結果が得られたら、それが正しいと確信していますか?もしそうなら、あなたは次のようなことをすることができます:
function pos = ChoosePosition(posGood, posA, posB)
%# posGood is the known good answer, posA and posB are candidates
if norm(posA - posGood) > norm(posB - posGood)
pos = posB;
else
pos = posA;
すべてを自動化したい場合は、すべての測定値をNx2マトリックスにまとめて、次のようにすることができます。
function [dist, idx] = RankPositions(pos)
%# pos should be an Nx2 matrix of x,y candidate positions
dist = pos - repmat(mean(pos), length(pos), 1); %# this is for octave, matlab might handle pos - mean(pos)
dist = norm(dist, 'rows');
[dist, idx] = sort(dist);
%# one liner:
%# [dist, idx] = sort(norm(pos - repmat(mean(pos), length(pos), 1)), 'rows'));
これにより、すべてのポイントの平均からの各ポイントの距離のランク付けされた品揃えが得られます。次に、(たとえば)10個の画像があるが、14個(またはその他)の結果が得られたことがわかっているので、実際の位置として最も低い10個の距離を取ることができます。
realpos = pos(idx(1:10));
于 2010-03-11T01:13:31.960 に答える
1
はい。座標で外れ値検出を実行してみることができます。これには、座標の最大の累積が十字の真の中心にあることが必要です。あなたが説明したことから、この仮定は満たされています。
%# Assume the cross should be around [0,0],
%# and you are storing the coordinates in a cell array
coordCell = {[0,0],[0.1,-0.05;4,4],[0.3,0.2;-2,5],[-0.25,0;2,-3]};
%# collect the coordinates of all images
allCoords = cat(1,coordCell{:});
%# take the median
medCoord = median(allCoords,1);
%# calculate the residuals, take the median of them
res2 = bsxfun(@minus,allCoords,medCoord).^2;
medRes = median(res2,1);
%# outliers are some factor above the median residual
%# Rousseeuw & Leroy, 1987, calculated how much for us (1.4826).
%# The factor k is the stringency (how many 'sigmas' do you have
%# to be away from the median to be counted an outlier)
%# A common value for k is 3.
k = 3;
testValue = bsxfun(@rdivide,res2,medRes*1.4826^2);
outlierIdx = any(testValue>k^2,2);
%# now you can throw out the outliers
allCoords(outlierIdx,:) = [];
于 2010-03-11T01:24:46.257 に答える