solving single nonlinear equation

1 view (last 30 days)
Dominique
Dominique on 29 Apr 2013
Hey all
I have a mathematical problem solving nonlinear equation: (d / d(delta(d))) omega = 0 (derivation to delta(d))
with omega(delta(d)) = sum(Di-Dj)² --> min(delta(d)) with i and j the 3 different colorchannels (RGB)
So we have 3 different calibrationcurves of the form c+(b/(d-a)) that give D (solution) for the 3 RGB channels (input = d = optical density and a,b,c = fitting constants)
If i now take a pixel with known d and I want to solve this to a minimum for the 3 channels, how do I do that best? (So i get the best fitted Dx for all 3 curves).
I have sorted this already out using lsqnonlin function, but this takes 1.5 hour for a 550 x 550 matrix of pixels. Any suggestions to simplify the maths of the problem or using another function to speed up the proces?
if true
for i=1:(film_size(1,1))
for j=1:film_size(1,2)
d0 = [input(i,j,1) input(i,j,2) input(i,j,3)];
Drgb=@(d) [(cR+(bR/(d(1)-aR));(cG+(bG/(d(2)-aG));(cB+(bB/(d(3)-aB))];
f=@(d) [1 0 -1; 0 -1 1; -1 1 0]*Drgb(d);
options = optimset('Display','off');
lowerbounds=[d0(1)-500 d0(2)-500 d0(3)-1000];
upperbounds=[d0(1)+500 d0(2)+500 d0(3)+1000];
[d,resnorm] = lsqnonlin(f,d0,lowerbounds,upperbounds,options);
output(i,j) = d; //d with values for the 3 colorchannels
end
end
end
and this for 550 x 550 matrix.
Hope this is clear and someone can help me... :)
Thanks in advance!!
Dominique

Answers (1)

Alan Weiss
Alan Weiss on 29 Apr 2013
You would speed things up a little bit by getting the optimset call out of the loop. But I have no specific advice for your question.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Comment
Dominique
Dominique on 29 Apr 2013
Yes i know, but this is just to point out that i have looked into optimset, bounds,... :) Thanks for the answer nonetheless!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!