(tile_width_pix, tile_height_pix, img_width, img_height, offsets=[(0, 0)])
| 296 | return unary_union(polys) |
| 297 | |
| 298 | def 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 | |
| 322 | def 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 |
no outgoing calls
no test coverage detected