adjust weight of red , green ,blue in color image

36 次查看(过去 30 天)
I have three images and I use cat command to convert them from 2D to 3D. By default I am getting very dark image. I know if I multiply different channel (red,green and blue) by some different scalars I will get image with new color.I know what image I should expect to get. I would like to know is there any algorithm that according to my expected image finds the closes coefficient that I should multiply different channel by?
rgb=cat(3,red,green,blue) % this is too dark
I want to know how to find m,n,k that
rgb=cat(3,red*m,green*n,blue*k)
becomes close to expected image I have.

回答(3 个)

Image Analyst
Image Analyst 2014-8-23
What kind of images are red, green, and blue? Are they uint8 images in the range of 0-255? I'd bet not. They're either binary/logical images with values of 0 and 1 (false and true) or else floating point numbers instead of uint8.
  5 个评论
chess
chess 2014-8-23
I believe I should cast the image to smaller uint. But My question is what is the algorithm that give me appropriate coefficient of red blue and green channel to get some random RGB image.
Image Analyst
Image Analyst 2014-8-23
Hmmmm.... Maybe
randomRGB = uint8(rand(1)*double(red)+rand(1)*double(green)+rand(1)*double(blue));

请先登录,再进行评论。


oni
oni 2014-8-25
I wanted to do the same and ended up normalizing the images from the three channels with their maximum intensity value:
maxRGB(1) = max(max(red));
maxRGB(2) = max(max(green));
maxRGB(3) = max(max(blue));
maxRGB2 = max(maxRGB);
indR = maxRGB2/maxRGB(1);
indG = maxRGB2/maxRGB(2);
indB = maxRGB2/maxRGB(3);
sclRGB = cat(3,red.*indR,green.*indG,blue.*indB);
This may not be the most ideal solution (e.g., it weighs the three channels the same), but it made the RGB image more balanced (I was getting something super green too before this).
HTH!
  1 个评论
Image Analyst
Image Analyst 2014-8-25
You're right - it's not ideal in the vast majority of cases. And it does not weight the color channels the same - it weights them by inverse of their respective max values. Unless the separate color channels all have the same max value, it will cause a color shift in the image. Now whether this color shift produces a better or worse image depends on the situation. It sounds like in your case it produced a better image - maybe your camera was not properly white balanced in advance. If I white balanced by camera and then took a photo of the lawn, or of the sky, and then applied your algorithm, it would make the scene more gray (less saturated) than it should be. So it just depends on why or if the image was messed up to start with.

请先登录,再进行评论。


oni
oni 2014-8-26
You are absolutely right, and thanks for pointing out that the weights are inverse of the max values. Please bear with me while I explain when this may be useful. I needed to merge/overlay three fluorescent channels (green, orange and red emissions) and wanted to use 'cat' (with false colors). This is something that people often do for imaging different fluorescent reporters in cells. Oftentimes, green fluorescent reporters are much stronger than others, while reds are often quite week. The max/inverse worked in my case because it allowed me to see the week signal by eye, while suppressing the dominant one. So, if someone is merging fluorescent channels, the inverse of 'max' may work to the advantage.
This should not work for images from a color camera. (Of course, I was not thinking about a color camera at all when I saw the original post- I must have a serious case of tunnel vision! Apologies.)
  1 个评论
Image Analyst
Image Analyst 2014-8-26
I agree that there are some cases when that type of color enhancement might be desirable, and selectively enhancing colors in fluorescence microscopy, as you described, seems like it would be one of those situations.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by