Effacer les filtres
Effacer les filtres

Solve least square error optimization

2 vues (au cours des 30 derniers jours)
Kees de Kapper
Kees de Kapper le 2 Déc 2019
Commenté : Adam Danz le 3 Déc 2019
Dear all,
I've got the following optimization problem:
D1 = F1 (d1), D2 = F2(d2), D3 = F3(d3) are seperate functions for three different measurements
d1=ds1*x; d2=ds2*x; d3=ds3*x; ds123 is the sample measurement, and the x is the correction of the error.
To find the optimal correction value x, the following should be minimized:
min( (D1-D2)^2 + (D2-D3)^2 + (D3-D1)^2 , x)
This might be done using an optimization routine but becomes very slow if the number of measurements increases (in case of an image).
Is there a straight forward way to perfom, which is considerably faster?
many thanks in advance.
all the best,
Kees
  5 commentaires
Kees de Kapper
Kees de Kapper le 3 Déc 2019
Thanks for considering my question.
This is basically my code:
function Main(ImgData)
% FuncModel and ParameterSet are known variables
for d = 1:3
F{d} = cfit(FuncModel, ParameterSet{d});
end;
x = ones(size(ImgData, 1),size(ImgData, 2));
x0 = 1;
for n1 = 1:size(ImgData, 1)
for n2 = 1:size(ImgData, 2)
[x(n1,n2),fval,exitflag,output] = fmincon(@(x)evalfnc(x, F,ImgData(n1,n2)), x0, [],[],[],[], 0.5, 1.5, []);
end;
end;
function v = evalfnc(x, F, ImgPixel)
for d=1:3
v(d) = F{d}(x*ImgPixel(d));
end;
v = (v(1)-v(2)).^2 + (v(2)-v(3)).^2 + (v(3)-v(1)).^2;
Indeed "x" is a scalar value, d1,2,3 are scalar values per measurement but stored as an array (three channel image).
Adam Danz
Adam Danz le 3 Déc 2019
Any chance you could attach a mat file with all the variables needed to run the code? It's just a lot faster for us mortals if we can step through the code rather than imagining it.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by