Ejemplo n.º 1
0
def test_isodata_camera_image():
    camera = skimage.img_as_ubyte(data.camera())

    threshold = threshold_isodata(camera)
    assert np.floor((camera[camera <= threshold].mean() +
                     camera[camera > threshold].mean()) / 2.0) == threshold
    assert threshold == 87

    assert threshold_isodata(camera, return_all=True) == [87]
Ejemplo n.º 2
0
def test_isodata_coins_image():
    coins = skimage.img_as_ubyte(data.coins())

    threshold = threshold_isodata(coins)
    assert np.floor((coins[coins <= threshold].mean() +
                     coins[coins > threshold].mean()) / 2.0) == threshold
    assert threshold == 107

    assert threshold_isodata(coins, return_all=True) == [107]
Ejemplo n.º 3
0
def test_isodata_coins_image():
    coins = skimage.img_as_ubyte(data.coins())

    threshold = threshold_isodata(coins)
    assert np.floor((coins[coins <= threshold].mean() +
                     coins[coins > threshold].mean()) / 2.0) == threshold
    assert threshold == 107

    assert threshold_isodata(coins, return_all=True) == [107]
Ejemplo n.º 4
0
def test_isodata_camera_image():
    camera = skimage.img_as_ubyte(data.camera())

    threshold = threshold_isodata(camera)
    assert np.floor((camera[camera <= threshold].mean() +
                     camera[camera > threshold].mean()) / 2.0) == threshold
    assert threshold == 87

    assert threshold_isodata(camera, return_all=True) == [87]
Ejemplo n.º 5
0
def test_isodata_moon_image_negative_float():
    moon = skimage.img_as_ubyte(data.moon()).astype(np.float64)
    moon -= 100

    assert -14 < threshold_isodata(moon) < -13

    thresholds = threshold_isodata(moon, return_all=True)
    assert_almost_equal(thresholds,
                        [-13.83789062, -12.84179688, -11.84570312, 22.02148438,
                         23.01757812, 24.01367188, 38.95507812, 39.95117188])
Ejemplo n.º 6
0
def test_isodata_moon_image_negative_float():
    moon = skimage.img_as_ubyte(data.moon()).astype(np.float64)
    moon -= 100

    assert -14 < threshold_isodata(moon) < -13

    thresholds = threshold_isodata(moon, return_all=True)
    assert_almost_equal(thresholds,
                        [-13.83789062, -12.84179688, -11.84570312, 22.02148438,
                         23.01757812, 24.01367188, 38.95507812, 39.95117188])
Ejemplo n.º 7
0
def test_isodata_moon_image():
    moon = skimage.img_as_ubyte(data.moon())

    threshold = threshold_isodata(moon)
    assert np.floor((moon[moon <= threshold].mean() +
                     moon[moon > threshold].mean()) / 2.0) == threshold
    assert threshold == 86

    thresholds = threshold_isodata(moon, return_all=True)
    for threshold in thresholds:
        assert np.floor((moon[moon <= threshold].mean() +
                         moon[moon > threshold].mean()) / 2.0) == threshold
    assert_equal(thresholds, [86, 87, 88, 122, 123, 124, 139, 140])
Ejemplo n.º 8
0
def test_isodata_moon_image():
    moon = skimage.img_as_ubyte(data.moon())

    threshold = threshold_isodata(moon)
    assert np.floor((moon[moon <= threshold].mean() +
                     moon[moon > threshold].mean()) / 2.0) == threshold
    assert threshold == 86

    thresholds = threshold_isodata(moon, return_all=True)
    for threshold in thresholds:
        assert np.floor((moon[moon <= threshold].mean() +
                         moon[moon > threshold].mean()) / 2.0) == threshold
    assert_equal(thresholds, [86, 87, 88, 122, 123, 124, 139, 140])
Ejemplo n.º 9
0
def test_isodata_moon_image_negative_int():
    moon = skimage.img_as_ubyte(data.moon()).astype(np.int32)
    moon -= 100

    threshold = threshold_isodata(moon)
    assert np.floor((moon[moon <= threshold].mean() +
                     moon[moon > threshold].mean()) / 2.0) == threshold
    assert threshold == -14

    thresholds = threshold_isodata(moon, return_all=True)
    for threshold in thresholds:
        assert np.floor((moon[moon <= threshold].mean() +
                         moon[moon > threshold].mean()) / 2.0) == threshold
    assert_equal(thresholds, [-14, -13, -12,  22,  23,  24,  39,  40])
Ejemplo n.º 10
0
def test_isodata_moon_image_negative_int():
    moon = skimage.img_as_ubyte(data.moon()).astype(np.int32)
    moon -= 100

    threshold = threshold_isodata(moon)
    assert np.floor((moon[moon <= threshold].mean() +
                     moon[moon > threshold].mean()) / 2.0) == threshold
    assert threshold == -14

    thresholds = threshold_isodata(moon, return_all=True)
    for threshold in thresholds:
        assert np.floor((moon[moon <= threshold].mean() +
                         moon[moon > threshold].mean()) / 2.0) == threshold
    assert_equal(thresholds, [-14, -13, -12,  22,  23,  24,  39,  40])
