Skip to content

radial_profile: 'center' mode passes physical coordinates where pixel indices are expected #93

Closed

Description

@PierreRaybaut

Problem

sigima.proc.image.radial_profile with center="center" passes the physical coordinates of the image center (ImageObj.xc, yc) to sigima.tools.image.get_radial_profile, which expects pixel indices (the centroid mode passes indices, and the x0/y0 parameters of the user mode are documented in pixels). The result is only correct for images with x0 = y0 = 0 and dx = dy = 1.

Reproduction (Gaussian peak at the center of an 11 × 11 image):

import numpy as np, sigima.objects as so, sigima.proc.image as sipi, sigima.params as sp
y, x = np.indices((11, 11)); data = np.exp(-((x - 5) ** 2 + (y - 5) ** 2) / 4.0)
for x0, dx in ((0.0, 1.0), (100.0, 1.0), (0.0, 0.1)):
    img = so.create_image("g", data.copy()); img.set_uniform_coords(dx, dx, x0, x0)
    s = sipi.radial_profile(img, sp.RadialProfileParam.create(center="center"))
    print(x0, dx, img.xc, len(s.y), np.nanmax(s.y))
x0, dx center used profile
0, 1 (5, 5) correct (15 points, maximum 1 at distance 0)
100, 1 (105, 105) 297 points, NaN values
0, 0.1 (0.5, 0.5) profile around the top-left corner

The X axis of the profile (distances) is also in pixels whatever the calibration, and non-uniform coordinates are not taken into account.

Found while auditing the 1.4 contract versions (#87): radial_profile is now at contract version 2 because xc/yc changed; this issue is about its pre-existing mix of physical and pixel coordinates.

Expected

The center mode uses the pixel indices of the center of the pixel grid (or the whole function works in physical coordinates, consistently for the three modes and for the X axis of the profile).

Activity

  1. PierreRaybaut commented on Oct 25, 2026

    @PierreRaybaut
    ContributorAuthor

    Scope extended (maintainer decision): instead of only fixing radial_profile centering, the whole image-profile family (line, segment, average, radial) now uses physical coordinates, consistently with ROIs and analysis results (physical since Sigima 1.0).

    While doing so, further defects were found and fixed: vertical profiles carried the X axis unit, all profiles carried the image unit while their X axis was in pixels, and anti-diagonal segments were extracted along the other diagonal. The four contracts are bumped to version 2 (rule from #96).

  2. PierreRaybaut commented on Oct 25, 2026

    @PierreRaybaut
    ContributorAuthor

    Fixed by #98 (merged into develop).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions