Azzera filtri
Azzera filtri

Real time Rgb2gray convert

1 visualizzazione (ultimi 30 giorni)
Zakaria Boussaid
Zakaria Boussaid il 31 Mag 2021
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')

Risposta accettata

Image Analyst
Image Analyst il 31 Mag 2021
Modificato: Image Analyst il 31 Mag 2021
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 Commenti
Image Analyst
Image Analyst il 2 Giu 2021
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 il 2 Giu 2021
thank you for this informative answer

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by