Why the threshold is 0.90 used to obtain the white component from RGB channels ?

1 次查看(过去 30 天)
vid = videoinput('winvideo',1, 'YUY2_1280x720');
thresh = 0.90;
% Set the properties of the video object
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval = 5;
%start the video aquisition here
start(vid)
% Set a loop that stop after 100 frames of aquisition
while(vid.FramesAcquired<=100)
% Get the snapshot of the current frame
data = getsnapshot(vid);
bwredFrame = imbinarize(data(:,:,1), thresh); % obtain the white component from red layer
bwgreenFrame = imbinarize(data(:,:,2), thresh); % obtain the white component from green layer
bwblueFrame = imbinarize(data(:,:,3), thresh); % obtain the white component from blue layer
diff_im = bwredFrame & bwgreenFrame & bwblueFrame; % get the common region

回答(1 个)

Guillaume
Guillaume 2019-10-17
You will have to ask whoever wrote that code why they chose that threshold.
Most likely, the answer will be : because it worked for my particular video
  1 个评论
Steven Lord
Steven Lord 2019-10-17
According to Google it looks like this code is from a question posted to MATLAB Answers in 2017, almost exactly two years ago.
And I agree with Guillaume that it's probably a judgment call on the part of that author (or the person from whom they obtained that code) as to what constituted a "white enough" region of their particular video frames. If I were to run that example right now on the view outside my office window trying to detect the (storm) clouds, I'd need to adjust that threshold quite a bit.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by