Code covered by the BSD License

### Highlights from Gray image thresholding using the Triangle Method

4.6
4.6 | 7 ratings Rate this file 28 Downloads (last 30 days) File Size: 2.8 KB File ID: #28047 Version: 1.1

# Gray image thresholding using the Triangle Method

### Bernard Panneton (view profile)

28 Jun 2010 (Updated )

Computes a threshold the Triangle method.

File Information
Description

The Triangle method is due to Zack (Zack GW, Rogers WE, Latt SA (1977), "Automatic measurement of sister chromatid exchange frequency", J. Histochem. Cytochem. 25 (7): 741–53.

A line is constructed between the maximum of the histogram at b on the gray level axis and the lowest (or highest depending on context) value a on the gray level axis where the histogram is significantly larger than 0. The distance L normal to the line and between the line and the histogram is computed for all values from a to b. The level where the distance between the histogram and the line is maximal is the threshold value (level). This technique is particularly effective when the object pixels produce a weak peak in the histogram.

Acknowledgements

This file inspired Analysis Of Platelet Aggregate Morphology Using 2 D Autocorrelation.

MATLAB release MATLAB 7.5 (R2007b)
16 Nov 2014 Dheepan

### Dheepan (view profile)

29 Sep 2014 Image Analyst

### Image Analyst (view profile)

Threshold is misspelled at Threshnold in legend. Demo doesn't run because second line of comment doesn't have a % at the beginning of the line. Once that was corrected, it was fine.

30 Sep 2013 Bernard Panneton

### Bernard Panneton (view profile)

There are a couple of assumptions that can change the end result. One is that the histogram has one tail longer than the other and that the threshold has to be on the long tail side. The other is the definition of the end point of a histogram tail. In the code, this is set to 10000 (i.e. tails end when there are less than 10000 pixels in the corresponding histogram bin). Depending on the size of the image, this might not be an optimum choice.

Comment only
29 Sep 2013 Ramzan Basheer

### Ramzan Basheer (view profile)

19 Apr 2013 Jan Motl

### Jan Motl (view profile)

It's giving different threshold than triangle method in ImageJ applied to the same image.

14 Apr 2013 Jan Motl

### Jan Motl (view profile)

06 Oct 2010 Image Analyst

### Image Analyst (view profile)

Including a screenshot of a bar chart of a histogram with a vertical red bar where the histogram gets thresholded would be helpful for people to understand what they'd be downloading.

Comment only
22 Jul 2010 ula?

### ula? (view profile)

09 Jul 2010 Image Analyst

### Image Analyst (view profile)

This is a very useful and practical way to do thresholding. It may not be based on any theory, but in practice it's one of the best methods for thresholding a skewed histogram.

One way to improve this submission would be to include a little demo program to call it that would read in a standard MATLAB demo image (such as the cameraman), display it and its histogram, draw a line on the histogram where the threshold level is calculated, and then finally display the binarized image. I had to write all this myself.