R
It's a little difficult to answer your question without context. However, I suppose these images are stored as vectors and numerical arrays.If my assumption is correct, this is called "logical indexing", similar to that offered by numpy (if not exactly the same thing).I will explain through an example using numpy. We start by creating a vector:>>> import numpy as np
>>> l = [1,2,3,4]
>>> l
[1, 2, 3, 4]
>>> x = np.array(l)
>>> x
array([1, 2, 3, 4])
The vector and the list behave quite differently. The following is worthy of note:>>> l>2
True
>>> x>2
array([False, False, True, True], dtype=bool)
When you make a comparison between a vector and a number, the result is a logical vector with the comparison value for each vector element. This is true for more complex comparisons also:>>> l%2==0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for %: 'list' and 'int'
>>> x%2==0
array([False, True, False, True], dtype=bool)
And when you use a logical vector instead of the index of another vector, the result is a vector with all the elements corresponding to positions occupied by "True" in the logical vector:>>> x[x>2]
array([3, 4])
>>> x[x%2==0]
array([2, 4])
Finally, when you do an assignment, this applies to the original vector elements:>>> x[x%2==0] *= 10
>>> x
array([ 1, 20, 3, 40])
You can assign a list, and the list values are passed in order:>>> x[x%2==1] = [-1,-3]
>>> x
array([-1, 20, -3, 40])
But the list needs to be the right size. That is, if you have n values that satisfy the condition and you pass a list, the list needs to have exactly n values:>>> x[x%2==1] = [-1,-3, -5]
>>> x[x%2==0] = range(10, 150, 10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 2 output values where the mask is true
>>> x = np.array(range(15))
>>> x[x%2==0] = [-1,-3]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: NumPy boolean array indexing assignment cannot assign 2 input values to the 8 output values where the mask is true
What your code excerpt does is equivalent to that. Booting in words: vector positions image corresponding to vector positions dst where the value is greater than 1% of the maximum of this vector receive the values [0.0.255].As this sounds like a trio of RGB values, I imagine that what is happening is not exactly the same as assigning a list to a vector. Most likely the pixels of dst that satisfy the condition will correspond to blue pixels in image.