mirror of
https://github.com/opencv/opencv.git
synced 2025-07-30 17:37:05 +08:00
Make Otsu and Triangle algorithms mutually exclusive
Make Otsu and Triangle algorithms mutually exclusive in cv::threshold code. Signed-off-by: Miroslav Benes <mbenes@suse.cz>
This commit is contained in:
parent
5b1fd739d9
commit
4046f0398a
@ -1189,17 +1189,16 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
|
|||||||
ocl_threshold(_src, _dst, thresh, maxval, type), thresh)
|
ocl_threshold(_src, _dst, thresh, maxval, type), thresh)
|
||||||
|
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
bool use_otsu = (type & THRESH_OTSU) != 0;
|
int automatic_thresh = (type & ~CV_THRESH_MASK);
|
||||||
bool use_triangle = (type & THRESH_TRIANGLE) != 0;
|
|
||||||
type &= THRESH_MASK;
|
type &= THRESH_MASK;
|
||||||
|
|
||||||
if( use_otsu )
|
CV_Assert( automatic_thresh != (CV_THRESH_OTSU | CV_THRESH_TRIANGLE) );
|
||||||
|
if( automatic_thresh == CV_THRESH_OTSU )
|
||||||
{
|
{
|
||||||
CV_Assert( src.type() == CV_8UC1 );
|
CV_Assert( src.type() == CV_8UC1 );
|
||||||
thresh = getThreshVal_Otsu_8u( src );
|
thresh = getThreshVal_Otsu_8u( src );
|
||||||
}
|
}
|
||||||
|
else if( automatic_thresh == CV_THRESH_TRIANGLE )
|
||||||
if( use_triangle )
|
|
||||||
{
|
{
|
||||||
CV_Assert( src.type() == CV_8UC1 );
|
CV_Assert( src.type() == CV_8UC1 );
|
||||||
thresh = getThreshVal_Triangle_8u( src );
|
thresh = getThreshVal_Triangle_8u( src );
|
||||||
|
Loading…
Reference in New Issue
Block a user