I have a sequence of frames of a moving camera. The frames have been stabilized. I want to calculate the frame difference between each two subsequent frames. I do it using
diff = abs(frame1 - frame2);
Frames are Mat objects. However, the two frames will have areas that are not overlapped (i.e. one of the two pixel values of the two frames will be equal to 0), which I don't want to include.
If two pixel values are a (= 0)
and b (!= 0)
, then the abs()
will be |b|, but I would like to instead have the value 0 if one of the two pixels is 0.
EDIT: I would like to do it without looping over the pixels