skills/cv/histopathology-image-inversion/SKILL.md
Inverts whole slide image pixel values (1 - x) so white background becomes zero, enabling standard zero-padding and making tissue regions the active signal.
npx skillsauth add wenmin-wu/ds-skills cv-histopathology-image-inversionInstall 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.
H&E-stained histopathology slides have a white background (255) and colored tissue. Standard CNNs and zero-padding assume background is black (0). Inverting the image (1.0 - x after normalizing to [0,1]) makes the background zero and tissue non-zero. This means zero-padding naturally extends the background, and the model's normalization statistics better reflect tissue content. A simple trick that improves convergence and is standard in WSI competition pipelines.
import numpy as np
import torch
# Inverted mean/std (computed from 1.0 - pixel_values)
MEAN = torch.tensor([1.0 - 0.9095, 1.0 - 0.8189, 1.0 - 0.8780])
STD = torch.tensor([0.3636, 0.4998, 0.4048])
def preprocess_wsi_tile(tile):
"""Invert and normalize a WSI tile."""
x = torch.from_numpy(tile).float() / 255.0
x = 1.0 - x # invert: white bg → 0, tissue → non-zero
x = x.permute(2, 0, 1) # HWC → CHW
x = (x - MEAN[:, None, None]) / STD[:, None, None]
return x
x = 1.0 - xdata-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