In two processed images, one shows 3 centroids and another shows 4 centroids. How to eliminate this extra centroids from centroids array.

2 次查看(过去 30 天)
I have two images taken from two stereo cameras in which one contain three white objects and another contain four white objects. I processed both images to find out the centroids. Ofcourse first one give three centroids and second give four centroids and I stored these centroids into arrays called 'centroids1' and 'centroids2'. Now, I want two things here. First, if in 'centroids1' first entry is for object 1, then in 'centroids2' also, first entry should be for object 1 only, likewise for all objects. Second, I want to eliminate any extra centroids present in any of 'centroids' array i.e. I want only corresponding centriods in both 'centroids1' and 'centroids2' array.
I'm attaching my images and code here.

采纳的回答

Dima Lisin
Dima Lisin 2016-2-29
Hi Naseeb,
The triangulate function can return reprojection errors, which can tell you whether or not a match is correct.
  1 个评论
Naseeb Gill
Naseeb Gill 2016-3-1
Thanks Dima, As you suggest triangulate function, using this clue I tried to solve my problem and I came out with this code. It works similar to as I want.
load('C:\Users\Naseeb\Desktop\centroids1.mat');
load('C:\Users\Naseeb\Desktop\centroids2.mat');
B = centroids1; % center of white objects from left cam
A = centroids2; % center of white objects from right cam
n = size(A,1);
m = size(B,1);
s = n-m;
if s >= 0
A(m+1:n,:)=[];
else
B(n+1:m,:)=[];
end
r = reprojectionErrors; % obtain from triangulate function
C = cat(2,B,r(:,1)); % for left image
D = cat(2,A,r(:,1)); % for right image
nA=[];
for j=1:size(C,1)
if (C(j,3)<3);
nA=[nA; C(j,:)];
end
end
nB=[];
for j=1:size(D,1)
if (D(j,3)<3);
nB=[nB; D(j,:)];
end
end
Suggest something if I missed or can be add in this. Also, I'm using triangulate function to find center of white objects,so suggest something regarding how to approach effectively please.
Thanks.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Computer Vision Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by