Computer Vision
Data Augmentation
Change an image transform and trace which source pixels and value adjustments produce each output.
The original image, before any transform. Edit a scalar value to make a fixture.
Original input · 6×6
Rotation 0 degrees, shift 0 pixels, fixed-pattern strength 0. Output [0, 0] ← original [0, 0] = 0. Continuous source (x,y) = (0, 0), rounded (0, 0). Sample 0 + perturbation −0 = preclip 0; clip to [0,1] → 0. Clipping delta 0. Pixel similarity 1.
Opacity uses the shared fixed [0,1] mapping, without per-image normalisation. SVG labels round to two decimals and disappear in small cells. Raw table values are unrounded. Outlines show the selected output and its actual rounded source, or no source for fill. All settings remain effective on stage return.
- Original
- Transformed
- Selected coordinate
Edit original scalar input
What does one pixel represent?
Inspect one scalar plane. Edit values to test the transform on your own small fixture.
Scalar plane
One value at each row and column, without a channel axis.
Check this stage
Check your understanding
Trace an augmented pixel through rotation, translation, nearest sampling, a fixed noise pattern and clipping. A changed image alone cannot prove better training.
What this experiment shows
Data augmentation transforms examples and changes the distribution used for training. It can help when the transformed examples suit the task, but it does not guarantee useful diversity, invariance or generalisation. This lab computes images and a pixel-difference statistic. It has no trained model, class labels, confidence, accuracy or training curve.
Start with the original T, or open Edit original scalar input and change its values. In Spatial Transformations, set Shift X to one and select output [1, 2]. It reads original [1, 1]. Set Shift X to two and the same output reads original [1, 0]. The values follow the inverse mapping, rather than a visual CSS transform.
Representation and coordinate convention
The UI uses one 6×6 scalar plane with intensities in [0,1]. Values are indexed image[y][x]: zero-based row first, then column. The origin is the upper-left sample centre; x increases right and y increases down. Sample centres are integer coordinates, translation units are pixels and rotation units are degrees. There are no RGB, alpha, batch or annotation axes.
The rotation centre is exactly (W/2, H/2), here (3,3). This preserves the lab's computation; it is not the midpoint (2.5,2.5) of the sample centres. A positive forward angle rotates clockwise on these y-down axes. Positive Shift X moves right. The pure function also accepts a vertical shift: positive values move up. That vertical parameter has no UI control.
Geometry: undo, round, sample
The forward order is rotation about the declared centre, then translation. Each destination independently undoes that composition to find one source. There is no intermediate raster resampling between rotation and translation.
The implementation calls Math.round on each continuous source coordinate. Half ties round toward positive infinity, including −0.5 to negative zero, which indexes column zero. It then checks those rounded indices. A continuous coordinate just outside the input can still round to a valid sample; a rounded index outside supplies literal zero. There are no bilinear weights or antialiasing. Nearest sampling selects values without averaging, but it can duplicate some samples and omit others.
Original input, geometric intermediate and final clipped output are different arrays. Select a cell in either output map, or use Inspect output [row, column], to connect the same destination to its original sample or boundary fill and to its arithmetic. An output coordinate retains its identity even when the source changes. Several outputs may read one source; some source samples may be unused. The outline marks the actual rounded source, never an invented edge-clamped pixel.
The canvas stays 6×6. Content outside it is discarded; this is not a crop-and-resize augmentation. In a 3×3 pure-function example the centre is (1.5,1.5), so clockwise 90° at destination (x=2,y=1) reads source (1,1). At destination (0,0) it rounds to outside source (0,3), giving zero fill. Those 90° and rectangular cases test the pure API; the UI angle remains −45° to +45°.
Value operation: a fixed pattern, then clipping
In Pixel-level Transformations, Noise Level scales a deterministic pattern at each destination. It does not draw a new random number on an edit or render.
Here % means JavaScript signed remainder, not a mathematical modulo that always returns a nonnegative value. Thus r is in (−1,1) and the coefficient is in (−3,1). This pattern is neither symmetric uniform nor Gaussian noise. No probability, independent sampling assumption, seed or mutable random state exists. Identical source values and settings replay the same computation; strength zero makes every perturbation zero.
At output [0,0], the phase, z and remainder are zero. The coefficient is −1. If its sampled value is 0.2 and strength is 0.5, the preclip value is −0.3 and the output is zero. If its sample is 0.8 instead, the preclip and output are 0.3. Noise also affects boundary-filled destinations. Clipping discards information below zero or above one; the table keeps preclip values and clipping deltas. This scalar operation changes intensity, not colour saturation or hue.
Composition and comparisons
Changing an angle or strength changes a parameter within the fixed order. It does not change that order. Rotation followed by translation generally differs from translation followed by rotation: a rightward displacement rotated clockwise becomes downward. Adding a destination-coordinate pattern after sampling also differs from adding it before geometric sampling. The lab supplies no order selector or comparison mode for those alternative algorithms.
The geometric intermediate and final view hold the input, angle, shift, nearest rule and zero fill fixed. The final view adds only the fixed destination pattern and clipping. There are no random draws to pair. No model evaluation is held fixed because none is performed.
The original and final arrays are compared at corresponding coordinates:
For the original binary T shifted two columns right, fifteen of thirty-six cells differ, so S = 21/36, approximately 0.583. The challenge asks you to cross 0.6 on the original source. Edited sources must first return to the original values to solve that stated challenge. The threshold has no semantic or statistical calibration. A low S need not invalidate a class label; a high S need not preserve task-relevant information.
Task validity and concepts beyond this lab
Whether an augmentation preserves a target depends on the task and its assumptions. Classification may seek invariance, an unchanged output under a transform. Localisation may require equivariance, an output that transforms correspondingly. A plausible-looking image is not automatically a valid labelled example. Stronger transformations are not universally better, and random variation is not evidence of appropriateness.
Rotation can alter orientation-sensitive targets. Cropping can remove essential content. A vertical flip is a mirror operation, not generally a 180° rotation. A task involving handwritten digits needs more care than the slogan that an upside-down six is a nine. This lab does not store or transform labels, masks, keypoints or bounding boxes; it cannot test annotation alignment.
The TensorFlow augmentation tutorial illustrates training-time pipelines and stateless random operations. Torchvision RandomAffine exposes framework sampling options; its conventions are not a promise of numerical parity with this lab. Colour jitter and random resized crops are other operations, not controls implemented here.
Cutout masks an input region. Mixup combines both examples and targets. Elastic deformations can model plausible nonrigid variation in some handwriting or biomedical tasks. Generated examples and minority-class augmentation require checks for validity, bias and sampling effects; transformed copies are not independent original observations. Test-time augmentation aggregates actual model predictions under a declared protocol. None of these techniques runs in this lab, and none guarantees a training improvement here. Finite precision, repeated settings and identity transforms can repeat outputs rather than provide endlessly unique images.
Inspect, share and recover
Under the hood exposes every output's continuous and rounded source, sample or fill, pattern intermediates, preclip value, final value and clipping delta, alongside the complete original source. Opacity uses a fixed shared mapping of [0,1], with no per-map normalisation. SVG labels round to two decimals or disappear in small cells; raw inspection preserves unrounded values. Display choices do not alter computation.
Finite UI edits clamp and snap to the declared control grids; empty and nonfinite source drafts are ignored. The pure API accepts rectangular finite planes, including empty and zero-width shapes, and rejects ragged rows, negative noise strength, nonfinite inputs and nonfinite intermediate arithmetic. Finite signed or out-of-range API intensities are allowed, then final output clips to [0,1]; their similarity need not stay in [0,1]. Empty or mismatched valid shapes return similarity sentinel zero. The bounded UI cannot overflow its arithmetic.
Stage return retains effective settings and keeps active operations visible. Mathematical edits, output selection, stage changes and sandbox changes clear predictions; Help, inspection, presentation and motion choices preserve them. Reset restores default source, parameters and selection at the current guided stage, returns guided and clears prediction and recovery. Shared links restore every source value, settings, selected output and displayed stage in guided mode. They exclude guesses and recovery. URL navigation also clears those local states. Restore experiment returns the full in-memory experiment, including original guided stage, sandbox and revealed prediction, after further edits. No algorithm cursor, history, upload or seed is needed for this synchronous computation.
Stage recap
The Original Image
Inspect one scalar plane. Edit values to test the transform on your own small fixture.
Spatial Transformations
Rotate clockwise for positive angles, then shift right for positive X. The fixed canvas can discard content.
Pixel-level Transformations
Noise Level scales a fixed coordinate pattern. It is not a fresh random draw, and its signed remainder is not symmetric.
Reference
- Augmentation
- Transforming examples changes the training distribution; benefits depend on the task and evaluation.
- Inverse sampling
- Visit each destination and find a source sample, or supply boundary fill.
- Pixel similarity
- One minus mean absolute corresponding-pixel difference; not semantic similarity.
- Invariance and equivariance
- Invariance keeps an output unchanged; equivariance transforms it in correspondence with the input.
Break it on purpose
Pixel similarity is below 0.6. This measures corresponding-pixel difference, not label validity or model performance.
Explore next
- Hough TransformEach point votes for possible lines; shared accumulator bins collect evidence for the same hypothesis.
- Convolution / CNNChange the filter and trace the dot product that builds each cell of the output feature map.
- IoU & Non-Max SuppressionIoU measures shared geometry; greedy NMS decides which scored boxes remain under an explicit overlap rule.