Histogram matching of two colored images in matlab

一曲冷凌霜 提交于 2019-12-03 19:21:20

问题


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

回答1:


You can just do:

im2(:, :, 1) = red2n;

etc.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/6351377/histogram-matching-of-two-colored-images-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!