1

链接文本

根据上面的链接,我设法获得了交叉点,但有时我得到了 2 个或更多结果。我有 10 幅相似的图像,每帧中的十字都略微移动。有没有一种方法可以通过将其与第一张图像的交叉点进行比较来去除与其他 9 张图像非常偏离的多余像素?由于移动非常小,是否应该说应该从我获得的 2 个或更多结果中选择的像素应该是与上一张图像的像素具有最接近值的像素?有没有办法做到这一点?谢谢!

4

2 回答 2

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 回答