Boundary Moments

$ \def \EN {\quad \mbox{and} \quad} \def \half {\frac{1}{2}} \def \hieruit {\quad \Longrightarrow \quad} $ Hithereto, moments actually have been calculated over the surface which is enclosed by a contour. It's also possible, however, to define the moments of a contour over its boundary only. Since all contours can be thought as being built up from infinitely many straight line segments, it is sufficient, for our purpose, to restrict attention to straight line segments. The governing equations of any such a segment are: $$ \begin{array}{l} x = x_1 + (x_2-x_1).t \\ y = y_1 + (y_2-y_1).t \end{array} $$ Here $(x_1,y_1)$ and $(x_2,y_2)$ are the end-points of the segment and $0 \le t \le 1$ .
The moments are calculated now in chronological order. First we do the length of the line segment: $$ \int_{(1)}^{(2)} ds = \int_{(1)}^{(2)} \sqrt{dx^2 + dy^2} = \int_0^1 \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2} \, dt \hieruit $$ $$ \mbox{Length} = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2} $$ Then we do the middle of the line segment: $$ \frac{ \left( \int_{(1)}^{(2)} x \, ds \: , \: \int_{(1)}^{(2)} y \, ds \right)} { \mbox{Length} } = \frac{ \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2} \left( \int_0^1 x \, dt \: , \: \int_0^1 y \, dt \right) } { \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2} } $$ $$ = \left( \int_0^1 x \, dt \: , \: \int_0^1 y \, dt \right) $$ It is seen that the square root, representing the length of the line segment, is just cancelled out. This is a common feature of all boundary moment calculations. $$ \left( \int_0^1 x \, dt \: , \: \int_0^1 y \, dt \right) = \left( \int_0^1 \left[ x_1 + (x_2-x_1).t \right] \, dt \: , \: \int_0^1 \left[ y_1 + (y_2-y_1).t \right] \, dt \right) $$ $$ = \left( x_1.1 + (x_2-x_1).\half \: , \: y_1.1 + (y_2-y_1).\half \right) \hieruit $$ $$ \mbox{Middle} = \half \left( x_1 + x_2 \: , y_1 + y_2 \right) $$ Well, guess that we did'nt expect this result. Anyway, here comes the matrix of second order moments, at last: $$ \left( \begin{array}{cc} \int_0^1 x^2 \, dt & \int_0^1 x y \, dt \\ & \\ \int_0^1 x y \, dt & \int_0^1 y^2 \, dt \end{array} \right) $$ Same trick as always: calculate $\overline{xy}$ only and find $\overline{x^2}$ as well as $\overline{y^2}$ later on by proper substitution herein. $$ \int_0^1 x y \, dt = \int_0^1 \left[ x_1 + (x_2-x_1).t \right] \left[ y_1 + (y_2-y_1).t \right] \, dt $$ $$ = x_1 y_1 + x_1 (y_2-y_1).\half + (x_2-x_1) y_1.\half + (x_2-x_1)(y_2-y_1).\frac{1}{3} $$ Here come the results: $$ \overline{xy} = \frac{1}{3} ( x_1 y_1 + x_2 y_2 ) + \frac{1}{6} ( x_1 y_2 + x_2 y_1 ) \hieruit $$ $$ \overline{x^2} = \frac{1}{3} ( x_1 x_1 + x_1 x_2 + x_2 x_2 ) \EN \overline{y^2} = \frac{1}{3} ( y_1 y_1 + y_1 y_2 + y_2 y_2 ) $$ Boundary moments (lijn) are used in the program as error estimates for the corresponding surface moments ({\bf vlak}). To see how this is possible, some well-known facts about the area and (arc)length of a circle come into mind: $$ \mbox{Area} = \pi r^2 \qquad \mbox{Length} = 2 \pi r \hieruit d \mbox{Area} = 2 \pi r \, dr = \mbox{Length} . \mbox{Thickness} $$ The same kind of thought can be produced for a square with edge-length $2a$ : $$ \mbox{Area} = (2a)^2 \qquad \mbox{Length} = 8 a \hieruit d \mbox{Area} = 8 a \, da = \mbox{Length} . \mbox{Thickness} $$ The generalization of these facts reads as follows: $$ d (\mbox{surface moment}) = (\mbox{boundary moment}) \times \mbox{thickness} $$ In words: an estimate for the error in a surface moment is the magnitude of the corresponding boundary moment times the thickness of the boudary. The latter is not difficult to find, since most of the time the accuracy / thickness of the boundary is equal to one or two pixels in the image at hand.