Skip to content

Commit 06fddaa

Browse files
Merge pull request #39 from matthewtownson/master
Fixed bug in centroiders and updated test
2 parents e79b145 + cbf5a73 commit 06fddaa

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

aotools/image_processing/centroiders.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy
1010

1111

12-
def correlation_centroid(im, ref, threshold):
12+
def correlation_centroid(im, ref, threshold=0.):
1313
"""
1414
Correlation Centroider, currently only works for 3d im shape.
1515
Performs a simple thresholded COM on the correlation.
@@ -80,9 +80,6 @@ def centreOfGravity(img, threshold=0, **kwargs):
8080
y_centroid = (y_cent*img).sum(-1).sum(-1)/img.sum(-1).sum(-1)
8181
x_centroid = (x_cent*img).sum(-1).sum(-1)/img.sum(-1).sum(-1)
8282

83-
y_centroid+=0.5
84-
x_centroid+=0.5
85-
8683
return numpy.array([x_centroid, y_centroid])
8784

8885

test/test_centroiders.py

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ def test_centreOfGravity_many():
1515
assert(com.shape[0] == 2)
1616
assert(com.shape[1] == 5)
1717

18+
def test_centreOfGravity_value():
19+
img = numpy.zeros((1, 5, 5))
20+
img[0, 1:3, 2:4] = 1.
21+
centroid = image_processing.centreOfGravity(img)
22+
numpy.testing.assert_almost_equal(centroid, numpy.array([[2.5], [1.5]]))
1823

1924
def test_brightestPxl_single():
2025
img = numpy.random.random((10, 10))

0 commit comments

Comments
 (0)