"Bruno Luong" <firstname.lastname@example.org> wrote in message <email@example.com>... > "K M" wrote in message <firstname.lastname@example.org>... > > > > > I is the image to be transformed and thus X in the MATLAB lsqcurvefit syntax. > > 1_ Fine, but where do you declare it (I) in cost? Did you want I to be x_data? > > 2) If you want to solve least-square equality: y_data = a*x_data + b, > > then just do > P = [ones(numel(xdata,1) xdata(:)] \ y_data(:); > a = P(2); b = P(1); > > 3) But I still don't think that's the correct way to formulate the matching intensity. The unknown affine transform is operated on the input space of the histogram, not the output values; which is entirely different. > > Bruno
My apologies Bruno. I have spotted a rather big typo. The function is F = cost(val,I)) and not F = cost(val,xo,x_data,y_data).
I wanted the probability density function of I to be x_data so that the function would find a linear transformation for I such that its histogram matches y_data.
I think your comment in point 3 describes why it is not working. However, I was under the impression that by stipulating the histogram of I to be x_data and by defining the function as I did, lsqcurvefit would find the parameters such that
hist(fun(I)) is approximately hist(J) and thus does operate on the input space ?