lsqnonlin time optimization of matrix
1 view (last 30 days)
Show older comments
Dear all
I have a 551*551 matrix with RGB values. I need to optimize these values to "normal conditions" with calibration functions of the form D = a+(b/(x-c)) with each separate a, b and c constants and x the color value.
I rescale the RGB values to something known and "normal" (I remove component that doesn't need to influence the RGB values accoriding to calibration conditions).
So i need to perform (D_red-D_blue)²+(D_blue-D_green)²+(D_green-D_red)²=0 with D_color = a+(b/((x*rescaling_factor)-c)).
This function works:
%first vectorized the matrix tot 1:551*551
%and with a RGB to optical density conversion (10.^-(X*factor))
parfor i=1:(551*551)
f=@(factor) [(aR+(bR/((10.^-(R(i)*factor))-cR)))-(aB+(bB/((10.^-(B(i)*factor))-cB)));...
(aB+(bB/((10.^-(B(i)*factor))-cB)))-(aG+(bG/((10.^-(G(i)*factor))-cG)));...
(aG+(bG/((10.^-(G(i)*factor))-cG)))-(aR+(bR/((10.^-(R(i)*factor))-cR)))]
output(i)=lsqnonlin(f,factor,lb,ub,options);
end
But it takes aprox. 300s to perform on a 551*551 matrix.
My knowledge of matlab isn't great, so I would like to know is there a much faster way to calculate this with the same results? Is the use of Jacobian possible here and will it give a performance boost? Maybe mex file?
Thank you for your help!!
Dominique
0 Comments
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!