In this section, R-histogram, which represents the relative attitude relationship between two shapes, is first defined, and then its symmetry and affine invariance are explored.

### Definition of R-histogram

As shown in Figure1, two shapes *A* and *B*, which are located in an original positively oriented orthonormal frame\left(O,\overrightarrow{i},\overrightarrow{j}\right), are denoted as{E}^{A} and{E}^{B} respectively. To measure the attitude of *A* relative to *B*, we first define a relative positively oriented orthonormal frame\left(O,{\overrightarrow{x}}_{\mathit{AB}},{\overrightarrow{y}}_{\mathit{AB}}\right) (Figure1a), in which, the{x}_{\mathit{AB}}-\text{axis} has the same direction with{\overrightarrow{v}}_{{c}_{B}{c}_{A}}. *c*_{
A
} and *c*_{
B
} are the centroids of *A* and *B*, respectively.l\left(v\right) is the line parallel to the{x}_{\mathit{AB}}-\text{axis} with *v* the intercept on{y}_{\mathit{AB}}-\text{axis}. For any real number *v*, the intersection{E}^{A}\cap l\left(v\right), denoted by{E}^{A}\left(v\right), is a longitudinal segment of _{
A
}. In this article, as the term “*shape*” denotes a 2D plane which may have holes in it or may consist of many connected components,{E}^{A}\left(v\right) e.g.,{E}^{A}\left({{v}_{N}}_{-1}\right) in Figure1a is the union of a finite number of disjoint segments. Similarly,{E}^{B}\left(v\right)\phantom{\rule{0.5em}{0ex}}\left({E}^{B}\cap l\left(v\right)\right) stands for a longitudinal segment of shape *B*.

The R-histogram of *A* with respect to *B*, whose elements are the length ratios of the collinear longitudinal segments, is represented by *R*_{
AB
} as

{R}_{\mathit{AB}}\left(n\right)=\frac{L\left({E}^{A}\left({v}_{n}\right)\right)}{L\left({E}^{B}\left({v}_{n}\right)\right)}\phantom{\rule{0.3em}{0ex}},{v}_{n}={v}_{min}+n*\frac{{v}_{max}-{v}_{min}}{N},\phantom{\rule{0.7em}{0ex}}n=0,1,2,\dots ,N\text{.}

(1)

In Equation (1), *L*(*ξ*) denotes the length of the longitudinal segment *ξ*, *N* is the number of *v* that are sampled equidistantly in the range of\left[{v}_{min},{v}_{max}\right],{v}_{min} and{v}_{max} are the minimum and maximum intercepts of the valid lines *l*(*v*) which have nonempty intersections with both *A* and *B*, i.e.,

\begin{array}{c}\hfill {v}_{min}=max\left({v}_{min}^{A},{v}_{min}^{B}\right)\hfill \\ \hfill {v}_{max}=min\left({v}_{max}^{A},{v}_{max}^{B}\right)\hfill \end{array}\text{.}

(2)

{v}_{min}^{A} and{v}_{max}^{A} are the minimum and maximum intercepts of the lines *l*(*v*) which have nonempty intersections with *A*. Similarly,{v}_{min}^{B} and{v}_{max}^{B} are the minimum and maximum intercepts of *l*(*v*) which have nonempty intersections with *B*.

Similarly, the R-histogram of *B* relative to *A* is

{R}_{\mathit{BA}}\left(n\right)=\frac{L\left({E}^{B}\left({v}_{n}\right)\right)}{L\left({E}^{A}\left({v}_{n}\right)\right)},\phantom{\rule{0.8000001em}{0ex}}{v}_{n}={v}_{min}+n*\frac{{v}_{max}-{v}_{min}}{N},\phantom{\rule{0.7em}{0ex}}n=0,1,2,\dots ,N\text{.}

(3)

Note that, the *R*_{
BA
} is calculated based on the relative positively oriented orthonormal frame\left(O,{\overrightarrow{x}}_{\mathit{BA}},{\overrightarrow{y}}_{\mathit{BA}}\right) (Figure1b), where the{x}_{\mathit{BA}}-\text{axis} has the same direction with{\overrightarrow{v}}_{{c}_{B}{c}_{A}}.

### Symmetry and affine invariance

Here, desirable properties (i.e., symmetry and affine invariance) of R-histogram for shape matching are proved.

#### Symmetry

As shown in Figure1, the direction of{x}_{\mathit{AB}}-\text{axis} of the frame\left(O,{\overrightarrow{x}}_{\mathit{AB}},{\overrightarrow{y}}_{\mathit{AB}}\right) (Figure1a) is opposite to the direction of{x}_{\mathit{BA}}-\text{axis} of the frame\left(O,{\overrightarrow{x}}_{\mathit{BA}},{\overrightarrow{y}}_{\mathit{BA}}\right) (Figure1b). Consequently, the lines *l*(*v*_{
min
}) and *l*(*v*_{
max
}) in\left(O,{\overrightarrow{x}}_{\mathit{AB}},{\overrightarrow{y}}_{\mathit{AB}}\right) for *R*_{
AB
} are interchanged into the lines *l*(*v*_{
max
}) and *l*(*v*_{
min
}) in\left(O,{\overrightarrow{x}}_{\mathit{BA}},{\overrightarrow{y}}_{\mathit{BA}}\right) while *R*_{
BA
} is being computed. Therefore, the symmetry of R-histogram, which describes the mathematical link between *R*_{
AB
} and *R*_{
BA
}, is deduced as

