创建我自己的颜色贴图,这样两种不同的颜色可以在Matlab中绘制在一幅图像上

创建我自己的颜色贴图,这样两种不同的颜色可以在Matlab中绘制在一幅图像上,matlab,colormap,Matlab,Colormap,我想有更明亮的像素出来绿色和不在明亮的功能出来蓝色。这是我试过的 for i=1:128 mycolormap(64:128,2)=i/128; mycolormap(1:63,3)=i/128; mycolormap(1:63,2)=0; mycolormap(64:128,3)=0; mycolormap(i,1)=0; end 我正在使用Uint16.tif的图像 我考虑过在实例化之前将colormap强制转换为double。 谢谢 阅读你添加的评论内容真的能帮助我想清楚,所以我调整了代

我想有更明亮的像素出来绿色和不在明亮的功能出来蓝色。这是我试过的

for i=1:128
mycolormap(64:128,2)=i/128;
mycolormap(1:63,3)=i/128;
mycolormap(1:63,2)=0;
mycolormap(64:128,3)=0;
mycolormap(i,1)=0;
end
我正在使用Uint16.tif的图像 我考虑过在实例化之前将colormap强制转换为double。 谢谢

阅读你添加的评论内容真的能帮助我想清楚,所以我调整了代码,通过做一些廉价的编码得到了我想要的。但现在我得到了我想要的谢谢

     for i=1:128                  % start a loop (see comment above about i variable)
                             % then in EACH iteration
mycolormap(i,2)=i/128;  % fill bottom half of 2nd column of MYCOLORMAP with i/128
mycolormap(i:63,3)=i/128;    % fill top    half of 3rd column of MYCOLORMAP with i/128
mycolormap(1:63,2)=0;        % fill top    half of 2nd column of MYCOLORMAP with 0
mycolormap(64:128,3)=0;      % fill bottom half of 3rd column of MYCOLORMAP with 0
mycolormap(i,1)=0;           % fill i-th   row  of 1st column with 0
end
>> mycolormap

mycolormap =

         0         0    0.0078
         0         0    0.0156
         0         0    0.0234
         0         0    0.0313
         0         0    0.0391
         0         0    0.0469
         0         0    0.0547
         0         0    0.0625
         0         0    0.0703
         0         0    0.0781
         0         0    0.0859
         0         0    0.0938
         0         0    0.1016
         0         0    0.1094
         0         0    0.1172
         0         0    0.1250
         0         0    0.1328
         0         0    0.1406
         0         0    0.1484
         0         0    0.1563
         0         0    0.1641
         0         0    0.1719
         0         0    0.1797
         0         0    0.1875
         0         0    0.1953
         0         0    0.2031
         0         0    0.2109
         0         0    0.2188
         0         0    0.2266
         0         0    0.2344
         0         0    0.2422
         0         0    0.2500
         0         0    0.2578
         0         0    0.2656
         0         0    0.2734
         0         0    0.2813
         0         0    0.2891
         0         0    0.2969
         0         0    0.3047
         0         0    0.3125
         0         0    0.3203
         0         0    0.3281
         0         0    0.3359
         0         0    0.3438
         0         0    0.3516
         0         0    0.3594
         0         0    0.3672
         0         0    0.3750
         0         0    0.3828
         0         0    0.3906
         0         0    0.3984
         0         0    0.4063
         0         0    0.4141
         0         0    0.4219
         0         0    0.4297
         0         0    0.4375
         0         0    0.4453
         0         0    0.4531
         0         0    0.4609
         0         0    0.4688
         0         0    0.4766
         0         0    0.4844
         0         0    0.4922
         0    0.5000         0
         0    0.5078         0
         0    0.5156         0
         0    0.5234         0
         0    0.5313         0
         0    0.5391         0
         0    0.5469         0
         0    0.5547         0
         0    0.5625         0
         0    0.5703         0
         0    0.5781         0
         0    0.5859         0
         0    0.5938         0
         0    0.6016         0
         0    0.6094         0
         0    0.6172         0
         0    0.6250         0
         0    0.6328         0
         0    0.6406         0
         0    0.6484         0
         0    0.6563         0
         0    0.6641         0
         0    0.6719         0
         0    0.6797         0
         0    0.6875         0
         0    0.6953         0
         0    0.7031         0
         0    0.7109         0
         0    0.7188         0
         0    0.7266         0
         0    0.7344         0
         0    0.7422         0
         0    0.7500         0
         0    0.7578         0
         0    0.7656         0
         0    0.7734         0
         0    0.7813         0
         0    0.7891         0
         0    0.7969         0
         0    0.8047         0
         0    0.8125         0
         0    0.8203         0
         0    0.8281         0
         0    0.8359         0
         0    0.8438         0
         0    0.8516         0
         0    0.8594         0
         0    0.8672         0
         0    0.8750         0
         0    0.8828         0
         0    0.8906         0
         0    0.8984         0
         0    0.9063         0
         0    0.9141         0
         0    0.9219         0
         0    0.9297         0
         0    0.9375         0
         0    0.9453         0
         0    0.9531         0
         0    0.9609         0
         0    0.9688         0
         0    0.9766         0
         0    0.9844         0
         0    0.9922         0
         0    1.0000         0

您的代码看起来有些奇怪:

for i=1:128                  % start a loop (see comment above about i variable)
                             % then in EACH iteration
mycolormap(64:128,2)=i/128;  % fill bottom half of 2nd column of MYCOLORMAP with i/128
mycolormap(1:63,3)=i/128;    % fill top    half of 3rd column of MYCOLORMAP with i/128
mycolormap(1:63,2)=0;        % fill top    half of 2nd column of MYCOLORMAP with 0
mycolormap(64:128,3)=0;      % fill bottom half of 3rd column of MYCOLORMAP with 0
mycolormap(i,1)=0;           % fill i-th   row  of 1st column with 0
end
因此,在循环之后
-MYCOLORMAP第二列的下半部分用1填充
-MYCOLORMAP第3列的上半部分用1填充

这是因为在循环中,您使用不同的值填充了colormap中完全相同的元素,因此只有最后一个元素保留了
i=128

通过以下方式更容易实现此结果:

mycolormap = zeros(128,3);
mycolormap(64:128,2)=1;
mycolormap(1:63,3)=1;

但是,如果这不是您所期望的颜色映射,请详细说明您需要什么。

您能告诉我们您从中得到了什么吗?我在这里回答了类似的问题:另外:不要在matlab中使用I作为变量,使用ii。我是复数