Error using ==> corr at 103 X and Y must have the same number of rows. Error in ==> motion_corr2 at 108 [a, F] = corr(p1, p2, C, 'sdthresh', sdthresh, corr_opts{:}); Error in ==> symmetric_match at 3 [p2a,p1a,a2,Fa] = motion_corr2(f2,k2,f1,k1,im2,
11 views (last 30 days)
Show older comments
Error using ==> corr at 103 X and Y must have the same number of rows.
Error in ==> motion_corr2 at 108 [a, F] = corr(p1, p2, C, 'sdthresh', sdthresh, corr_opts{:});
Error in ==> symmetric_match at 3 [p2a,p1a,a2,Fa] = motion_corr2(f2,k2,f1,k1,im2,
function corr.m
if (nargin < 2) || ischar(varargin{1})
corrXX = true;
y = x;
p2 = p1;
% Both x and y given, compute the pairwise rank cross correlations
else
y = varargin{1};
varargin = varargin(2:end);
if size(y,1) ~= n
error('stats:corr:InputSizeMismatch', ...
'X and Y must have the same number of rows.');
end
corrXX = false;
p2 = size(y,2);
end
outClass = superiorfloat(x,y);
function motion_corr2.m
function [p1, p2 , a, F] = motion_corr2(f1,k1,f2,k2,im1,im2, varargin)
[p1, ...
smoothing, ...
nmsrad, ...
rthresh, ...
rthresh2, ...
sdthresh, ...
dthresh, ...
corr_opts] = process_options(varargin, 'p1', [], ...
'smoothing', 2, ...
'nmsrad', 2, ...
'rthresh', 0.3, ...
'rthresh2', nan, ...
'sdthresh', 1e-2, ...
'dthresh', 30);
if (isnan(rthresh2)) rthresh2 = rthresh / 2.0; end
C = make_cost(k1,k2);
p1 = f1(:,1:2); %create homogeneous coordinates
p2 = f2(:,1:2);
p1(:,3) = 1;
p2(:,3) = 1;
[a, F] = corr(p1, p2, C, 'sdthresh', sdthresh, corr_opts{:});
symmetric_match.m
[p2a,p1a,a2,Fa] = motion_corr2(f2,k2,f1,k1,im2,im1, 'sdthresh', 1e-4);
'done with #1';
[p1b,p2b,a1,Fb] = motion_corr2(f1,k1,f2,k2,im1,im2,'sdthresh', 1e-4);
r=zeros(size(a1,1),1);
for i=1:size(a1,1)
if a1(i)>0
if a2(a1(i)) == i
r(i)=1;
end
end
end
showfeatures(f2,im2);
showfeatures(f1,im1);
hold on
for i=1:size(p1b,1)
x = p1b(i,1);
y = p1b(i,2);
if a1(i)~=0 & r(i)>0
u = p2b(a1(i),1)-p1b(i,1);
v = p2b(a1(i),2)-p1b(i,2);
plot([x x+u],[y y+v],'y');
end
end
pt1 = p1b(find(r),:);
pt2 = p2b(a1(find(r)),:);
w1 = f1(find(r),4);
w2 = f2(a1(find(r)),4);
g=sampson(pt1, pt2, Fb);
m = mean(g);
fk1 = k1(find(r),:);
fk2 = k2(a1(find(r)),:);
for i=1:size(fk1,1)
c(i) = sum((fk1(i,:)-fk2(i,:)).^2);
end
cavg = mean(c);
pt1 = pt1(:,1:2)';
pt2 = pt2(:,1:2)';
pt1 = (pt1-1)/2;
pt2 = (pt2-1)/2;
w1 = (w1/2)';
w2 = (w2/2)';
2 Comments
Walter Roberson
on 21 Dec 2012
Edited: Walter Roberson
on 21 Dec 2012
Please read the guide to tags and add good tags to this question. "confuse" does not describe anything about the topic of your question. See http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags
Walter Roberson
on 21 Dec 2012
Do not open new questions for the same topic. Instead, reply with the updated information.
Answers (1)
Walter Roberson
on 21 Dec 2012
In your routine symmetric_match, the first thing you do is call motion_corr2, passing in a number of parameters. The first and third parameters, f1 and f2, need to have the same number of rows but they do not.
Is symmetric_match a function or a script? Did you forget to paste the "function" line from the start of the routine? How are you running symmetric_match ?
8 Comments
Walter Roberson
on 21 Dec 2012
Why do you think that detect_features is going to find exactly the same number of positive features for img1 and it would for img2 ? If the number of detected features is different by even 1, then you are going to be trying to do motion correlation between different number of features, and that is going to cause the problems you are getting with corr()
See Also
Categories
Find more on Tracking and Sensor Fusion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!