Skip to content

Add rescaling API to skimage2#8075

Merged
lagru merged 13 commits intoscikit-image:mainfrom
lagru:sk2-rescale
Mar 19, 2026
Merged

Add rescaling API to skimage2#8075
lagru merged 13 commits intoscikit-image:mainfrom
lagru:sk2-rescale

Conversation

@lagru
Copy link
Copy Markdown
Member

@lagru lagru commented Mar 2, 2026

Description

This PR ports the current implementation of _rescale_value_range and _minmax_scale_value_range to skimage2. We want this functionality early so that we can craft nice migration advice for function that use preserve_range or the new prescale API.

Currently this is a draft. I kept _rescale_value_range internal, and exposed both modes as the new functions minmax_rescale and legacy_rescale. Somehow I feel that this is is simpler in multiple ways than keeping them in the same do-everything function. Especially, if we decide to add more rescaling modes that might need additional parameters, I think keeping separate function is clearly the better call – remember the discussion around enabling batched scaling with something like prescale=("minmax", 10, 100).

But I'm totally happy to hear and open to other suggestions.

Checklist

Release note

For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.

...

@lagru lagru added 🔧 type: Maintenance Refactoring and maintenance of internals 🥾 Path to skimage2 A step towards the new "API 2.0" labels Mar 2, 2026
@lagru lagru marked this pull request as draft March 2, 2026 20:06
@lagru lagru marked this pull request as ready for review March 11, 2026 17:20
@lagru lagru moved this to Doing in Work pitches Mar 12, 2026
@lagru lagru self-assigned this Mar 12, 2026
@lagru lagru moved this from Doing to Needs review in Work pitches Mar 12, 2026
@lagru lagru mentioned this pull request Mar 12, 2026
1 task
Copy link
Copy Markdown
Member

@stefanv stefanv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; we just need to fix the names. Left some minor docstring comments too.

@stefanv stefanv moved this from Review to Doing in Work pitches Mar 13, 2026
lagru and others added 5 commits March 13, 2026 23:33
If we ever change this, we don't risk forgetting both places.
This is fine according to our recently proposed import hierarchy.
Co-authored-by: Stefan van der Walt <github@mentat.za.net>
@lagru lagru moved this from Doing to Review in Work pitches Mar 13, 2026
@lagru lagru requested a review from stefanv March 13, 2026 23:02
lagru and others added 3 commits March 15, 2026 10:34
import numpy as np


def rescale_minmax(image):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we try upstreaming this function to NumPy (or SciPy)? Might be to "trivial" but the handling of overflow errors might make it worth it? And convenience functions still have their place...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth it, but I suspect the (0, 1) range is too specific. My guess is that it might be attractive if we had a range parameter with desired min and max.

@stefanv stefanv moved this from Review to Doing in Work pitches Mar 19, 2026
@lagru lagru merged commit 16df38b into scikit-image:main Mar 19, 2026
24 checks passed
@github-project-automation github-project-automation bot moved this from Doing to Done in Work pitches Mar 19, 2026
@stefanv stefanv added this to the 0.27 milestone Mar 19, 2026
@lagru lagru deleted the sk2-rescale branch March 19, 2026 11:18
matthew-brett added a commit that referenced this pull request Apr 10, 2026
* origin/main: (27 commits)
  Move `_shared` to `_skimage2` (#8102)
  Port `pad_footprint` & `mirror_footprint` to `skimage2` (#8094)
  Add rescaling API to skimage2 (#8075)
  Move `skimage2` implementation into `_skimage2` (#8093)
  Undo (double) mirroring in `ski2.morphology.dilation` (#8060)
  Grammar (#8091)
  Move `ensure_spacing` into `skimage2` (#8067)
  Ensure that `skimage2` does not eagerly import `skimage` (#8087)
  Use lazy-loader 0.5 (#8080)
  MAINT: make ellipse fitting forward compatible  (#8054)
  Avoid deprecated assign to ndarray.shape (#8020)
  Avoid circular import in `feature/corner.py` (#8077)
  Turn off coderabbit auto-labeling & label checks (#8070)
  Fix GIL being re-enabled by C++ extensions (#8059)
  Fix conventions following docstub and misc. (#8055)
  Port grayscale morphology operators to skimage2 (#8046)
  Add revised `peak_local_max` to `skimage2` (#8039)
  Allow read-only arrays as input to remap (#7535)
  Add `prescale`  parameter to "blob functions" (#7858)
  Try to make coderabbit respect exisiting type labels (#8042)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🥾 Path to skimage2 A step towards the new "API 2.0" 🔧 type: Maintenance Refactoring and maintenance of internals

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants