matlab中的热量和强度图

时间:2016-03-21 10:45:54

标签: matlab

我有一个问题:有一个2-D强度数组 - Z [(x,y)是一个矩阵,值是一个强度]。

1 2 3 4 ...
1 3 4 6 ... // ~ 1000 colums. 
2 6 7 8 ...

创建热图:I=imagesc(Z).

然后,我想要为列着色,例如100-200列 - 蓝色,200-300 - 绿色,300-400 - 红色。一些东西,比如柱子的渐变。

enter image description here

非常感谢!

UPD *:我有这个,我想把它着色。通过“滤色器”,例如轴X [0,100] - >蓝色。 X [100,200] - 红色。

获取我上面附上的图像。有可能吗?

enter image description here

1 个答案:

答案 0 :(得分:1)

我对颜色强度/光强度部分不太确定,但我认为这应该可以做到:

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。

========编辑更新的内容============

假设您的强度矩阵(或您的灰度图像)是我

您应该先将其转换为百分比:

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); 

其余的只是调整每个部分的颜色。

相关问题