Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Histogram matching of two colored images in matlab

Anyone knows how to perform RGB histogram matching on two colored images?

for example this is an image to be re-mapped:

image to be re-mapped

and this is a target image

target image

Then the RGB remapped image look like this

re-mapped image

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);
like image 978
Glove Avatar asked Jun 14 '11 23:06

Glove


People also ask

How do you match a histogram to two pictures?

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.

What is histogram matching in Matlab?

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.

How do you compare histograms in Matlab?

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.


2 Answers

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);

like image 186
Bee Avatar answered Nov 10 '22 06:11

Bee


You can just do:

im2(:, :, 1) = red2n;

etc.

like image 28
Oliver Charlesworth Avatar answered Nov 10 '22 07:11

Oliver Charlesworth