Anyone knows how to perform RGB histogram matching on two colored images?
for example this is an image to be re-mapped:
and this is a target image
Then the RGB remapped image look like this
here is what I did so far, in this code I took two color images im1
and im2
I took the im1
which is the one that has to be remapped then broke it up into
its colors then I took each color of im1 and used histeq
to match their histograms to
each color in im2
.
I don't know how to reconstruct the re-mapped image from the colors I matched, any help please that would be nice??:
im1 = imread('Atlas-Mer.png');
im2 = imread('techno-trs.png');
Red1 = im1(:, :, 1);
Green1 = im1(:, :, 2);
Blue1 = im1(:, :, 3);
.
.
.
Red2 = im2(:, :, 1);
Green2 = im2(:, :, 2);
Blue2 = im2(:, :, 3);
red2n = histeq(Red2,HnRed1);
green2n = histeq(Green2,HnGreen1);
blue2n = histeq(Blue2,HnBlue1);
In order to match the histogram of images A and B, we need to first equalize the histogram of both images. Then, we need to map each pixel of A to B using the equalized histograms. Then we modify each pixel of A based on B.
You can adjust the intensity values of image pixels automatically using histogram equalization. Histogram equalization involves transforming the intensity values so that the histogram of the output image approximately matches a specified histogram.
Jonathan's nhist lets you compare the histograms of the data sets easily. ans = mu_is_Zero: 'mu_is_Zero: mean=0.00, std=1.00, 3 points counted in the ...' mu_is_Two: 'mu_is_Two: mean=2.00, std=1.00, 1 points counted in the r...' Note that it automatically uses the field names for the legend.
Well it's been months since the original question was posted but I think everyone can use an alternative approach to what was suggested: the following code puts the three color channels into one RGB image:
rgb_out = cat(3, red2n, green2n, blue2n);
You can just do:
im2(:, :, 1) = red2n;
etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With