← All posts
Tag

opencv

9 posts · browse all tags

Fundamentals

An Image Is an Array: Shape, dtype, and Why OpenCV Hands You BGR

Lesson 1 of The Image as Data. One photograph, held three ways: a 24.7 MB mosaic of 12-bit counts, a 74.2 MB 16-bit development, and the 37.1 MB 8-bit array imread would give you. Two thirds of the numbers in that last one were never measured, adding 60 to a value of 207 gives 11, and a slice you write into changes the original.

computer-visionimage-processingopencvnumpy
Read more →
Fundamentals

File Formats: What the Encoder Did Before You Read the Pixels

Lesson 5 of The Image as Data. A JPEG quality sweep costs almost nothing in PSNR and takes Canny's edge agreement from 0.949 to 0.895. Chroma subsampling saves 40% of the bytes for 0.09 of ΔE. And OpenCV and Pillow decode every JPEG here bit-for-bit identically — the disagreement is a 16-bit PNG, which Pillow silently opens as 8-bit.

computer-visionimage-processingcompressionjpeg
Read more →
Fundamentals

Lens Distortion: Where the Straight-Line Model Actually Fails

Lesson 3 of the Image Formation unit. Real glass bends rays more at the edges, and the error grows with the sixth power of radius. Measured on OpenCV's calibration set: the top-left pixel of a 640x480 frame belongs 51.22 px from where the pinhole model puts it, and adding the Brown-Conrady terms drops the mean reprojection error of one view from 2.55 px to 0.170 px. Straightening it back costs field of view rather than pixels: 61.67 degrees becomes 67.32.

computer-visioncamera-calibrationopencvoptics
Read more →
Fundamentals

The Image as Data: The Grid, the Integers, the Axes, and the File

The unit overview: what an array actually holds, where its samples sit, how finely each one is written down, what its three numbers mean, and what the encoder did before you read any of it. Measured on one photograph: two thirds of a colour image is interpolated, a 7.4-pixel ribbing returns as 96-pixel banding when you decimate by eight, bit depth stops buying anything at 9.4 bits, and the naive route from file to colour lands 9.54 ΔE from the light in the room.

computer-visionimage-processingopencvsampling
Read more →
Fundamentals

Fisheye Models: When Correcting the Lens Stops Working

Lesson 4 of the Image Formation unit. Past roughly 120 degrees the pinhole model is not inaccurate, it is the wrong shape, because tan θ runs to infinity while the sensor does not. Fitted to the same 15 photographs of one fisheye lens, pinhole plus Brown-Conrady reaches 7.326 px RMS and Kannala-Brandt reaches 0.644 px. At 80 degrees the first model predicts a radius of -35,572 px, a sign flip; the second predicts 458.8 px, which is on the sensor.

computer-visioncamera-calibrationopencvoptics
Read more →
Fundamentals

Structure from Motion, from Scratch: 47 Photos to a 3-D Temple in ~800 Lines of Python

How overlapping 2-D photos become 3-D points and camera poses: SIFT matching, the essential matrix, triangulation, PnP growth, and sparse bundle adjustment, built from scratch with OpenCV + SciPy. The pipeline registers all 47 Middlebury temple views at 0.25 px mean reprojection error, next to COLMAP's 0.30 px on the same images. Worked examples, three interactive labs, and the reconstruction growing image by image.

computer-visiongeometrysfmopencv
Read more →
Fundamentals

Camera Models, End to End: K, the Extrinsics, Calibration & PnP, with OpenCV

How a 3-D point becomes a pixel and back again: the intrinsic matrix K, the extrinsics R|t that place the camera in the world, Zhang calibration to 0.35 px reprojection error, and solvePnP recovering a 68-px-off pose to ~0. The math, two interactive labs, and runnable OpenCV in Python and C++.

computer-visioncamera-calibrationopencvgeometry
Read more →
Fundamentals

How 2D Convolution Works on Images: Kernels, Filters, and the Math, Interactively

2D convolution is the operation behind blur, sharpening, edge detection, and every CNN. Slide a kernel, multiply, sum: see it happen step by step in an interactive demo, apply real kernels to a live image, and get the math plus runnable OpenCV in Python and C++.

computer-visionimage-processingconvolutionkernels
Read more →
Fundamentals

Colour Spaces: Choosing Axes You Can Threshold

Lesson 4 of The Image as Data. A colour space is a choice of axes for the same three numbers, and the choice is what makes a question easy or impossible. Worked on one measured chart patch: RGB (149.8, 58.3, 34.0) becomes luma 82.8, hue 12 degrees stored as 6, and a Lab triple — plus the five-line red detector that is brittle in RGB and robust in HSV.

computer-visionimage-processingopencvcolor-spaces
Read more →