cv2.inRange(src, lowerb, upperb[, dst]) → dst
The function checks the range as follows:
- For every element of a single-channel input array: $$\text{dst}(I)=\text{lowerb}(I)_0 \leq \text{src}(I)_0 \leq \text{upperb}(I)_0$$
- For two-channel arrays:
$$\text{dst}(I)= \left( \text{lowerb}(I)_0 \leq \text{src}(I)_0 \leq \text{upperb}(I)_0 \right) \wedge \left( \text{lowerb}(I)_1 \leq \text{src}(I)_1 \leq \text{upperb}(I)_1 \right)$$
...and so on. That is, \(\text{dst}(I)\) is set to 255 (all 1-bits) if \(\text{src}(I)\) is within the specified 1D, 2D, 3D, ... boundaries and 0 otherwise. When the lower and/or upper boundary parameters are scalars, the indices \(I\) at
lowerb
and
upperb
in the above formulas should be omitted, but the channel indices remain.