Пример #1
0
def test_multichannel():
    """Test that computing multichannel properties works."""
    astro = data.astronaut()[::4, ::4]
    astro_green = astro[..., 1]
    labels = slic(astro.astype(float), start_label=1)

    segment_idx = np.max(labels) // 2
    region = regionprops(labels,
                         astro_green,
                         extra_properties=[intensity_median])[segment_idx]
    region_multi = regionprops(labels,
                               astro,
                               extra_properties=[intensity_median
                                                 ])[segment_idx]

    for prop in list(PROPS.keys()) + ["intensity_median"]:
        p = region[prop]
        p_multi = region_multi[prop]
        if np.shape(p) == np.shape(p_multi):
            # property does not depend on multiple channels
            assert_array_equal(p, p_multi)
        else:
            # property uses multiple channels, returns props stacked along
            # final axis
            assert_allclose(p,
                            np.asarray(p_multi)[..., 1],
                            rtol=1e-12,
                            atol=1e-12)
Пример #2
0
def test_column_dtypes_complete():
    assert set(COL_DTYPES.keys()).union(OBJECT_COLUMNS) == set(PROPS.values())
Пример #3
0
def test_props_dict_complete():
    region = regionprops(SAMPLE)[0]
    properties = [s for s in dir(region) if not s.startswith('_')]
    assert set(properties) == set(PROPS.values())