Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eccentricity estimation in Python

Tags:

python

pca

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
like image 946
ajwood Avatar asked Feb 14 '26 21:02

ajwood


1 Answers

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:

mean

where rho is your label (it as no index since it is a scalar). Then compute:

tensor

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.

like image 170
hpixel Avatar answered Feb 17 '26 11:02

hpixel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!