Combining RGB to colored image after normalization
23 views (last 30 days)
Show older comments
Anna Flavia Di Natale on 25 Jan 2021
Answered: Hrishikesh Borate on 5 Feb 2021
I am trying to equate low-level statistical properties of a set of pictures using the SHINE toolbox http://www.mapageweb.umontreal.ca/gosselif/shine/SHINEmanual.pdf . In particular I am willing to use the histMatch function to match the luminance histograms.
I want to match the RGB layers of the images separately, and then recombine the processed layers to produce color images.
In order to split the color of the images into their 3 RGB channels, I used to code by @Image Analyst found here https://it.mathworks.com/matlabcentral/answers/91036-how-do-i-split-a-color-image-into-its-3-rgb-channels which is the following.
% Read in original RGB image.
rgbImage = imread('flower.png');
% Extract color channels.
redChannel = rgbImage(:,:,1); % Red channel
greenChannel = rgbImage(:,:,2); % Green channel
blueChannel = rgbImage(:,:,3); % Blue channel
% Create an all black channel.
allBlack = zeros(size(rgbImage, 1), size(rgbImage, 2), 'uint8');
% Create color versions of the individual color channels.
just_red = cat(3, redChannel, allBlack, allBlack);
just_green = cat(3, allBlack, greenChannel, allBlack);
just_blue = cat(3, allBlack, allBlack, blueChannel);
I did that for all my pictures and saved their R, G, B images separately like this:
Then I took the red images, green images and blue images of each picture separately and match them using the histMatch function of theSHINE toolbox. For each image of each channel, I get a calibrated gray image, like this:
For each image I then try to recombine the three gray images to get a colored image using again the code above mentioned:
rgbImage = cat(3, final_red,final_green,final_blue);
However I get a greenish picture like this (image 1 example):
Hrishikesh Borate on 5 Feb 2021
I understand that you are combining the red, green, blue channels of an image after histogram matching operation and you are observing a predominantly greenish output.
This is observed as the final_green image has more bright pixels as compared to the final_red and final_blue images.
Find more on Color in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!