Fitting a smooth curve to dataset containing tuples in MATLAB/OpenCV <p>I have a dataset of <strong>actual</strong> normalized R,G,B values for a number of pixels in the form of [R, G] values (as B value can be calculated using B = 1 - R - G). All these values are unique. I also have a similar dataset of <strong>observed</strong> R,G,B values in the same format i.e. [R, G]. Since these are observed, these values might not be unique. I want to fit a smooth curve based on Least Squares method on the <strong>observed</strong> values, so that I can get one-to-one correspondence between observed and actual values when reverse mapping <strong>actual</strong> values from <strong>observed</strong> RGB values. Individual fitting of R and G values can be easily done using MATLAB functions but they are not completely independent so the dataset points have to be considered as tuples. Is there any way to do this in MATLAB/OpenCV?</p> <p>Edit: Simplifying my question a bit, I want a surface fit or a function such that f(R<sub>obs</sub>, G<sub>obs</sub>) -> R<sub>actual</sub> and g(R<sub>obs</sub>, G<sub>obs</sub>) -> G<sub>actual</sub>. So that I can get a net combined mapping h(R<sub>obs</sub>, G<sub>obs</sub>) -> (R<sub>actual</sub>, G<sub>actual</sub>).</p>