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.

Nonflat grayscale dilation and erosion

Blog reader Alex asked for an explanation of nonflat grayscale dilation and erosion.

In the most commonly-used form of dilation, the structuring element defines a neighborhood of a pixel. In the output image, a pixel is computed by taking the maximum of all the input pixels in the neighborhood. For erosion, an output image pixel is computed by taking the minimum of all the input pixels in the neighborhood.

In nonflat dilation and erosion, each neighbor has an associated height. A dilation output pixel is computed by first adding the neighbor heights to the neighbor input pixels, and then taking the maximum.

Here's how Digital Image Processing Using MATLAB describes the operation, including the mathematical equation. (This excerpt is from section 9.6.1, pages 366-367.)

"The gray-scale dilation of f by structuring element b [...] is defined as

where D_b is the domain of b, and f(x,y) is assumed equal to [minus infinity] outside the domain of f. This equation implements a process similar to spatial convolution [...]. Conceptually, we can think of rotation the structuring element about its origin and translating it to all locations in the image, just as the convolution kernel is rotated and then translated about the image. At each translated location, the rotated structuring element values are added to the image pixel values and the maximum is computed."

The 'ball' option of the strel function produces a nonflat structuring element.

se = strel('ball',5,5)
 
se =
 
Nonflat STREL object containing 109 neighbors.
Decomposition: 8 STREL objects containing a total of 24 neighbors

Neighborhood:
     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
     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     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     1     1     0
     0     0     1     1     1     1     1     1     1     0     0


Height:
  Columns 1 through 10

      -Inf      -Inf         0    0.6248    1.2497    1.8745    1.2497    0.6248         0      -Inf
      -Inf    0.6248    1.2497    1.8745    2.4994    2.4994    2.4994    1.8745    1.2497    0.6248
         0    1.2497    1.8745    2.4994    3.1242    3.1242    3.1242    2.4994    1.8745    1.2497
    0.6248    1.8745    2.4994    3.1242    3.7491    3.7491    3.7491    3.1242    2.4994    1.8745
    1.2497    2.4994    3.1242    3.7491    4.3739    4.3739    4.3739    3.7491    3.1242    2.4994
    1.8745    2.4994    3.1242    3.7491    4.3739    4.9987    4.3739    3.7491    3.1242    2.4994
    1.2497    2.4994    3.1242    3.7491    4.3739    4.3739    4.3739    3.7491    3.1242    2.4994
    0.6248    1.8745    2.4994    3.1242    3.7491    3.7491    3.7491    3.1242    2.4994    1.8745
         0    1.2497    1.8745    2.4994    3.1242    3.1242    3.1242    2.4994    1.8745    1.2497
      -Inf    0.6248    1.2497    1.8745    2.4994    2.4994    2.4994    1.8745    1.2497    0.6248
      -Inf      -Inf         0    0.6248    1.2497    1.8745    1.2497    0.6248         0      -Inf

  Column 11

      -Inf
      -Inf
         0
    0.6248
    1.2497
    1.8745
    1.2497
    0.6248
         0
      -Inf
      -Inf

 

As far as I know, flat dilation and erosion are far more commonly used. If you know of an image processing application particularly well-suited for applying nonflat dilation and erosion, send me a note - I'd love to hear about it.




Published with MATLAB® 7.3

|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。