from skimage import measure import numpy as np x = np.eye(3).astype(int) x[0][0] =2 print(x) print(measure.label(x,connectivity=1)) # measure.regionprops() class A(): def __init__(self): self.a = 1 def repr__(self): return "2" a = A() b = {} b[a] = 2 print(list(b.keys())[0].a)