MORPHOLOGY C/C++ EXTENSIONS TO FOIL

Morphology/BLOBs


Morphology operations generally follow the following steps

  • Image Conditioning
  • Binarization
  • Binary image conditioning
  • Labeling
  • Feature extraction

Image conditioning


This step falls outside the morphology library, but provides for the improvement of the quality of the image by filtering. Linear and non-linear filtering is done to improve the quality of the binarization.


Binarization

  • Fixed Threshold
    Fixed threshold binarization converts the gray scale image to a binary image by comparing the input image to a PAIR of thresholds. If the image pixel value is between the upper and lower threshold value, or outside of the range defined by the two thresholds (a user option which is used), then the resulting binary pixel value is 1 otherwise it is zero.
  • Dynamic Threshold
    A Dynamic threshold replaces the two threshold numbers with two images. If the pixel value of the input image is between the upper and lower input images pixel values, then the resulting pixel is 1, or zero (user option).

Binary Image Conditioning

Structuring Elements


Structuring elements are small binary templates that are used to define the other morphology operations.

  • Erosion
    This operation does the following at each pixel location in the image. The selected template is centered at the pixel location. At each location where the template is 1, the input image pixel must be one. If that is true the output pixel is 1, if it is false the output pixel is zero.
  • Dilation
    This operation does the following at each pixel location in the input image. The selected template is centered at the pixel location. At each location where the template is 1, if any input image pixel is one, then the output pixel is one, otherwise it is zero. Intuitively this will add to the edges of regions. Dilation is complementary to Erosion, Dilation is an OR function Erosion is an AND function.
  • Open
    Open is an erosion followed by a dilation. Normally the function also carries a repetition factor, Open N times.
  • Close
    Close is dilation followed by erosion. Normally the function also carries a repetition factor, Close N times.


Labeling BLOBs

Binary Large Objects are extracted from the processed image by a labeling step. This step is performed by labeling each pixel, in the image, with an integer, so each pixel that ‘touches’ another pixel, has the same label value. Pixel ‘touching’ is defined by two neighborhood templates, that is there is an option which form of touching you want to use when doing the labeling, one is if any pixel in the 3x3 region around the pixel has the same value, the other excludes the diagonals. The label values can be 8,16, or 32 bit values. When a labeling operation runs out of values the function call fails. Each region of the image that has the same label value is called a blob. The output of the labeling operation is two tables, one the same shape as the image, but each pixel is its label value, is an vector of vectors, which contain the x, y coordinates of each blob.


Feature Extraction

After the labeling operation is complete, various ‘features’ are extracted from the label. The features take two forms, unary features, that is the feature of one ‘blob’, and binary features, that is relationships between blobs. Feature operations can be performed on a single blob, or on all the blobs in the label table.


Unary Features

  • Centroid
    This is the average of the X and Y values of all the pixels in a blob.
  • Perimeter
    This is a vector of all the pixels coordinates that touch another different blob. Note: this can be several lists, as the blob might have holes. In addition to the lists the total length of the perimeter is provided.
  • Area
    The Area is number of pixels in the blob.
  • Extract
    This makes an binary image of just this blob.
  • Bounding Box
    This takes two forms, the min and max of the x and y values (four numbers), and the size of the smallest box that the blob would fit in if it were rotated.
  • Diameter
    The maximum distance between a pair of pixels in the blob.
  • Hole Count
    The number of holes in the blob.
  • Hole List
    A list of blobs that are enclosed by this blob.

Binary Features

These features are extracted from a pair of blobs.

  • Distance
    The minimum and the maximum distance between all the pairs of pixels, one in each blob.
  • Contains
    Returns true if a blob is contained in the other.
  • Touching
    Returns true if the distance is zero.
  • Sort
    Provides a list of blobs sorted by any unary numerical feature of the blobs, or an binary numerical feature.

 

MORPHOLOGY/BLOB CLASSIFICATION

Click here to Download the datasheet or here to Register to Download Manual