Reputation:
I faced one time in an opencv code this expression:
Mat bimage = image >= sliderPos;
Known that sliderPos
is an integer.
What does that mean please.
Thanks in advance
ADDITION: of course the type of image
is cv::Mat
Upvotes: 0
Views: 232
Reputation: 31647
The expression
Mat bimage = image >= sliderPos;
tests whether image
is larger or equal to sliderPos
(which usually yields a bool
) and assigns the result of the test to the newly created variable bimage
of type Mat
.
If the >=
operator is overloaded for (decltype(image), int)
, it might not yield a bool
. If this is the case, look in the documentation of the type of image
for details. In any case, it yields something, from wich a Mat
can be constructed.
Upvotes: 1
Reputation: 82041
It is hard to tell without knowing the type of image
, but according to the OpenCV documentation, I think this line converts image
into a black and white image, using sliderPos
as a threshold to determine which pixels will be black.
From the OpenCV documentation about matrices:
Comparison: A cmpop B, A cmpop alpha, alpha cmpop A, where cmpop is one of : >, >=, ==, !=, <=, <. The result of comparison is an 8-bit single channel mask whose elements are set to 255 (if the particular element or pair of elements satisfy the condition) or 0.
Upvotes: 3