LESSON
Region Perimeter
Share
Transcript
We can find additional information to describe the shape of an object by looking at its perimeter, by looking at its boundary.
Here we have a very simple scene with a dark object against a white background. The simplest way to compute the length of the perimeter of the object is to simply trace around the outside of the object. So the lines are either vertical or horizontal, and this is a technique called crack coding. We measure the length of this blue path. It tells us something about the length of the perimeter of the object.
Another way of measuring the perimeter of the object is to first of all consider all of the pixels that sit on the edge of the object, and those pixels are all marked with a red dot. Those red dots are the centres of the pixels that are on the edge of the object. And an alternative technique is to join the centres of the dots. This is called an 8-neighbour chain code. So the length of this path can be considered to be the length of the boundary of the object.
We can see that there are going to be some differences here. The crack code is perhaps going to overestimate the boundary of the object. The chain code is going to perhaps underestimate the boundary of the object, but the chain code does a much better job when the object has got sides that are neither vertical nor horizontal. When there are sloped segments on the object, chain code can perhaps give a slightly more realistic estimate.
In this case with very small objects the difference between the two approaches is going to be quite significant. When objects are very large with hundreds or thousands of pixels, the difference is much less significant.
Now if we compute the perimeter using either of the techniques just mentioned, and we call that the perimeter length p, we can compute a measure that we call circularity and this is a measure that is related to compactness. So we take 4x π, multiplied by the area of the object, which comes from the zeroth moment, and we divide it by the perimeter squared. So this is a non-dimensional quantity. The numerator contains the area, which has got units of pixels squared. We divided by the length, which has got units of pixels squared. So this non-dimensional quantity has got no units.
For the case of the circle, circularity has got a value of 1 … 1 means it’s a circle. For less than 1 it means that it’s not a circle, and for a long line it approaches 0, so it cannot be bigger than 1, it can be less than 1. 1 if it’s a circle.
Code
We can also describe a blob by its contour or perimeter. Let’s look at how we determine the length of a blob’s perimeter using crack code and chain code. We can use the perimeter length to determine another scale and invariant shape parameter called circularity which indicates how compact, or circle-like, the blob is.
Skill level
MATLAB experience
This content assumes an understanding of high school level mathematics; for example, trigonometry, algebra, calculus, physics (optics) and experience with MATLAB command line and programming, for example workspace, variables, arrays, types, functions and classes.