Image slicing for fulldome (and other applications)

Multiple projector systems, in this case for fulldome projection, typically slice
up high resolution movie content into smaller segments. These segments contain that
portion of the image required plus extra for alignment adjustment and edge blending.
There is no one slicing, it depends on the projector arrangement, field of view and
the other intrinsic optical attributes. The supplier of the projection system will
provide the details of how the images should be sliced, this is generally in the
form of a 4 sided polygon defined by the 4 corner vertices.
The transformation, as illustrated below, requires a warping (image transformation)
between the 4 sided polygon
to the rectangular image that will be sent to the projector.

The mathematics for this mapping is straightforward and is outlined below, the symbols
refer to the figure on the right in the above illustration. As with all such mapping one
needs to find the input pixel for every output pixel, that is, a reverse mapping rather than
a forward mapping.
If "p" is a pixel in the output
image, it can defined in normalized coordinates as shown. In the input image one finds
P1 and P2 based upon the value of ux. Then the point
Q is found using the value of uy to interpolate between
P1 and P2. One can imagine this is a stretching of
the polygon space in the input image to the rectangular output image.

p1x = cx0 + ux (cx2 - cx0)
p1y = cx1 + ux (cx3 - cx1)

p2x = cx6 + ux (cx4 - cx6)
p2y = cx7 + ux (cx5 - cx7)

qx = p1x + uy (p2x - p1x)
qy = p1y + uy (p2y - p1y)

In practice one needs to perform antialiasing, generally supersampling is the easiest. This
means one samples multiple times around the output pixel to be estimated, each time finding
the corresponding pixel value in the input image, averaging those values to determine
the final output image pixel value. This reinforces the need to work in continuous normalized
coordinates rather than integer pixel coordinates.

The implementation here as a proof of concept is a C/C++ utility initially intended for
UNIX systems, for example flavours of Linux and Mac OSX. The "mapfile" just lists the
values of cx0, cx1, cx2, cx3, cx4, cx5, cx6, cx7. The input image is read only once and
all the output slices generated from that based upon the map files.

The following is one frame from the Dark fulldome movie.
Note the original is a 4K fulldome production.

The eight resulting output images are below. The grey regions are those where the polygon
extended outside the image bounds, normally this would be shaded black but left grey
here of illustrative purposes.

The example presented here is performed solely on the CPU and as implemented is only single core.
As it happens the process of applying this is real life to movie sequences is highly parallel,
simply by splitting the frames up into sections or applying N conversions to frames modulo N.
An alternative would be to perform this on the GPU. Another is to use OpenGL (or DirectX) and
treat each frame as a texture on an appropriate mesh.