# Spacial Quantization Error

Hard thresholding works well at segmenting images. But when blob analysis of the resulting segmented image is performed, the results of the analysis are often degraded by spatial quantization error.

Spatial quantization error results from the fact that the exact edge of an object in a scene almost never falls precisely at the boundary between two pixels in an image of that scene. The pixels in which the edge of the blob falls have some intermediate pixel value. Depending on how much of the object lies on the pixel, the pixel is counted as an object pixel or a background pixel. A very small change in the position of a blob can result in a large change in the reported position of the blob edge.

The following figure illustrates spatial quantization error. While the edge of the blob has only moved a tiny fraction of a pixel, the edge of the blob as reported by the hard thresholded image has moved an entire pixel width.

Spatial quantization error can affect the size, perimeter, and location that are reported for a blob. The effect of spatial quantization error on a blob's area differs depending on the shape of the blob.

The following examples assume that pixels covered less than 50 percent by the blob are assigned as background pixels while pixels covered 50 percent or more by the blob are assigned as object pixels.

In both sets of figures, note how the number of pixels assigned as object pixels changes as a result of a slight shift in the blob's position on the pixel grid. In the previous figure, the blob is a square measuring 8.5x8.5 pixels. On the left side of the figure, the blob is centered on the grid so that the blob fully covers 64 pixels (the 8x8 square of pixels at the center of the grid) plus one quarter of each of the pixels that border the blob. Since the border pixels are less than 50% covered by the blob, they are not counted as object pixels and the total number of object pixels is 64. On the right side of the figure the blob is centered on the grid so that the blob fully covers 49 pixels (the 7x7 square of pixels at the center of the grid) plus three quarters of each of the pixels that border the blob. Since the border pixels are more than 50% covered by the blob, they are counted as object pixels, and the total number of object pixels is 81.

The severity of spatial quantization errors depends on the ratio of perimeter to area in the image. Note how much greater the effect of spatial quantization error becomes in the following figure, where there is a greater ratio of perimeter to area.

Edges that are aligned with the pixel grid, such as those of rectangles, tend to produce systematic reinforcing errors, while other edges, such as those of round objects, tend to produce random canceling errors.