def test_threshold_minimum(): camera = skimage.img_as_ubyte(data.camera()) threshold = threshold_minimum(camera) assert_equal(threshold, 76) astronaut = skimage.img_as_ubyte(data.astronaut()) threshold = threshold_minimum(astronaut) assert_equal(threshold, 114)
def test_threshold_minimum(): camera = skimage.img_as_ubyte(data.camera()) threshold = threshold_minimum(camera) assert_equal(threshold, 76) astronaut = skimage.img_as_ubyte(data.astronaut()) threshold = threshold_minimum(astronaut) assert_equal(threshold, 114)
def test_threshold_minimum(): camera = util.img_as_ubyte(data.camera()) threshold = threshold_minimum(camera) assert_equal(threshold, 85) astronaut = util.img_as_ubyte(data.astronaut()) threshold = threshold_minimum(astronaut) assert_equal(threshold, 114)
def test_threshold_minimum(): camera = skimage.img_as_ubyte(data.camera()) threshold = threshold_minimum(camera) assert threshold == 76 threshold = threshold_minimum(camera, bias='max') assert threshold == 77 astronaut = skimage.img_as_ubyte(data.astronaut()) threshold = threshold_minimum(astronaut) assert threshold == 117
def test_threshold_minimum(): camera = skimage.img_as_ubyte(data.camera()) threshold = threshold_minimum(camera) assert threshold == 76 threshold = threshold_minimum(camera, bias='max') assert threshold == 77 astronaut = skimage.img_as_ubyte(data.astronaut()) threshold = threshold_minimum(astronaut) assert threshold == 117
def test_threshold_minimum_synthetic(): img = np.arange(25 * 25, dtype=np.uint8).reshape((25, 25)) img[0:9, :] = 50 img[14:25, :] = 250 threshold = threshold_minimum(img, bias='min') assert threshold == 93 threshold = threshold_minimum(img, bias='mid') assert threshold == 159 threshold = threshold_minimum(img, bias='max') assert threshold == 225
def test_threshold_minimum_synthetic(): img = np.arange(25*25, dtype=np.uint8).reshape((25, 25)) img[0:9, :] = 50 img[14:25, :] = 250 threshold = threshold_minimum(img, bias='min') assert threshold == 93 threshold = threshold_minimum(img, bias='mid') assert threshold == 159 threshold = threshold_minimum(img, bias='max') assert threshold == 225
def test_threshold_minimum_synthetic(): img = np.arange(25*25, dtype=np.uint8).reshape((25, 25)) img[0:9, :] = 50 img[14:25, :] = 250 threshold = threshold_minimum(img) assert_equal(threshold, 95)
def test_threshold_minimum_synthetic(): img = np.arange(25 * 25, dtype=np.uint8).reshape((25, 25)) img[0:9, :] = 50 img[14:25, :] = 250 threshold = threshold_minimum(img) assert_equal(threshold, 95)
def test_threshold_minimum_failure(): img = np.zeros((16*16), dtype=np.uint8) with pytest.raises(RuntimeError): threshold_minimum(img)
def test_threshold_minimum_failure(): img = np.zeros((16 * 16), dtype=np.uint8) with testing.raises(RuntimeError): threshold_minimum(img)
def test_minimum(self): with pytest.raises(RuntimeError): threshold_minimum(self.image)
def test_threshold_minimum_counts(): camera = util.img_as_ubyte(data.camera()) counts, bin_centers = histogram(camera.ravel(), 256, source_range='image') threshold = threshold_minimum(hist=counts) assert_equal(threshold, 85)
def test_threshold_minimum_histogram(): camera = util.img_as_ubyte(data.camera()) hist = histogram(camera.ravel(), 256, source_range='image') threshold = threshold_minimum(hist=hist) assert_equal(threshold, 85)
The minimum algorithm takes a histogram of the image and smooths it repeatedly until there are only two peaks in the histogram. Then it finds the minimum value between the two peaks. After smoothing the histogram, there can be multiple pixel values with the minimum histogram count, so you can pick the 'min', 'mid', or 'max' of these values. """ import matplotlib.pyplot as plt from skimage import data from skimage.filters.thresholding import threshold_minimum image = data.camera() threshold = threshold_minimum(image, bias='min') binarized = image > threshold fig, axes = plt.subplots(nrows=2, figsize=(7, 8)) ax0, ax1 = axes plt.gray() ax0.imshow(image) ax0.set_title('Original image') ax1.imshow(binarized) ax1.set_title('Result') for ax in axes: ax.axis('off')
def test_minimum(self): with pytest.raises(RuntimeError): threshold_minimum(self.image)
def test_threshold_minimum_deprecated_max_iter_kwarg(): camera = util.img_as_ubyte(data.camera()) hist = histogram(camera.ravel(), 256, source_range='image') with expected_warnings(["`max_iter` is a deprecated argument"]): threshold_minimum(hist=hist, max_iter=5000)