Module: data Standard test images. For more images, see  http://sipi.usc.edu/database/database.php
skimage.data.astronaut() Color image of the astronaut Eileen Collins.
skimage.data.binary_blobs([length, …]) Generate synthetic binary image with several rounded blob-like objects.
skimage.data.brain() Subset of data from the University of North Carolina Volume Rendering Test Data Set.
skimage.data.brick() Brick wall.
skimage.data.camera() Gray-level “camera” image.
skimage.data.cat() Chelsea the cat.
skimage.data.cell() Cell floating in saline.
skimage.data.cells3d() 3D fluorescence microscopy image of cells.
skimage.data.checkerboard() Checkerboard image.
skimage.data.chelsea() Chelsea the cat.
skimage.data.clock() Motion blurred clock.
skimage.data.coffee() Coffee cup.
skimage.data.coins() Greek coins from Pompeii.
skimage.data.colorwheel() Color Wheel.
skimage.data.download_all([directory]) Download all datasets for use with scikit-image offline.
skimage.data.eagle() A golden eagle.
skimage.data.grass() Grass.
skimage.data.gravel() Gravel
skimage.data.horse() Black and white silhouette of a horse.
skimage.data.hubble_deep_field() Hubble eXtreme Deep Field.
skimage.data.human_mitosis() Image of human cells undergoing mitosis.
skimage.data.immunohistochemistry() Immunohistochemical (IHC) staining with hematoxylin counterstaining.
skimage.data.kidney() Mouse kidney tissue.
skimage.data.lbp_frontal_face_cascade_filename() Return the path to the XML file containing the weak classifier cascade.
skimage.data.lfw_subset() Subset of data from the LFW dataset.
skimage.data.lily() Lily of the valley plant stem.
skimage.data.logo() Scikit-image logo, a RGBA image.
skimage.data.microaneurysms() Gray-level “microaneurysms” image.
skimage.data.moon() Surface of the moon.
skimage.data.page() Scanned page.
skimage.data.retina() Human retina.
skimage.data.rocket() Launch photo of DSCOVR on Falcon 9 by SpaceX.
skimage.data.shepp_logan_phantom() Shepp Logan Phantom.
skimage.data.skin() Microscopy image of dermis and epidermis (skin layers).
skimage.data.stereo_motorcycle() Rectified stereo image pair with ground-truth disparities.
skimage.data.text() Gray-level “text” image used for corner detection.   astronaut
skimage.data.astronaut() [source]

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.
 Examples using skimage.data.astronaut

  Flood Fill   binary_blobs
skimage.data.binary_blobs(length=512, blob_size_fraction=0.1, n_dim=2, volume_fraction=0.5, seed=None) [source]

Generate synthetic binary image with several rounded blob-like objects.  Parameters

lengthint, optional

Linear size of output image.
blob_size_fractionfloat, optional

Typical linear size of blob, as a fraction of length, should be smaller than 1.
n_dimint, optional

Number of dimensions of output image.
volume_fractionfloat, default 0.5

Fraction of image pixels covered by the blobs (where the output is 1). Should be in [0, 1].
seedint, optional

Seed to initialize the random number generator. If None, a random seed from the operating system is used.    Returns

blobsndarray of bools

Output binary image     Examples >>> from skimage import data
>>> data.binary_blobs(length=5, blob_size_fraction=0.2, seed=1)
array([[ True, False,  True,  True,  True],
       [ True,  True,  True, False,  True],
       [False,  True, False,  True,  True],
       [ True, False, False,  True,  True],
       [ True, False, False, False,  True]])
>>> blobs = data.binary_blobs(length=256, blob_size_fraction=0.1)
>>> # Finer structures
>>> blobs = data.binary_blobs(length=256, blob_size_fraction=0.05)
>>> # Blobs cover a smaller volume fraction of the image
>>> blobs = data.binary_blobs(length=256, volume_fraction=0.3)

 brain
skimage.data.brain() [source]

Subset of data from the University of North Carolina Volume Rendering Test Data Set. The full dataset is available at [1].  Returns

image(10, 256, 256) uint16 ndarray
   Notes The 3D volume consists of 10 layers from the larger volume. References
1
https://graphics.stanford.edu/data/voldata/
 Examples using skimage.data.brain

  Local Histogram Equalization

  Rank filters   brick
skimage.data.brick() [source]

Brick wall.  Returns

brick(512, 512) uint8 image

A small section of a brick wall.     Notes The original image was downloaded from CC0Textures 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.
 camera
skimage.data.camera() [source]

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).  Changed in version 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
 Examples using skimage.data.camera

  Tinting gray-scale images

  Masked Normalized Cross-Correlation

  Entropy

  GLCM Texture Features

  Multi-Otsu Thresholding

  Flood Fill

  Rank filters   cat
skimage.data.cat() [source]

Chelsea the cat. An example with texture, prominent edges in horizontal and diagonal directions, as well as features of differing scales.  Returns

chelsea(300, 451, 3) uint8 ndarray

Chelsea image.     Notes No copyright restrictions. CC0 by the photographer (Stefan van der Walt).
 cell
skimage.data.cell() [source]

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
 cells3d
skimage.data.cells3d() [source]

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).
 Examples using skimage.data.cells3d

  3D adaptive histogram equalization

  Use rolling-ball algorithm for estimating background intensity

  Explore 3D images (of cells)   checkerboard
skimage.data.checkerboard() [source]

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.
 Examples using skimage.data.checkerboard

  Flood Fill   chelsea
skimage.data.chelsea() [source]

Chelsea the cat. An example with texture, prominent edges in horizontal and diagonal directions, as well as features of differing scales.  Returns

chelsea(300, 451, 3) uint8 ndarray

Chelsea image.     Notes No copyright restrictions. CC0 by the photographer (Stefan van der Walt).
 Examples using skimage.data.chelsea

  Phase Unwrapping

  Flood Fill   clock
skimage.data.clock() [source]

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.
 coffee
skimage.data.coffee() [source]

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).  Returns

coffee(400, 600, 3) uint8 ndarray

Coffee image.     Notes No copyright restrictions. CC0 by the photographer (Rachel Michetti).
 coins
skimage.data.coins() [source]

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.  Returns

coins(303, 384) uint8 ndarray

Coins image.     Notes This image was downloaded from the Brooklyn Museum Collection. No known copyright restrictions.
 Examples using skimage.data.coins

  Finding local maxima

  Measure region properties

  Use rolling-ball algorithm for estimating background intensity   colorwheel
skimage.data.colorwheel() [source]

Color Wheel.  Returns

colorwheel(370, 371, 3) uint8 image

A colorwheel.
 download_all
skimage.data.download_all(directory=None) [source]

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.
 eagle
skimage.data.eagle() [source]

A golden eagle. Suitable for examples on segmentation, Hough transforms, and corner detection.  Returns

eagle(2019, 1826) uint8 ndarray

Eagle image.     Notes No copyright restrictions. CC0 by the photographer (Dayane Machado).
 Examples using skimage.data.eagle

  Markers for watershed transform   grass
skimage.data.grass() [source]

Grass.  Returns

grass(512, 512) uint8 image

Some grass.     Notes The original image was downloaded from DeviantArt and licensed underthe 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.
 gravel
skimage.data.gravel() [source]

Gravel  Returns

gravel(512, 512) uint8 image

Grayscale gravel sample.     Notes The original image was downloaded from CC0Textures 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.
 horse
skimage.data.horse() [source]

Black and white silhouette of a horse. This image was downloaded from openclipart No copyright restrictions. CC0 given by owner (Andreas Preuss (marauder)).  Returns

horse(328, 400) bool ndarray

Horse image.
 hubble_deep_field
skimage.data.hubble_deep_field() [source]

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.  Returns

hubble_deep_field(872, 1000, 3) uint8 ndarray

Hubble deep field image.     Notes This image was downloaded from HubbleSite. The image was captured by NASA and may be freely used in the public domain.
 human_mitosis
skimage.data.human_mitosis() [source]

