Vision Project - CS223B - Winter 97
Eric Frew, Andreas Huster, Edward LeMaster

Image Thresholding for Object Detection

Proposal

The HUMMINGBIRD project at the Aerospace Robotics Lab is a robot helicopter with a computer vision system used to survey a grass field and locate objects of interest. These objects currently consist of orange disks and black barrels and are designed to be easily identified. To detect objects, we currently apply thresholds to an LUV color segmented image. Objects are defined as regions that are greater than the threshold in one of the color segments. Because this is a real-time control system, algorithm speed, reliability and robustness are all important factors. While the thresholding process is fast enough, it is too sensitive to the thresholding levels and not robust to changes in lighting. For scenes with more than one object, we currently have difficulty determining object locations.

In an effort to improve the segmentation by thresholding process and add robustness to lighting changes, we will implement some of the improvements discussed in section 3.3.1 of Nalwa's book [Nalwa 1993]. Specifically, we propose to investigate algorithms that automatically select the thresholds before processing the image (e.g., [Prewitt 1970]). This will include intensity and color information, seeking to use both in the best manner. Furthermore, we will implement an algorithm to identify regions based on the thresholded image (e.g.,[Beveridge et al. 1989]). Success will be measured based on how accurately single regions correspond to world objects.

We are using Teleos AVP digitizer hardware, which provides real-time color-segmented images. For this project, we will write a C/C++ program that will read an image in PPM format. It will threshold the image based on values it will automatically determine and then calculate the location of the regions created by this process. The program will create two output images, also in PPM format, with (1) the thresholded image and (2) the original image with cross hairs marking the perceived object locations. Furthermore, it will show numerical values for the object coordinates. If time permits, we will implement the algorithm in real-time. Each test image will consist of one or more objects (barrels or disks) on a green grass background. The test images will use various lighting and object configurations to test the robustness of the algorithm.

Test Images

Any attempt to find an algorithm to solve a problem requires a rigidly-defined series of tests in order to evaluate performance. To collect our test images, we simulated a helicopter flight by holding the actual helicopter cameras about 2m above a grass field, looking downward. This is the approximate configuration encountered during flight conditions. We then took a series of images, with several varying parameters. Objects of interest in any given image include green grass, 4 inch orange metal disks, or 1 m long black barrels. Representative images can have multiple objects and were taken in direct sunlight, partial shadow, and complete shadow.

Preliminary image processing is provided by the Teleos Advanced Vision Processing System (AVP). This includes a color digitizer which automatically segments the pictures into three color components:

  • L - The greyscale intensity
  • U - Primarily blue (with some green) information
  • V - Primarily red (with some yellow) information
We then converted these three components to PGM images for further processing. To display the test images we also did an LUV to RGB conversion, outputting the files in PPM format. Note that since the AVP digitizer automatically segments into LUV components, we do not do any algorithm processing on the RGB components.

Algorithm #1

The first segmentation algorithm we implemented involved computing histograms for each color component and then applying thresholds at the local minima, or 'valleys', as per [Prewitt and Mendelsohn]. Barrels are located in the segmented U-component image, and disks are located in the V-component image. A quick outline of the algorithm follows...
  • Load raw image components (LUV)
  • Smooth each component image
  • Generate histograms
  • Smooth histograms and take derivatives
  • Apply thresholds at local minima (zero-crossings)
  • Use logic to improve success rate
    • Thresholds must be certain distance apart
    • U-Thresholds must be above a certain value
    • Objects in U-component must be larger than certain size
More detailed information can be found in in the attached page. In addition, a summary of results for each test image is also available. The table below summarizes the success rate of the algorithm.

Images Examined15
Barrels Found8/8
Overall Barrel Success Rate100%
Disks Found11/13
Overall Disk Success Rate93.3%

Algorithm #2

The second algorithm selects the segmentation threshold by averaging the pixel values of those pixels with high gradient values - edge pixels. Given the primary assumption that the images contain only disks and barrels, edge pixels will occur mainly in the neighborhood of the boundaries between disks/barrels and the background. If the image is properly smoothed, approximately half of the selected pixels are background pixels and half belong to the object. Thus, the algorithm calculates a segmentation threshold as the average of the selected pixel values, or more intuitively, by calculating the first moment of the intensity histogram of edge pixels. The result is surprisingly stable as indicated by the results below.

High-gradient pixels are selected as the top n% of all pixels based on the gradients. n is 10% for barrels and 2% for disks based on the expected length of edges in each type of image. These are magic numbers, but the algorithm is not very sensitive to these quantities. Also, the algorithm will always generate exactly one threshold, even when there are no objects in the image. However, when there is no object, the threshold will be close to the average value of the entire image which indicates that the threshold is not meaningful and can thus be discarded.

Following is a high-level view of the algorithm:

  • Load raw image components (LUV)
  • Smooth U-Image
  • Calculate the U-Image gradients
  • Calculate gradient histogram
  • Calculate gradient threshold as a percentile
  • Separate pixels with large gradients
  • Calculate image threshold as average pixel value of high-gradient pixels
  • Ensure validity of threshold by comparing it to average image intensity
  • Apply threshold to image to find barrels
  • Repeat on V-Image to find disks
Asummary of results for each test image can be found in the attached pages. Quantitative results are tabulated below, and show that this algorithm is extremely successful.

Images Examined15
Barrels Found8/8
Overall Barrel Success Rate100%
Disks Found13/13
Overall Disk Success Rate100%

Algorithm #3

The third algorithm determines a threshold such that a given percentage of pixels remain after thresholding. Therefore the algorithm will always provide false positive information when an object is not present. The routine found all objects when present, but since it cannot distinguish the presence of an object or not, it is a failure. The complete algorithm is outlined as follows:
  • Load raw image components (LUV)
  • Smooth each component image
  • Generate histograms
  • Calculate threshold to keep given percentage of pixels
More detailed information.

Created Code

In order to implement the algorithms above, we were required to generate a significant amount of code. Unless otherwise noted, all of the code presented here is our own implementation, although we used function packages where available. This code can be grouped into 2 main areas:
  • AVP Code - This is code we wrote to interface with the AVP processor, and to convert LUV segmented images into more standard formats for display. All AVP code is in C/C++.
  • Matlab Code - Where possible, we tested and implemented our algorithms in Matlab to reduce coding and debugging time.
    Copyright © 1997 by Eric Frew, Andreas Huster, & Edward LeMaster.