2015-09-26 424 views

回答

3

這需要在HSV(色相飽和度值)顏色空間中完成。

如果你有HSV中的圖像,這是非常容易的(否則將其轉換爲HSV)。 H是唯一提供顏色信息的變量,如果您檢查維基百科頁面Shades of Yellow,您會注意到它們都在45到60度之間。因此,帶上HSV圖像,選擇該範圍內的H並增加這些值的S(飽和度)。

在Matlab中:

%Read image 
imghsv=imread('http://7-themes.com/data_images/out/34/6884934-yellow-flowers.jpg'); 
imghsv=rgb2hsv(im2double(imghsv)); 

%pick yellow 
yellowIndex=repmat((imghsv(:,:,1)>45/360)&(imghsv(:,:,1)<60/360),[1 1 3]); 
yellow=imghsv.*yellowIndex; 

%Saturate it 
moreSaturation=2; 
yellowsaturated=yellow(:,:,2)*moreSaturation; 
yellow(:,:,2)=yellowsaturated; 

%put it back 
newHsv=imghsv; 
newHsv(yellowIndex)=yellow(yellowIndex); 

結果:

原始

enter image description here

黃色像素

enter image description here

飽和

enter image description here