I think you can test this simple way:
calculate the histogram of your two sample images for each RGB channel. then calculate the ratio of histograms of each image: ratio = imhist(im2) ./ imhist(im1) %DO THIS FOR EACH RGB CHANNEL
Now you have ratio that able to convert intensities in each color of each image. So multiply the ratio to the input image and get the output histogram. (OutputHistogram = imhist(InputImage) .* ratio). Then use histeq(InputImage , OutputHistogram) to change the input image to the desired colors.
I haven't tested this way, but I think it can be useful.