Add Triangle thresholding algorithm

Add Triangle method for automatic threshold computation next to the existing
Otsu's method. Triangle deals better with images whose histogram does not
contain dominant peak.

See paper Zack GW, Rogers WE, Latt SA.: Automatic measurement of sister
chromatid exchange frequency. J Histochem Cytochem. 1977 Jul;25(7):741-53.
On Wed, 5 Nov 2014, Vadim Pisarevsky wrote:

> 
> In modules/imgproc/src/thresh.cpp:
> 
> > @@ -1086,6 +1190,7 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
> >  
> >      Mat src = _src.getMat();
> >      bool use_otsu = (type & THRESH_OTSU) != 0;
> > +    bool use_triangle = (type & THRESH_TRIANGLE) != 0;
> 
> OTSU and Triangle algorithms are mutually exclusive. Can you use something like:
> 
> int automatic_algo = type & ~CV_THRESH_MASK;
> if( automatic_algo == 0 ) // no automatic thresholding
> {
> }
> else if( automatic_algo == CV_THRESH_OTSU )
> {
> ...
> }
> else if( automatic_algo == CV_THRESH_TRIANGLE )
> {
> ...
> }
> 
> ?

Hi,

it is done now and pushed to the original pull request. I added CV_Assert 
to make sure that there is a call only with either TRIANGLE or OTSU. 
However I am not sure it CV_Assert is the right way to do it (is there a 
better way to propagate such runtime error?).

Second question is to CV_ and "non-CV_" types (e.g. THRESH_OTSU and 
CV_THRESH_OTSU). What is the difference? They are now mixed in the source 
code...

Thank you

--
Miroslav Benes
SUSE Labs