Image of human cells undergoing mitosis.  Returns
 human_mitosis: (512, 512) uint8 ndimage

Data of human cells undergoing mitosis taken during the preperation 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
 Examples using skimage.data.human_mitosis

  Segment human cells (in mitosis)   immunohistochemistry
skimage.data.immunohistochemistry() [source]

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.
 kidney
skimage.data.kidney() [source]

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.  Returns

kidney(16, 512, 512, 3) uint16 ndarray

Kidney 3D multichannel image.     Notes This image was acquired by Genevieve Buckley at Monasoh Micro Imaging in 2018. License: CC0
 lbp_frontal_face_cascade_filename
skimage.data.lbp_frontal_face_cascade_filename() [source]

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
 lfw_subset
skimage.data.lfw_subset() [source]

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/
 Examples using skimage.data.lfw_subset

  Specific images   lily
skimage.data.lily() [source]

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.  Returns

lily(922, 922, 4) uint16 ndarray

Lily 2D multichannel image.     Notes This image was acquired by Genevieve Buckley at Monasoh Micro Imaging in 2018. License: CC0
 logo
skimage.data.logo() [source]

Scikit-image logo, a RGBA image.  Returns

logo(500, 500, 4) uint8 ndarray

Logo image.
 microaneurysms
skimage.data.microaneurysms() [source]

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/  Returns

microaneurysms(102, 102) uint8 ndarray

Retina image with lesions.     Notes No copyright restrictions. CC0 given by owner (Andreas Maier). 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
 moon
skimage.data.moon() [source]

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.
 Examples using skimage.data.moon

  Local Histogram Equalization   page
skimage.data.page() [source]

Scanned page. This image of printed text is useful for demonstrations requiring uneven background illumination.  Returns

page(191, 384) uint8 ndarray

Page image.
 Examples using skimage.data.page

  Use rolling-ball algorithm for estimating background intensity

  Rank filters   retina
skimage.data.retina() [source]

Human retina. This image of a retina is useful for demonstrations requiring circular images.  Returns

retina(1411, 1411, 3) uint8 ndarray

Retina image in RGB.     Notes This image was downloaded from wikimedia. 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
 rocket
skimage.data.rocket() [source]

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.  Returns

rocket(427, 640, 3) uint8 ndarray

Rocket image.     Notes This image was downloaded from SpaceX Photos. The image was captured by SpaceX and released in the public domain.
 shepp_logan_phantom
skimage.data.shepp_logan_phantom() [source]

Shepp Logan Phantom.  Returns

phantom(400, 400) float64 image

Image of the Shepp-Logan phantom in grayscale.     References
1
L. A. Shepp and B. F. Logan, “The Fourier reconstruction of a head section,” in IEEE Transactions on Nuclear Science, vol. 21, no. 3, pp. 21-43, June 1974. DOI:10.1109/TNS.1974.6499235
 skin
skimage.data.skin() [source]

Microscopy image of dermis and epidermis (skin layers). Hematoxylin and eosin stained slide at 10x of normal epidermis and dermis with a benign intradermal nevus.  Returns

skin(960, 1280, 3) RGB image of uint8
   Notes This image requires an Internet connection the first time it is called, and to have the pooch package installed, in order to fetch the image file from the scikit-image datasets repository. The source of this image is https://en.wikipedia.org/wiki/File:Normal_Epidermis_and_Dermis_with_Intradermal_Nevus_10x.JPG The image was released in the public domain by its author Kilbad.
 Examples using skimage.data.skin

  Trainable segmentation using local features and random forests   stereo_motorcycle
skimage.data.stereo_motorcycle() [source]

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/
 Examples using skimage.data.stereo_motorcycle

  Specific images

  Registration using optical flow   text
skimage.data.text() [source]

Gray-level “text” image used for corner detection.  Returns

text(172, 448) uint8 ndarray

Text image.     Notes This image was downloaded from Wikipedia <https://en.wikipedia.org/wiki/File:Corner.png>`__. No known copyright restrictions, released into the public domain.


skimage.data.astronaut() [source]

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.


skimage.data.binary_blobs(length=512, blob_size_fraction=0.1, n_dim=2, volume_fraction=0.5, seed=None) [source]

Generate synthetic binary image with several rounded blob-like objects.  Parameters

lengthint, optional

Linear size of output image.
blob_size_fractionfloat, optional

Typical linear size of blob, as a fraction of length, should be smaller than 1.
n_dimint, optional

Number of dimensions of output image.
volume_fractionfloat, default 0.5

Fraction of image pixels covered by the blobs (where the output is 1). Should be in [0, 1].
seedint, optional

Seed to initialize the random number generator. If None, a random seed from the operating system is used.    Returns

blobsndarray of bools

Output binary image     Examples >>> from skimage import data
>>> data.binary_blobs(length=5, blob_size_fraction=0.2, seed=1)
array([[ True, False,  True,  True,  True],
       [ True,  True,  True, False,  True],
       [False,  True, False,  True,  True],
       [ True, False, False,  True,  True],
       [ True, False, False, False,  True]])
>>> blobs = data.binary_blobs(length=256, blob_size_fraction=0.1)
>>> # Finer structures
>>> blobs = data.binary_blobs(length=256, blob_size_fraction=0.05)
>>> # Blobs cover a smaller volume fraction of the image
>>> blobs = data.binary_blobs(length=256, volume_fraction=0.3)


skimage.data.brain() [source]

Subset of data from the University of North Carolina Volume Rendering Test Data Set. The full dataset is available at [1].  Returns

image(10, 256, 256) uint16 ndarray
   Notes The 3D volume consists of 10 layers from the larger volume. References
1
https://graphics.stanford.edu/data/voldata/


skimage.data.brick() [source]

Brick wall.  Returns

brick(512, 512) uint8 image

A small section of a brick wall.     Notes The original image was downloaded from CC0Textures 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.


skimage.data.camera() [source]

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).  Changed in version 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


skimage.data.cat() [source]

Chelsea the cat. An example with texture, prominent edges in horizontal and diagonal directions, as well as features of differing scales.  Returns

chelsea(300, 451, 3) uint8 ndarray

Chelsea image.     Notes No copyright restrictions. CC0 by the photographer (Stefan van der Walt).


skimage.data.cell() [source]

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


skimage.data.cells3d() [source]

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).


skimage.data.checkerboard() [source]

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.


skimage.data.chelsea() [source]

Chelsea the cat. An example with texture, prominent edges in horizontal and diagonal directions, as well as features of differing scales.  Returns

chelsea(300, 451, 3) uint8 ndarray

Chelsea image.     Notes No copyright restrictions. CC0 by the photographer (Stefan van der Walt).


skimage.data.clock() [source]

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.


skimage.data.coffee() [source]

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).  Returns

coffee(400, 600, 3) uint8 ndarray

Coffee image.     Notes No copyright restrictions. CC0 by the photographer (Rachel Michetti).


skimage.data.coins() [source]

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.  Returns

coins(303, 384) uint8 ndarray

Coins image.     Notes This image was downloaded from the Brooklyn Museum Collection. No known copyright restrictions.


skimage.data.colorwheel() [source]

Color Wheel.  Returns

colorwheel(370, 371, 3) uint8 image

A colorwheel.


skimage.data.download_all(directory=None) [source]

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.


skimage.data.eagle() [source]

A golden eagle. Suitable for examples on segmentation, Hough transforms, and corner detection.  Returns

eagle(2019, 1826) uint8 ndarray

Eagle image.     Notes No copyright restrictions. CC0 by the photographer (Dayane Machado).


skimage.data.grass() [source]

Grass.  Returns

grass(512, 512) uint8 image

Some grass.     Notes The original image was downloaded from DeviantArt and licensed underthe 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.


skimage.data.gravel() [source]

Gravel  Returns

gravel(512, 512) uint8 image

Grayscale gravel sample.     Notes The original image was downloaded from CC0Textures 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.


skimage.data.horse() [source]

Black and white silhouette of a horse. This image was downloaded from openclipart No copyright restrictions. CC0 given by owner (Andreas Preuss (marauder)).  Returns

