Hi I am working on some simple computer vision stuff and bumped into this &= assignment. However googling &= sucks.
What does this &= do in this case?
backproj &= mask;
backproj and mask are both matrices containing a part of a picture. I could found on this forum that normally &= is a bitwise comparison assigning the AND logic operator to backproj.
So normally "a&=b;" is the same as "a = (a && b) ? true : false;"?
However, even if that is the case, I don't how this would translate when the input is a matrix/array. Does anyone know this?
Background: I am currently porting the Camshift opencv algorithm to work with another QT-platform from our university (parlevision), everything cpp. I never learned the basics of cpp but somehow manage to get stuff working most of the time with some feeling for pointers and references. I never asked a question here so my appologies if I am doing something incorrect.
a &= b; // same as
a = a & b; // here, bitwise AND
Bitwise AND works on the bit level, according to this table:
&|01
-+--
0|00
1|01
if a is represented as 00110011
if b is represented as 11101110
and if c = a & b
00110011 &
11101110
--------
c is represented as 00100010
Typically b has the role of the "mask" when a is used to store flags.
ABCDEFGH (flags)
a is represented as 10010001
The bits of a show that flags A, D and H are set.
How to check the state of flag E?
consider e is the mask for flag E, then
ABCDEFGH (mask)
e is represented as 00001000
r = a & e
if r == 0, flag E is not set
if r != 0, flag E is set