Repository navigation
Conversation
Add `return_area` to `get_centroids`: labels report their pixel (voxel) count, circles pi * r**2 and polygons their geometric area, as an `area` column of the returned points element (for 3D labels a volume, as in skimage's regionprops). Points raise. Multiscale labels are measured on scale0. As in scverse#1150, the area is intrinsic, so it is only allowed for a coordinate system whose transformation is the identity. Co-authored-by: Tim Treis <tim.treis@helmholtz-munich.de>
…d, no behaviour change) Merge the per-type registrations into one registration with _intrinsic_centroid_frame, _get_centroids_for_shapes and _points_from_centroids as in scverse#1150, so this branch can be compared with scverse#1150 without structural noise. Reverted at the end of this branch.
Instead of allowing return_area only for identity transformations, scale the intrinsic area by |det| of the linear part of the transformation, which is exact for affine maps; _points_from_centroids applies it next to transforming the centroids. Tests cover rotation + scale, anisotropic and 3D scales, and that the centroids are unchanged by return_area.
Undo the review-aid restructure: keep main's per-type get_centroids registrations (typed signatures, one docstring each) with the shared _points_from_centroids, now also scaling the area.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1337 +/- ##
==========================================
+ Coverage 91.77% 91.78% +0.01%
==========================================
Files 53 53
Lines 8398 8414 +16
==========================================
+ Hits 7707 7723 +16
Misses 691 691
🚀 New features to boost your workflow:
|
Collaborator
Author
|
@LucaMarconato @timtreis could you review this one? It is the first step of a short stack towards the centroids/area API:
Comments on the overall direction are welcome here too. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #1150 by @timtreis, keeping only the area part. Persisting centroids into tables is left for a separate design discussion (see #1150 (comment)). Builds on #1335, which already moved #1150's shared _points_from_centroids helper and small fixes to main.
What
get_centroids(..., return_area=True) adds the size of each geometry as an area column of the returned points element:
The area is reported in the requested coordinate_system, like the centroids: the intrinsic size is multiplied by |det| of the linear part of the transformation, which is exact for affine maps. This addresses the concern in #1150 that the area stayed intrinsic while the centroids were transformed, without restricting return_area to identity transformations.
Commits
The commits are meant to be read one by one (the PR is intended to be squash-merged):