网络摄像头视频捕获的色彩映射

时间:2012-10-21 10:47:23

标签: matlab video webcam color-mapping

我目前正在为matlab工作,遇到我的网络摄像头项目。这是我的代码:

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 个答案:

答案 0 :(得分:1)

使用3个通道R G B定义彩色图像(包括视频帧)。当您只有1个通道的信息并将单个值映射到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通道,或将单个通道创建为多个通道的组合。

相关问题