@@ -41,7 +41,7 @@ def correlation_centroid(im, ref, threshold=0., padding=1):
41
41
# Correlate frame with reference image
42
42
corr = cross_correlate (im [frame ], ref , padding = padding )
43
43
44
- cx , cy = centreOfGravity (corr , threshold = threshold )
44
+ cx , cy = centre_of_gravity (corr , threshold = threshold )
45
45
46
46
cy -= float (ny ) / 2. * (float (padding ) - 1 )
47
47
cx -= float (nx ) / 2. * (float (padding ) - 1 )
@@ -51,20 +51,16 @@ def correlation_centroid(im, ref, threshold=0., padding=1):
51
51
return centroids
52
52
53
53
54
- def centreOfGravity (img , threshold = 0 , minThreshold = 0 , ** kwargs ):
54
+ def centre_of_gravity (img , threshold = 0 , min_threshold = 0 , ** kwargs ):
55
55
"""
56
56
Centroids an image, or an array of images.
57
57
Centroids over the last 2 dimensions.
58
58
Sets all values under "threshold*max_value" to zero before centroiding
59
59
Origin at 0,0 index of img.
60
60
61
- The value under which pixels are set to 0
62
- is max(threshold*max_value, minThreshold)
63
-
64
61
Parameters:
65
62
img (ndarray): ([n, ]y, x) 2d or greater rank array of imgs to centroid
66
63
threshold (float): Percentage of max value under which pixels set to 0
67
- minThreshold (float): Absolute max value under which pixels set to 0
68
64
69
65
Returns:
70
66
ndarray: Array of centroid values (2[, n])
@@ -73,10 +69,10 @@ def centreOfGravity(img, threshold=0, minThreshold=0, **kwargs):
73
69
74
70
if threshold != 0 :
75
71
if len (img .shape ) == 2 :
76
- thres = numpy .max ((threshold * img .max (), minThreshold ))
72
+ thres = numpy .max ((threshold * img .max (), min_threshold ))
77
73
img = numpy .where (img > thres , img - thres , 0 )
78
74
else :
79
- thres = numpy .maximum (threshold * img .max (- 1 ).max (- 1 ), [minThreshold ]* img .shape [0 ])
75
+ thres = numpy .maximum (threshold * img .max (- 1 ).max (- 1 ), [min_threshold ]* img .shape [0 ])
80
76
img_temp = (img .T - thres ).T
81
77
zero_coords = numpy .where (img_temp < 0 )
82
78
img [zero_coords ] = 0
@@ -94,7 +90,7 @@ def centreOfGravity(img, threshold=0, minThreshold=0, **kwargs):
94
90
return numpy .array ([x_centroid , y_centroid ])
95
91
96
92
97
- def brightestPxl (img , threshold , ** kwargs ):
93
+ def brightest_pixel (img , threshold , ** kwargs ):
98
94
"""
99
95
Centroids using brightest Pixel Algorithm
100
96
(A. G. Basden et al, MNRAS, 2011)
@@ -124,7 +120,7 @@ def brightestPxl(img, threshold, **kwargs):
124
120
img [:] = (img .T - pxlValues ).T
125
121
img = img .clip (0 , img .max (), out = img )
126
122
127
- return centreOfGravity (img )
123
+ return centre_of_gravity (img )
128
124
129
125
130
126
def cross_correlate (x , y , padding = 1 ):
0 commit comments