"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "skimage/segmentation/tests/test_slic.py" between
scikit-image-0.19.1.tar.gz and scikit-image-0.19.2.tar.gz

About: scikit-image is a collection of algorithms for image processing in Python.

test_slic.py  (scikit-image-0.19.1):test_slic.py  (scikit-image-0.19.2)
from itertools import product from itertools import product
import numpy as np import numpy as np
import pytest import pytest
from numpy.testing import assert_equal from numpy.testing import assert_equal
from skimage import data, img_as_float from skimage import data, filters, img_as_float
from skimage._shared.testing import test_parallel, expected_warnings from skimage._shared.testing import test_parallel, expected_warnings
from skimage.segmentation import slic from skimage.segmentation import slic
@test_parallel() @test_parallel()
def test_color_2d(): def test_color_2d():
rnd = np.random.default_rng(0) rnd = np.random.default_rng(0)
img = np.zeros((20, 21, 3)) img = np.zeros((20, 21, 3))
img[:10, :10, 0] = 1 img[:10, :10, 0] = 1
img[10:, :10, 1] = 1 img[10:, :10, 1] = 1
img[10:, 10:, 2] = 1 img[10:, 10:, 2] = 1
skipping to change at line 515 skipping to change at line 515
assert_equal(seg[s][2:-2, 2:-2, 2:-2], c) assert_equal(seg[s][2:-2, 2:-2, 2:-2], c)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"dtype", ['float16', 'float32', 'float64', 'uint8', 'int'] "dtype", ['float16', 'float32', 'float64', 'uint8', 'int']
) )
def test_dtype_support(dtype): def test_dtype_support(dtype):
img = np.random.rand(28, 28).astype(dtype) img = np.random.rand(28, 28).astype(dtype)
# Simply run the function to assert that it runs without error # Simply run the function to assert that it runs without error
slic(img, start_label=1) slic(img, start_label=1)
def test_start_label_fix():
"""Tests the fix for a bug producing a label < start_label (gh-6240).
For the v0.19.1 release, the `img` and `slic` call as below result in two
non-contiguous regions with value 0 despite `start_label=1`. We verify that
the minimum label is now `start_label` as expected.
"""
# generate bumpy data that gives unexpected label prior to bug fix
rng = np.random.default_rng(9)
img = rng.standard_normal((8, 13)) > 0
img = filters.gaussian(img, sigma=1)
start_label = 1
superp = slic(img, start_label=start_label, channel_axis=None,
n_segments=6, compactness=0.01, enforce_connectivity=True,
max_num_iter=10)
assert superp.min() == start_label
 End of changes. 2 change blocks. 
1 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)