I've got a binary numpy array and have labeled the connected regions with scipy.ndimage. Is there a call that I can make to estimate the eccentricity of each labeled section?
Edit:
I'm trying to develop criteria to find and toss the labeled sections that are much longer than they are wide. In the following array, I might want to keep the 7s and toss the 3s.
3 3 0 0 0 0
3 3 0 7 7 7
3 3 0 7 7 7
3 3 0 7 0 7
3 3 0 0 0 0
I guess you first need a bit of math. Let first consider you have only one blob labeled as 1. Your matrix label will be a scalar field. You should first compute its average:
where is your label (it as no index since it is a scalar).
Then compute:
A good definition of eccentricity would be the ratio of the two biggest eigenvalues of the traceless part of this matrix (in 2D, you will have only 2 eigenvalues). You can also normalize it to get a value between 0 and 1. I am not used enough with scipy to write an efficient code for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With