horse(328, 400) bool ndarray

Horse image.


skimage.data.hubble_deep_field() [source]

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.  Returns

hubble_deep_field(872, 1000, 3) uint8 ndarray

Hubble deep field image.     Notes This image was downloaded from HubbleSite. The image was captured by NASA and may be freely used in the public domain.


skimage.data.human_mitosis() [source]

Image of human cells undergoing mitosis.  Returns
 human_mitosis: (512, 512) uint8 ndimage

Data of human cells undergoing mitosis taken during the preperation 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


skimage.data.immunohistochemistry() [source]

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.


skimage.data.kidney() [source]

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.  Returns

kidney(16, 512, 512, 3) uint16 ndarray

Kidney 3D multichannel image.     Notes This image was acquired by Genevieve Buckley at Monasoh Micro Imaging in 2018. License: CC0


skimage.data.lbp_frontal_face_cascade_filename() [source]

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


skimage.data.lfw_subset() [source]

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/


skimage.data.lily() [source]

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.  Returns

lily(922, 922, 4) uint16 ndarray

Lily 2D multichannel image.     Notes This image was acquired by Genevieve Buckley at Monasoh Micro Imaging in 2018. License: CC0


skimage.data.logo() [source]

Scikit-image logo, a RGBA image.  Returns

logo(500, 500, 4) uint8 ndarray

Logo image.


skimage.data.microaneurysms() [source]

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/  Returns

microaneurysms(102, 102) uint8 ndarray

Retina image with lesions.     Notes No copyright restrictions. CC0 given by owner (Andreas Maier). 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


skimage.data.moon() [source]

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.


skimage.data.page() [source]

Scanned page. This image of printed text is useful for demonstrations requiring uneven background illumination.  Returns

page(191, 384) uint8 ndarray

Page image.


skimage.data.retina() [source]

Human retina. This image of a retina is useful for demonstrations requiring circular images.  Returns

retina(1411, 1411, 3) uint8 ndarray

Retina image in RGB.     Notes This image was downloaded from wikimedia. 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


skimage.data.rocket() [source]

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.  Returns

rocket(427, 640, 3) uint8 ndarray

Rocket image.     Notes This image was downloaded from SpaceX Photos. The image was captured by SpaceX and released in the public domain.


skimage.data.shepp_logan_phantom() [source]

Shepp Logan Phantom.  Returns

phantom(400, 400) float64 image

Image of the Shepp-Logan phantom in grayscale.     References
1
L. A. Shepp and B. F. Logan, “The Fourier reconstruction of a head section,” in IEEE Transactions on Nuclear Science, vol. 21, no. 3, pp. 21-43, June 1974. DOI:10.1109/TNS.1974.6499235


skimage.data.skin() [source]

Microscopy image of dermis and epidermis (skin layers). Hematoxylin and eosin stained slide at 10x of normal epidermis and dermis with a benign intradermal nevus.  Returns

skin(960, 1280, 3) RGB image of uint8
   Notes This image requires an Internet connection the first time it is called, and to have the pooch package installed, in order to fetch the image file from the scikit-image datasets repository. The source of this image is https://en.wikipedia.org/wiki/File:Normal_Epidermis_and_Dermis_with_Intradermal_Nevus_10x.JPG The image was released in the public domain by its author Kilbad.


skimage.data.stereo_motorcycle() [source]

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/


skimage.data.text() [source]

Gray-level “text” image used for corner detection.  Returns

text(172, 448) uint8 ndarray

Text image.     Notes This image was downloaded from Wikipedia <https://en.wikipedia.org/wiki/File:Corner.png>`__. No known copyright restrictions, released into the public domain.


Module: draw
skimage.draw.bezier_curve(r0, c0, r1, c1, …) Generate Bezier curve coordinates.
skimage.draw.circle(r, c, radius[, shape]) Generate coordinates of pixels within circle.
skimage.draw.circle_perimeter(r, c, radius) Generate circle perimeter coordinates.
skimage.draw.circle_perimeter_aa(r, c, radius) Generate anti-aliased circle perimeter coordinates.
skimage.draw.disk(center, radius, *[, shape]) Generate coordinates of pixels within circle.
skimage.draw.ellipse(r, c, r_radius, c_radius) Generate coordinates of pixels within ellipse.
skimage.draw.ellipse_perimeter(r, c, …[, …]) Generate ellipse perimeter coordinates.
skimage.draw.ellipsoid(a, b, c[, spacing, …]) Generates ellipsoid with semimajor axes aligned with grid dimensions on grid with specified spacing.
skimage.draw.ellipsoid_stats(a, b, c) Calculates analytical surface area and volume for ellipsoid with semimajor axes aligned with grid dimensions of specified spacing.
skimage.draw.line(r0, c0, r1, c1) Generate line pixel coordinates.
skimage.draw.line_aa(r0, c0, r1, c1) Generate anti-aliased line pixel coordinates.
skimage.draw.line_nd(start, stop, *[, …]) Draw a single-pixel thick line in n dimensions.
skimage.draw.polygon(r, c[, shape]) Generate coordinates of pixels within polygon.
skimage.draw.polygon2mask(image_shape, polygon) Compute a mask from polygon.
skimage.draw.polygon_perimeter(r, c[, …]) Generate polygon perimeter coordinates.
skimage.draw.random_shapes(image_shape, …) Generate an image with random shapes, labeled with bounding boxes.
skimage.draw.rectangle(start[, end, extent, …]) Generate coordinates of pixels within a rectangle.
skimage.draw.rectangle_perimeter(start[, …]) Generate coordinates of pixels that are exactly around a rectangle.
skimage.draw.set_color(image, coords, color) Set pixel color in the image at the given coordinates.   bezier_curve
skimage.draw.bezier_curve(r0, c0, r1, c1, r2, c2, weight, shape=None) [source]

Generate Bezier curve coordinates.  Parameters

r0, c0int

Coordinates of the first control point.
r1, c1int

Coordinates of the middle control point.
r2, c2int

Coordinates of the last control point.
weightdouble

Middle control point weight, it describes the line tension.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for curves that exceed the image size. If None, the full extent of the curve is used.    Returns

rr, cc(N,) ndarray of int

Indices of pixels that belong to the Bezier curve. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Notes The algorithm is the rational quadratic algorithm presented in reference [1]. References
1
A Rasterizing Algorithm for Drawing Curves, A. Zingl, 2012 http://members.chello.at/easyfilter/Bresenham.pdf   Examples >>> import numpy as np
>>> from skimage.draw import bezier_curve
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = bezier_curve(1, 5, 5, -2, 8, 8, 2)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 1, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

 circle
skimage.draw.circle(r, c, radius, shape=None) [source]

Generate coordinates of pixels within circle.  Parameters

r, cdouble

Center coordinate of disk.
radiusdouble

Radius of disk.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for disks that exceed the image size. If None, the full extent of the disk is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, ccndarray of int

Pixel coordinates of disk. May be used to directly index into an array, e.g. img[rr, cc] = 1.    Warns
 Deprecated:

 New in version 0.17: This function is deprecated and will be removed in scikit-image 0.19. Please use the function named disk instead.
 circle_perimeter
skimage.draw.circle_perimeter(r, c, radius, method='bresenham', shape=None) [source]

Generate circle perimeter coordinates.  Parameters

r, cint

Centre coordinate of circle.
radiusint

Radius of circle.
method{‘bresenham’, ‘andres’}, optional

bresenham : Bresenham method (default) andres : Andres method
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for circles that exceed the image size. If None, the full extent of the circle is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, cc(N,) ndarray of int

Bresenham and Andres’ method: Indices of pixels that belong to the circle perimeter. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Notes Andres method presents the advantage that concentric circles create a disc whereas Bresenham can make holes. There is also less distortions when Andres circles are rotated. Bresenham method is also known as midpoint circle algorithm. Anti-aliased circle generator is available with circle_perimeter_aa. References
1
J.E. Bresenham, “Algorithm for computer control of a digital plotter”, IBM Systems journal, 4 (1965) 25-30.
2
E. Andres, “Discrete circles, rings and spheres”, Computers & Graphics, 18 (1994) 695-706.   Examples >>> from skimage.draw import circle_perimeter
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = circle_perimeter(4, 4, 3)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

 circle_perimeter_aa
