/
__init__.py
433 lines (324 loc) · 11.6 KB
/
__init__.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
# coding: utf-8
"""Standard test images.
For more images, see
- http://sipi.usc.edu/database/database.php
"""
import os as _os
import numpy as _np
from ..io import imread, use_plugin
from .._shared._warnings import expected_warnings, warn
from ..util.dtype import img_as_bool
from ._binary_blobs import binary_blobs
import os.path as osp
data_dir = osp.abspath(osp.dirname(__file__))
__all__ = ['data_dir',
'load',
'astronaut',
'binary_blobs',
'camera',
'checkerboard',
'chelsea',
'clock',
'coffee',
'coins',
'horse',
'hubble_deep_field',
'immunohistochemistry',
'lfw_subset',
'logo',
'moon',
'page',
'text',
'rocket',
'stereo_motorcycle']
def load(f, as_gray=False, as_grey=None):
"""Load an image file located in the data directory.
Parameters
----------
f : string
File name.
as_gray : bool, optional
Convert to grayscale.
as_grey : bool or None, optional
Deprecated keyword argument. Use `as_gray` instead.
If None, `as_gray` is used.
Convert to grayscale.
Returns
-------
img : ndarray
Image loaded from ``skimage.data_dir``.
"""
if as_grey is not None:
as_gray = as_grey
warn('`as_grey` has been deprecated in favor of `as_gray`'
' and will be removed in v0.16.')
use_plugin('pil')
return imread(_os.path.join(data_dir, f), as_gray=as_gray)
def camera():
"""Gray-level "camera" image.
Often used for segmentation and denoising examples.
Returns
-------
camera : (512, 512) uint8 ndarray
Camera image.
"""
return load("camera.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("astronaut.png")
def text():
"""Gray-level "text" image used for corner detection.
Notes
-----
This image was downloaded from Wikipedia
<http://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("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("chessboard_GRAY.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("coins.png")
def logo():
"""Scikit-image logo, a RGBA image.
Returns
-------
logo : (500, 500, 4) uint8 ndarray
Logo image.
"""
return load("logo.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("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("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>`
Released into public domain and drawn and uploaded by Andreas Preuss
(marauder).
Returns
-------
horse : (328, 400) bool ndarray
Horse image.
"""
with expected_warnings(['Possible precision loss', 'Possible sign loss']):
return img_as_bool(load("horse.png", as_gray=True))
def clock():
"""Motion blurred clock.
This photograph of a wall clock was taken while moving the camera in an
aproximately 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("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("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("chelsea.png")
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 course wood grain).
Notes
-----
No copyright restrictions. CC0 by the photographer (Rachel Michetti).
Returns
-------
coffee : (400, 600, 3) uint8 ndarray
Coffee image.
"""
return load("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("hubble_deep_field.jpg")
def rocket():
"""Launch photo of DSCOVR on Falcon 9 by SpaceX.
This is the launch photo of Falcon 9 carrying DSCOVR lifted off from
SpaceX's Launch Complex 40 at Cape Canaveral Air Force Station, FL.
Notes
-----
This image was downloaded from
`SpaceX Photos
<https://www.flickr.com/photos/spacexphotos/16511594820/in/photostream/>`__.
The image was captured by SpaceX and `released in the public domain
<http://arstechnica.com/tech-policy/2015/03/elon-musk-puts-spacex-photos-into-the-public-domain/>`_.
Returns
-------
rocket : (427, 640, 3) uint8 ndarray
Rocket image.
"""
return load("rocket.jpg")
def stereo_motorcycle():
"""Rectified stereo image pair with ground-truth disparities.
The two images are rectified such that every pixel in the left image has
its corresponding pixel on the same scanline in the right image. That means
that both images are warped such that they have the same orientation but a
horizontal spatial offset (baseline). The ground-truth pixel offset in
column direction is specified by the included disparity map.
The two images are part of the Middlebury 2014 stereo benchmark. The
dataset was created by Nera Nesic, Porter Westling, Xi Wang, York Kitajima,
Greg Krathwohl, and Daniel Scharstein at Middlebury College. A detailed
description of the acquisition process can be found in [1]_.
The images included here are down-sampled versions of the default exposure
images in the benchmark. The images are down-sampled by a factor of 4 using
the function `skimage.transform.downscale_local_mean`. The calibration data
in the following and the included ground-truth disparity map are valid for
the down-sampled images::
Focal length: 994.978px
Principal point x: 311.193px
Principal point y: 254.877px
Principal point dx: 31.086px
Baseline: 193.001mm
Returns
-------
img_left : (500, 741, 3) uint8 ndarray
Left stereo image.
img_right : (500, 741, 3) uint8 ndarray
Right stereo image.
disp : (500, 741, 3) float ndarray
Ground-truth disparity map, where each value describes the offset in
column direction between corresponding pixels in the left and the right
stereo images. E.g. the corresponding pixel of
``img_left[10, 10 + disp[10, 10]]`` is ``img_right[10, 10]``.
NaNs denote pixels in the left image that do not have ground-truth.
Notes
-----
The original resolution images, images with different exposure and
lighting, and ground-truth depth maps can be found at the Middlebury
website [2]_.
References
----------
.. [1] D. Scharstein, H. Hirschmueller, Y. Kitajima, G. Krathwohl, N.
Nesic, X. Wang, and P. Westling. High-resolution stereo datasets
with subpixel-accurate ground truth. In German Conference on Pattern
Recognition (GCPR 2014), Muenster, Germany, September 2014.
.. [2] http://vision.middlebury.edu/stereo/data/scenes2014/
"""
return (load("motorcycle_left.png"),
load("motorcycle_right.png"),
_np.load(_os.path.join(data_dir, "motorcycle_disp.npz"))["arr_0"])
def lfw_subset():
"""Subset of data from the LFW dataset.
This database is a subset of the LFW database containing:
* 100 faces
* 100 non-faces
The full dataset is available at [2]_.
Returns
-------
images : (200, 25, 25) uint8 ndarray
100 first images are faces and subsequent 100 are non-faces.
Notes
-----
The faces were randomly selected from the LFW dataset and the non-faces
were extracted from the background of the same dataset. The cropped ROIs
have been resized to a 25 x 25 pixels.
References
----------
.. [1] Huang, G., Mattar, M., Lee, H., & Learned-Miller, E. G. (2012).
Learning to align from scratch. In Advances in Neural Information
Processing Systems (pp. 764-772).
.. [2] http://vis-www.cs.umass.edu/lfw/
"""
return _np.load(_os.path.join(data_dir, 'lfw_subset.npy'))