colormap on webcam video capture

I am currently working for a matlab meets my webcam project. Here is my code:

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

The video was displayed as it is in webcam. However the colormap cool; seems no effect in the video. I tried replacing the video by a dummy imag and the colormap cool; takes effect.

Is there any way for me to control the colormap of my video?


Color images (including video frames) are defined using 3 channels, RG B. Colormaps are used when you only have 1 channel of information and MAP a single value to a 3 channel RGB value.

For example:

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

If you want to use a colormap for your video you'll have to select either the R, G, or B channel or create a single channel as a combination of multiple channels.

链接地址: http://www.djcxy.com/p/81028.html

上一篇: 如何减少从网络摄像头捕获的图像的大小

下一篇: 网络摄像头视频拍摄的色彩地图