sidescanpy.export.augment#

Training-time augmentation for exported windows: random flips and jitter.

Every function takes an explicit numpy.random.Generator so a seeded export is reproducible, and every flip moves the annotated target positions (Target.sample = column, extra_attributes["window_row"] = row) together with the pixels.

2026 rshomberg@uri.edu

Contents

random_flip

Flip window horizontally and vertically, each with probability 0.5.

jitter_offset_m

Uniform integer pixel jitter in [-jitter_px, jitter_px], in meters.

jitter_latlon

Offset a WGS84 point by exact north/east meters via its UTM zone.

augmented_file_name

<stem>.png for a single draw, <stem>_a<aug_idx>.png when n_augment > 1.

sidescanpy.export.augment.random_flip(window, targets, rng, *, edge_coords)#

Flip window horizontally and vertically, each with probability 0.5.

Applied after display orientation; every target is remapped to match. Two draws are always taken from rng (horizontal, then vertical), so the generator advances identically whether or not anything flips.

Parameters:
windownp.ndarray

(n_rows, n_cols) image.

targetslist of Target

Window-local positions.

rngnp.random.Generator
edge_coordsbool

True for continuous pixel-edge coordinates (geometric/georef windows: pixel i spans [i, i+1)), mirrored as n - x; False for integer pixel-center indices (sample/ping windows), mirrored as n - 1 - x.

Returns:
(window, targets, flipped_h, flipped_v)

window is C-contiguous.

sidescanpy.export.augment.jitter_offset_m(jitter_px, resolution_m, rng)#

Uniform integer pixel jitter in [-jitter_px, jitter_px], in meters.

Same convention as extract_chip()’s pixel jitter, scaled by the window’s resolution_m. jitter_px == 0 returns 0.0 without drawing from rng.

sidescanpy.export.augment.jitter_latlon(lat, lon, north_jitter_m, east_jitter_m)#

Offset a WGS84 point by exact north/east meters via its UTM zone.

The round trip through the auto-selected UTM zone avoids a small-angle degrees approximation. A zero offset returns the input unchanged.

Returns:
(lat, lon)
sidescanpy.export.augment.augmented_file_name(stem, aug_idx, n_augment)#

<stem>.png for a single draw, <stem>_a<aug_idx>.png when n_augment > 1.