Skip to content

Instantly share code, notes, and snippets.

@afermg
Created November 5, 2025 00:08
Show Gist options
  • Select an option

  • Save afermg/7d3bb6258f47ae05b50269efa757a301 to your computer and use it in GitHub Desktop.

Select an option

Save afermg/7d3bb6258f47ae05b50269efa757a301 to your computer and use it in GitHub Desktop.
Find the number of output features in scikit image
import numpy as np
from skimage.measure import regionprops_table
img = np.ones((5, 5), dtype=int)
mask = np.zeros((5, 5), dtype=int)
mask[0:3, 0:3] = 1
feat_names = (
"area",
"bbox",
"area_bbox",
"moments_central",
"centroid",
"area_convex",
# 'ConvexHull',
# "image_convex",
# "coords",
"eccentricity",
"equivalent_diameter_area",
"euler_number",
"extent",
# 'Extrema',
"feret_diameter_max",
"area_filled",
# "image_filled",
"moments_hu",
# "image",
"inertia_tensor",
"inertia_tensor_eigvals",
# "image_intensity",
"centroid_local",
"axis_major_length",
"intensity_max",
"intensity_mean",
"intensity_min",
"intensity_std",
"axis_minor_length",
"axis_minor_length",
"moments",
"moments_normalized",
"orientation",
"perimeter",
"perimeter_crofton",
# 'PixelIdxList',
# 'PixelList',
# "slice",
"solidity",
# 'SubarrayIdx'
"moments_weighted_central",
"moments_weighted_central",
"centroid_weighted",
"centroid_weighted",
"moments_weighted_hu",
"moments_weighted_hu",
"centroid_weighted_local",
"centroid_weighted_local",
"moments_weighted",
"moments_weighted",
"moments_weighted_normalized",
"moments_weighted_normalized",
)
feats = regionprops_table(img, mask, properties=feat_names)
from pprint import pprint
pprint(feats)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment