Home DALSA Digital Imaging Home

Features Download Buy News Support

Counting Beans

This igraph illustrates the use of the distMap operator and blob analysis operators to count the number of beans in an image.

  1. readObj reads in an image with black and white beans, some of which are touching.
  2. thresh thresholds the image at a predetermined level, producing a binary image.
  3. distMap computes the distance map. Each pixel value now represents how close the pixel was from any off pixel in the binary image. Pixels which were on and far away from any off pixels will have a high value in the distance map. Pixels which were on but close to an off pixel will have lower values. Pixels which were off will become zero.
  4. thresh #1 picks up only the peaks of the distance map.
  5. getBlobFeatures converts the image into a set of blobs.
  6. plotFeatures extracts the centroid of each blob and create a graphic point object for each centroid.
  7. overlayData superimposes the centroids on top of the original image.

  8. getField extract the size field from the vector (list) of blobs. This field corresponds to the number of blobs, and therefore beans, in the original image.
  9. The number of beans is displayed as a large number with display.