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

1 view (last 30 days)
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

Answers (1)

Guillaume
Guillaume on 17 Oct 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 Comment
Steven Lord
Steven Lord on 17 Oct 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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!