:py:mod:`kwimage.im_demodata` ============================= .. py:module:: kwimage.im_demodata Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: kwimage.im_demodata._update_hashes kwimage.im_demodata.grab_test_image kwimage.im_demodata.grab_test_image_fpath kwimage.im_demodata.checkerboard Attributes ~~~~~~~~~~ .. autoapisummary:: kwimage.im_demodata._TEST_IMAGES kwimage.im_demodata.keys kwimage.im_demodata.keys .. py:data:: _TEST_IMAGES .. py:function:: _update_hashes() 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 .. py:function:: grab_test_image(key='astro', space='rgb', dsize=None, interpolation='lanczos') 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 :rtype: ndarray CommandLine: xdoctest -m kwimage.im_demodata grab_test_image .. rubric:: 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) .. py:function:: grab_test_image_fpath(key='astro') 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 :rtype: str CommandLine: python -c "import kwimage; print(kwimage.grab_test_image_fpath('airport'))" .. rubric:: 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)) .. py:data:: keys .. py:data:: keys .. py:function:: checkerboard(num_squares=8, dsize=(512, 512)) Creates a checkerboard image :Parameters: * **num_squares** (*int*) -- number of squares in a row * **dsize** (*Tuple[int, int]*) -- width and height .. rubric:: References https://stackoverflow.com/questions/2169478/how-to-make-a-checkerboard-in-numpy .. rubric:: Example >>> from kwimage.im_demodata import * # NOQA >>> img = checkerboard()