skimage.draw.circle_perimeter_aa(r, c, radius, shape=None) [source]

Generate anti-aliased circle perimeter coordinates.  Parameters

r, cint

Centre coordinate of circle.
radiusint

Radius of circle.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for circles that exceed the image size. If None, the full extent of the circle is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, cc, val(N,) ndarray (int, int, float)

Indices of pixels (rr, cc) and intensity values (val). img[rr, cc] = val.     Notes Wu’s method draws anti-aliased circle. This implementation doesn’t use lookup table optimization. Use the function draw.set_color to apply circle_perimeter_aa results to color images. References
1
X. Wu, “An efficient antialiasing technique”, In ACM SIGGRAPH Computer Graphics, 25 (1991) 143-152.   Examples >>> from skimage.draw import circle_perimeter_aa
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc, val = circle_perimeter_aa(4, 4, 3)
>>> img[rr, cc] = val * 255
>>> img
array([[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,  60, 211, 255, 211,  60,   0,   0,   0],
       [  0,  60, 194,  43,   0,  43, 194,  60,   0,   0],
       [  0, 211,  43,   0,   0,   0,  43, 211,   0,   0],
       [  0, 255,   0,   0,   0,   0,   0, 255,   0,   0],
       [  0, 211,  43,   0,   0,   0,  43, 211,   0,   0],
       [  0,  60, 194,  43,   0,  43, 194,  60,   0,   0],
       [  0,   0,  60, 211, 255, 211,  60,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0]], dtype=uint8)
 >>> from skimage import data, draw
>>> image = data.chelsea()
>>> rr, cc, val = draw.circle_perimeter_aa(r=100, c=100, radius=75)
>>> draw.set_color(image, (rr, cc), [1, 0, 0], alpha=val)

 disk
skimage.draw.disk(center, radius, *, shape=None) [source]

Generate coordinates of pixels within circle.  Parameters

centertuple

Center coordinate of disk.
radiusdouble

Radius of disk.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for disks that exceed the image size. If None, the full extent of the disk is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, ccndarray of int

Pixel coordinates of disk. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Examples >>> from skimage.draw import disk
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = disk((4, 4), 5)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 1, 1, 1, 1, 1, 1, 1, 0, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 1, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

 ellipse
skimage.draw.ellipse(r, c, r_radius, c_radius, shape=None, rotation=0.0) [source]

Generate coordinates of pixels within ellipse.  Parameters

r, cdouble

Centre coordinate of ellipse.
r_radius, c_radiusdouble

Minor and major semi-axes. (r/r_radius)**2 + (c/c_radius)**2 = 1.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for ellipses which exceed the image size. By default the full extent of the ellipse are used. Must be at least length 2. Only the first two values are used to determine the extent.
rotationfloat, optional (default 0.)

Set the ellipse rotation (rotation) in range (-PI, PI) in contra clock wise direction, so PI/2 degree means swap ellipse axis    Returns

rr, ccndarray of int

Pixel coordinates of ellipse. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Notes The ellipse equation: ((x * cos(alpha) + y * sin(alpha)) / x_radius) ** 2 +
((x * sin(alpha) - y * cos(alpha)) / y_radius) ** 2 = 1
 Note that the positions of ellipse without specified shape can have also, negative values, as this is correct on the plane. On the other hand using these ellipse positions for an image afterwards may lead to appearing on the other side of image, because image[-1, -1] = image[end-1, end-1] >>> rr, cc = ellipse(1, 2, 3, 6)
>>> img = np.zeros((6, 12), dtype=np.uint8)
>>> img[rr, cc] = 1
>>> img
array([[1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1],
       [1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1],
       [1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1],
       [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1]], dtype=uint8)
 Examples >>> from skimage.draw import ellipse
>>> img = np.zeros((10, 12), dtype=np.uint8)
>>> rr, cc = ellipse(5, 6, 3, 5, rotation=np.deg2rad(30))
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0],
       [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

 Examples using skimage.draw.ellipse

  Masked Normalized Cross-Correlation

  Measure region properties   ellipse_perimeter
skimage.draw.ellipse_perimeter(r, c, r_radius, c_radius, orientation=0, shape=None) [source]

Generate ellipse perimeter coordinates.  Parameters

r, cint

Centre coordinate of ellipse.
r_radius, c_radiusint

Minor and major semi-axes. (r/r_radius)**2 + (c/c_radius)**2 = 1.
orientationdouble, optional

Major axis orientation in clockwise direction as radians.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for ellipses that exceed the image size. If None, the full extent of the ellipse is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, cc(N,) ndarray of int

Indices of pixels that belong to the ellipse perimeter. May be used to directly index into an array, e.g. img[rr, cc] = 1.     References
1
A Rasterizing Algorithm for Drawing Curves, A. Zingl, 2012 http://members.chello.at/easyfilter/Bresenham.pdf   Examples >>> from skimage.draw import ellipse_perimeter
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = ellipse_perimeter(5, 5, 3, 4)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
       [0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
 Note that the positions of ellipse without specified shape can have also, negative values, as this is correct on the plane. On the other hand using these ellipse positions for an image afterwards may lead to appearing on the other side of image, because image[-1, -1] = image[end-1, end-1] >>> rr, cc = ellipse_perimeter(2, 3, 4, 5)
>>> img = np.zeros((9, 12), dtype=np.uint8)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],
       [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
       [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]], dtype=uint8)

 ellipsoid
skimage.draw.ellipsoid(a, b, c, spacing=(1.0, 1.0, 1.0), levelset=False) [source]

Generates ellipsoid with semimajor axes aligned with grid dimensions on grid with specified spacing.  Parameters

afloat

Length of semimajor axis aligned with x-axis.
bfloat

Length of semimajor axis aligned with y-axis.
cfloat

Length of semimajor axis aligned with z-axis.
spacingtuple of floats, length 3

Spacing in (x, y, z) spatial dimensions.
levelsetbool

If True, returns the level set for this ellipsoid (signed level set about zero, with positive denoting interior) as np.float64. False returns a binarized version of said level set.    Returns

ellip(N, M, P) array

Ellipsoid centered in a correctly sized array for given spacing. Boolean dtype unless levelset=True, in which case a float array is returned with the level set above 0.0 representing the ellipsoid.
 ellipsoid_stats
skimage.draw.ellipsoid_stats(a, b, c) [source]

Calculates analytical surface area and volume for ellipsoid with semimajor axes aligned with grid dimensions of specified spacing.  Parameters

afloat

Length of semimajor axis aligned with x-axis.
bfloat

Length of semimajor axis aligned with y-axis.
cfloat

Length of semimajor axis aligned with z-axis.    Returns

volfloat

Calculated volume of ellipsoid.
surffloat

Calculated surface area of ellipsoid.
 line
skimage.draw.line(r0, c0, r1, c1) [source]

Generate line pixel coordinates.  Parameters

r0, c0int

Starting position (row, column).
r1, c1int

End position (row, column).    Returns

rr, cc(N,) ndarray of int

Indices of pixels that belong to the line. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Notes Anti-aliased line generator is available with line_aa. Examples >>> from skimage.draw import line
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = line(1, 1, 8, 8)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

 line_aa
skimage.draw.line_aa(r0, c0, r1, c1) [source]

Generate anti-aliased line pixel coordinates.  Parameters

r0, c0int

Starting position (row, column).
r1, c1int

End position (row, column).    Returns

rr, cc, val(N,) ndarray (int, int, float)

