skills/cv/tile-grid-mosaic-assembly/SKILL.md
Assembles N extracted tiles into a sqrt(N) x sqrt(N) mosaic image for single-forward-pass CNN inference on whole slide images.
npx skillsauth add wenmin-wu/ds-skills cv-tile-grid-mosaic-assemblyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
After extracting the top-N informative tiles from a WSI, they need to be fed into a standard CNN. Rather than processing tiles independently, this technique arranges them into a sqrt(N) x sqrt(N) grid image (e.g., 36 tiles of 256px → one 1536x1536 image). This preserves some spatial context between adjacent tiles and allows a single forward pass through a standard image classifier. Per-tile augmentation can be applied before assembly, and whole-grid augmentation after.
import numpy as np
def assemble_mosaic(tiles, tile_size=256, n_tiles=36, transform=None):
"""Arrange N tiles into a square grid image."""
n_row = int(np.sqrt(n_tiles))
mosaic = np.ones((tile_size * n_row, tile_size * n_row, 3),
dtype=np.uint8) * 255 # white background
for i in range(min(len(tiles), n_tiles)):
h, w = i // n_row, i % n_row
tile = tiles[i]
if transform:
tile = transform(image=tile)['image']
mosaic[h*tile_size:(h+1)*tile_size,
w*tile_size:(w+1)*tile_size] = tile
return mosaic
# Usage
mosaic = assemble_mosaic(top_tiles, tile_size=256, n_tiles=36)
# Feed mosaic to standard image classifier
data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF