mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-30 20:00:37 +08:00
fixed threshold to add otsu as a kwarg
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
+217
-217
File diff suppressed because it is too large
Load Diff
@@ -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)
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user