Indices of pixels (rr, cc) and intensity values (val). img[rr, cc] = val.     References
1
A Rasterizing Algorithm for Drawing Curves, A. Zingl, 2012 http://members.chello.at/easyfilter/Bresenham.pdf   Examples >>> from skimage.draw import line_aa
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc, val = line_aa(1, 1, 8, 8)
>>> img[rr, cc] = val * 255
>>> img
array([[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0, 255,  74,   0,   0,   0,   0,   0,   0,   0],
       [  0,  74, 255,  74,   0,   0,   0,   0,   0,   0],
       [  0,   0,  74, 255,  74,   0,   0,   0,   0,   0],
       [  0,   0,   0,  74, 255,  74,   0,   0,   0,   0],
       [  0,   0,   0,   0,  74, 255,  74,   0,   0,   0],
       [  0,   0,   0,   0,   0,  74, 255,  74,   0,   0],
       [  0,   0,   0,   0,   0,   0,  74, 255,  74,   0],
       [  0,   0,   0,   0,   0,   0,   0,  74, 255,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0]], dtype=uint8)

 line_nd
skimage.draw.line_nd(start, stop, *, endpoint=False, integer=True) [source]

Draw a single-pixel thick line in n dimensions. The line produced will be ndim-connected. That is, two subsequent pixels in the line will be either direct or diagonal neighbours in n dimensions.  Parameters

startarray-like, shape (N,)

The start coordinates of the line.
stoparray-like, shape (N,)

The end coordinates of the line.
endpointbool, optional

Whether to include the endpoint in the returned line. Defaults to False, which allows for easy drawing of multi-point paths.
integerbool, optional

Whether to round the coordinates to integer. If True (default), the returned coordinates can be used to directly index into an array. False could be used for e.g. vector drawing.    Returns

coordstuple of arrays

The coordinates of points on the line.     Examples >>> lin = line_nd((1, 1), (5, 2.5), endpoint=False)
>>> lin
(array([1, 2, 3, 4]), array([1, 1, 2, 2]))
>>> im = np.zeros((6, 5), dtype=int)
>>> im[lin] = 1
>>> im
array([[0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0],
       [0, 1, 0, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0]])
>>> line_nd([2, 1, 1], [5, 5, 2.5], endpoint=True)
(array([2, 3, 4, 4, 5]), array([1, 2, 3, 4, 5]), array([1, 1, 2, 2, 2]))

 polygon
skimage.draw.polygon(r, c, shape=None) [source]

Generate coordinates of pixels within polygon.  Parameters

r(N,) ndarray

Row coordinates of vertices of polygon.
c(N,) ndarray

Column coordinates of vertices of polygon.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for polygons that exceed the image size. If None, the full extent of the polygon is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, ccndarray of int

Pixel coordinates of polygon. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Examples >>> from skimage.draw import polygon
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> r = np.array([1, 2, 8])
>>> c = np.array([1, 7, 4])
>>> rr, cc = polygon(r, c)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

 polygon2mask
skimage.draw.polygon2mask(image_shape, polygon) [source]

Compute a mask from polygon.  Parameters

image_shapetuple of size 2.

The shape of the mask.
polygonarray_like.

The polygon coordinates of shape (N, 2) where N is the number of points.    Returns

mask2-D ndarray of type ‘bool’.

The mask that corresponds to the input polygon.     Notes This function does not do any border checking, so that all the vertices need to be within the given shape. Examples >>> image_shape = (128, 128)
>>> polygon = np.array([[60, 100], [100, 40], [40, 40]])
>>> mask = polygon2mask(image_shape, polygon)
>>> mask.shape
(128, 128)

 polygon_perimeter
skimage.draw.polygon_perimeter(r, c, shape=None, clip=False) [source]

Generate polygon perimeter coordinates.  Parameters

r(N,) ndarray

Row coordinates of vertices of polygon.
c(N,) ndarray

Column coordinates of vertices of polygon.
shapetuple, optional

Image shape which is used to determine maximum extents of output pixel coordinates. This is useful for polygons that exceed the image size. If None, the full extents of the polygon is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.
clipbool, optional

Whether to clip the polygon to the provided shape. If this is set to True, the drawn figure will always be a closed polygon with all edges visible.    Returns

rr, ccndarray of int

Pixel coordinates of polygon. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Examples >>> from skimage.draw import polygon_perimeter
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = polygon_perimeter([5, -1, 5, 10],
...                            [-1, 5, 11, 5],
...                            shape=img.shape, clip=True)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0, 1, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
       [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
       [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
       [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
       [0, 1, 1, 0, 0, 0, 0, 0, 0, 1],
       [0, 0, 0, 1, 0, 0, 0, 1, 1, 0],
       [0, 0, 0, 0, 1, 1, 1, 0, 0, 0]], dtype=uint8)

 random_shapes
skimage.draw.random_shapes(image_shape, max_shapes, min_shapes=1, min_size=2, max_size=None, multichannel=True, num_channels=3, shape=None, intensity_range=None, allow_overlap=False, num_trials=100, random_seed=None) [source]

Generate an image with random shapes, labeled with bounding boxes. The image is populated with random shapes with random sizes, random locations, and random colors, with or without overlap. Shapes have random (row, col) starting coordinates and random sizes bounded by min_size and max_size. It can occur that a randomly generated shape will not fit the image at all. In that case, the algorithm will try again with new starting coordinates a certain number of times. However, it also means that some shapes may be skipped altogether. In that case, this function will generate fewer shapes than requested.  Parameters

image_shapetuple

The number of rows and columns of the image to generate.
max_shapesint

The maximum number of shapes to (attempt to) fit into the shape.
min_shapesint, optional

The minimum number of shapes to (attempt to) fit into the shape.
min_sizeint, optional

The minimum dimension of each shape to fit into the image.
max_sizeint, optional

The maximum dimension of each shape to fit into the image.
multichannelbool, optional

If True, the generated image has num_channels color channels, otherwise generates grayscale image.
num_channelsint, optional

Number of channels in the generated image. If 1, generate monochrome images, else color images with multiple channels. Ignored if multichannel is set to False.
shape{rectangle, circle, triangle, ellipse, None} str, optional

The name of the shape to generate or None to pick random ones.
intensity_range{tuple of tuples of uint8, tuple of uint8}, optional

The range of values to sample pixel values from. For grayscale images the format is (min, max). For multichannel - ((min, max),) if the ranges are equal across the channels, and ((min_0, max_0), … (min_N, max_N)) if they differ. As the function supports generation of uint8 arrays only, the maximum range is (0, 255). If None, set to (0, 254) for each channel reserving color of intensity = 255 for background.
allow_overlapbool, optional

If True, allow shapes to overlap.
num_trialsint, optional

How often to attempt to fit a shape into the image before skipping it.
random_seedint, optional

Seed to initialize the random number generator. If None, a random seed from the operating system is used.    Returns

imageuint8 array

An image with the fitted shapes.
labelslist

A list of labels, one per shape in the image. Each label is a (category, ((r0, r1), (c0, c1))) tuple specifying the category and bounding box coordinates of the shape.     Examples >>> import skimage.draw
>>> image, labels = skimage.draw.random_shapes((32, 32), max_shapes=3)
>>> image
array([
   [[255, 255, 255],
    [255, 255, 255],
    [255, 255, 255],
    ...,
    [255, 255, 255],
    [255, 255, 255],
    [255, 255, 255]]], dtype=uint8)
>>> labels
[('circle', ((22, 18), (25, 21))),
 ('triangle', ((5, 6), (13, 13)))]

 rectangle
skimage.draw.rectangle(start, end=None, extent=None, shape=None) [source]

Generate coordinates of pixels within a rectangle.  Parameters

starttuple

Origin point of the rectangle, e.g., ([plane,] row, column).
endtuple

End point of the rectangle ([plane,] row, column). For a 2D matrix, the slice defined by the rectangle is [start:(end+1)]. Either end or extent must be specified.
extenttuple

The extent (size) of the drawn rectangle. E.g., ([num_planes,] num_rows, num_cols). Either end or extent must be specified. A negative extent is valid, and will result in a rectangle going along the opposite direction. If extent is negative, the start point is not included.
shapetuple, optional

Image shape used to determine the maximum bounds of the output coordinates. This is useful for clipping rectangles that exceed the image size. By default, no clipping is done.    Returns

coordsarray of int, shape (Ndim, Npoints)

The coordinates of all pixels in the rectangle.     Notes This function can be applied to N-dimensional images, by passing start and end or extent as tuples of length N. Examples >>> import numpy as np
>>> from skimage.draw import rectangle
>>> img = np.zeros((5, 5), dtype=np.uint8)
>>> start = (1, 1)
>>> extent = (3, 3)
>>> rr, cc = rectangle(start, extent=extent, shape=img.shape)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)
 >>> img = np.zeros((5, 5), dtype=np.uint8)
