Mat is a common structure used in OpenCV to store two and higher dimensional data. It is a derivation of the internal Array structure. A relational operator can applied between two Mat objects or a Mat object and a scalar, and the result is a 8-bit single-channel Mat.
Any of these operations is nothing but a call to compare function. This results in a per-element comparison of the Mat. The key information to remember is that for every element whose result is true, the value in the result Mat is set to
0xFF, that is
255. If result is false, it is set to
0. This behavior is so that the resulting Mat can be used as a mask image if needed for other operations.
The operators that are supported are equal, not-equal, greater, greater-or-equal, lesser and lesser-or-equal.
Example usage of such operations:
cv::Mat m0, m1;
cv::Mat m2(m0 == 0);
m2 = m0 > m1;
m2 = m1 <= m0;
m2 = m1 != 1;
if i == j:
# Do something
if i is j:
# Do something
== operator checks the values behind the two names. It returns True if the two values are equal, False otherwise.
is operator checks the objects behind the two names. It returns True if both the names refer to the same object, False otherwise.
Tried with: Python 3.2
In Python, the
* (asterisk) character is not only used for multiplication and replication, but also for unpacking. There does not seem to be any name for this kind of
* operator and thus searching for it online is difficult. But, it is commonly called as the unpack or splat operator in this role.
* on any iterable object, by placing it to the left of the object, produces the individual elements of the iterable.
I imagine this operator as shattering the container that holds the items together, so they are now free and individual. The look of the asterisk character helps bolster this imagination.
def foo( x, y, z ):
print( "First is ", x, " then ", y, " lastly ", z )
a = [ 1, 50, 99 ]
foo( a )
# TypeError: foo() takes exactly 3 arguments (1 given)
foo( *a )
# First is 1 then 50 lastly 99
b = [ [55,66,77], 88, 99 ]
foo( *b )
# First is [55,66,77] then 88 lastly 99
For more info, see More Control Flow Tools.
Tried with: Python 3.2.2
The output redirection operators > and >> work in PowerShell just like they do in any other shell. > overwrites a file while >> appends to the file.
These output redirection operators are just aliases for the Out-File cmdlet. The equivalent invocations for > and >> are Out-File and Out-File -Append
Tried with: PowerShell 2.0