I have several pictures of plants (tif files). Each picture contains a set of Munsell color chips. The "true" RGB values of the Munsell color chips are known. My goal is to correct the colors of the pictures, by comparing the "observed" and the "true" colors of the Munsell color chips. I tried to use a simple linear regression for each channel. Here is an example for the Red channel: (EDITED:)
x1 = mean_value_of_red_channel_of_observed_color_chip_1
x2 = mean_value_of_red_channel_of_observed_color_chip_2
y1 = red_value_of_true_color_chip_1
y2 = red_value_of_true_color_chip_2
x_mean = (x1+x2)/2
y_mean = (y1+y2)/2
slope = ((x1-x_mean)*(y1-y_mean)+(x2-x_mean)*(y2-y_mean))/((y1-y_mean)^2+(y2-y_mean)^2)
y_intercept = y_mean-(slope*x_mean)
corrected_red_channel_of_image = (slope*red_channel_of_image)+y_intercept
The result does not look right:
Original Image
Corrected Image
For the conversion I used Python 3.6 with Open CV.
Any ideas what I did wrong?