>>> start = (0, 1)
>>> end = (3, 3)
>>> rr, cc = rectangle(start, end=end, shape=img.shape)
>>> img[rr, cc] = 1
>>> img
array([[0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)
 >>> import numpy as np
>>> from skimage.draw import rectangle
>>> img = np.zeros((6, 6), dtype=np.uint8)
>>> start = (3, 3)
>>>
>>> rr, cc = rectangle(start, extent=(2, 2))
>>> img[rr, cc] = 1
>>> rr, cc = rectangle(start, extent=(-2, 2))
>>> img[rr, cc] = 2
>>> rr, cc = rectangle(start, extent=(-2, -2))
>>> img[rr, cc] = 3
>>> rr, cc = rectangle(start, extent=(2, -2))
>>> img[rr, cc] = 4
>>> print(img)
[[0 0 0 0 0 0]
 [0 3 3 2 2 0]
 [0 3 3 2 2 0]
 [0 4 4 1 1 0]
 [0 4 4 1 1 0]
 [0 0 0 0 0 0]]

 rectangle_perimeter
skimage.draw.rectangle_perimeter(start, end=None, extent=None, shape=None, clip=False) [source]

Generate coordinates of pixels that are exactly around a rectangle.  Parameters

starttuple

Origin point of the inner rectangle, e.g., (row, column).
endtuple

End point of the inner rectangle (row, column). For a 2D matrix, the slice defined by inner the rectangle is [start:(end+1)]. Either end or extent must be specified.
extenttuple

The extent (size) of the inner rectangle. E.g., (num_rows, num_cols). Either end or extent must be specified. Negative extents are permitted. See rectangle to better understand how they behave.
shapetuple, optional

Image shape used to determine the maximum bounds of the output coordinates. This is useful for clipping perimeters that exceed the image size. By default, no clipping is done. Must be at least length 2. Only the first two values are used to determine the extent of the input image.
clipbool, optional

Whether to clip the perimeter to the provided shape. If this is set to True, the drawn figure will always be a closed polygon with all edges visible.    Returns

coordsarray of int, shape (2, Npoints)

The coordinates of all pixels in the rectangle.     Examples >>> import numpy as np
>>> from skimage.draw import rectangle_perimeter
>>> img = np.zeros((5, 6), dtype=np.uint8)
>>> start = (2, 3)
>>> end = (3, 4)
>>> rr, cc = rectangle_perimeter(start, end=end, shape=img.shape)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0],
       [0, 0, 1, 1, 1, 1],
       [0, 0, 1, 0, 0, 1],
       [0, 0, 1, 0, 0, 1],
       [0, 0, 1, 1, 1, 1]], dtype=uint8)
 >>> img = np.zeros((5, 5), dtype=np.uint8)
>>> r, c = rectangle_perimeter(start, (10, 10), shape=img.shape, clip=True)
>>> img[r, c] = 1
>>> img
array([[0, 0, 0, 0, 0],
       [0, 0, 1, 1, 1],
       [0, 0, 1, 0, 1],
       [0, 0, 1, 0, 1],
       [0, 0, 1, 1, 1]], dtype=uint8)

 set_color
skimage.draw.set_color(image, coords, color, alpha=1) [source]

Set pixel color in the image at the given coordinates. Note that this function modifies the color of the image in-place. Coordinates that exceed the shape of the image will be ignored.  Parameters

image(M, N, D) ndarray

Image
coordstuple of ((P,) ndarray, (P,) ndarray)

Row and column coordinates of pixels to be colored.
color(D,) ndarray

Color to be assigned to coordinates in the image.
alphascalar or (N,) ndarray

Alpha values used to blend color with image. 0 is transparent, 1 is opaque.     Examples >>> from skimage.draw import line, set_color
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = line(1, 1, 20, 20)
>>> set_color(img, (rr, cc), 1)
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]], dtype=uint8)


skimage.draw.bezier_curve(r0, c0, r1, c1, r2, c2, weight, shape=None) [source]

Generate Bezier curve coordinates.  Parameters

r0, c0int

Coordinates of the first control point.
r1, c1int

Coordinates of the middle control point.
r2, c2int

Coordinates of the last control point.
weightdouble

Middle control point weight, it describes the line tension.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for curves that exceed the image size. If None, the full extent of the curve is used.    Returns

rr, cc(N,) ndarray of int

Indices of pixels that belong to the Bezier curve. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Notes The algorithm is the rational quadratic algorithm presented in reference [1]. References
1
A Rasterizing Algorithm for Drawing Curves, A. Zingl, 2012 http://members.chello.at/easyfilter/Bresenham.pdf   Examples >>> import numpy as np
>>> from skimage.draw import bezier_curve
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = bezier_curve(1, 5, 5, -2, 8, 8, 2)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 1, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)


skimage.draw.circle(r, c, radius, shape=None) [source]

Generate coordinates of pixels within circle.  Parameters

r, cdouble

Center coordinate of disk.
radiusdouble

Radius of disk.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for disks that exceed the image size. If None, the full extent of the disk is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, ccndarray of int

Pixel coordinates of disk. May be used to directly index into an array, e.g. img[rr, cc] = 1.    Warns
 Deprecated:

 New in version 0.17: This function is deprecated and will be removed in scikit-image 0.19. Please use the function named disk instead.


skimage.draw.circle_perimeter(r, c, radius, method='bresenham', shape=None) [source]

Generate circle perimeter coordinates.  Parameters

r, cint

Centre coordinate of circle.
radiusint

Radius of circle.
method{‘bresenham’, ‘andres’}, optional

bresenham : Bresenham method (default) andres : Andres method
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for circles that exceed the image size. If None, the full extent of the circle is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, cc(N,) ndarray of int

Bresenham and Andres’ method: Indices of pixels that belong to the circle perimeter. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Notes Andres method presents the advantage that concentric circles create a disc whereas Bresenham can make holes. There is also less distortions when Andres circles are rotated. Bresenham method is also known as midpoint circle algorithm. Anti-aliased circle generator is available with circle_perimeter_aa. References
1
J.E. Bresenham, “Algorithm for computer control of a digital plotter”, IBM Systems journal, 4 (1965) 25-30.
2
E. Andres, “Discrete circles, rings and spheres”, Computers & Graphics, 18 (1994) 695-706.   Examples >>> from skimage.draw import circle_perimeter
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = circle_perimeter(4, 4, 3)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)


skimage.draw.circle_perimeter_aa(r, c, radius, shape=None) [source]

Generate anti-aliased circle perimeter coordinates.  Parameters

r, cint

Centre coordinate of circle.
radiusint

Radius of circle.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for circles that exceed the image size. If None, the full extent of the circle is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, cc, val(N,) ndarray (int, int, float)

Indices of pixels (rr, cc) and intensity values (val). img[rr, cc] = val.     Notes Wu’s method draws anti-aliased circle. This implementation doesn’t use lookup table optimization. Use the function draw.set_color to apply circle_perimeter_aa results to color images. References
1
X. Wu, “An efficient antialiasing technique”, In ACM SIGGRAPH Computer Graphics, 25 (1991) 143-152.   Examples >>> from skimage.draw import circle_perimeter_aa
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc, val = circle_perimeter_aa(4, 4, 3)
>>> img[rr, cc] = val * 255
>>> img
array([[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,  60, 211, 255, 211,  60,   0,   0,   0],
       [  0,  60, 194,  43,   0,  43, 194,  60,   0,   0],
       [  0, 211,  43,   0,   0,   0,  43, 211,   0,   0],
       [  0, 255,   0,   0,   0,   0,   0, 255,   0,   0],
       [  0, 211,  43,   0,   0,   0,  43, 211,   0,   0],
       [  0,  60, 194,  43,   0,  43, 194,  60,   0,   0],
       [  0,   0,  60, 211, 255, 211,  60,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0]], dtype=uint8)
 >>> from skimage import data, draw
