【问题标题】:imagesc change background colour to white matlabimagesc 将背景颜色更改为白色 matlab
【发布时间】:2012-11-12 06:12:59
【问题描述】:

我有一个大小为 150 x 150 的滤镜 当使用 imagesc 绘制滤镜时,背景是绿色的

minValue = -1.5;最大值 = +1.5;

图像中零的 RGB 索引(绿色)为 0.5,1,0.5

我想将图像中的所有索引“0”/背景颜色更改为白色,同时尽可能保留其余部分。

尺寸(颜色图):64 3

我尝试了以下方法,但它似乎不适用于我的图像: matlab's imagesc background color

非常感谢

【问题讨论】:

    标签: matlab


    【解决方案1】:

    这是我的解决方案。直方图图像强度,找到最接近零的那些,然后将其设置为白色。例如:

     m=peaks(100); % generate data
     imagesc(m);   
    
     colormap_range=64; % default colormap_range is 64, but change it to your needs
     [n,xout] =hist(m(:),colormap_range);   % hist intensities according to the colormap range
     [val ind]=sort(abs(xout)); % sort according to values closest to zero
     j = jet;
     j(ind(1),:) = [ 1 1 1 ]; % also see comment below
     % you can also use instead something like j(ind(1:whatever),:)=ones(whatever,3); 
     colormap(j);
    

    您可以使用min 而不是sort,但我认为通过排序您还可以编辑更多的内容,而不是使用其他行,例如j(ind(1:3),:)=ones(3);。下图就是用这个做的……

    【讨论】:

      猜你喜欢
      • 2011-12-08
      • 2014-01-19
      • 2019-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-01
      • 1970-01-01
      • 2019-08-20
      相关资源
      最近更新 更多