Shades of ash (gray scale) live

1 回表示 (過去 30 日間)
almog haviv
almog haviv 2022 年 5 月 29 日
回答済み: Image Analyst 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 Center および File ExchangeRed についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by