python - Scikit-image and central moments: what is the meaning? -


looking examples of how use image processing tools "describe" images , shapes of sort, have stumbled upon scikit-image skimage.measure.moments_central(image, cr, cc, order=3) function.

they give example of how use function:

from skimage import measure #package name in enthought canopy import numpy np  image = np.zeros((20, 20), dtype=np.double) #square image of zeros image[13:17, 13:17] = 1 #adding square of 1s m = moments(image) cr = m[0, 1] / m[0, 0] #row of centroid (x coordinate) cc = m[1, 0] / m[0, 0] #column of centroid (y coordinate)  in[1]: moments_central(image, cr, cc) out[1]: array([[ 16.,   0.,  20.,   0.],        [  0.,   0.,   0.,   0.],        [ 20.,   0.,  25.,   0.],        [  0.,   0.,   0.,   0.]]) 

1) each of values represent? since (0,0) element 16, number corresponds area of square of 1s, , therefore mu zero-zero. how others?

2) symmetric matrix?

3) values associated famous second central moments?

the array returned measure.moments_central correspond formula of https://en.wikipedia.org/wiki/image_moment (section central moment). mu_00 corresponds indeed area of object.

formula wikipedia (image moment)

the inertia matrix not symmetric, shown example object rectangle instead of square.

>>> image = np.zeros((20, 20), dtype=np.double) #square image of zeros >>> image[14:16, 13:17] = 1 >>> m = measure.moments(image) >>> cr = m[0, 1] / m[0, 0] >>> cc = m[1, 0] / m[0, 0] >>> measure.moments_central(image, cr, cc) array([[  8. ,   0. ,   2. ,   0. ],        [  0. ,   0. ,   0. ,   0. ],        [ 10. ,   0. ,   2.5,   0. ],        [  0. ,   0. ,   0. ,   0. ]]) 

as second-order moments, mu_02, mu_11, , mu_20 (coefficients on diagonal + j = 1). same wikipedia page https://en.wikipedia.org/wiki/image_moment explains how use second-order moments computing orientation of objects.


Comments