【问题标题】:Create an RGB image from a grayscale image and custom color map从灰度图像和自定义颜色映射创建 RGB 图像
【发布时间】:2014-09-17 21:16:25
【问题描述】:

我有一个灰度 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')

【问题讨论】:

    标签: image matlab image-processing colors


    【解决方案1】:
    cmap = colormap(map);
    imwrite(i_adjust,cmap, 'colormap45.png', 'png');
    

    将最后一部分改成这个..希望这会有所帮助..

    【讨论】:

      猜你喜欢
      • 2021-10-08
      • 1970-01-01
      • 2015-09-01
      • 2013-01-12
      • 1970-01-01
      • 1970-01-01
      • 2018-02-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多