1 | %VGG_SINGF_FROM_FF Linearly combines two 3x3 matrices to a singular one.
|
---|
2 | %
|
---|
3 | % a = vgg_singF_from_FF(F) computes scalar(s) a such that given two 3x3 matrices F{1} and F{2},
|
---|
4 | % it is det( a*F{1} + (1-a)*F{2} ) == 0.
|
---|
5 |
|
---|
6 | function a = vgg_singF_from_FF(F)
|
---|
7 |
|
---|
8 | % precompute determinants made from columns of F{1}, F{2}
|
---|
9 | for i1 = 1:2
|
---|
10 | for i2 = 1:2
|
---|
11 | for i3 = 1:2
|
---|
12 | D(i1,i2,i3) = det([F{i1}(:,1) F{i2}(:,2) F{i3}(:,3)]);
|
---|
13 | end
|
---|
14 | end
|
---|
15 | end
|
---|
16 |
|
---|
17 | % Solve The cubic equation for a
|
---|
18 | a = roots([-D(2,1,1)+D(1,2,2)+D(1,1,1)+D(2,2,1)+D(2,1,2)-D(1,2,1)-D(1,1,2)-D(2,2,2)
|
---|
19 | D(1,1,2)-2*D(1,2,2)-2*D(2,1,2)+D(2,1,1)-2*D(2,2,1)+D(1,2,1)+3*D(2,2,2)
|
---|
20 | D(2,2,1)+D(1,2,2)+D(2,1,2)-3*D(2,2,2)
|
---|
21 | D(2,2,2)]);
|
---|
22 | a = a(abs(imag(a))<10*eps);
|
---|
23 |
|
---|
24 | return |
---|