skills/cv/tissue-content-tile-selection/SKILL.md
Selects the top-N most informative tiles from a gigapixel whole slide image by ranking on pixel intensity sum, keeping tiles with the most tissue content.
npx skillsauth add wenmin-wu/ds-skills cv-tissue-content-tile-selectionInstall 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.
Whole slide images (WSIs) in histopathology are gigapixel-scale — too large for direct model input. Most of the image is white background. This technique splits the image into a grid of fixed-size tiles using numpy reshape+transpose (no Python loops), ranks tiles by pixel sum (darkest = most tissue on white-background H&E slides), and selects the top-N tiles. This is the standard first step in WSI classification pipelines, reducing a 50,000x50,000 image to 16-36 informative patches.
import numpy as np
import skimage.io
def extract_top_tiles(img, tile_size=256, n_tiles=36):
"""Extract top-N tiles by tissue content from WSI."""
h, w, c = img.shape
pad_h = (tile_size - h % tile_size) % tile_size
pad_w = (tile_size - w % tile_size) % tile_size
img = np.pad(img, [[pad_h//2, pad_h-pad_h//2],
[pad_w//2, pad_w-pad_w//2], [0,0]],
constant_values=255)
# Reshape into grid of tiles (no loops)
tiles = img.reshape(img.shape[0]//tile_size, tile_size,
img.shape[1]//tile_size, tile_size, 3)
tiles = tiles.transpose(0, 2, 1, 3, 4).reshape(-1, tile_size, tile_size, 3)
# Rank by pixel sum (lowest = darkest = most tissue)
sums = tiles.reshape(tiles.shape[0], -1).sum(axis=1)
idxs = np.argsort(sums)[:n_tiles]
return tiles[idxs]
wsi = skimage.io.MultiImage('slide.tiff')[1] # median resolution
tiles = extract_top_tiles(wsi, tile_size=256, n_tiles=36)
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