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
Flip |
|
Uniform integer pixel jitter in |
|
Offset a WGS84 point by exact north/east meters via its UTM zone. |
|
|
- sidescanpy.export.augment.random_flip(window, targets, rng, *, edge_coords)#
Flip
windowhorizontally 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
Truefor continuous pixel-edge coordinates (geometric/georef windows: pixelispans[i, i+1)), mirrored asn - x;Falsefor integer pixel-center indices (sample/ping windows), mirrored asn - 1 - x.
- Returns:
- (window, targets, flipped_h, flipped_v)
windowis 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’sresolution_m.jitter_px == 0returns0.0without drawing fromrng.
- 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>.pngfor a single draw,<stem>_a<aug_idx>.pngwhenn_augment > 1.