User:Rummelt/sandbox

The Hexagonal Efficient Coordinate System (HECS) (formerly known as Array Set Addressing or ASA) is a coordinate system for hexagonal grids that allows hexagonally sampled images to be efficiently stored and processed on digital systems. HECS represents the hexagonal grid as a set of two interleaved rectangular sub-arrays, which can be addressed by normal integer row and column coordinates and are distinguished with a single binary coordinate. Hexagonal sampling is the optimal approach for isotropically band-limited two-dimensional signals and its use provides a sampling efficiency improvement of 13.4% over rectangular sampling. The HECS system enables the use of hexagonal sampling for digital imaging applications without requiring significant additional processing to address the hexagonal array.

Introduction
The advantages of sampling on a hexagonal grid instead of the standard rectangular grid for digital imaging applications include: more efficient sampling, consistent connectivity, equidistant neighboring pixels, greater angular resolution, and higher circular symmetry. Sometimes, more than one of these advantages compound together, thereby increasing the efficiency by 50% in terms of computation and storage when compared to rectangular sampling. Researchers have shown  that the hexagonal grid is the optimal sampling lattice and its use provides a sampling efficiency improvement of 13.4% over rectangular sampling for isotropically band-limited two-dimensional signals. Despite all of these advantages of hexagonal sampling over rectangular sampling, its application has been limited because of the lack of an efficient coordinate system. However that limitation has been removed with the recent development of HECS.

Description
The Hexagonal Efficient Coordinate System (HECS) is based on the idea of representing the hexagonal grid as a set of two rectangular arrays which can be individually indexed using familiar integer-valued row and column indices. The arrays are distinguished using a single binary coordinate so that a full address for any point on the hexagonal grid is uniquely represented by three coordinates


 * $$ (a,r,c) \in \{ 0,1 \} \times$$ ℤ $$\times$$ ℤ

where the coordinates represent the array, row, and column, respectively. The hexagonal grid is separated into rectangular arrays by taking every other row as one array and the remaining rows as the other array, as shown in the figure.

Nearest Neighbors
The addresses of the nearest neighbors of a pixel (or grid point) are easily determined by simple expressions which are functions of the pixel’s coordinates, as shown.

Convert to Cartesian
Converting coordinates in HECS to their Cartesian counterparts is done with a simple matrix multiplication
 * $$\begin{bmatrix}

x\\y \end{bmatrix} = \begin{bmatrix} \frac{1}{2} & 0 & 1 \\ \frac{\sqrt{3}}{2} & \sqrt{3} & 0 \end{bmatrix}\begin{bmatrix} a\\r\\c \end{bmatrix} = \begin{bmatrix} \frac{a}{2} + c \\(\sqrt{3})(\frac{a}{2} + r) \end{bmatrix}$$.

Preliminaries
Let the set of all possible HECS addresses be $$ HECS = \{ 0,1 \} \times$$ ℤ $$\times$$ ℤ.
 * $$\mathbf{p}_i =\begin{bmatrix}

a_i\\r_i\\c_i \end{bmatrix} \in HECS$$.
 * $$\mathbf{p} =\begin{bmatrix}

a\\r\\c \end{bmatrix} \in HECS$$.
 * $$ k \in $$ ℕ.

Addition
A binary addition operator $$(HECS,+)$$ has been defined as
 * $$\mathbf{p}_1 + \mathbf{p}_2=\begin{bmatrix}

a_1 \oplus a_2\\r_1 + r_2 + (a_1 \land a_2)\\c_1 + c_2 + (a_1 \land a_2) \end{bmatrix}, $$ where $$\oplus$$ is the logical XOR operator and $$\land$$ is the logical AND operator.

Negation
A unary negation operator $$(HECS,-)$$ has been defined as
 * $$-\mathbf{p} =\begin{bmatrix}

a\\-r-a\\-c-a \end{bmatrix} $$.

Subtraction
A binary subtraction operator $$(HECS,-)$$ has been defined by combining the negation and addition operations as
 * $$\mathbf{p}_1-\mathbf{p}_2 = \mathbf{p}_1 + (-\mathbf{p}_2)$$.

Scalar Multiplication
Scalar multiplication has been defined for non-negative integer scalars multipliers as
 * $$k\mathbf{p}=\begin{bmatrix}

(ak) \text{ mod } 2\\kr + (a)\left\lfloor \frac{k}{2} \right\rfloor \\kc + (a)\left\lfloor \frac{k}{2} \right\rfloor \end{bmatrix}, $$ and
 * $$-k\mathbf{p}=k(-\mathbf{p})$$.

Separable Fourier Kernel
The hexagonal discrete Fourier transform (HDFT) was developed by Mersereau and was converted to an HECS representation by Rummelt. Let $$x(a, r, c)$$ be a two-dimensional hexagonally sampled signal and let both arrays be of size $$n$$ x $$m$$. Let, $$X(b, s, d)$$ be the Fourier transform of x. The HDFT equation for the forward transform is given by
 * $$X(b, s, d) = \sum_{a} \sum_{r} \sum_{c} x(a, r, c)exp[-j\pi(\frac{(a+2c)(b+2d)}{2m} + \frac{(a+2r)(b+2s)}{n})] $$

Notice that the HECS representation of the HDFT overcomes Mersereau's "insurmountable difficulty" since it is a separable kernel, which led to the development of the Hexagonal Fast Fourier Transform.

Alternative Addressing Schemes
There have been several attempts to develop efficient coordinate systems for the hexagonal grid. Snyder describes a coordinate system based on non-orthogonal bases which is referred to as the h2 system. Her developed an interesting three coordinate system that uses an oblique plane in three dimensional space. For various reasons, both of these approaches require cumbersome machine representations that lead to inefficient image processing operations. General Balanced Ternary (GBT) is based on a hierarchy of cells, where at every level the cells are each aggregates of cells from the previous level. In two-dimensions, GBT can be used to address the hexagonal grid where each grid point is addressed with a string of base-7 digits and each digit indicates the hexagon's position within that level of the hierarchy. The use of GBT and slightly modified versions of GBT such as HIP and Spiral Architecture for addressing hexagonal grids in two dimensions are abundant in the literature. While these approaches have some interesting mathematical properties, they fail to be convenient or efficient for image processing.

Other 2D Hexagonal Grid Applications
Although HECS was developed mainly for digital image processing of hexagonally sampled images, its benefits extend to other applications such as finding the shortest path distance and shortest path routing between points in hexagonal interconnection networks. Other addressing approaches have been developed for such applications  but they suffer the same drawbacks as the ones described above.