필터 지우기
필터 지우기

Real time Rgb2gray convert

조회 수: 1 (최근 30일)
Zakaria Boussaid
Zakaria Boussaid 2021년 5월 31일
댓글: Zakaria Boussaid 2021년 6월 2일
hey guys i want to know if it is possible to convert in real time a RGB form video to a gray Form.
I tried to use rgbgray function and min function but i wasn't able to get what i want
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
%===============================================================================
%activate the integrated camera
web = webcam('HD Webcam')
set(web,'Resolution','640x480')
preview(web)
pause(5)
img = snapshot(web)
imshow(img)
%===============================================================================
% Read in a demo image.
%grayImage= min(originalRGBImage, [], 3); % Useful for finding image and color map regions of image.
grayImage = rgbgray(web); % Useful for finding image and color map regions of image.
imshow(grayImage)
clear('web')

채택된 답변

Image Analyst
Image Analyst 2021년 5월 31일
편집: Image Analyst 2021년 5월 31일
You need to pass in the color image, not the webcam object. And you need to call rgb2gray(), not rgbgray().
rgbimage = snapshot(web)
grayImage = rgb2gray(rgbImage);
imshow(grayImage);
drawnow;
  댓글 수: 3
Image Analyst
Image Analyst 2021년 6월 2일
Not that I know of. You might be able to do it with the Image Acquisition Toolbox if you set the returned output space to RGB but I don't know if you can do that for the real-time LIVE webcam object. However you can do it not in real time by grabbing and image, converting it, and then displaying it like I showed. Not sure how much this would slow down the frame rate as compared to just letting it go full speed. And of course you can convert a non-real-time, saved video that is recalled from disk to gray scale very easily.
Zakaria Boussaid
Zakaria Boussaid 2021년 6월 2일
thank you for this informative answer

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by