我想让更明亮的像素以绿色显示而不是以明亮的特征显示为蓝色。这是我试过的
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
答案 0 :(得分:1)
你的代码看起来有些奇怪:
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第2列的下半部分填充1 - MYCOLORMAP第3列的上半部分为1。
这是因为在循环中,您使用不同的值填充色彩映射的完全相同的元素,因此只剩下i=128
的最后一个元素。
通过以下方式更容易实现此结果:
mycolormap = zeros(128,3);
mycolormap(64:128,2)=1;
mycolormap(1:63,3)=1;
但是,如果这不是您期望的色彩映射,请详细说明您需要的内容。