### Lengths of digital curves

This is a problem most people outside the field are unaware of. In fact, I have also overlooked it for a while. The problem is, **how do we measure lengths of curves in digital images**? First, why do we need that? Because we want to be able to evaluate shapes of objects and the most elementary way to do it is to compare their areas to their perimeters. For example, area/(perimeter)^2 will tell circles from squares.

In the digital domain, curves are represented as sequences of points. It seems “obvious” that the length is the total sum of distances between consecutive points. The trouble starts as soon as you realize that the same “physical” curve will have many digital representations – depending on the resolution of the image and the orientation of the curve with respect to the grid of the image.

Consider this example. If r is the size of the pixel, a line segment of length a will be represented by roughly a/r pixels… but only if it is placed horizontally or vertically! If it is placed diagonally, there will be √2*a/r pixels arranged in the staircase pattern. The result is that **the digital length of a curve may vary by 40%**. If you overlook this difference, the consequences may be disastrous.

To be continued…

October 20th, 2007 at 7:03 pm

[…] Recall that in the last post we observed that, since a curve in a digital image is represented as sequences of points, it is natural to think of its length as the total sum of distances between consecutive points. However, with this approach the length of a diagonally oriented segment will be overestimated by 40%. […]

November 7th, 2007 at 3:21 pm

[…] From the three previous posts on the topic (Lengths of digital curves, parts 1, 2, 3) and a little presentation I gave recently I created an article for the wiki. In comparison, analysis is more extensive and there are more illustrations. At the end there are two examples of computation of roundness with Pixcavator 2.4. Circles have roundness close to 90, squares close to 80. It works quite well for large objects. You can now distinguish between circles and squares and between squares and elongated objects. For example, you have now a new way to automatically count (round) cells in the image and ignore (rough edged) noise. […]