{R}_{\mathit{BA}}\left({v}_{n}\right)=1/{R}_{\mathit{AB}}\left({v}_{N-n}\right)\text{.}

(4)

#### Affine invariance

The general 2D affine transformationT=\left\{{A}_{T},b\right\} transforms point *p* in the original image into its corresponding point *q* in the transformed image by *q*q={A}_{T}p+b, where{b}_{2\times 1} is the translation vector and{{A}_{T}}_{2\times 2} is the affine transformation matrix between the two images. Rotation, scaling and shearing, considered as the special cases of affine transform, are represented as the following matrices:

{{A}_{T}}_{\mathit{scaling}}=\left(\begin{array}{l}{s}_{x}\phantom{\rule{0.7em}{0ex}}0\\ 0\phantom{\rule{1em}{0ex}}{s}_{y}\end{array}\right),\phantom{\rule{0.5em}{0ex}}{{A}_{T}}_{\mathit{rotation}}=\left(\begin{array}{l}cos\theta \phantom{\rule{0.7em}{0ex}}-sin\theta \\ sin\theta \phantom{\rule{1.4em}{0ex}}cos\theta \end{array}\right),\phantom{\rule{0.5em}{0ex}}{{A}_{T}}_{\mathit{shearing}}=\left(\begin{array}{l}1\phantom{\rule{0.9em}{0ex}}k\\ 0\phantom{\rule{1em}{0ex}}1\end{array}\right)\text{.}

(5)

If two shapes *A* and *B* are transformed into *A*′ and *B*′ by an affine transformation, we have

\begin{array}{c}\hfill {R}_{\mathit{AB}}\left(n\right)={R}_{{A}^{\prime}{B}^{\prime}}\left(n\right)\hfill \\ \hfill {R}_{\mathit{BA}}\left(n\right)={R}_{{B}^{\prime}{A}^{\prime}}\left(n\right)\hfill \end{array}\text{.}

(6)

Equation 6 reveals that a shape pair preserves its R-histogram while the affine mapping.

Obviously, the R-histogram is invariant to translation transformation, thus, we only explain the invariance of the R-histogram to affine transformation matrix. As shown in Figure2, in an original positively oriented orthonormal frame\left(O,\overrightarrow{i},\overrightarrow{j}\right), two shapes *A* and *B* (Figure2a) are transformed into *A*′ and *B*′ (Figure2b) by an affine transformation matrix *A*_{
T
}.\left(O,{\overrightarrow{x}}_{\mathit{AB}},{\overrightarrow{y}}_{\mathit{AB}}\right) and\left(O,{\overrightarrow{x}}_{A\text{'}B\text{'}},{\overrightarrow{y}}_{A\text{'}B\text{'}}\right) are the relative frames for *R*_{
AB
} and *R*_{
A′B′
}. *c*_{
A
}, *c*_{
B
}, *c*_{
A′
} and *c*_{
B′
} are centroids of *A*, *B*, *A*′ and *B*′, respectively. It can be deduced that, if the projection of a point on *y*_{
AB
}-axis is known, the projection of the mapped point on *y*_{
A’B’
}-axis can be obtained by

{v}^{\prime}=\frac{det\left({A}_{T}\right)dis\left({c}_{A},{c}_{B}\right)}{dis\left({c}_{A\text{'}},{c}_{B\text{'}}\right)}v\propto v\text{.}

(7)

In Equation (7), det(*A*_{
T
}), which is the determinate of the transformation matrix, is positive.dis\left(\cdot ,\cdot \right) is the distance between two points, *v* is the projection of a point on *y*_{
AB
}-axis, and *v′* is the projection of the mapped point on *y*_{
A’B’
}-axis.

Eq. 7 reveals that the projection of the transformed points on *y*_{
A’B’
}-axis is directly proportional to the projection of the original points on *y*_{
AB
}-axis. Moreover,{E}^{A}\left(v\right), representing the intersection{E}^{A}\cap l\left(v\right), can be treated as the union of points of shape *A* with the projection value of *v* on *y*_{
AB
}-axis. Therefore, we have

{E}^{A}\left({v}_{n}\right)\iff {E}^{A\text{'}}\left(v{\text{'}}_{n}\right),\phantom{\rule{0.5em}{0ex}}{E}^{B}\left({v}_{n}\right)\iff {E}^{B\text{'}}\left(v{\text{'}}_{n}\right){v}_{n}={v}_{min}+\frac{n}{N}({v}_{max}-{v}_{min}),\phantom{\rule{0.5em}{0ex}}v{\text{'}}_{n}=v{\text{'}}_{min}+\frac{n}{N}(v{\text{'}}_{max}-v{\text{'}}_{min})\text{,}

(8)

where, “⇔” denotes the correspondence relationship. As introduced in “Definition of R-histogram” section,{v}_{min},{v}_{max},{{v}^{\prime}}_{min} and{{v}^{\prime}}_{max} are the minimum and maximum values of intercepts of valid lines for original and transformed shape pairs. So far, as{E}^{A}\left({v}_{n}\right) and{E}^{B}\left({v}_{n}\right) are collinear, the affine invariance of R-histogram is proved due to the collinear distance invariance[18] of the affine transformation.