kwimage.im_demodata
¶
Module Contents¶
Functions¶
for dev use to update hashes of the demo images |
|
|
Ensures that the test image exists (this might use the network), reads it |
|
Ensures that the test image exists (this might use the network) and returns |
|
Creates a checkerboard image |
Attributes¶
- kwimage.im_demodata._update_hashes()[source]¶
for dev use to update hashes of the demo images
- CommandLine:
xdoctest -m kwimage.im_demodata _update_hashes xdoctest -m kwimage.im_demodata _update_hashes –require-hashes
- kwimage.im_demodata.grab_test_image(key='astro', space='rgb', dsize=None, interpolation='lanczos')[source]¶
Ensures that the test image exists (this might use the network), reads it and returns the the image pixels.
- Parameters
key (str) – which test image to grab. Valid choices are: astro - an astronaught carl - Carl Sagan paraview - ParaView logo stars - picture of stars in the sky airport - SkySat image of Beijing Capital International Airport on 18 February 2018 See
kwimage.grab_test_image.keys
for a full list.space (str, default=’rgb’) – which colorspace to return in
dsize (Tuple[int, int], default=None) – if specified resizes image to this size
- Returns
the requested image
- Return type
ndarray
- CommandLine:
xdoctest -m kwimage.im_demodata grab_test_image
Example
>>> # xdoctest: +REQUIRES(--network) >>> import kwimage >>> for key in kwimage.grab_test_image.keys(): >>> print('attempt to grab key = {!r}'.format(key)) >>> kwimage.grab_test_image(key) >>> print('grabbed key = {!r}'.format(key)) >>> kwimage.grab_test_image('astro', dsize=(255, 255)).shape (255, 255, 3)
- kwimage.im_demodata.grab_test_image_fpath(key='astro')[source]¶
Ensures that the test image exists (this might use the network) and returns the cached filepath to the requested image.
- Parameters
key (str) – which test image to grab. Valid choices are: astro - an astronaught carl - Carl Sagan paraview - ParaView logo stars - picture of stars in the sky
- Returns
path to the requested image
- Return type
- CommandLine:
python -c “import kwimage; print(kwimage.grab_test_image_fpath(‘airport’))”
Example
>>> # xdoctest: +REQUIRES(--network) >>> import kwimage >>> for key in kwimage.grab_test_image.keys(): ... print('attempt to grab key = {!r}'.format(key)) ... kwimage.grab_test_image_fpath(key) ... print('grabbed grab key = {!r}'.format(key))
- kwimage.im_demodata.checkerboard(num_squares=8, dsize=(512, 512))[source]¶
Creates a checkerboard image
- Parameters
num_squares (int) – number of squares in a row
dsize (Tuple[int, int]) – width and height
References
https://stackoverflow.com/questions/2169478/how-to-make-a-checkerboard-in-numpy
Example
>>> from kwimage.im_demodata import * # NOQA >>> img = checkerboard()