skills/cv/percentile-contrast-stretch/SKILL.md
Normalize high-dynamic-range satellite or medical imagery to [0,1] using per-channel percentile clipping to suppress outliers while preserving relative contrast
npx skillsauth add wenmin-wu/ds-skills cv-percentile-contrast-stretchInstall 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.
Satellite and medical images often have extreme pixel outliers that wash out simple min-max normalization. Percentile contrast stretching clips each channel at the 2nd and 98th percentiles, then linearly maps to [0,1]. This preserves meaningful contrast while being robust to dead pixels, sensor noise, and atmospheric artifacts.
import numpy as np
def percentile_stretch(image, lower=2, upper=98):
out = np.zeros_like(image, dtype=np.float32)
for c in range(image.shape[2]):
lo = np.percentile(image[:, :, c], lower)
hi = np.percentile(image[:, :, c], upper)
out[:, :, c] = (image[:, :, c] - lo) / (hi - lo + 1e-10)
return np.clip(out, 0, 1)
rgb_stretched = percentile_stretch(rgb_image)
(pixel - lo) / (hi - lo)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