Expand description
Replicates RidgeMap.preprocess: water/lake masking + vertical scaling.
Upstream, in order:
- NaN -> array min, then min-max normalize to [0, 1].
- water mask: value below the
water_ntilepercentile. - lake mask: 3x3 morphological gradient (max - min) of the u8-quantized
image (
skimage.util.img_as_ubyte->skimage.filters.rank.gradientwith a 3x3 footprint) belowlake_flatness. - restore NaNs, apply both masks as NaN.
- flip rows (south becomes the “front” of the picture) and multiply by
vertical_ratio.
Re-exports§
pub use crate::upstream::numpy::percentile_linear;pub use crate::upstream::skimage::gradient3x3;pub use crate::upstream::skimage::morphological_gradient;
Functions§
- masked_
gradient3x3 - 3x3 max - min gradient that IGNORES excluded cells (water/NaN): the
neighborhood keeps only in-bounds, non-excluded samples, and a cell with
no valid neighbors gets 0 (flat). Mirrors skimage’s masked rank filters
(
is_in_mask), which upstream never used. - preprocess
flatness_scaledensity-compensates the lake-flatness test: it multiplies the normalized threshold (lake_flatness/255). 1.0 = naive upstream semantics at the grid’s own sampling. For a disc grid viewed through a coarser anisotropic window, pass (disc_step / display_row_step) so the test measures the same terrain slope at any sampling density.