Steve on Image Processing with MATLAB

Image processing concepts, algorithms, and MATLAB

Note

Steve on Image Processing with MATLAB has been archived and will not be updated.

Dilation algorithms—decomposing more shapes

In my previous post on dilation algorithms I discussed structuring element decomposition. We looked at the decomposition of structuring elements with rectangular domains. Today I want to follow up on the idea by looking at decompositions of other structuring element shapes.

The strel function offers a variety of flat structuring element shapes:

  • diamond
  • disk
  • line
  • octagon
  • pair
  • periodicline
  • rectangle
  • square

(The strel function also offers nonflat shapes, and shapes with arbitrary domains.)

Let's look at the 'diamond' shape. The doc says SE = strel('diamond', R) creates a flat, diamond-shaped structuring element, where R specifies the distance from the structuring element origin to the points of the diamond." For example:

se1 = strel('diamond', 5)
 
se1 =
 
Flat STREL object containing 61 neighbors.
Decomposition: 4 STREL objects containing a total of 17 neighbors

Neighborhood:
     0     0     0     0     0     1     0     0     0     0     0
     0     0     0     0     1     1     1     0     0     0     0
     0     0     0     1     1     1     1     1     0     0     0
     0     0     1     1     1     1     1     1     1     0     0
     0     1     1     1     1     1     1     1     1     1     0
     1     1     1     1     1     1     1     1     1     1     1
     0     1     1     1     1     1     1     1     1     1     0
     0     0     1     1     1     1     1     1     1     0     0
     0     0     0     1     1     1     1     1     0     0     0
     0     0     0     0     1     1     1     0     0     0     0
     0     0     0     0     0     1     0     0     0     0     0

 

The display says the structuring element has 61 neighbors in its domain, but the four decomposed structuring elements have a total of only 17 neighbors.

What shapes makes up the decomposition? We can use getsequence and getnhood to find out.

se1_seq = getsequence(se1);
for k = 1:numel(se1_seq)
    getnhood(se1_seq(k))
ans =

     0     1     0
     1     1     1
     0     1     0

ans =

     0     1     0
     1     0     1
     0     1     0

ans =

     0     0     1     0     0
     0     0     0     0     0
     1     0     0     0     1
     0     0     0     0     0
     0     0     1     0     0

ans =

     0     1     0
     1     0     1
     0     1     0

end

This decomposition comes from Rein van den Boomgard and Richard van Balen, "Methods for Fast Morphological Image Transforms Using Bitmapped Binary Images," Computer Vision, Graphics, and Image Processing: Models and Image Processing, vol. 54, no. 3, May 1992, pp. 252-254. (That journal name sure is a mouthful!)

Now let's look at the 'disk' structuring element. By default, strel('disk',R) actually gives you an approximation to a disk shape, where the approximation is based on a technique called radial decomposition using periodic lines. The reference sources are:

  • Rolf Adams, "Radial Decomposition of Discs and Spheres," Computer Vision, Graphics, and Image Processing: Graphical Models and Image Processing, vol. 55, no. 5, September 1993, pp. 325-332.
  • Ronald Jones and Pierre Soille, "Periodic lines: Definition, cascades, and application to granulometries," Pattern Recognition Letters, vol. 17, 1996, 1057-1063.
se2 = strel('disk', 5)
 
se2 =
 
Flat STREL object containing 69 neighbors.
Decomposition: 6 STREL objects containing a total of 18 neighbors

Neighborhood:
     0     0     1     1     1     1     1     0     0
     0     1     1     1     1     1     1     1     0
     1     1     1     1     1     1     1     1     1
     1     1     1     1     1     1     1     1     1
     1     1     1     1     1     1     1     1     1
     1     1     1     1     1     1     1     1     1
     1     1     1     1     1     1     1     1     1
     0     1     1     1     1     1     1     1     0
     0     0     1     1     1     1     1     0     0

 

Similar to the 'diamond' shape above, the 'disk' shape is decomposed into a sequence of smaller structuring elements:

se2_seq = getsequence(se2);
for k = 1:numel(se2_seq)
    getnhood(se2_seq(k))
ans =

     1
     1
     1

ans =

     1     0     0
     0     1     0
     0     0     1

ans =

     1     1     1

ans =

     0     0     1
     0     1     0
     1     0     0

ans =

     1     1     1

ans =

     1
     1
     1

end

I mentioned above that strel('disk',R) gives you an approximation to a disk. Let's see what that approximation looks like with a larger radius:

se3 = strel('disk', 21);
imshow(getnhood(se3), 'InitialMagnification', 'fit')

Well, that's definitely an approximation. It looks a lot more like an octagon than a circle. The syntax strel('disk',R,N) gives you more control over the approximation. N can be 0, 4, 6, or 8. The values 4, 6, and 8 indicate different levels of approximation. The default value is 4. With N equal to 8, the result looks closer to a circle, but dilation is a little slower because the decomposition isn't as efficient.

se4 = strel('disk', 21, 8);
imshow(getnhood(se4), 'InitialMagnification', 'fit')

Setting N = 0 asks strel to construct a disk shape with no decomposition approximation.

se5 = strel('disk', 21, 0);
imshow(getnhood(se5), 'InitialMagnification', 'fit')

Using getsequence we can see that there is no decomposition for se5:

numel(getsequence(se5))
ans =

     1

Next time we'll do some timing experiments with the decomposed structuring elements.




Published with MATLAB® 7.6

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.