我有一个灰度级matlab图像,我想将其转换为带有自定义颜色贴图的RGB图像。我用我想要的颜色显示图像没有问题,但是当我使用imwrite时,图形不会保存为RGB图像。它不是300x1000x3数据结构,而是300x1000。我该怎么做才能解决这个问题?
m=255;
map = ones(m,3);
strongsignal = [3, 7, 41]./ 255;
DRAQ = [100, 85, 105]./255;
R = linspace(DRAQ(1),strongsignal(1),254);
G = linspace(DRAQ(2),strongsignal(2),254);
B = linspace(DRAQ(3),strongsignal(3),254);
Sample = [R', G', B'];
i = imread('sliceXY045_660.png');
limits = graythresh(i);
i_adjust = im2bw(i,limits);
map(2:255,:)= Sample;
imagesc(i_adjust)
colormap(map)
imwrite(i_adjust,map,'colormap45.png')
答案 0 :(得分:1)
cmap = colormap(map);
imwrite(i_adjust,cmap, 'colormap45.png', 'png');
将最后一部分改为此..希望这会有所帮助..