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.
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.
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.
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.