## October 12, 2007

### Lengths of digital curves

Filed under: computer vision/machine vision/AI, mathematics — Peter @ 3:49 am

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…

### 2 Responses to “Lengths of digital curves”

1. Computer Vision for Dummies » Lengths of digital curves, continued Says:

[…] 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%. […]

2. Computer Vision for Dummies » Lengths of digital curves, part 4 Says:

[…] 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. […]