2012-11-12 103 views
2

我有一个大小为150的滤镜150通过使用imagesc来绘制滤镜,背景为绿色imagesc将背景颜色更改为白色matlab

minValue = -1.5; maxValue = +1.5;

零的图像(绿色)的RGB指数是0.5,1,0.5

我想改变所有的索引“0” /背景颜色的图像中的白色,同时留下剩余因为他们是可能的。

尺寸(颜色映射):64 3

我曾尝试以下,但它似乎没有我的形象上工作: matlab's imagesc background color

非常感谢

回答

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);水平。下图所示下面就是用这个做...

enter image description here

+0

这是完美..非常感谢您的帮助! – Ash