kwcoco.util.lazy_frame_backends module¶
Ducktyped interfaces for loading subregions of images with standard slice syntax
- class kwcoco.util.lazy_frame_backends.CacheDict(*args, cache_len: int = 10, **kwargs)[source]¶
Bases:
OrderedDict
Dict with a limited length, ejecting LRUs as needed.
Example
>>> c = CacheDict(cache_len=2) >>> c[1] = 1 >>> c[2] = 2 >>> c[3] = 3 >>> c CacheDict([(2, 2), (3, 3)]) >>> c[2] 2 >>> c[4] = 4 >>> c CacheDict([(2, 2), (4, 4)]) >>>
References
https://gist.github.com/davesteele/44793cd0348f59f8fadd49d7799bd306
- class kwcoco.util.lazy_frame_backends.LazySpectralFrameFile(fpath)[source]¶
Bases:
NiceRepr
Potentially faster than GDAL for HDR formats.
- property ndim¶
- property shape¶
- property dtype¶
- class kwcoco.util.lazy_frame_backends.LazyRasterIOFrameFile(fpath)[source]¶
Bases:
NiceRepr
fpath = ‘/home/joncrall/.cache/kwcoco/demo/large_hyperspectral/big_img_128.bsq’ lazy_rio = LazyRasterIOFrameFile(fpath) ds = lazy_rio._ds
- property ndim¶
- property shape¶
- property dtype¶
- class kwcoco.util.lazy_frame_backends.LazyGDalFrameFile(fpath, nodata_method=None, overview=None)[source]¶
Bases:
NiceRepr
Todo
[ ] Move to its own backend module
- [ ] When used with COCO, allow the image metadata to populate the
height, width, and channels if possible.
Example
>>> # xdoctest: +REQUIRES(module:osgeo) >>> self = LazyGDalFrameFile.demo() >>> print('self = {!r}'.format(self)) >>> self[0:3, 0:3] >>> self[:, :, 0] >>> self[0] >>> self[0, 3]
>>> # import kwplot >>> # kwplot.imshow(self[:])
- Parameters
fpath (str) – the path to the file to load
nodata_method (None | int | str) – how to handle nodata
overview (int) – The overview level to load (zero is no overview)
Example
>>> # See if we can reproduce the INTERLEAVE bug
data = np.random.rand(128, 128, 64) import kwimage import ubelt as ub from os.path import join dpath = ub.ensure_app_cache_dir(‘kwcoco/tests/reader’) fpath = join(dpath, ‘foo.tiff’) kwimage.imwrite(fpath, data, backend=’skimage’) recon1 = kwimage.imread(fpath) recon1.shape
self = LazyGDalFrameFile(fpath) self.shape self[:]
- property ndim¶
- property num_overviews¶
- property num_absolute_overviews¶
- property shape¶
- property dtype¶