Fill intensity grayscale with a colour channel

2 次查看(过去 30 天)
I have read most of the posted questions but could not find a suitable solution for my problem. I have a grayscale image (uint16) that I would like to convert to RGB. I know that this is only possible with a pseudocolour map. Therefore, I created a colourmap with:
colourArray = 0:255;
colourArray = colourMap';
colourMap = [AcolourArray zeros(size(AcolourArray,1),2)];
Then I converted the image from uint16 to uint8 and convert the grayscale to a pseudo RGB:
rgbImage = cat(3, image, image, image)
What I want is to colorise the grayscale image in blue (smooth gradient) based on their intensities.
Due to the problem, that Matlab can not import .lsm files in colour I thought about this way to at least imitate the colour channel. Here is an example image how matlab shows it after import and how I would like to have it:
(Please ignore that the position I took the screenshot varies)

采纳的回答

Guillaume
Guillaume 2017-3-31
Converting the grey image to pure blue with the same intensity is actually very easy, just use that image as the blue colour plane, and put 0 everywhere in the red and green planes:
rgbimage = cat(3, zeros(size(greyimage)), zeros(size(greyimage)), greyimage);
Converting the grey image to a colour that is not one of the primary is a bit more difficult. The easiest way is to do the conversion in the HSV colour space first. The grey image becomes the luminance (value), and you fix the hue plane to whatever constant you want. Then convert the HSV image to RGB:
hue = 29/256; %for example, some sort of orange. Has to be double
hsvimage = cat(3, repmat(hue, size(greyimage)), ones(size(greyimage)), im2double(greyimage));
rgbimage = hsv2rgb(hsvimage);
  2 个评论
Kamu
Kamu 2017-3-31
that works like charm. Thanks a lot. I have one more question. Let's say I have 4 rgb images, how can I overlay them to 1 composite image?
Image Analyst
Image Analyst 2017-4-29
See this paper for a variety of ways to composite (overlay) more than three images into one color image: http://my.ece.msstate.edu/faculty/du/JSTARS-VIS.pdf

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modify Image Colors 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by