-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
API changes for skimage2
Lars Grüter edited this page Mar 17, 2026
·
42 revisions
Other lists and resources that touch and inform this document:
- Meta-issue: pending API changes for 1.0 #5439 (comment pulled into this doc on 2023-02-10)
- A pragmatic pathway towards skimage2 (discuss.scientific-python.org/t/530)
- Restructuring of API #2538
- skimage2 API (GitHub Project)
- Registration and warping (GitHub Project) proposes designing our API for n-dimensional registration.
- Old HackMD version of this list
- Timeline & process from skimage2 coordination meeting on January 29, 2024
These changes are difficult to do with deprecations.
- Consistently preserve the range of user-provided inputs #5439 (comment)
- How do we handle this for functions that do need to know the range?
- Examples?
- If range needs to be known, it is a required user keyword,
data_range=.... - See also this argument in #3009 (comment) for not rescaling to [0, 1], #5281 (comment), and Remove preserve_range kwarg #6319
- Remove
preserve_rangeand don't scale cval inskimage.transform.warp#7336 - Funcs using
img_as_floatinternally: Tracking: Optional range preservation #7796 - Sprint: No need for cval rescale, once
preserve_rangeis always True in skimage2
- Functions that take in x/y (transposed) coordinates should take axis-aligned (aka rc) coordinates instead. #5439 (Juan's request), #5439 (Greg's list). related: #2275
- past tentative work (closed PR): #3148
- our coordinate conventions
- OpenCV?
- Sprint: Still want this for skimage2! Will need to screen our API for where this applies...
- Unify boundary extension mode names used across the library. #5439 (comment)
- Currently we have 21 functions that use boundary mode names compatible with scipy.ndimage while we have another set of 12 functions that use names compatible with
numpy.pad. Filtering/morphology functions tend to use the scipy.ndimage names while those in restoration/transforms tend to use the NumPy ones. Out of these the subtle difference between reflect/mirror/symmetric can be quite confusing to users with reflect unfortunately being a valid name, but with different behavior in the two conventions! - list of specific functions following each convention
- Sprint: We probably want to follow
scipy.ndimagefor skimage2!
- Currently we have 21 functions that use boundary mode names compatible with scipy.ndimage while we have another set of 12 functions that use names compatible with
- Promote small integer types to float32 instead of float64. Conserves memory and may have some performance benefit, but can change precision of resulting floating point computations #6310. cuCIM already changed to this convention in June 2022 because the benefit of float32 vs. float64 for performance is large on GPU (cucim#278)
-
skimage.feature.canny'smodeargument should not default toconstant, since that usually results in an edge on the boundary. #6874 (comment) #5439 (comment)- Sprint: still relevant, should be changed to
"nearest"
- Sprint: still relevant, should be changed to
- Use Euclidean distance in
skimage.feature.peak_local_maxas new default for thep_normparameter #6608- Sprint: still relevant and agree
- Implemented in #8039
- Switch the sign of the internal Laplace operator in
skimage.filters.laplaceso that it returns a negative number at the position of a maximum. #7357
- Change regionprops so that indices match labels #2755
- Return a dictionary, keyed on
label, instead of a list:{1: RegionProp<label=1>, 2: RegionProp<label=2>, ...} - Instead of dictionary, perhaps we return a set.
- Sprint: come back later with Juan's perspective...
- Return a dictionary, keyed on
- Update API and behavior of morphological filters as described in #7238. Change default mode to
"ignore"to have less impact- Sprint: still want this and need skimage2
- Set
mirrorto same value for gray and binary morphology operators (see #6695)
- Remove default clipping and switch to
clip=Falseas the new default in deconvolution functions inskimage.restoration#7477 (comment).-
clipis useful since restoration often produces ringing, but agreed it should not be on by default. - Remove
clipand encourage user to providedata_range. We needdata_rangefor clipping anyway. - Sprint: keep for skimage2
-
- In
watershedfunction, compute local minima withski.morphology.label(ski.morphology.local_minima(image))#7117?- Sprint: keep for skimage2
- Make behavior of the
shearparameter inskimage.transform.AffineTransformconsistent [#6717 (comment)](https://github.com/scikit-image/scikit-image/pull/6717#issuecomment-1423602071-
Sprint decision: Passing in a single scalar value shouldn't be interpreted as
shear_x, shear_y = (shear, 0). Force user to pass a tuple. )
-
Sprint decision: Passing in a single scalar value shouldn't be interpreted as
These should be doable with normal deprecations, right away.
- Add a
coordinatesor similar flag to each function inskimage.transform, to change it from working withxytorc. For 2.0, we'll change the default fromxytorc.- See "Functions that take in x/y (transposed) coordinates should take axis-aligned (aka rc) coordinates instead" above.
- Maybe consolidate footprint generating functions in their public
footprintnamespace or evenskimage.shapesmodule? #2538-
ski.morphology.footprint.diskvsski.morphology.footprint_disk? Probably will stick to single level deep submodule, to make it easier to discover:footprint_*. - Replace square, rectangle, cube with footprint_rectangular #7566
- Refactor to skimage.morphology.footprint_ellipse #7628
-
- Use consistent API and parameters for footprint generation. #5439 (comment)
- These are currently a mess of size, width, height, m, n, radius, etc. #4536. I would argue that we really only need a n-dimensional rectangle implementation rather than separate square, rectangle, cube, etc. Likewise an n-dimensional sphere (or more generally an n-dimensinal ellipse) rather than ball and disk.I would argue that the shape is not quite right currently in disk/ball/ellipse generation functions and should be changed (needing adjustment by 0.5 pixels internally): discussion under "Use a consistent API (e.g. using radius) ..."
-
Sprint: Use
selem_type(shape=...). Default to 2D name, since that's the most common use-case, but support higher-dimensional (at least 3). For circledisk(shape=(3, 3))for spheredisk(shape=(3, 3, 3)).diskcan also support ellipse/ellipsoid, it's not too confusing. Other names:rectangleExamples from diplib's ShapeCode
- Prefer composed footprints as default where possible (
decomposition="sequence") for performance reasons - Create nicer container for decomposed footprints, that's still usable as a primitive tuple or similar
- E.g., dataclass
- Must allow for easy conversion to dense footprint
- Should have
reprthat renders it intuitively (display dense version)
-
binary_morphological functions should be deprecated because they use SciPy's (regressed) slow versions under the hood scipy/scipy#13991, #1990- If we add back a faster binary version at some point, can just do it internally for binary input
- Deprecate slow
binary_*functions in skimage.morphology #7665
- Turn
skimage.iomodule into a thin wrapper around imageio #5439 (comment) - Unify interface for algorithms that expect binary images. Either, only accept binary images (maybe preferred) or convert implicitly to binary images everywhere. #7095 (comment)
- Team sense: require user to explicitly convert. This avoids accidentally accepting the wrong argument (user passes in image, instead of mask, e.g.).
- Not skimage2, can be done right now.
- Remove legacy property names. We have some properties that have even been renamed twice, leaving a mess of legacy names that are still supported (and, hence, tested), which represents a certain maintenance burden. #5439 (comment)
- Not documented, so really no problem, and not urgent for skimage2.
- Sprint: We can deprecate and remove these any time we like (e.g., right now).
- In
skimage.draw, accept coordinates as a single keyword value, e.g.center=(0,1), rather than splitting intorow=0andcol=1, as it is currently done. This will allow us to extend to N-D in the future. #2538 (comment)ski.draw.circle_perimeter(r, c, radius, method='bresenham', shape=None)- Typically called as
circle_perimeter(10, 10, 50) - Could change outside of skimage2, but would then become:
circle_perimeter(center=(10, 10), radius=50)(via keyword-only arguments) - Sprint: deprecate using positional arguments for separate dimensions, use stuff like
center
- Consistently use
label_imageas the parameter name refering to label images. #5439 (comment)- In docstrings, docs, plain English, use "label image" everywhere instead of "labeled image" and "labels image" (unless it's actually part of the meaning of the sentence, e.g., "... and we end up with a labeled image").
- Consistently use
imagerather thanimg,arr,data, etc for image inputs. #5439 (comment) - Move
skimage.future.graphtoskimage.graph. #3105- Completed in #6674
- Change
outputtooutinskimage.filters.gaussianfor consistency with other skimage functions supporting output to a user-provided array. #5439 (comment)- Older use of an in_place kwarg was already deprecated some in places in 0.19.
- Deprecate output and positional args in filters.gaussian #7225
- Make functions in
skimage.filters.thresholdbehave consistently. #5439 (comment)- Many currently return a numeric threshold value, but some return a thresholded image instead.
-
Sprint:
- There are three cases to deal with:
- Function that returns threshold
- Threshold can be scalar or array
- Function that computes thresholded image directly
- Suggested interface:
threshold_*-> scalar or array thresholdthresholded_image_*-> thresholded image - Can be done outside
skimage2 - May want to flesh out the collection of functions so that we can (in most cases) either calculate the threshold image or the threshold value(s).
- There are three cases to deal with:
- Consistently use
num_workers/workersfor any parameter related to the number of threads/processes #5439 (comment)- Use num_workers instead of alternate parameter names #7302, WIP waiting for SPEC
- Sprint: agreed to standardize our library on
num_workers
- Resolve API inconsistency between the parameter names
min_sizeandarea_thresholdinremove_small_holesandremove_small_objects#4003-
Sprint: Not a strong preference, but seems like agreement to move back to
min_size(for now, will check again)
-
Sprint: Not a strong preference, but seems like agreement to move back to
- Address nomenclature for
perimeter,area,volumeinregionpropsfor 2D and 3D cases #3812. - Remove
skimage.viewermodule as napari is a more actively developed and more powerful third-party alternative. #5439 (comment) - Unify API on seed keyword for random seeds / generator #5359
- Where function signatures still use
im1, im2, finally replace them with eitherimage0, image1orreference_image, target_image. #4187 - Audit our modules to cluster functions based on purpose and "interchangeability". #5439 (comment)
-
"The "big picture" in this case is to be sklearn-like in that it will enable easier interoperability between skimage and libraries replicating or extending the skimage API."
- TODO: The comment above missing, and the link in the issue is broken. Please clarify the intent / meaning of this item.
-
- Potentially move thresholding functions to their own new submodule, e.g.
skimage.binarize. #2538- S:
binarizedoesn't fit for me with other submodule names;thresholdwould be fine?- In this case, we can also immediately rename the functions to whatever we want. Recall
threshold_image_*vsthreshold_discussion.
- In this case, we can also immediately rename the functions to whatever we want. Recall
- S:
- Rename
skimage.util.img_as_*functions torescale_to_*. #1234- S: +1 With scaling / data-type range interpretation deprecated in most contexts, it makes sense to be explicit here.
- Rename img_as_* functions to rescale_to_* #7697