Shades of ash (gray scale) live

1 次查看(过去 30 天)
almog haviv
almog haviv 2022-5-29
Grayscale. I need a code that will convert what the USB camera transmits live into gray scale. For shades of gray where 0 = white and 255 = Black. My program should have the option to play with the values and choose which value I want the camera to bounce an alert on my screen. For example, as soon as the camera detects a hue of 15 or higher, it will pop up an on-screen alert.

回答(1 个)

Image Analyst
Image Analyst 2022-5-29
Try something like this (untested)
% Get alert gray level from GUI
alertGrayLevel = app.edtAlert.Value;
% Make up colormap to show red pixels if image is above the alert gray level.
cmap = gray(256);
cmap(alertGrayLevel:end, :) = repmat([1,0,0], alertGrayLevel:end, 1);
% Get the current image.
thisFrame = getdata(videoObject)
if ndims == 3
% It's color so convert to gray scale.
thisFrame = rgb2gray(thisFrame);
end
if app.chkInvertGrayScale
% If they have checked the checkbox to invert the gray scale, do that.
thisFrame = 255 - thisFrame;
end
imshow(thisFrame, 'ColorMap', cmap);
% Display the colormap next to the image.
colormap(cmap);
colorbar;

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by