For performance reasons, integer values are used to represent positions. As the
summation of 3 integer values to
obtain the
or
position of a cell's projection
introduces an error of up to 1.5 pixels in
and
,
the arrays have to contain sub-pixel coordinates
to keep the error below one pixel.
In combination with precalculated templates, the projection of a cell becomes simple and efficient. Cmax is obtained in a way described in the following paragraph, img_width is the width of the image in pixels. .pixel is the x or y coordinate of an image pixel, .subpix is a sub-pixel offset.
(xp,yp)=projection(cell.v1);
imgpos=xp.pixel+yp.pixel*img_width;
template=subtemplate[xp.subpix, yp.subpix];
for all elements in template
{
if(image[imgpos+template_element.imgoffset]<Cmax)
evaluate cell contribution at this pixel
}