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

1 visualizzazione (ultimi 30 giorni)
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

Risposte (1)

Guillaume
Guillaume il 17 Ott 2019
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 Commento
Steven Lord
Steven Lord il 17 Ott 2019
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.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by