mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-13 16:56:11 +08:00
Remove binarize function
This commit is contained in:
@@ -1 +1,2 @@
|
||||
from .thresholding import threshold_otsu, binarize
|
||||
from .thresholding import threshold_otsu
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import numpy as np
|
||||
|
||||
import skimage
|
||||
from skimage import data
|
||||
from skimage.thresholding import threshold_otsu, binarize
|
||||
from skimage.thresholding import threshold_otsu
|
||||
|
||||
|
||||
class TestSimpleImage():
|
||||
@@ -24,14 +24,6 @@ class TestSimpleImage():
|
||||
image = np.float64(self.image)
|
||||
assert 2 <= threshold_otsu(image) < 3
|
||||
|
||||
def test_binarize(self):
|
||||
expected = np.array([[0, 0, 0, 1, 1],
|
||||
[0, 0, 1, 1, 1],
|
||||
[0, 0, 1, 1, 0],
|
||||
[0, 1, 1, 0, 0],
|
||||
[1, 1, 0, 0, 0]])
|
||||
assert np.all(binarize(self.image) == expected)
|
||||
|
||||
|
||||
def test_otsu_camera_image():
|
||||
assert threshold_otsu(data.camera()) == 87
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
__all__ = ['threshold_otsu', 'binarize']
|
||||
__all__ = ['threshold_otsu']
|
||||
|
||||
|
||||
def threshold_otsu(image, bins=256):
|
||||
@@ -45,28 +45,6 @@ def threshold_otsu(image, bins=256):
|
||||
return threshold
|
||||
|
||||
|
||||
_threshold_funcs = {'otsu': threshold_otsu}
|
||||
def binarize(image, method='otsu'):
|
||||
"""Return binary image using an automatic thresholding method.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : array
|
||||
Input array.
|
||||
method : {'otsu'}
|
||||
Method used to calculate threshold value. Currently, only Otsu's method
|
||||
is implemented.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : array
|
||||
Thresholded image.
|
||||
"""
|
||||
get_threshold = _threshold_funcs[method]
|
||||
threshold = get_threshold(image)
|
||||
return image > threshold
|
||||
|
||||
|
||||
def histogram(image, bins):
|
||||
"""Return histogram of image.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user