2012-11-12 102 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