Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
481 lines (361 sloc) 12.9 KB
"""Standard test images.
For more images, see
import os as _os
import numpy as _np
from import imread, use_plugin
from .._shared._warnings import expected_warnings, warn
from ..util.dtype import img_as_bool
from ._binary_blobs import binary_blobs
from ._detect import lbp_frontal_face_cascade_filename
import os.path as osp
data_dir = osp.abspath(osp.dirname(__file__))
__all__ = ['data_dir',
def load(f, as_gray=False):
"""Load an image file located in the data directory.
f : string
File name.
as_gray : bool, optional
Whether to convert the image to grayscale.
img : ndarray
Image loaded from ``skimage.data_dir``.
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.
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
No known copyright restrictions, released into the public domain.
astronaut : (512, 512, 3) uint8 ndarray
Astronaut image.
return load("astronaut.png")
def text():
"""Gray-level "text" image used for corner detection.
This image was downloaded from Wikipedia
No known copyright restrictions, released into the public domain.
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.
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.
This image was downloaded from the
`Brooklyn Museum Collection
No known copyright restrictions.
coins : (303, 384) uint8 ndarray
Coins image.
return load("coins.png")
def logo():
"""Scikit-image logo, a RGBA image.
logo : (500, 500, 4) uint8 ndarray
Logo image.
return load("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:
No copyright restrictions. CC0 given by owner (Andreas Maier).
microaneurysms : (102, 102) uint8 ndarray
Retina image with lesions.
.. [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,
return load("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.
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.
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 <>`
No copyright restrictions. CC0 given by owner (Andreas Preuss (marauder)).
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).
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
No known copyright restrictions.
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.
No copyright restrictions. CC0 by the photographer (Stefan van der Walt).
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).
No copyright restrictions. CC0 by the photographer (Rachel Michetti).
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
This image was downloaded from
The image was captured by NASA and `may be freely used in the public domain
hubble_deep_field : (872, 1000, 3) uint8 ndarray
Hubble deep field image.
return load("hubble_deep_field.jpg")
def retina():
"""Human retina.
This image of a retina is useful for demonstrations requiring circular
This image was downloaded from
`wikimedia <>`.
This file is made available under the Creative Commons CC0 1.0 Universal
Public Domain Dedication.
.. [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
retina : (1411, 1411, 3) uint8 ndarray
Retina image in RGB.
return load("retina.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.
This image was downloaded from
`SpaceX Photos
The image was captured by SpaceX and `released in the public domain
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
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.
The original resolution images, images with different exposure and
lighting, and ground-truth depth maps can be found at the Middlebury
website [2]_.
.. [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]
return (load("motorcycle_left.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]_.
images : (200, 25, 25) uint8 ndarray
100 first images are faces and subsequent 100 are non-faces.
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.
.. [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]
return _np.load(_os.path.join(data_dir, 'lfw_subset.npy'))
You can’t perform that action at this time.