large_image icon indicating copy to clipboard operation
large_image copied to clipboard

Feature: add exact option to tile_size dictionary argument in tileiterator

Open YoniSchirris opened this issue 4 years ago • 0 comments

Feature summary

The current scale.exact allows to only return an exact magnification without resampling.

A tile_size.exact flag could be added to state that the user only wants tiles returned with the exact tile size at the given scale, i.e. not returning edge tiles that do not fit the requested tile size.

Currently, the options to do this are:

  • while iterating tiles, check the size of the tile, and continue if the size of the tile doesn't match
  • in some way, set the region_width and region_height in 'px' units to a value that is divisible by my tile_size that is near-100% of the width and height at the scale & magnification computed by the tileiterator, this would require to know the width of the full image at the scale & magnification computed by the tileIterator before initializing the tileIterator which, to my knowledge, is currently not doable (if so, kindly let me know, since then this feature is not needed)

Current result

When creating a tile iterator with

li_slide.tileIterator(scale=scale_dict,
                                              region=dict(left=0, top=0, right=full_width_at_max_res, bottom=full_height_at_max_res),
                                              tile_size=dict(width=225 height=225),
                                              tile_overlap=dict(x=0, y=0),
                                              format=large_image.tilesource.TILE_FORMAT_NUMPY,
                                              resample=resample)

I get tiles that are 225x66 at the right edge and 205x225 at the bottom edge

Preferred result

When creating a tile iterator with

li_slide.tileIterator(scale=scale_dict,
                                              region=dict(left=0, top=0, right=full_width_at_max_res, bottom=full_height_at_max_res),
                                              tile_size=dict(width=225 height=225, exact=True),
                                              tile_overlap=dict(x=0, y=0),
                                              format=large_image.tilesource.TILE_FORMAT_NUMPY,
                                              resample=resample)

Would only return tiles that are exactly 225*225, and will not return these edge cases.

YoniSchirris avatar Apr 23 '20 12:04 YoniSchirris