-direction2rgb

Figure 1: A Goudy 1911 Bookletter Ampersand in Neon Lights

This command visualizes 2D direction fields using color. 2D direction fields have two channels, their constituent pixels are taken to be vectors in a rectangular coodinate system, and the overall image is taken to be a field of such vectors. 

The command takes no parameters, but expects the selected images to be 2D direction fields: one slice (i.e. depth of one) The command silently ignores any channels other than 0 (x components) and 1 (y components). 

Internally, the command converts vectors from rectangular (x, y) to polar form (r, θ), with θ in channel zero, in degrees and r in channel one. The command inserts an additional unity-filled channel between zero and one and, regarding the ensemble as an HSV image, invokes -hsv2rgb to complete the new representation of the 2D direction field.

In this representation, vectors pointing in the x+ direction (left to right) are red, x- direction (right to left) are cyan, y+(pointing down) are blue violet and y- (pointing up) are lime green. Generally, the assignment of color to direction follows from the HSV color wheel.

See -quiver, which produces an equivalent representation of 2D direction fields by rendering small arrows.