
among them, to the ones using general-purpose de-
compositions. The quadtree, as well as the run-length
encoding, are general compression schemes for im-
ages, so it is likely that an input image is already
given in this format. Other decompositions (such as
those from morphological erosion or distance trans-
form) do not correspond to an image format, and they
should be constructed ad-hoc for moment computa-
tion. Therefore, they are not considered in this com-
parison. Some preliminary experiments also showed
that the quadtree-based approach is faster than the one
based on runs, so we concentrate our comparison on
methods working with quadtrees.
We compared our new algorithm with the algo-
rithm by Wu et al. (Wu et al., 2001), the only one in
the literature using a quadtree. We used a sequential
implementation of both algorithms.
Both algorithms have been implemented in
Python and share the same module for the manage-
ment of the quadtree. They differ in the main pro-
cedure used for computing the moments. The used
quadtree implementation maintains a list of all the
leaves, therefore it is not necessary to descend the tree
from the root in order to process all the leaves. The
programs were run on a PC equipped with an Intel
CPU i7-2600K CPU at 3.4 Gigahertz with 32 Giga-
bytes of RAM.
We tested the algorithms on 80 im-
ages from the MPEG7 set available at
https://dabi.temple.edu/external/shape/
MPEG7/MPEG7dataset.zip and featuring different
object shapes and sizes. This set contains 70 classes
of object types with 20 elements each. We selected
the first four elements of twenty classes. Figure 2
shows an element for each selected class.
Note that each class contains semantically the
same object (e.g., an apple or a camel), but the im-
age sizes, the size of the object inside the image, the
thickness of the set of black pixels, may be very dif-
ferent. The given images present a white object on a
black background, and the colors have been inverted
to meet our convention. Figure 3 shows the four se-
lected images in the ”beetle” class.
The total running time of the two algorithms has
the same order of magnitude, and ranges from 0.04
to to 12.7 seconds depending on the size of the im-
age and on the size of the object contained in the im-
age. As Python is an interpreted language, it is easy
to obtain the running time of each executed function
separately. The execution time is dominated by the
construction of the quadtree, which takes from 87%
to 99% of the total time. Figure 4 shows the plot
of the times for building the quadtree (the graph of
the total running time would be almost superimposed
to this). In the figure we note three clusters of run-
ning times around 0.6, 3 and 12 seconds, respectively.
These clusters correspond to three different ranges of
image sizes. For example, among the four images of
class ”beetle” (see Figure 3), beetle-1 takes 12.171
seconds (first cluster from top), beetle-2 and beetle-
4 take 2.886 and 2.882 seconds, respectively (second
cluster), and beetle-3 takes 0.637 seconds (third clus-
ter).
Disregarding the time for building the quadtree,
the remaining time is the one actually used for com-
puting the moments, and is specific of each of the two
algorithms. Figure 5 provides a graphic comparison
of the times for computing the moments by our al-
gorithm (on the x-axis) and the algorithm by Wu et
al. (on the y-axis). Each point corresponds to a test
image. Our algorithm is faster where the point lies
over the bisector of the first quadrant. This happens
for all the test images, the ratio of our execution time
over that by Wu et. al. being on average 36% and at
most 69%. Indeed in Figure 5 we find three clusters
of dots, all aligned on a line of the form y = cx + d
where c ≃ 5 and d is different in each cluster. As the
clusters of Figure 4, also these clusters correspond to
the three different ranges of image sizes. Finally, we
note that the time for computing the central moments
of squares in our algorithm is negligible (less than one
millisecond).
6 SUMMARY AND FUTURE
WORK
We proposed an algorithm for the computation of dis-
crete geometric moments of 2D binary objects en-
coded in the quadtree data structure. It is based on
precomputing the moments of the squares centered
at the origin, and using the connection between cen-
tral and ordinary moments to compute the moments
of the given object. Our algorithm improves the run-
ning time of the previous quadtree-based algorithm
for moments computation by Wu et al. (Wu et al.,
2001) in its sequential form. Both the construction
of the quadtree and the computation of the moments
from it could benefit from a parallel implementation,
as in Wu et al. (Wu et al., 2001).
This work has several possible extensions. It can
be extended to the computation of geometric mo-
ments of
• 3D objects encoded in the octree data structure;
• greyscale images by decomposing the image into
a binary image for each grey level, as done in (Pa-
pakostas et al., 2008);
ICPRAM 2025 - 14th International Conference on Pattern Recognition Applications and Methods
20