>>> image = data.chelsea()
>>> rr, cc, val = draw.circle_perimeter_aa(r=100, c=100, radius=75)
>>> draw.set_color(image, (rr, cc), [1, 0, 0], alpha=val)


skimage.draw.disk(center, radius, *, shape=None) [source]

Generate coordinates of pixels within circle.  Parameters

centertuple

Center coordinate of disk.
radiusdouble

Radius of disk.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for disks that exceed the image size. If None, the full extent of the disk is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, ccndarray of int

Pixel coordinates of disk. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Examples >>> from skimage.draw import disk
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = disk((4, 4), 5)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 1, 1, 1, 1, 1, 1, 1, 0, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 1, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)


skimage.draw.ellipse(r, c, r_radius, c_radius, shape=None, rotation=0.0) [source]

Generate coordinates of pixels within ellipse.  Parameters

r, cdouble

Centre coordinate of ellipse.
r_radius, c_radiusdouble

Minor and major semi-axes. (r/r_radius)**2 + (c/c_radius)**2 = 1.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for ellipses which exceed the image size. By default the full extent of the ellipse are used. Must be at least length 2. Only the first two values are used to determine the extent.
rotationfloat, optional (default 0.)

Set the ellipse rotation (rotation) in range (-PI, PI) in contra clock wise direction, so PI/2 degree means swap ellipse axis    Returns

rr, ccndarray of int

Pixel coordinates of ellipse. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Notes The ellipse equation: ((x * cos(alpha) + y * sin(alpha)) / x_radius) ** 2 +
((x * sin(alpha) - y * cos(alpha)) / y_radius) ** 2 = 1
 Note that the positions of ellipse without specified shape can have also, negative values, as this is correct on the plane. On the other hand using these ellipse positions for an image afterwards may lead to appearing on the other side of image, because image[-1, -1] = image[end-1, end-1] >>> rr, cc = ellipse(1, 2, 3, 6)
>>> img = np.zeros((6, 12), dtype=np.uint8)
>>> img[rr, cc] = 1
>>> img
array([[1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1],
       [1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1],
       [1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1],
       [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1]], dtype=uint8)
 Examples >>> from skimage.draw import ellipse
>>> img = np.zeros((10, 12), dtype=np.uint8)
>>> rr, cc = ellipse(5, 6, 3, 5, rotation=np.deg2rad(30))
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0],
       [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)


skimage.draw.ellipse_perimeter(r, c, r_radius, c_radius, orientation=0, shape=None) [source]

Generate ellipse perimeter coordinates.  Parameters

r, cint

Centre coordinate of ellipse.
r_radius, c_radiusint

Minor and major semi-axes. (r/r_radius)**2 + (c/c_radius)**2 = 1.
orientationdouble, optional

Major axis orientation in clockwise direction as radians.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for ellipses that exceed the image size. If None, the full extent of the ellipse is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, cc(N,) ndarray of int

Indices of pixels that belong to the ellipse perimeter. May be used to directly index into an array, e.g. img[rr, cc] = 1.     References
1
A Rasterizing Algorithm for Drawing Curves, A. Zingl, 2012 http://members.chello.at/easyfilter/Bresenham.pdf   Examples >>> from skimage.draw import ellipse_perimeter
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = ellipse_perimeter(5, 5, 3, 4)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
       [0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
 Note that the positions of ellipse without specified shape can have also, negative values, as this is correct on the plane. On the other hand using these ellipse positions for an image afterwards may lead to appearing on the other side of image, because image[-1, -1] = image[end-1, end-1] >>> rr, cc = ellipse_perimeter(2, 3, 4, 5)
>>> img = np.zeros((9, 12), dtype=np.uint8)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],
       [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
       [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]], dtype=uint8)


skimage.draw.ellipsoid(a, b, c, spacing=(1.0, 1.0, 1.0), levelset=False) [source]

Generates ellipsoid with semimajor axes aligned with grid dimensions on grid with specified spacing.  Parameters

afloat

Length of semimajor axis aligned with x-axis.
bfloat

Length of semimajor axis aligned with y-axis.
cfloat

Length of semimajor axis aligned with z-axis.
spacingtuple of floats, length 3

Spacing in (x, y, z) spatial dimensions.
levelsetbool

If True, returns the level set for this ellipsoid (signed level set about zero, with positive denoting interior) as np.float64. False returns a binarized version of said level set.    Returns

ellip(N, M, P) array

Ellipsoid centered in a correctly sized array for given spacing. Boolean dtype unless levelset=True, in which case a float array is returned with the level set above 0.0 representing the ellipsoid.


skimage.draw.ellipsoid_stats(a, b, c) [source]

Calculates analytical surface area and volume for ellipsoid with semimajor axes aligned with grid dimensions of specified spacing.  Parameters

afloat

Length of semimajor axis aligned with x-axis.
bfloat

Length of semimajor axis aligned with y-axis.
cfloat

Length of semimajor axis aligned with z-axis.    Returns

volfloat

Calculated volume of ellipsoid.
surffloat

Calculated surface area of ellipsoid.


skimage.draw.line(r0, c0, r1, c1) [source]

Generate line pixel coordinates.  Parameters

r0, c0int

Starting position (row, column).
r1, c1int

End position (row, column).    Returns

rr, cc(N,) ndarray of int

Indices of pixels that belong to the line. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Notes Anti-aliased line generator is available with line_aa. Examples >>> from skimage.draw import line
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = line(1, 1, 8, 8)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)


skimage.draw.line_aa(r0, c0, r1, c1) [source]

Generate anti-aliased line pixel coordinates.  Parameters

r0, c0int

Starting position (row, column).
r1, c1int

End position (row, column).    Returns

rr, cc, val(N,) ndarray (int, int, float)

Indices of pixels (rr, cc) and intensity values (val). img[rr, cc] = val.     References
1
A Rasterizing Algorithm for Drawing Curves, A. Zingl, 2012 http://members.chello.at/easyfilter/Bresenham.pdf   Examples >>> from skimage.draw import line_aa
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc, val = line_aa(1, 1, 8, 8)
>>> img[rr, cc] = val * 255
>>> img
array([[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0, 255,  74,   0,   0,   0,   0,   0,   0,   0],
       [  0,  74, 255,  74,   0,   0,   0,   0,   0,   0],
       [  0,   0,  74, 255,  74,   0,   0,   0,   0,   0],
       [  0,   0,   0,  74, 255,  74,   0,   0,   0,   0],
       [  0,   0,   0,   0,  74, 255,  74,   0,   0,   0],
       [  0,   0,   0,   0,   0,  74, 255,  74,   0,   0],
       [  0,   0,   0,   0,   0,   0,  74, 255,  74,   0],
       [  0,   0,   0,   0,   0,   0,   0,  74, 255,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0]], dtype=uint8)


skimage.draw.line_nd(start, stop, *, endpoint=False, integer=True) [source]

Draw a single-pixel thick line in n dimensions. The line produced will be ndim-connected. That is, two subsequent pixels in the line will be either direct or diagonal neighbours in n dimensions.  Parameters

startarray-like, shape (N,)

The start coordinates of the line.
stoparray-like, shape (N,)

The end coordinates of the line.
endpointbool, optional

Whether to include the endpoint in the returned line. Defaults to False, which allows for easy drawing of multi-point paths.
integerbool, optional

Whether to round the coordinates to integer. If True (default), the returned coordinates can be used to directly index into an array. False could be used for e.g. vector drawing.    Returns

coordstuple of arrays

