adjust weight of red , green ,blue in color image

조회 수: 5 (최근 30일)
chess
chess 2014년 8월 23일
댓글: Image Analyst 2014년 8월 26일
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