LESSON
Region Hierarchy
Share
Transcript
We talked a moment ago about the background blob and the fact that it has two holes in it, which represented the foreground objects. Let’s look at this more complicated example. A binary image, large number of blobs, blobs with holes in them, and then blobs within holes within the blobs and so on.
If we apply the connectivity analysis we’re able to label all of these individual blobs. It doesn’t matter if the blobs are black or white; they are distinct, coherent regions of the same colour, and we can compute labels for them. And this is the value of the labels of each of those blobs.
The background blob is number 1, and within the background there are three top-level objects, and they are blobs 3, 2 and 6. We can consider that these blobs are children of the background. The foreground objects are children of the background object. Now object number 3 has got two holes in it, and we can consider these holes as children of blob number 3. So we’re building up a bit of a family tree here. One is the background, it’s got children 2, 3 and 6; 3 has got children 5 and 7; 2 has got one child, which is blob number 4, and blob 6 has got two children, 8 and 9.
Now 9 is a bit more complicated: it’s a hole. Within that hole are two white objects, regions 10 and 11. So we can build up a family tree of objects — a blob hierarchy.
Let’s try this out.
I’m going to load the image that we were just looking at, it’s in the file multiblobs.png and we can display that just to verify the image that we’re looking at. Now I am going to compute a label image as we did a little time ago. I use the ilabel function, pass in the image. We see that nb has got a value of 11: there are 11 unique blobs in this particular image, and we will display the label image. Here we see the label image and we see all the pixels that belong to blob number 1, all the pixels here belong to blob number 3. This blob up here has been labelled 5, this blob down here has been labelled 10, and so on.
Now we’ll use again the iblobs function that we used in a previous segment, and I’m going to pass in the original image, and the result is a vector of blob objects, or region feature objects. And we see that there are 11 objects here.
There’s some pretty interesting information that we see in the attributes of these individual objects. In particular, we have an attribute which is the parent attribute. So here, for instance, we can see that blob number 2 has got as its parent blob number 1. Blob number 1 is the large blob, which is the background. If we go and look at the information for blob number 1 we’ll see that its colour is 0, it’s a black blob, and we see that it’s got a massive area so it’s clearly a background blob. We also see that its touchflag is set to 1, and that means that it’s a blob that touches the edge of the image, and it’s the only blob that does so.
So we can see again the blob number 2, its parent is blob number 1. We can also see that blob number 3 has parent blob number 1, and blob number 6 has as its parent blob number 1. Clearly we can see that blob number 3 has got two blobs within it, and we can see that blob number 5 has as a parent blob number 3, and so does blob number 7.
The situation is quite complex for blob number 6. We can see that blob number 6 has got two children and they are blob number 8 — its parent is blob 6 — and blob number 9 — its parent is also 6. Now blob 9 has got two children of its own, and they are blobs 10 and 11. So we’re able to build up, if you like, a family tree — a hierarchy of blobs. At the top we have the background blob, then we have the three white blobs, blobs 2, 3 and 6, and each of those have children.
We can represent this information, this relationship between the blobs, as a hierarchy or a family tree diagram, and we can represent it quite clearly and powerfully in a graphical representation.
Code
In a binary image a white blob could contain one or more holes or black blobs. Those block blobs in turn could contain one or more white blobs and so on. Any blob that is surrounded by another blob, of the opposite color, is considered to be the child of the surrounding blob. This gives us a very powerful way to represent the organisation of the blobs in a scene by means of a family tree hiearachy or graph.
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.