Ejemplo n.º 11
0
 def test_isodata_blank_zero(self):
     image = np.zeros((5, 5), dtype=np.uint8)
     assert threshold_isodata(image) == 0
Ejemplo n.º 12
0
def test_isodata_moon_image():
    moon = skimage.img_as_ubyte(data.moon())
    assert threshold_isodata(moon) == 87
Ejemplo n.º 13
0
 def test_isodata_16bit(self):
     np.random.seed(0)
     imfloat = np.random.rand(256, 256)
     assert 0.49 < threshold_isodata(imfloat, nbins=1024) < 0.51
     assert all(0.49 < threshold_isodata(imfloat, nbins=1024,
                                         return_all=True))
Ejemplo n.º 14
0
 def test_isodata_blank_zero(self):
     image = np.zeros((5, 5), dtype=np.uint8)
     assert threshold_isodata(image) == 0
     assert threshold_isodata(image, return_all=True) == [0]
Ejemplo n.º 15
0
 def test_isodata(self):
     assert threshold_isodata(self.image) == 2
Ejemplo n.º 16
0
def test_isodata_moon_image_negative_float():
    moon = skimage.img_as_ubyte(data.moon()).astype(np.float64)
    moon -= 100
    assert -13 < threshold_isodata(moon) < -12
Ejemplo n.º 17
0
def test_isodata_moon_image_negative_int():
    moon = skimage.img_as_ubyte(data.moon()).astype(np.int32)
    moon -= 100
    assert threshold_isodata(moon) == -13
Ejemplo n.º 18
0
def test_isodata_moon_image():
    moon = skimage.img_as_ubyte(data.moon())
    assert threshold_isodata(moon) == 87
Ejemplo n.º 19
0
def test_isodata_coins_image():
    coins = skimage.img_as_ubyte(data.coins())
    assert threshold_isodata(coins) == 107
Ejemplo n.º 20
0
def test_isodata_camera_image():
    camera = skimage.img_as_ubyte(data.camera())
    assert threshold_isodata(camera) == 88
Ejemplo n.º 21
0
 def test_isodata_linspace(self):
     assert -63.8 < threshold_isodata(np.linspace(-127, 0, 256)) < -63.6
Ejemplo n.º 22
0
 def test_isodata(self):
     assert threshold_isodata(self.image) == 2
     assert threshold_isodata(self.image, return_all=True) == [2]
Ejemplo n.º 23
0
 def test_isodata_blank_zero(self):
     image = np.zeros((5, 5), dtype=np.uint8)
     assert threshold_isodata(image) == 0
Ejemplo n.º 24
0
 def test_isodata_linspace(self):
     image = np.linspace(-127, 0, 256)
     assert -63.8 < threshold_isodata(image) < -63.6
     assert_almost_equal(threshold_isodata(image, return_all=True),
                         [-63.74804688, -63.25195312])
Ejemplo n.º 25
0
 def test_isodata(self):
     assert threshold_isodata(self.image) == 2
     assert threshold_isodata(self.image, return_all=True) == [2]
Ejemplo n.º 26
0
def test_isodata_moon_image_negative_int():
    moon = skimage.img_as_ubyte(data.moon()).astype(np.int32)
    moon -= 100
    assert threshold_isodata(moon) == -13
Ejemplo n.º 27
0
 def test_isodata_linspace(self):
     image = np.linspace(-127, 0, 256)
     assert -63.8 < threshold_isodata(image) < -63.6
     assert_almost_equal(threshold_isodata(image, return_all=True),
                         [-63.74804688, -63.25195312])
Ejemplo n.º 28
0
def test_isodata_coins_image():
    coins = skimage.img_as_ubyte(data.coins())
    assert threshold_isodata(coins) == 107
Ejemplo n.º 29
0
def test_isodata_moon_image_negative_float():
    moon = skimage.img_as_ubyte(data.moon()).astype(np.float64)
    moon -= 100
    assert -13 < threshold_isodata(moon) < -12
Ejemplo n.º 30
0
 def test_isodata_linspace(self):
     assert -63.8 < threshold_isodata(np.linspace(-127, 0, 256)) < -63.6
Ejemplo n.º 31
0
 def test_isodata(self):
     assert threshold_isodata(self.image) == 2
Ejemplo n.º 32
0
 def test_isodata_blank_zero(self):
     image = np.zeros((5, 5), dtype=np.uint8)
     assert threshold_isodata(image) == 0
     assert threshold_isodata(image, return_all=True) == [0]
Ejemplo n.º 33
0
 def test_isodata_16bit(self):
     np.random.seed(0)
     imfloat = np.random.rand(256, 256)
     t = threshold_isodata(imfloat, nbins=1024)
     assert 0.49 < t < 0.51
Ejemplo n.º 34
0
 def test_isodata_16bit(self):
     np.random.seed(0)
     imfloat = np.random.rand(256, 256)
     assert 0.49 < threshold_isodata(imfloat, nbins=1024) < 0.51
     assert all(0.49 < threshold_isodata(imfloat, nbins=1024,
                                         return_all=True))
Ejemplo n.º 35
0
def test_isodata_camera_image():
    camera = skimage.img_as_ubyte(data.camera())
    assert threshold_isodata(camera) == 88