我不太确定颜色强度/光强度部分,但我认为这应该可以完成工作:
intense = [0 2 3 4;1 3 4 6;2 6 7 8];
intense = intense./100; %//Convert to percentage
RGBmat = zeros([size(intense), 3]); %//Create blank RGB map
%//set Col1 to red
RGBmat (:,1,1) = 255;
%//set Col2 to green
RGBmat(:,2,2) = 255;
%//set Col3 to Blue
RGBmat(:,3,3) = 255;
%//multiply intensity
Res = RGBmat .* repmat(intense,[1,1,3]); %//I am not sure about adjusting the intensity of each pixel.
据此帖Adjusting image intensity values
它应该看起来像这样?
J = (RGBmat ./ 255).^ repmat(intense,[1,1,3])*255 %//This is assuming that intensity matrix is from 0 to 255 not 1 to 100, you will have to normalize it I guess.
imshow(Res,'InitialMagnification','fit')
imshow(J,'InitialMagnification','fit')
注意 100 强度不是白色,而是默认黑色,这是因为当我将 RGBmat 设置为默认值时,我使用了零(这意味着黑色),如果你想它是白色的,你需要设置RGBmat 归零(...).*255;但是,这意味着当您将列设置为红色、绿色和蓝色时,您需要将其他通道设置为零:
所以对于红色,而不是将红色设置为 255;您需要将蓝色和绿色设置为 0。
========编辑更新内容============
假设您的强度矩阵(或您的灰度图像)是 I
你应该先把它转换成百分比:
Ipercent = double(I)./255;
接下来将其制作成 3D RGB 图像 -
IRGB = repmat(Ipercent,[1,1,3]);
现在你可以将你的颜色掩码乘以它:
%This line will multiply your first 1:100 column with a red mask
IRGB(:,1:100,1) = uint8(IRGB(:,1:100,1).*255);
剩下的只是调整每个部分的颜色。