Husam Alhomsi

PQ Images

PQ images are a kind of mathematical art. I discovered them around 2019.

Software

These programs and libraries are part of Misk. I use pq-fb to explore the images and pq-png to save them.

Definition

In a PQ image, a function of the form p#(q, (x, y)) is applied to every pixel. The #, q, x, y, and output of the function are nonnegative integers. The function is called a painter. The # is called the identifier (ID). The q is called the q-value. The x and y are the horizontal and vertical coordinates of a pixel, respectively. Pixel (x, y) is black if p#(q, (x, y)) = 0, otherwise it is white.

For pixel (x, y), the pixel to its right is at (x + 1, y), and the pixel below it is at (x, y + 1). The top-left pixel is at (x0, y0), where x0 and y0 are nonnegative integers called x-offset and y-offset, respectively. Pixel (0, 0) is called the origin.

There are 50 defined painters, 0 through 49, divided into 10 classes, 0 through 9. Painters in odd classes divide by q, so q = 0 is undefined for them. For all painters, p#(q, (x, y)) = p#(q, (y, x)).

The following is a list of all painters, where & denotes bitwise AND, | denotes bitwise inclusive OR, ^ denotes bitwise exclusive OR, * denotes multiplication, which has the highest precedence, and % denotes modulo:

Example

For a PQ image with width 3, height 2, x-offset x0 = 1, and y-offset y0 = 2, the pixels of the image are numbered as follows:

(1, 2)(2, 2)(3, 2)
(1, 3)(2, 3)(3, 3)

Painter 8 with q-value 4 is applied to every pixel as follows:

The pixels are colored as follows:

WhiteBlackWhite
BlackWhiteWhite

Pixel (2, 2) is black because p8(4, (2, 2)) = 0. Pixel (1, 2) is white because p8(4, (1, 2)) ≠ 0.

Observations

Demo

Here is an interactive demo of PQ images. From the options below, select a painter and input the q-value to paint the canvas. Note that the options are limited in comparison with those of the main program: pq-png.

Options comparison
ProgramPainterLength Offset
Demo 2 or 42256 0
Main 0 to 491 to 2150 to 232 - 1
Options

Canvas

Gallery

Here are some images written using pq-png. They are 256 pixels in width and height. Their captions show the painter and q-value used to paint them.

p0 q128
p1 q128
p2 q128
p3 q128
p4 q128
p10 q256
p11 q256
p12 q256
p13 q256
p14 q256