Remove binarize function

This commit is contained in:
Tony S Yu
2011-12-08 23:52:10 -05:00
parent 10c1f471a0
commit 5a171a2bfb
3 changed files with 4 additions and 33 deletions
+2 -1
View File
@@ -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 -23
View File
@@ -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.