Description:
There is a chance I'm holding this wrong. I was just trying to add an extra property to my regions that would compute the pixelwise mean along an axis. The length of the property will always be equal to the dimension of the bounding box along that axis. Since the regions are not the same size, this property ends up having varying length.
From the notes of _props_to_dict I get the impression that this should be possible.
For multidimensional properties that don't have a fixed size, such as
"image" (the image of a region varies in size depending on the region
size), an object array will be used, with the corresponding property name
as the key.
But something is stange with the _infer_regionprop_dtype test because I keep getting index out of range error so it is not set as an object array. I think because the test is using regionsmasks of the same size it never gets varying lengths property for my edge case property.
Note: this is fine with regionprops it just seems to be an issue with making the dictionary.
Way to reproduce:
import numpy as np
from skimage.measure import regionprops, regionprops_table, label
from skimage import data
image = data.coins()
def bbox_length_property(regionmask):
return [0] * regionmask.shape[1]
label_image = label( image > 110)
table_props = regionprops_table(label_image,
intensity_image=image,
extra_properties=(bbox_length_property, ),
)
<python3.8 path>\lib\site-packages\skimage\measure\_regionprops.py", line 878, in _props_to_dict
column_data[k, i] = rp[loc]
IndexError: list index out of range
Version information:
3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
Windows-10-10.0.19045-SP0
scikit-image version: 0.20.0
numpy version: 1.24.4
Description:
There is a chance I'm holding this wrong. I was just trying to add an extra property to my regions that would compute the pixelwise mean along an axis. The length of the property will always be equal to the dimension of the bounding box along that axis. Since the regions are not the same size, this property ends up having varying length.
From the notes of
_props_to_dictI get the impression that this should be possible.But something is stange with the
_infer_regionprop_dtypetest because I keep getting index out of range error so it is not set as an object array. I think because the test is using regionsmasks of the same size it never gets varying lengths property for my edge case property.Note: this is fine with
regionpropsit just seems to be an issue with making the dictionary.Way to reproduce:
Version information: