MCPcopy Create free account
hub / github.com/AIRMEC/HECTOR / generate_tiles

Function generate_tiles

extract_features.py:298–320  ·  view source on GitHub ↗
(tile_width_pix, tile_height_pix, img_width, img_height, offsets=[(0, 0)])

Source from the content-addressed store, hash-verified

296 return unary_union(polys)
297
298def generate_tiles(tile_width_pix, tile_height_pix, img_width, img_height, offsets=[(0, 0)]):
299 # Generate tiles covering the entire image.
300 # Provide an offset (x,y) to create a stride-like overlap effect.
301 # Add an additional tile size to the range stop to prevent tiles being cut off at the edges.
302 range_stop_width = int(np.ceil(img_width + tile_width_pix))
303 range_stop_height = int(np.ceil(img_height + tile_height_pix))
304
305 rects = []
306 for xmin, ymin in offsets:
307 cols = range(int(np.floor(xmin)), range_stop_width, tile_width_pix)
308 rows = range(int(np.floor(ymin)), range_stop_height, tile_height_pix)
309 for x in cols:
310 for y in rows:
311 rect = Polygon(
312 [
313 (x, y),
314 (x + tile_width_pix, y),
315 (x + tile_width_pix, y - tile_height_pix),
316 (x, y - tile_height_pix),
317 ]
318 )
319 rects.append(rect)
320 return rects
321
322def make_tile_QC_fig(tiles, slide, level, line_width_pix=1, extra_tiles=None):
323 # Render the tiles on an image derived from the specified zoom level

Callers 1

create_tissue_tilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected