skills/cv/microscope-circular-mask-aug/SKILL.md
Mask the corners of a dermoscopy image with a random-radius black circle to mimic the dark vignette of a dermatoscope field of view
npx skillsauth add wenmin-wu/ds-skills cv-microscope-circular-mask-augInstall 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.
About half the dermoscopy images in ISIC datasets have the characteristic dark circular vignette of a dermatoscope; the other half are cropped rectangles. Models pick up the vignette as a shortcut feature correlated with source site, which breaks cross-site generalization. The fix is a symmetric augmentation: apply a random-radius circular mask to train images that don't have one, so the model learns to ignore the vignette. Cheap, interpretable, and directly closes a train/test distribution gap.
import cv2
import numpy as np
import random
class MicroscopeMask:
def __init__(self, p=0.5):
self.p = p
def __call__(self, img):
if random.random() > self.p:
return img
h, w = img.shape[:2]
circle = (np.ones(img.shape) * 255).astype(np.uint8)
radius = random.randint(h // 2 - 3, h // 2 + 15)
circle = cv2.circle(circle, (w // 2, h // 2), radius, (0, 0, 0), -1)
mask = circle - 255 # 0 inside circle, -255 outside
return np.multiply(img, mask) # zeros outside the circle
img_size / 2 — keeps the lesion visible while varying the vignettep=0.5 since roughly half the images already have a vignettedata-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