fixed threshold to add otsu as a kwarg

This commit is contained in:
sccolbert
2009-10-24 18:05:20 +02:00
parent 324fe7c9b0
commit 331125cc1c
4 changed files with 220 additions and 221 deletions
-1
View File
@@ -32,7 +32,6 @@ CV_THRESH_TRUNC = 2
CV_THRESH_TOZERO = 3
CV_THRESH_TOZERO_INV = 4
CV_THRESH_MASK = 7
CV_THRESH_OTSU = 8 # this must be combined with other flags
CV_ADAPTIVE_THRESH_MEAN_C = 0
CV_ADAPTIVE_THRESH_GAUSSIAN_C = 1
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1176,15 +1176,15 @@ def cvCvtColor(np.ndarray src, int code):
return out
def cvThreshold(np.ndarray src, double threshold, double max_value=255,
int threshold_type=CV_THRESH_BINARY):
int threshold_type=CV_THRESH_BINARY, use_otsu=False):
validate_array(src)
assert_nchannels(src, [1])
assert_dtype(src, [UINT8, FLOAT32])
use_otsu = (threshold_type & CV_THRESH_OTSU) != 0
if use_otsu:
assert_dtype(src, [UINT8])
threshold_type += 8
cdef np.ndarray out = new_array_like(src)
+1 -1
View File
@@ -208,7 +208,7 @@ class TestThreshold(OpenCVTest):
cvThreshold(self.lena_GRAY_U8, 100, threshold_type=CV_THRESH_TRUNC)
cvThreshold(self.lena_GRAY_U8, 100, threshold_type=CV_THRESH_TOZERO)
cvThreshold(self.lena_GRAY_U8, 100, threshold_type=CV_THRESH_TOZERO_INV)
cvThreshold(self.lena_GRAY_U8, 100, 1, CV_THRESH_BINARY+CV_THRESH_OTSU)
cvThreshold(self.lena_GRAY_U8, 100, 1, CV_THRESH_BINARY, use_otsu=True)
class TestAdaptiveThreshold(OpenCVTest):