2

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

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

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

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

尺寸(颜色图):64 3

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

非常感谢

4

1 回答 1

2

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

 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);

而不是sort你可以使用min,但我认为通过排序你还可以编辑更多的内容,而不是使用额外的行,例如,j(ind(1:3),:)=ones(3);。下图是用这个完成的......

在此处输入图像描述

于 2012-11-12T06:46:43.677 回答