-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
_fetchers.py
1241 lines (958 loc) · 37.6 KB
/
_fetchers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Standard test images.
For more images, see
- http://sipi.usc.edu/database/database.php
"""
import numpy as np
import shutil
from ..util.dtype import img_as_bool
from ._registry import registry, legacy_registry, registry_urls
from .. import __version__
import os.path as osp
import os
legacy_data_dir = osp.abspath(osp.dirname(__file__))
skimage_distribution_dir = osp.join(legacy_data_dir, '..')
try:
from pooch import file_hash
except ModuleNotFoundError:
# Function taken from
# https://github.com/fatiando/pooch/blob/master/pooch/utils.py
def file_hash(fname, alg="sha256"):
"""
Calculate the hash of a given file.
Useful for checking if a file has changed or been corrupted.
Parameters
----------
fname : str
The name of the file.
alg : str
The type of the hashing algorithm
Returns
-------
hash : str
The hash of the file.
Examples
--------
>>> fname = "test-file-for-hash.txt"
>>> with open(fname, "w") as f:
... __ = f.write("content of the file")
>>> print(file_hash(fname))
0fc74468e6a9a829f103d069aeb2bb4f8646bad58bf146bb0e3379b759ec4a00
>>> import os
>>> os.remove(fname)
"""
import hashlib
if alg not in hashlib.algorithms_available:
raise ValueError(f'Algorithm \'{alg}\' not available in hashlib')
# Calculate the hash in chunks to avoid overloading the memory
chunksize = 65536
hasher = hashlib.new(alg)
with open(fname, "rb") as fin:
buff = fin.read(chunksize)
while buff:
hasher.update(buff)
buff = fin.read(chunksize)
return hasher.hexdigest()
def _has_hash(path, expected_hash):
"""Check if the provided path has the expected hash."""
if not osp.exists(path):
return False
return file_hash(path) == expected_hash
def create_image_fetcher():
try:
import pooch
# older versions of Pooch don't have a __version__ attribute
if not hasattr(pooch, '__version__'):
retry = {}
else:
retry = {'retry_if_failed': 3}
except ImportError:
# Without pooch, fallback on the standard data directory
# which for now, includes a few limited data samples
return None, legacy_data_dir
# Pooch expects a `+` to exist in development versions.
# Since scikit-image doesn't follow that convention, we have to manually
# remove `.dev` with a `+` if it exists.
# This helps pooch understand that it should look in master
# to find the required files
if '+git' in __version__:
skimage_version_for_pooch = __version__.replace('.dev0+git', '+git')
else:
skimage_version_for_pooch = __version__.replace('.dev', '+')
if '+' in skimage_version_for_pooch:
url = ("https://github.com/scikit-image/scikit-image/raw/"
"{version}/skimage/")
else:
url = ("https://github.com/scikit-image/scikit-image/raw/"
"v{version}/skimage/")
# Create a new friend to manage your sample data storage
image_fetcher = pooch.create(
# Pooch uses appdirs to select an appropriate directory for the cache
# on each platform.
# https://github.com/ActiveState/appdirs
# On linux this converges to
# '$HOME/.cache/scikit-image'
# With a version qualifier
path=pooch.os_cache("scikit-image"),
base_url=url,
version=skimage_version_for_pooch,
version_dev="main",
env="SKIMAGE_DATADIR",
registry=registry,
urls=registry_urls,
# Note: this should read `retry_if_failed=3,`, but we generate that
# dynamically at import time above, in case installed pooch is a less
# recent version
**retry,
)
data_dir = osp.join(str(image_fetcher.abspath), 'data')
return image_fetcher, data_dir
image_fetcher, data_dir = create_image_fetcher()
if image_fetcher is None:
has_pooch = False
else:
has_pooch = True
def _skip_pytest_case_requiring_pooch(data_filename):
"""If a test case is calling pooch, skip it.
This running the test suite in environments without internet
access, skipping only the tests that try to fetch external data.
"""
# Check if pytest is currently running.
# Packagers might use pytest to run the tests suite, but may not
# want to run it online with pooch as a dependency.
# As such, we will avoid failing the test, and silently skipping it.
if 'PYTEST_CURRENT_TEST' in os.environ:
# https://docs.pytest.org/en/latest/example/simple.html#pytest-current-test-environment-variable # noqa
import pytest
# Pytest skip raises an exception that allows the
# tests to be skipped
pytest.skip(f'Unable to download {data_filename}',
allow_module_level=True)
def _fetch(data_filename):
"""Fetch a given data file from either the local cache or the repository.
This function provides the path location of the data file given
its name in the scikit-image repository.
Parameters
----------
data_filename:
Name of the file in the scikit-image repository. e.g.
'restoration/tess/camera_rl.npy'.
Returns
-------
Path of the local file as a python string.
Raises
------
KeyError:
If the filename is not known to the scikit-image distribution.
ModuleNotFoundError:
If the filename is known to the scikit-image distribution but pooch
is not installed.
ConnectionError:
If scikit-image is unable to connect to the internet but the
dataset has not been downloaded yet.
"""
resolved_path = osp.join(data_dir, '..', data_filename)
expected_hash = registry[data_filename]
# Case 1:
# The file may already be in the data_dir.
# We may have decided to ship it in the scikit-image distribution.
if _has_hash(resolved_path, expected_hash):
# Nothing to be done, file is where it is expected to be
return resolved_path
# Case 2:
# The user is using a cloned version of the github repo, which
# contains both the publicly shipped data, and test data.
# In this case, the file would be located relative to the
# skimage_distribution_dir
gh_repository_path = osp.join(skimage_distribution_dir, data_filename)
if _has_hash(gh_repository_path, expected_hash):
parent = osp.dirname(resolved_path)
os.makedirs(parent, exist_ok=True)
shutil.copy2(gh_repository_path, resolved_path)
return resolved_path
# Case 3:
# Pooch not found.
if image_fetcher is None:
_skip_pytest_case_requiring_pooch(data_filename)
raise ModuleNotFoundError(
"The requested file is part of the scikit-image distribution, "
"but requires the installation of an optional dependency, pooch. "
"To install pooch, use your preferred python package manager. "
"Follow installation instruction found at "
"https://scikit-image.org/docs/stable/install.html"
)
# Case 4:
# Pooch needs to download the data. Let the image fetcher to search for
# our data. A ConnectionError is raised if no internet connection is
# available.
try:
resolved_path = image_fetcher.fetch(data_filename)
except ConnectionError as err:
_skip_pytest_case_requiring_pooch(data_filename)
# If we decide in the future to suppress the underlying 'requests'
# error, change this to `raise ... from None`. See PEP 3134.
raise ConnectionError(
'Tried to download a scikit-image dataset, but no internet '
'connection is available. To avoid this message in the '
'future, try `skimage.data.download_all()` when you are '
'connected to the internet.'
) from err
return resolved_path
def _init_pooch():
os.makedirs(data_dir, exist_ok=True)
# Copy in the README.txt if it doesn't already exist.
# If the file was originally copied to the data cache directory read-only
# then we cannot overwrite it, nor do we need to copy on every init.
# In general, as the data cache directory contains the scikit-image version
# it should not be necessary to overwrite this file as it should not
# change.
dest_path = osp.join(data_dir, 'README.txt')
if not os.path.isfile(dest_path):
shutil.copy2(osp.join(skimage_distribution_dir, 'data', 'README.txt'),
dest_path)
# Fetch all legacy data so that it is available by default
for filename in legacy_registry:
_fetch(filename)
# This function creates directories, and has been the source of issues for
# downstream users, see
# https://github.com/scikit-image/scikit-image/issues/4660
# https://github.com/scikit-image/scikit-image/issues/4664
if has_pooch:
_init_pooch()
def download_all(directory=None):
"""Download all datasets for use with scikit-image offline.
Scikit-image datasets are no longer shipped with the library by default.
This allows us to use higher quality datasets, while keeping the
library download size small.
This function requires the installation of an optional dependency, pooch,
to download the full dataset. Follow installation instruction found at
https://scikit-image.org/docs/stable/install.html
Call this function to download all sample images making them available
offline on your machine.
Parameters
----------
directory: path-like, optional
The directory where the dataset should be stored.
Raises
------
ModuleNotFoundError:
If pooch is not install, this error will be raised.
Notes
-----
scikit-image will only search for images stored in the default directory.
Only specify the directory if you wish to download the images to your own
folder for a particular reason. You can access the location of the default
data directory by inspecting the variable `skimage.data.data_dir`.
"""
if image_fetcher is None:
raise ModuleNotFoundError(
"To download all package data, scikit-image needs an optional "
"dependency, pooch."
"To install pooch, follow our installation instructions found at "
"https://scikit-image.org/docs/stable/install.html"
)
# Consider moving this kind of logic to Pooch
old_dir = image_fetcher.path
try:
if directory is not None:
image_fetcher.path = directory
for filename in image_fetcher.registry:
_fetch(filename)
finally:
image_fetcher.path = old_dir
def lbp_frontal_face_cascade_filename():
"""Return the path to the XML file containing the weak classifier cascade.
These classifiers were trained using LBP features. The file is part
of the OpenCV repository [1]_.
References
----------
.. [1] OpenCV lbpcascade trained files
https://github.com/opencv/opencv/tree/master/data/lbpcascades
"""
return _fetch('data/lbpcascade_frontalface_opencv.xml')
def _load(f, as_gray=False):
"""Load an image file located in the data directory.
Parameters
----------
f : string
File name.
as_gray : bool, optional
Whether to convert the image to grayscale.
Returns
-------
img : ndarray
Image loaded from ``skimage.data_dir``.
"""
# importing io is quite slow since it scans all the backends
# we lazy import it here
from ..io import imread
return imread(_fetch(f), as_gray=as_gray)
def camera():
"""Gray-level "camera" image.
Can be used for segmentation and denoising examples.
Returns
-------
camera : (512, 512) uint8 ndarray
Camera image.
Notes
-----
No copyright restrictions. CC0 by the photographer (Lav Varshney).
.. versionchanged:: 0.18
This image was replaced due to copyright restrictions. For more
information, please see [1]_.
References
----------
.. [1] https://github.com/scikit-image/scikit-image/issues/3927
"""
return _load("data/camera.png")
def eagle():
"""A golden eagle.
Suitable for examples on segmentation, Hough transforms, and corner
detection.
Notes
-----
No copyright restrictions. CC0 by the photographer (Dayane Machado).
Returns
-------
eagle : (2019, 1826) uint8 ndarray
Eagle image.
"""
return _load("data/eagle.png")
def astronaut():
"""Color image of the astronaut Eileen Collins.
Photograph of Eileen Collins, an American astronaut. She was selected
as an astronaut in 1992 and first piloted the space shuttle STS-63 in
1995. She retired in 2006 after spending a total of 38 days, 8 hours
and 10 minutes in outer space.
This image was downloaded from the NASA Great Images database
<https://flic.kr/p/r9qvLn>`__.
No known copyright restrictions, released into the public domain.
Returns
-------
astronaut : (512, 512, 3) uint8 ndarray
Astronaut image.
"""
return _load("data/astronaut.png")
def brick():
"""Brick wall.
Returns
-------
brick : (512, 512) uint8 image
A small section of a brick wall.
Notes
-----
The original image was downloaded from
`CC0Textures <https://cc0textures.com/view.php?tex=Bricks25>`_ and licensed
under the Creative Commons CC0 License.
A perspective transform was then applied to the image, prior to
rotating it by 90 degrees, cropping and scaling it to obtain the final
image.
"""
"""
The following code was used to obtain the final image.
>>> import sys; print(sys.version)
>>> import platform; print(platform.platform())
>>> import skimage; print(f'scikit-image version: {skimage.__version__}')
>>> import numpy; print(f'numpy version: {numpy.__version__}')
>>> import imageio; print(f'imageio version {imageio.__version__}')
3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
Linux-5.0.0-20-generic-x86_64-with-debian-buster-sid
scikit-image version: 0.16.dev0
numpy version: 1.16.4
imageio version 2.4.1
>>> import requests
>>> import zipfile
>>> url = 'https://cdn.struffelproductions.com/file/cc0textures/Bricks25/%5B2K%5DBricks25.zip'
>>> r = requests.get(url)
>>> with open('[2K]Bricks25.zip', 'bw') as f:
... f.write(r.content)
>>> with zipfile.ZipFile('[2K]Bricks25.zip') as z:
... z.extract('Bricks25_col.jpg')
>>> from numpy.linalg import inv
>>> from skimage.transform import rescale, warp, rotate
>>> from skimage.color import rgb2gray
>>> from imageio import imread, imwrite
>>> from skimage import img_as_ubyte
>>> import numpy as np
>>> # Obtained playing around with GIMP 2.10 with their perspective tool
>>> H = inv(np.asarray([[ 0.54764, -0.00219, 0],
... [-0.12822, 0.54688, 0],
... [-0.00022, 0, 1]]))
>>> brick_orig = imread('Bricks25_col.jpg')
>>> brick = warp(brick_orig, H)
>>> brick = rescale(brick[:1024, :1024], (0.5, 0.5, 1))
>>> brick = rotate(brick, -90)
>>> imwrite('brick.png', img_as_ubyte(rgb2gray(brick)))
"""
return _load("data/brick.png", as_gray=True)
def grass():
"""Grass.
Returns
-------
grass : (512, 512) uint8 image
Some grass.
Notes
-----
The original image was downloaded from
`DeviantArt <https://www.deviantart.com/linolafett/art/Grass-01-434853879>`__
and licensed under the Creative Commons CC0 License.
The downloaded image was cropped to include a region of ``(512, 512)``
pixels around the top left corner, converted to grayscale, then to uint8
prior to saving the result in PNG format.
"""
"""
The following code was used to obtain the final image.
>>> import sys; print(sys.version)
>>> import platform; print(platform.platform())
>>> import skimage; print(f'scikit-image version: {skimage.__version__}')
>>> import numpy; print(f'numpy version: {numpy.__version__}')
>>> import imageio; print(f'imageio version {imageio.__version__}')
3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
Linux-5.0.0-20-generic-x86_64-with-debian-buster-sid
scikit-image version: 0.16.dev0
numpy version: 1.16.4
imageio version 2.4.1
>>> import requests
>>> import zipfile
>>> url = 'https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/a407467e-4ff0-49f1-923f-c9e388e84612/d76wfef-2878b78d-5dce-43f9-be36-26ec9bc0df3b.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcL2E0MDc0NjdlLTRmZjAtNDlmMS05MjNmLWM5ZTM4OGU4NDYxMlwvZDc2d2ZlZi0yODc4Yjc4ZC01ZGNlLTQzZjktYmUzNi0yNmVjOWJjMGRmM2IuanBnIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.98hIcOTCqXWQ67Ec5bM5eovKEn2p91mWB3uedH61ynI'
>>> r = requests.get(url)
>>> with open('grass_orig.jpg', 'bw') as f:
... f.write(r.content)
>>> grass_orig = imageio.imread('grass_orig.jpg')
>>> grass = skimage.img_as_ubyte(skimage.color.rgb2gray(grass_orig[:512, :512]))
>>> imageio.imwrite('grass.png', grass)
"""
return _load("data/grass.png", as_gray=True)
def gravel():
"""Gravel
Returns
-------
gravel : (512, 512) uint8 image
Grayscale gravel sample.
Notes
-----
The original image was downloaded from
`CC0Textures <https://cc0textures.com/view.php?tex=Gravel04>`__ and
licensed under the Creative Commons CC0 License.
The downloaded image was then rescaled to ``(1024, 1024)``, then the
top left ``(512, 512)`` pixel region was cropped prior to converting the
image to grayscale and uint8 data type. The result was saved using the
PNG format.
"""
"""
The following code was used to obtain the final image.
>>> import sys; print(sys.version)
>>> import platform; print(platform.platform())
>>> import skimage; print(f'scikit-image version: {skimage.__version__}')
>>> import numpy; print(f'numpy version: {numpy.__version__}')
>>> import imageio; print(f'imageio version {imageio.__version__}')
3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
Linux-5.0.0-20-generic-x86_64-with-debian-buster-sid
scikit-image version: 0.16.dev0
numpy version: 1.16.4
imageio version 2.4.1
>>> import requests
>>> import zipfile
>>> url = 'https://cdn.struffelproductions.com/file/cc0textures/Gravel04/%5B2K%5DGravel04.zip'
>>> r = requests.get(url)
>>> with open('[2K]Gravel04.zip', 'bw') as f:
... f.write(r.content)
>>> with zipfile.ZipFile('[2K]Gravel04.zip') as z:
... z.extract('Gravel04_col.jpg')
>>> from skimage.transform import resize
>>> gravel_orig = imageio.imread('Gravel04_col.jpg')
>>> gravel = resize(gravel_orig, (1024, 1024))
>>> gravel = skimage.img_as_ubyte(skimage.color.rgb2gray(gravel[:512, :512]))
>>> imageio.imwrite('gravel.png', gravel)
"""
return _load("data/gravel.png", as_gray=True)
def text():
"""Gray-level "text" image used for corner detection.
Notes
-----
This image was downloaded from Wikipedia
<https://en.wikipedia.org/wiki/File:Corner.png>`__.
No known copyright restrictions, released into the public domain.
Returns
-------
text : (172, 448) uint8 ndarray
Text image.
"""
return _load("data/text.png")
def checkerboard():
"""Checkerboard image.
Checkerboards are often used in image calibration, since the
corner-points are easy to locate. Because of the many parallel
edges, they also visualise distortions particularly well.
Returns
-------
checkerboard : (200, 200) uint8 ndarray
Checkerboard image.
"""
return _load("data/chessboard_GRAY.png")
def cells3d():
"""3D fluorescence microscopy image of cells.
The returned data is a 3D multichannel array with dimensions provided in
``(z, c, y, x)`` order. Each voxel has a size of ``(0.29 0.26 0.26)``
micrometer. Channel 0 contains cell membranes, channel 1 contains nuclei.
Returns
-------
cells3d: (60, 2, 256, 256) uint16 ndarray
The volumetric images of cells taken with an optical microscope.
Notes
-----
The data for this was provided by the Allen Institute for Cell Science.
It has been downsampled by a factor of 4 in the row and column dimensions
to reduce computational time.
The microscope reports the following voxel spacing in microns:
* Original voxel size is ``(0.290, 0.065, 0.065)``.
* Scaling factor is ``(1, 4, 4)`` in each dimension.
* After rescaling the voxel size is ``(0.29 0.26 0.26)``.
"""
return _load("data/cells3d.tif")
def human_mitosis():
"""Image of human cells undergoing mitosis.
Returns
-------
human_mitosis: (512, 512) uint8 ndarray
Data of human cells undergoing mitosis taken during the preparation
of the manuscript in [1]_.
Notes
-----
Copyright David Root. Licensed under CC-0 [2]_.
References
----------
.. [1] Moffat J, Grueneberg DA, Yang X, Kim SY, Kloepfer AM, Hinkle G,
Piqani B, Eisenhaure TM, Luo B, Grenier JK, Carpenter AE, Foo SY,
Stewart SA, Stockwell BR, Hacohen N, Hahn WC, Lander ES,
Sabatini DM, Root DE (2006) A lentiviral RNAi library for human and
mouse genes applied to an arrayed viral high-content screen. Cell,
124(6):1283-98 / :DOI: `10.1016/j.cell.2006.01.040` PMID 16564017
.. [2] GitHub licensing discussion
https://github.com/CellProfiler/examples/issues/41
"""
return _load('data/mitosis.tif')
def cell():
"""Cell floating in saline.
This is a quantitative phase image retrieved from a digital hologram using
the Python library ``qpformat``. The image shows a cell with high phase
value, above the background phase.
Because of a banding pattern artifact in the background, this image is a
good test of thresholding algorithms. The pixel spacing is 0.107 µm.
These data were part of a comparison between several refractive index
retrieval techniques for spherical objects as part of [1]_.
This image is CC0, dedicated to the public domain. You may copy, modify, or
distribute it without asking permission.
Returns
-------
cell : (660, 550) uint8 array
Image of a cell.
References
----------
.. [1] Paul Müller, Mirjam Schürmann, Salvatore Girardo, Gheorghe Cojoc,
and Jochen Guck. "Accurate evaluation of size and refractive index
for spherical objects in quantitative phase imaging." Optics Express
26(8): 10729-10743 (2018). :DOI:`10.1364/OE.26.010729`
"""
return _load('data/cell.png')
def coins():
"""Greek coins from Pompeii.
This image shows several coins outlined against a gray background.
It is especially useful in, e.g. segmentation tests, where
individual objects need to be identified against a background.
The background shares enough grey levels with the coins that a
simple segmentation is not sufficient.
Notes
-----
This image was downloaded from the
`Brooklyn Museum Collection
<https://www.brooklynmuseum.org/opencollection/archives/image/51611>`__.
No known copyright restrictions.
Returns
-------
coins : (303, 384) uint8 ndarray
Coins image.
"""
return _load("data/coins.png")
def kidney():
"""Mouse kidney tissue.
This biological tissue on a pre-prepared slide was imaged with confocal
fluorescence microscopy (Nikon C1 inverted microscope).
Image shape is (16, 512, 512, 3). That is 512x512 pixels in X-Y,
16 image slices in Z, and 3 color channels
(emission wavelengths 450nm, 515nm, and 605nm, respectively).
Real-space voxel size is 1.24 microns in X-Y, and 1.25 microns in Z.
Data type is unsigned 16-bit integers.
Notes
-----
This image was acquired by Genevieve Buckley at Monasoh Micro Imaging in
2018.
License: CC0
Returns
-------
kidney : (16, 512, 512, 3) uint16 ndarray
Kidney 3D multichannel image.
"""
return _load("data/kidney.tif")
def lily():
"""Lily of the valley plant stem.
This plant stem on a pre-prepared slide was imaged with confocal
fluorescence microscopy (Nikon C1 inverted microscope).
Image shape is (922, 922, 4). That is 922x922 pixels in X-Y,
with 4 color channels.
Real-space voxel size is 1.24 microns in X-Y.
Data type is unsigned 16-bit integers.
Notes
-----
This image was acquired by Genevieve Buckley at Monasoh Micro Imaging in
2018.
License: CC0
Returns
-------
lily : (922, 922, 4) uint16 ndarray
Lily 2D multichannel image.
"""
return _load("data/lily.tif")
def logo():
"""Scikit-image logo, a RGBA image.
Returns
-------
logo : (500, 500, 4) uint8 ndarray
Logo image.
"""
return _load("data/logo.png")
def microaneurysms():
"""Gray-level "microaneurysms" image.
Detail from an image of the retina (green channel).
The image is a crop of image 07_dr.JPG from the
High-Resolution Fundus (HRF) Image Database:
https://www5.cs.fau.de/research/data/fundus-images/
Notes
-----
No copyright restrictions. CC0 given by owner (Andreas Maier).
Returns
-------
microaneurysms : (102, 102) uint8 ndarray
Retina image with lesions.
References
----------
.. [1] Budai, A., Bock, R, Maier, A., Hornegger, J.,
Michelson, G. (2013). Robust Vessel Segmentation in Fundus
Images. International Journal of Biomedical Imaging, vol. 2013,
2013.
:DOI:`10.1155/2013/154860`
"""
return _load("data/microaneurysms.png")
def moon():
"""Surface of the moon.
This low-contrast image of the surface of the moon is useful for
illustrating histogram equalization and contrast stretching.
Returns
-------
moon : (512, 512) uint8 ndarray
Moon image.
"""
return _load("data/moon.png")
def page():
"""Scanned page.
This image of printed text is useful for demonstrations requiring uneven
background illumination.
Returns
-------
page : (191, 384) uint8 ndarray
Page image.
"""
return _load("data/page.png")
def horse():
"""Black and white silhouette of a horse.
This image was downloaded from
`openclipart <http://openclipart.org/detail/158377/horse-by-marauder>`
No copyright restrictions. CC0 given by owner (Andreas Preuss (marauder)).
Returns
-------
horse : (328, 400) bool ndarray
Horse image.
"""
return img_as_bool(_load("data/horse.png", as_gray=True))
def clock():
"""Motion blurred clock.
This photograph of a wall clock was taken while moving the camera in an
approximately horizontal direction. It may be used to illustrate
inverse filters and deconvolution.
Released into the public domain by the photographer (Stefan van der Walt).
Returns
-------
clock : (300, 400) uint8 ndarray
Clock image.
"""
return _load("data/clock_motion.png")
def immunohistochemistry():
"""Immunohistochemical (IHC) staining with hematoxylin counterstaining.
This picture shows colonic glands where the IHC expression of FHL2 protein
is revealed with DAB. Hematoxylin counterstaining is applied to enhance the
negative parts of the tissue.
This image was acquired at the Center for Microscopy And Molecular Imaging
(CMMI).
No known copyright restrictions.
Returns
-------
immunohistochemistry : (512, 512, 3) uint8 ndarray
Immunohistochemistry image.
"""
return _load("data/ihc.png")
def chelsea():
"""Chelsea the cat.
An example with texture, prominent edges in horizontal and diagonal
directions, as well as features of differing scales.
Notes
-----
No copyright restrictions. CC0 by the photographer (Stefan van der Walt).
Returns
-------
chelsea : (300, 451, 3) uint8 ndarray
Chelsea image.
"""
return _load("data/chelsea.png")
# Define an alias for chelsea that is more descriptive.
cat = chelsea
def coffee():
"""Coffee cup.
This photograph is courtesy of Pikolo Espresso Bar.
It contains several elliptical shapes as well as varying texture (smooth
porcelain to coarse wood grain).
Notes
-----
No copyright restrictions. CC0 by the photographer (Rachel Michetti).
Returns
-------
coffee : (400, 600, 3) uint8 ndarray
Coffee image.
"""
return _load("data/coffee.png")
def hubble_deep_field():
"""Hubble eXtreme Deep Field.
This photograph contains the Hubble Telescope's farthest ever view of
the universe. It can be useful as an example for multi-scale
detection.
Notes
-----
This image was downloaded from
`HubbleSite
<http://hubblesite.org/newscenter/archive/releases/2012/37/image/a/>`__.
The image was captured by NASA and `may be freely used in the public domain
<http://www.nasa.gov/audience/formedia/features/MP_Photo_Guidelines.html>`_.
Returns
-------
hubble_deep_field : (872, 1000, 3) uint8 ndarray
Hubble deep field image.
"""
return _load("data/hubble_deep_field.jpg")
def retina():
"""Human retina.
This image of a retina is useful for demonstrations requiring circular
images.
Notes
-----
This image was downloaded from
`wikimedia <https://commons.wikimedia.org/wiki/File:Fundus_photograph_of_normal_left_eye.jpg>`.
This file is made available under the Creative Commons CC0 1.0 Universal
Public Domain Dedication.
References
----------
.. [1] Häggström, Mikael (2014). "Medical gallery of Mikael Häggström 2014".
WikiJournal of Medicine 1 (2). :DOI:`10.15347/wjm/2014.008`.
ISSN 2002-4436. Public Domain
Returns
-------
retina : (1411, 1411, 3) uint8 ndarray
Retina image in RGB.
"""
return _load("data/retina.jpg")
def shepp_logan_phantom():
"""Shepp Logan Phantom.
References