The coordinates of points on the line.     Examples >>> lin = line_nd((1, 1), (5, 2.5), endpoint=False)
>>> lin
(array([1, 2, 3, 4]), array([1, 1, 2, 2]))
>>> im = np.zeros((6, 5), dtype=int)
>>> im[lin] = 1
>>> im
array([[0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0],
       [0, 1, 0, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0]])
>>> line_nd([2, 1, 1], [5, 5, 2.5], endpoint=True)
(array([2, 3, 4, 4, 5]), array([1, 2, 3, 4, 5]), array([1, 1, 2, 2, 2]))


skimage.draw.polygon(r, c, shape=None) [source]

Generate coordinates of pixels within polygon.  Parameters

r(N,) ndarray

Row coordinates of vertices of polygon.
c(N,) ndarray

Column coordinates of vertices of polygon.
shapetuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for polygons that exceed the image size. If None, the full extent of the polygon is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.    Returns

rr, ccndarray of int

Pixel coordinates of polygon. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Examples >>> from skimage.draw import polygon
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> r = np.array([1, 2, 8])
>>> c = np.array([1, 7, 4])
>>> rr, cc = polygon(r, c)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)


skimage.draw.polygon2mask(image_shape, polygon) [source]

Compute a mask from polygon.  Parameters

image_shapetuple of size 2.

The shape of the mask.
polygonarray_like.

The polygon coordinates of shape (N, 2) where N is the number of points.    Returns

mask2-D ndarray of type ‘bool’.

The mask that corresponds to the input polygon.     Notes This function does not do any border checking, so that all the vertices need to be within the given shape. Examples >>> image_shape = (128, 128)
>>> polygon = np.array([[60, 100], [100, 40], [40, 40]])
>>> mask = polygon2mask(image_shape, polygon)
>>> mask.shape
(128, 128)


skimage.draw.polygon_perimeter(r, c, shape=None, clip=False) [source]

Generate polygon perimeter coordinates.  Parameters

r(N,) ndarray

Row coordinates of vertices of polygon.
c(N,) ndarray

Column coordinates of vertices of polygon.
shapetuple, optional

Image shape which is used to determine maximum extents of output pixel coordinates. This is useful for polygons that exceed the image size. If None, the full extents of the polygon is used. Must be at least length 2. Only the first two values are used to determine the extent of the input image.
clipbool, optional

Whether to clip the polygon to the provided shape. If this is set to True, the drawn figure will always be a closed polygon with all edges visible.    Returns

rr, ccndarray of int

Pixel coordinates of polygon. May be used to directly index into an array, e.g. img[rr, cc] = 1.     Examples >>> from skimage.draw import polygon_perimeter
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = polygon_perimeter([5, -1, 5, 10],
...                            [-1, 5, 11, 5],
...                            shape=img.shape, clip=True)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0, 1, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
       [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
       [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
       [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
       [0, 1, 1, 0, 0, 0, 0, 0, 0, 1],
       [0, 0, 0, 1, 0, 0, 0, 1, 1, 0],
       [0, 0, 0, 0, 1, 1, 1, 0, 0, 0]], dtype=uint8)


skimage.draw.random_shapes(image_shape, max_shapes, min_shapes=1, min_size=2, max_size=None, multichannel=True, num_channels=3, shape=None, intensity_range=None, allow_overlap=False, num_trials=100, random_seed=None) [source]

Generate an image with random shapes, labeled with bounding boxes. The image is populated with random shapes with random sizes, random locations, and random colors, with or without overlap. Shapes have random (row, col) starting coordinates and random sizes bounded by min_size and max_size. It can occur that a randomly generated shape will not fit the image at all. In that case, the algorithm will try again with new starting coordinates a certain number of times. However, it also means that some shapes may be skipped altogether. In that case, this function will generate fewer shapes than requested.  Parameters

image_shapetuple

The number of rows and columns of the image to generate.
max_shapesint

The maximum number of shapes to (attempt to) fit into the shape.
min_shapesint, optional

The minimum number of shapes to (attempt to) fit into the shape.
min_sizeint, optional

The minimum dimension of each shape to fit into the image.
max_sizeint, optional

The maximum dimension of each shape to fit into the image.
multichannelbool, optional

If True, the generated image has num_channels color channels, otherwise generates grayscale image.
num_channelsint, optional

Number of channels in the generated image. If 1, generate monochrome images, else color images with multiple channels. Ignored if multichannel is set to False.
shape{rectangle, circle, triangle, ellipse, None} str, optional

The name of the shape to generate or None to pick random ones.
intensity_range{tuple of tuples of uint8, tuple of uint8}, optional

The range of values to sample pixel values from. For grayscale images the format is (min, max). For multichannel - ((min, max),) if the ranges are equal across the channels, and ((min_0, max_0), … (min_N, max_N)) if they differ. As the function supports generation of uint8 arrays only, the maximum range is (0, 255). If None, set to (0, 254) for each channel reserving color of intensity = 255 for background.
allow_overlapbool, optional

If True, allow shapes to overlap.
num_trialsint, optional

How often to attempt to fit a shape into the image before skipping it.
random_seedint, optional

Seed to initialize the random number generator. If None, a random seed from the operating system is used.    Returns

imageuint8 array

An image with the fitted shapes.
labelslist

A list of labels, one per shape in the image. Each label is a (category, ((r0, r1), (c0, c1))) tuple specifying the category and bounding box coordinates of the shape.     Examples >>> import skimage.draw
>>> image, labels = skimage.draw.random_shapes((32, 32), max_shapes=3)
>>> image
array([
   [[255, 255, 255],
    [255, 255, 255],
    [255, 255, 255],
    ...,
    [255, 255, 255],
    [255, 255, 255],
    [255, 255, 255]]], dtype=uint8)
>>> labels
[('circle', ((22, 18), (25, 21))),
 ('triangle', ((5, 6), (13, 13)))]


skimage.draw.rectangle(start, end=None, extent=None, shape=None) [source]

Generate coordinates of pixels within a rectangle.  Parameters

starttuple

Origin point of the rectangle, e.g., ([plane,] row, column).
endtuple

End point of the rectangle ([plane,] row, column). For a 2D matrix, the slice defined by the rectangle is [start:(end+1)]. Either end or extent must be specified.
extenttuple

The extent (size) of the drawn rectangle. E.g., ([num_planes,] num_rows, num_cols). Either end or extent must be specified. A negative extent is valid, and will result in a rectangle going along the opposite direction. If extent is negative, the start point is not included.
shapetuple, optional

Image shape used to determine the maximum bounds of the output coordinates. This is useful for clipping rectangles that exceed the image size. By default, no clipping is done.    Returns

coordsarray of int, shape (Ndim, Npoints)

The coordinates of all pixels in the rectangle.     Notes This function can be applied to N-dimensional images, by passing start and end or extent as tuples of length N. Examples >>> import numpy as np
>>> from skimage.draw import rectangle
>>> img = np.zeros((5, 5), dtype=np.uint8)
>>> start = (1, 1)
>>> extent = (3, 3)
>>> rr, cc = rectangle(start, extent=extent, shape=img.shape)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)
 >>> img = np.zeros((5, 5), dtype=np.uint8)
>>> start = (0, 1)
>>> end = (3, 3)
>>> rr, cc = rectangle(start, end=end, shape=img.shape)
>>> img[rr, cc] = 1
>>> img
array([[0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)
 >>> import numpy as np
>>> from skimage.draw import rectangle
>>> img = np.zeros((6, 6), dtype=np.uint8)
>>> start = (3, 3)
>>>
>>> rr, cc = rectangle(start, extent=(2, 2))
>>> img[rr, cc] = 1
>>> rr, cc = rectangle(start, extent=(-2, 2))
>>> img[rr, cc] = 2
>>> rr, cc = rectangle(start, extent=(-2, -2))
>>> img[rr, cc] = 3
>>> rr, cc = rectangle(start, extent=(2, -2))
>>> img[rr, cc] = 4
>>> print(img)
[[0 0 0 0 0 0]
 [0 3 3 2 2 0]
 [0 3 3 2 2 0]
 [0 4 4 1 1 0]
 [0 4 4 1 1 0]
 [0 0 0 0 0 0]]