CV Lab 04 · Module 1 — Foundations

Image Arithmetic & Blending

Images are grids of numbers, so you can add, subtract, multiply, and mask them just like any other matrix. Two images in, one image out — and this simple maths is the foundation of masking, background subtraction, HDR blending, and every double-exposure filter in your phone.

Image A
+
Image B
=
Result

Source

Camera → use as A

Source

Camera → use as B

Arithmetic

Bitwise & Masking

Result = saturate(A + B)

Adding two images clips at 255 — a bright pixel plus another bright pixel can't get brighter than white. That saturation is the reason "just add the frames" gives you a wash-out instead of a proper double exposure.

Where these operations show up in the real world

Absolute difference — motion detection

Take today's camera frame minus yesterday's background of the same scene. Everywhere the numbers are close, you get zero (black). Everywhere something moved, you get large positive values (bright). This one operation is the seed of every simple motion detector and security-camera alert.

Multiplication and masking — cutouts

Multiply an image by a 0/1 mask and everything outside the mask goes to zero. This is how green-screen compositing, Photoshop layer masks, and CV region-of-interest cropping all work under the hood.

Weighted blend — HDR & fades

α·A + (1−α)·B is a linear crossfade. Two exposures (dark for highlights, bright for shadows) blended this way produce HDR photos. Two consecutive video frames blended this way produce motion blur. Same maths, wildly different applications.

Predict, then verify

You want a security camera that flashes an alert whenever anything moves in front of a static wall. Which operation between the current frame (A) and the empty-wall reference (B) is the cleanest starting point?