Skip to content

Sample segment profiles from end point to end point - #102

Merged
PierreRaybaut merged 1 commit into
developfrom
fix/segment-profile-sampling
Oct 26, 2026
Merged

PierreRaybaut merged 1 commit into
developfrom
fix/segment-profile-sampling

Conversation

@PierreRaybaut

@PierreRaybaut PierreRaybaut commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #101

Summary

Since #98, segment_profile sampled the segment in steps of the smallest distance between pixel centers (count = floor(length / step) + 1):

  • the end point was omitted whenever the length was not a multiple of the step: the diagonal (0, 0)–(9, 9) of a 10 × 10 image gave 13 samples up to pixel (8, 8), duplicating some pixels and missing pixel (9, 9); a segment shorter than one step only sampled its start point;
  • the number of samples did not depend on the number of pixels: a tiny spacing (non-uniform coordinates [0, 1e-8, 1, 2, 3], or dx = 1e-8) gave hundreds of millions of samples (several GB) for a few pixels.

Segment profiles are now sampled like in Sigima 1.3 (csline), in physical coordinates:

  • max(|Δcolumn|, |Δrow|) + 1 samples, from the pixels nearest to the two end points;
  • evenly spaced along the segment, end points included (exactly: weighted interpolation), each taking the nearest pixel; the X axis remains the physical distance from the start point;
  • at most max(rows, columns) samples, whatever the pixel sizes.

The contract stays at version 2 (introduced by #98, not released yet). The release note no longer claims that all results are unchanged on images without calibration: horizontal, vertical and diagonal segments take the same pixels as in Sigima 1.3, other oblique segments take the nearest pixel instead of truncating its indices (French translation updated, checked with a gettext build + sphinx_intl update).

Companion: DataLab-Platform/DataLab#440 (same branch name) updates the description of the segment profile in the DataLab documentation.

Validation

  • New tests (profile_physical_unit_test.py): end points included on diagonal and oblique segments, identical to Sigima 1.3 for axis-aligned and diagonal segments (6 cases, reference reimplemented from 1.3), segments shorter than a pixel / within one pixel / of zero length, tiny spacings (non-uniform and anisotropic: 5 samples for a 5 × 5 image).
  • Validation test updated deliberately: the anti-diagonal segment now gives 31 samples (one per pixel, end pixel included) instead of 43.
  • Full suite: 2345 passed; --qualification-report: no problem (segment_profile v2 qualified, validation and replay passed).

Since #98, segment profiles were sampled in steps of the smallest distance
between pixel centers, up to floor(length / step) steps: the end point was
omitted whenever the length was not a multiple of the step (the diagonal of
a 10 x 10 image stopped at pixel (8, 8), duplicating some pixels), a segment
shorter than one step only sampled its start point, and a tiny spacing
(non-uniform coordinates, strongly anisotropic pixels) gave hundreds of
millions of samples for a few pixels.

Segment profiles are now sampled like in Sigima 1.3, in physical
coordinates: one sample per pixel along the axis where the segment spans the
most pixels (from the pixel nearest to its start point to the pixel nearest
to its end point), at regular steps from the start point to the end point
included, each sample taking the nearest pixel. The number of samples never
exceeds the number of rows or columns of the image. On images without
calibration, horizontal, vertical and diagonal segments take the same pixels
as in Sigima 1.3; other oblique segments take the nearest pixel instead of
truncating its indices. The release note no longer states that all results
are unchanged on such images.

The contract stays at version 2, introduced by #98 and not released yet.

Closes #101

Assisted-by: Claude Opus 5.5
@PierreRaybaut PierreRaybaut added the bug Something isn't working label Oct 26, 2026
@PierreRaybaut
PierreRaybaut merged commit 14b5462 into develop Oct 26, 2026
6 checks passed
@PierreRaybaut
PierreRaybaut deleted the fix/segment-profile-sampling branch October 26, 2026 08:25
@ThomasMalletCodra ThomasMalletCodra added this to the v1.4.0 milestone Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants