Shades of ash (gray scale) live
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Red에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!