What does this instruction returns.

1 view (last 30 days)
Neelum Dave
Neelum Dave on 18 Feb 2016
Answered: Jos (10584) on 18 Feb 2016
[hueChannel,~,~] = rgb2hsv(videoFrame)

Answers (1)

Jos (10584)
Jos (10584) on 18 Feb 2016
Apparently, the function rgb2hsv can return three output arguments. This line of code explicitly ignores the last two. A similar result can be obtained by implicitly ignoring them, by just retrieving one output.
hueChannel = rgb2hsv(videoFrame)
The use of the ~ is more commonly used to retrieve later output arguments and ignoring the earlier ones. As an example:
A = [1 4 5 3] ;
[maxValue, maxIndex] = max(A) % retrieve both
[~, maxIndex] = max(A) % use this if you are only interested in the second output
You have to look in the help of rgb2hsv to see what the first output variable will hold exactly.

Community Treasure Hunt

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

Start Hunting!