2012-10-21 31 views
2

我目前正在爲一個matlab工作符合我的攝像頭項目。這裏是我的代碼:關於攝像頭的colormap視頻捕獲

vid = videoinput('winvideo'); 
vidRes = get(vid, 'VideoResolution'); 
nBands = get(vid, 'NumberOfBands'); 
hImage = image(zeros(vidRes(2), vidRes(1), nBands)); 
preview(vid, hImage); 
colormap cool; 

該視頻被顯示,因爲它是在網絡攝像頭。然而colormap cool;在視頻中似乎沒有影響。我嘗試用虛擬圖像替換視頻,colormap cool;生效。

有沒有什麼方法可以控制我的視頻的顏色表?

回答

1

使用3個通道R G B定義彩色圖像(包括視頻幀)。當您只有1個通道信息並且MAP爲3通道RGB值的單個值時使用彩色地圖。

例如:

img1 = rand(20,20,3); 
imagesc(img); 
colormap hot; % This does nothing because the image has 3 channels 

img2 = rand(20,20); 
imagesc(img); 
colormap hot; % This works because a colormap is being used to map the 1 channel to a color 

如果你想用你的視頻顏色表,你必須選擇的R,G,或B信道或創建一個單獨的通道作爲多個通道的組合。

+0

非常感謝。高度讚賞。順便問一下,如果我要求一個示例代碼來創建單個通道作爲多個通道的組合,那麼可以嗎? – dmfrl

+1

@dmfrl:http://stackoverflow.com/questions/3547029/how-do-i-display-the-red-channel-of-an-image-in-matlab或http://www.mathworks.com/ matlabcentral/newsreader/view_thread/283668 – slayton

+0

非常感謝。 – dmfrl