You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segment profiles omit their end point and may allocate huge arrays #101
Since #93 (#98), segment_profile samples the segment in steps equal to the smallest distance between neighboring pixel centers: count = floor(length / step) + 1 samples at arange(count) * step. This has two consequences:
The end point may be omitted. When the length is not a multiple of the step, the last sample lies before the end point. On a 10 × 10 image with unit pixels, the segment from (0, 0) to (9, 9) (length ≈ 12.73) is sampled 13 times up to distance 12: the last sample takes pixel (8, 8), pixel (9, 9) is missing, and several diagonal pixels are duplicated. A segment shorter than one step only samples its start point. A local maximum at the end of the segment can thus be missed.
Unbounded memory. The number of samples does not depend on the number of pixels: one tiny spacing (non-uniform coordinates such as [0, 1e-8, 1, 2, 3], or strongly anisotropic pixels such as dx = 1e-8, dy = 1) gives hundreds of millions of samples (several GB) for a few dozen pixels.
Sigima 1.3 (csline) took one sample per pixel along the direction in which the segment spans the most pixels, end points included. The release notes of 1.4 state that "on images without calibration, results are unchanged", which is wrong for oblique segments (13 samples instead of 10 on the diagonal above). The existing tests only check axis-aligned segments and an anti-diagonal one whose end point happens to be reached.
Proposal
Sample the segment like Sigima 1.3, in physical coordinates:
as many samples as pixels between the nearest pixels of the two end points along the axis where the segment spans the most pixels: max(|Δcolumn|, |Δrow|) + 1;
samples evenly spaced along the segment, from the start point to the end point included (linspace), each taking the value of the nearest pixel; the X axis remains the physical distance from the start point;
hence no omitted end point, no duplicated pixel on diagonals, and at most max(rows, columns) samples, whatever the pixel spacing.
The contract stays at version 2: this version was introduced by #98 and was never released.
Tests: diagonal and anti-diagonal segments (end pixel included), segments shorter than a pixel, both end points in the same pixel, zero length, tiny spacings (bounded number of samples), comparison with the Sigima 1.3 profiles on images without calibration. Release notes and DataLab documentation updated.
Reported by an independent review of Sigima 1.4 (unreleased).
Activity
PierreRaybaut commentedon Oct 26, 2026
Fixed by #102 (merged into develop).