9873

Histogram Threshold by Max Contour Contrast

The display shows three ways of thresholding a gray-level image: using an interactive slider (top right), using the max-contour-contrast algorithm (middle right), or using the well-known Otsu min-variance algorithm (bottom right). Both algorithms work by examining image histograms.
The max-contrast algorithm calculates the average contrast along the boundary for each possible threshold value (center plot) and chooses a threshold at the greatest value (dashed blue line).
The Otsu algorithm sums the variance of the black pixels (less than the threshold) and the white pixels for each threshold value (bottom, center plot), and chooses a threshold at the minimum (dashed purple line).

THINGS TO TRY

SNAPSHOTS

  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]

DETAILS

Max-contour-contrast is a simple and useful little algorithm. Here is how it works:
The algorithm first histograms the 3×3 erosion and 3×3 dilation of the original image, then forms the cumulative sum of the difference of these two histograms. This array of values has the property that a pixel is counted whenever it is on a contour of the original image (why?). In other words, the algorithm counts the number of pixels on the contour, which is the contour length (left, center plot).
The algorithm finds the total contrast along a contour in a similar way, with a 2-input histogram, using the eroded and dilated images for bin values, and accumulating the corresponding contrast values. Dividing this array by the contour length gives the average contour contrast. Please see the code for details.
Unlike Otsu's, this algorithm can pick up small high-contrast areas. To dampen this effect slightly for the Demonstration, the contour contrast is multiplied by a weighting factor in the range 0-1, equal to the normalized contour length, raised to the power 0.25 (center plot).
R. M. Haralick and L. G. Shapiro, Computer and Robot Vision, vol. 1, Reading, MA: Addison-Wesley, 1992 pp. 14-23.
J. R. Parker, Algorithms for Image Processing and Computer Vision, New York: Wiley Computer Pub., 1997 pp. 116-128.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.









 
RELATED RESOURCES
Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2014 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+