15

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);
Glove
  • 960
  • 6
  • 17
  • 30

3 Answers3

5

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

Bee
  • 2,472
  • 20
  • 26
4

You can just do:

im2(:, :, 1) = red2n;

etc.

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
0

Matlab now has a built-in function in the Image Processing Toolbox to do this: http://www.mathworks.com/help/images/ref/imhistmatch.html

But if you have an older version of Matlab (I have 2010b and it does not include imhistmatch.m), this is function that does classic histogram matching: https://www.mathworks.com/matlabcentral/fileexchange/27396-matchhistograms