semmixcolor and perception

Pixel aspect ratio

Today nearly every pixel is square, but that was not always so. Digital SD television and old graphics cards used pixels narrower or wider than they were tall. If a program does not know the pixels are non-square, a circle on screen turns into an ellipse.

Pixel aspect versus display aspect

There are two ratios:

DAR = (width in pixels · PAR) / height in pixels

With square pixels PAR = 1 and DAR is simply the ratio of the dimensions, e.g. 1920 / 1080 = 16:9.

Non-square pixels in SD video

Digital SD video stores a 4:3 picture at 720 × 576 (PAL) or 720 × 480 (NTSC). Neither gives 4:3 with square pixels, so the pixels have a different shape. In one common convention:

PAL: 720 × 576, PAR = 16:15 ≈ 1.067 → 720 · 16/15 = 768, 768 / 576 = 4:3 NTSC: 720 × 480, PAR = 8:9 ≈ 0.889 → 720 · 8/9 = 640, 640 / 480 = 4:3

PAL pixels are therefore slightly wider than tall, NTSC slightly narrower. Showing such footage with PAR = 1 stretches or squeezes it by a few percent. The exact PAR values in video standards vary slightly depending on whether the active part of the line is counted, which is why editing software sometimes shows 59:54 and 10:11.

Aspect ratio in GIF

GIF has one byte for pixel aspect in the logical screen descriptor:

byte = 0 → not given (assume square) byte = N > 0 → PAR = (N + 15) / 64 N = 49 → PAR = 64 / 64 = 1 N = 1 → PAR = 16 / 64 = 1:4 (narrowest) N = 255 → PAR = 270 / 64 ≈ 4.2 (widest)

Nearly all software writes 0 here, and nearly all viewers ignore the byte even when it is not zero.

Aspect ratio versus DPI

PNG stores pixel density in the pHYs chunk, JPEG in the JFIF or EXIF header, separately for horizontal and vertical. The pixel aspect follows from these two numbers, but they are usually equal, e.g. 72 × 72 or 300 × 300 dpi.

DPI does not change how the image looks on screen. It only says how large the image should be when printed: 3000 pixels at 300 dpi is 10 inches, 25.4 cm. The same file at 72 dpi prints over a meter wide. The number of pixels is the same in both cases.

When processing images from SD video, rescale them to square pixels first, and only then measure angles, circles or object proportions.