diff --git a/TODO.txt b/TODO.txt index 9e31032b..d411d96e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -13,7 +13,6 @@ Version 0.14 parameters `(dist, theta)`, LineModelND has the more general parameters `(origin, direction)`. * Remove deprecated old syntax support for ``skimage.transform.integrate``. -* Remove deprecated ``skimage.data.lena`` and corresponding data files. * Remove deprecated ``skimage.measure.structural_similarity`` alias and deprecation warning test for this alias. * Remove deprecated ``sigma_range`` kwargs in ``skimage.restoration.denoise_bilateral`` diff --git a/doc/source/api_changes.txt b/doc/source/api_changes.txt index dc023149..cdf82eca 100644 --- a/doc/source/api_changes.txt +++ b/doc/source/api_changes.txt @@ -12,6 +12,7 @@ Version 0.12 `skimage.transform.PiecewiseAffineTransform.affines_*` attributes have been removed. - `skimage.filters.denoise_*` have moved to `skimage.restoration.denoise_*`. +- `skimage.data.lena` has been removed. Version 0.11 ------------ diff --git a/skimage/data/__init__.py b/skimage/data/__init__.py index ff8184b5..6dc5dd8e 100644 --- a/skimage/data/__init__.py +++ b/skimage/data/__init__.py @@ -61,13 +61,16 @@ def camera(): def lena(): """Colour "Lena" image. + **This image has been removed from scikit-image due to copyright + concerns.** + The standard, yet sometimes controversial Lena test image was scanned from the November 1972 edition of Playboy magazine. From an image processing perspective, this image is useful because it contains smooth, textured, shaded as well as detail areas. """ - return load("lena.png") + raise RuntimeError("This image has been removed due to copyright concerns.") def astronaut(): diff --git a/skimage/data/cvCalibrateCamera2TestData.npz b/skimage/data/cvCalibrateCamera2TestData.npz deleted file mode 100644 index effe2842..00000000 Binary files a/skimage/data/cvCalibrateCamera2TestData.npz and /dev/null differ diff --git a/skimage/data/diamond-bothat-matlab-output.npz b/skimage/data/diamond-bothat-matlab-output.npz deleted file mode 100644 index 1b0a65dd..00000000 Binary files a/skimage/data/diamond-bothat-matlab-output.npz and /dev/null differ diff --git a/skimage/data/diamond-close-matlab-output.npz b/skimage/data/diamond-close-matlab-output.npz deleted file mode 100644 index 4f39c48c..00000000 Binary files a/skimage/data/diamond-close-matlab-output.npz and /dev/null differ diff --git a/skimage/data/diamond-dilate-matlab-output.npz b/skimage/data/diamond-dilate-matlab-output.npz deleted file mode 100644 index f79d9a44..00000000 Binary files a/skimage/data/diamond-dilate-matlab-output.npz and /dev/null differ diff --git a/skimage/data/diamond-erode-matlab-output.npz b/skimage/data/diamond-erode-matlab-output.npz deleted file mode 100644 index 3b034cb4..00000000 Binary files a/skimage/data/diamond-erode-matlab-output.npz and /dev/null differ diff --git a/skimage/data/diamond-open-matlab-output.npz b/skimage/data/diamond-open-matlab-output.npz deleted file mode 100644 index 143fcd4d..00000000 Binary files a/skimage/data/diamond-open-matlab-output.npz and /dev/null differ diff --git a/skimage/data/diamond-tophat-matlab-output.npz b/skimage/data/diamond-tophat-matlab-output.npz deleted file mode 100644 index eb5cd8c1..00000000 Binary files a/skimage/data/diamond-tophat-matlab-output.npz and /dev/null differ diff --git a/skimage/data/disk-bothat-matlab-output.npz b/skimage/data/disk-bothat-matlab-output.npz deleted file mode 100644 index 352a8d76..00000000 Binary files a/skimage/data/disk-bothat-matlab-output.npz and /dev/null differ diff --git a/skimage/data/disk-close-matlab-output.npz b/skimage/data/disk-close-matlab-output.npz deleted file mode 100644 index 2e76e8e6..00000000 Binary files a/skimage/data/disk-close-matlab-output.npz and /dev/null differ diff --git a/skimage/data/disk-dilate-matlab-output.npz b/skimage/data/disk-dilate-matlab-output.npz deleted file mode 100644 index 9b7a5577..00000000 Binary files a/skimage/data/disk-dilate-matlab-output.npz and /dev/null differ diff --git a/skimage/data/disk-erode-matlab-output.npz b/skimage/data/disk-erode-matlab-output.npz deleted file mode 100644 index 43c6606d..00000000 Binary files a/skimage/data/disk-erode-matlab-output.npz and /dev/null differ diff --git a/skimage/data/disk-open-matlab-output.npz b/skimage/data/disk-open-matlab-output.npz deleted file mode 100644 index fcfc652f..00000000 Binary files a/skimage/data/disk-open-matlab-output.npz and /dev/null differ diff --git a/skimage/data/disk-tophat-matlab-output.npz b/skimage/data/disk-tophat-matlab-output.npz deleted file mode 100644 index 1e104c2e..00000000 Binary files a/skimage/data/disk-tophat-matlab-output.npz and /dev/null differ diff --git a/skimage/data/gray_morph_output.npz b/skimage/data/gray_morph_output.npz new file mode 100644 index 00000000..c89980e4 Binary files /dev/null and b/skimage/data/gray_morph_output.npz differ diff --git a/skimage/data/lena.png b/skimage/data/lena.png deleted file mode 100644 index 408111c9..00000000 Binary files a/skimage/data/lena.png and /dev/null differ diff --git a/skimage/data/lena_GRAY_U8.npy b/skimage/data/lena_GRAY_U8.npy deleted file mode 100644 index f6b9ba26..00000000 Binary files a/skimage/data/lena_GRAY_U8.npy and /dev/null differ diff --git a/skimage/data/lena_GRAY_U8.npz b/skimage/data/lena_GRAY_U8.npz deleted file mode 100644 index b3ca94c6..00000000 Binary files a/skimage/data/lena_GRAY_U8.npz and /dev/null differ diff --git a/skimage/data/lena_GRAY_U8_hog.npy b/skimage/data/lena_GRAY_U8_hog.npy deleted file mode 100644 index 71ebf61f..00000000 Binary files a/skimage/data/lena_GRAY_U8_hog.npy and /dev/null differ diff --git a/skimage/data/lena_RGB_U8.npy b/skimage/data/lena_RGB_U8.npy deleted file mode 100644 index 13653f90..00000000 Binary files a/skimage/data/lena_RGB_U8.npy and /dev/null differ diff --git a/skimage/data/lena_RGB_U8.npz b/skimage/data/lena_RGB_U8.npz deleted file mode 100644 index d822fd93..00000000 Binary files a/skimage/data/lena_RGB_U8.npz and /dev/null differ diff --git a/skimage/data/lenagray.png b/skimage/data/lenagray.png deleted file mode 100644 index b59ecc1f..00000000 Binary files a/skimage/data/lenagray.png and /dev/null differ diff --git a/skimage/data/tests/test_data.py b/skimage/data/tests/test_data.py index 38e4543a..e17b2f08 100644 --- a/skimage/data/tests/test_data.py +++ b/skimage/data/tests/test_data.py @@ -1,12 +1,11 @@ import numpy as np import skimage.data as data -from numpy.testing import assert_equal, assert_almost_equal +from numpy.testing import assert_equal, assert_almost_equal, assert_raises -def test_lena(): - """ Test that "Lena" image can be loaded. """ - lena = data.lena() - assert_equal(lena.shape, (512, 512, 3)) +def test_lena_removed(): + """ Test that "Lena" has been removed """ + assert_raises(RuntimeError, data.lena) def test_astronaut(): diff --git a/skimage/io/collection.py b/skimage/io/collection.py index cf57f5f7..4f3ee264 100644 --- a/skimage/io/collection.py +++ b/skimage/io/collection.py @@ -143,11 +143,11 @@ class ImageCollection(object): >>> import skimage.io as io >>> from skimage import data_dir - >>> coll = io.ImageCollection(data_dir + '/lena*.png') + >>> coll = io.ImageCollection(data_dir + '/chess*.png') >>> len(coll) 2 >>> coll[0].shape - (512, 512, 3) + (200, 200) >>> ic = io.ImageCollection('/tmp/work/*.png:/tmp/other/*.jpg') diff --git a/skimage/morphology/tests/test_grey.py b/skimage/morphology/tests/test_grey.py index cbf7d2b8..f6faaec8 100644 --- a/skimage/morphology/tests/test_grey.py +++ b/skimage/morphology/tests/test_grey.py @@ -4,66 +4,46 @@ import numpy as np from numpy import testing from scipy import ndimage as ndi -from skimage import data_dir, img_as_uint +from skimage import color, data, transform +from skimage import img_as_uint, img_as_ubyte, data_dir from skimage.morphology import grey, selem from skimage._shared._warnings import expected_warnings -lena = np.load(os.path.join(data_dir, 'lena_GRAY_U8.npy')) -bw_lena = lena > 100 - - class TestMorphology(): - def morph_worker(self, img, fn, morph_func, strel_func): - matlab_results = np.load(os.path.join(data_dir, fn)) - k = 0 - for arrname in sorted(matlab_results): - expected_result = matlab_results[arrname] - mask = strel_func(k) - actual_result = morph_func(lena, mask) - testing.assert_equal(expected_result, actual_result) - k = k + 1 + # These expected outputs were generated with skimage v0.12.1 + # using: + # + # from skimage.morphology.tests.test_grey import TestMorphology + # import numpy as np + # output = TestMorphology()._build_expected_output() + # np.savez_compressed('gray_morph_output.npz', **output) - def test_erode_diamond(self): - self.morph_worker(lena, "diamond-erode-matlab-output.npz", - grey.erosion, selem.diamond) - def test_dilate_diamond(self): - self.morph_worker(lena, "diamond-dilate-matlab-output.npz", - grey.dilation, selem.diamond) + def _build_expected_output(self): + funcs = (grey.erosion, grey.dilation, grey.opening, grey.closing, + grey.white_tophat, grey.black_tophat) + selems_2D = (selem.square, selem.diamond, + selem.disk, selem.star) - def test_open_diamond(self): - self.morph_worker(lena, "diamond-open-matlab-output.npz", - grey.opening, selem.diamond) + with expected_warnings(['Possible precision loss']): + image = img_as_ubyte(transform.downscale_local_mean( + color.rgb2gray(data.coffee()), (20, 20))) - def test_close_diamond(self): - self.morph_worker(lena, "diamond-close-matlab-output.npz", - grey.closing, selem.diamond) + output = {} + for n in range(1, 4): + for strel in selems_2D: + for func in funcs: + output['{}_{}_{}'.format(strel.__name__, n, func.__name__)]\ + = func(image, strel(n)) - def test_tophat_diamond(self): - self.morph_worker(lena, "diamond-tophat-matlab-output.npz", - grey.white_tophat, selem.diamond) + return output - def test_bothat_diamond(self): - self.morph_worker(lena, "diamond-bothat-matlab-output.npz", - grey.black_tophat, selem.diamond) - - def test_erode_disk(self): - self.morph_worker(lena, "disk-erode-matlab-output.npz", - grey.erosion, selem.disk) - - def test_dilate_disk(self): - self.morph_worker(lena, "disk-dilate-matlab-output.npz", - grey.dilation, selem.disk) - - def test_open_disk(self): - self.morph_worker(lena, "disk-open-matlab-output.npz", - grey.opening, selem.disk) - - def test_close_disk(self): - self.morph_worker(lena, "disk-close-matlab-output.npz", - grey.closing, selem.disk) + def test_gray_morphology(self): + expected = dict(np.load(os.path.join(data_dir, 'gray_morph_output.npz'))) + calculated = self._build_expected_output() + testing.assert_equal(expected, calculated) class TestEccentricStructuringElements(): @@ -119,6 +99,7 @@ class TestEccentricStructuringElements(): tophat = grey.black_tophat(self.white_pixel, s) assert np.all(tophat == 0) + def test_default_selem(): functions = [grey.erosion, grey.dilation, grey.opening, grey.closing, @@ -142,6 +123,7 @@ def test_default_selem(): im_test = function(image) yield testing.assert_array_equal, im_expected, im_test + def test_3d_fallback_default_selem(): # 3x3x3 cube inside a 7x7x7 image: image = np.zeros((7, 7, 7), np.bool) @@ -154,6 +136,7 @@ def test_3d_fallback_default_selem(): image_expected[2:5, 2:5, 2:5] = ndi.generate_binary_structure(3, 1) testing.assert_array_equal(opened, image_expected) + def test_3d_fallback_cube_selem(): # 3x3x3 cube inside a 7x7x7 image: image = np.zeros((7, 7, 7), np.bool) @@ -165,6 +148,7 @@ def test_3d_fallback_cube_selem(): new_image = function(image, cube) yield testing.assert_array_equal, new_image, image + def test_3d_fallback_white_tophat(): image = np.zeros((7, 7, 7), dtype=bool) image[2, 2:4, 2:4] = 1 @@ -178,6 +162,7 @@ def test_3d_fallback_white_tophat(): image_expected = ndi.white_tophat(image,footprint=footprint) testing.assert_array_equal(new_image, image_expected) + def test_3d_fallback_black_tophat(): image = np.ones((7, 7, 7), dtype=bool) image[2, 2:4, 2:4] = 0 @@ -191,6 +176,7 @@ def test_3d_fallback_black_tophat(): image_expected = ndi.black_tophat(image,footprint=footprint) testing.assert_array_equal(new_image, image_expected) + def test_2d_ndimage_equivalence(): image = np.zeros((9, 9), np.uint8) image[2:-2, 2:-2] = 128 @@ -207,6 +193,7 @@ def test_2d_ndimage_equivalence(): testing.assert_array_equal(opened, ndimage_opened) testing.assert_array_equal(closed, ndimage_closed) + # float test images im = np.array([[ 0.55, 0.72, 0.6 , 0.54, 0.42], [ 0.65, 0.44, 0.89, 0.96, 0.38], @@ -246,8 +233,9 @@ def test_float(): def test_uint16(): - im16, eroded16, dilated16, opened16, closed16 = ( - map(img_as_uint, [im, eroded, dilated, opened, closed])) + with expected_warnings(['Possible precision loss']): + im16, eroded16, dilated16, opened16, closed16 = ( + map(img_as_uint, [im, eroded, dilated, opened, closed])) np.testing.assert_allclose(grey.erosion(im16), eroded16) np.testing.assert_allclose(grey.dilation(im16), dilated16) np.testing.assert_allclose(grey.opening(im16), opened16)