Skip to content

Commit f9822c2

Browse files
committed
fix bug in centerfinder related to 8-bit processing and regold test
1 parent 7484739 commit f9822c2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

holopy/core/process/centerfinder.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ def center_find(image, centers=1, threshold=.5, blursize=3.):
8585
contribute to finding the centers and the code will take a little
8686
bit longer.
8787
"""
88-
image=copy(image)
88+
# cast image to float to avoid running gaussian filter on 8-bit images.
89+
# As noted in the documentation for scipy.ndimage.gaussian_filter, "...for
90+
# output types with a limited precision, the results may be imprecise
91+
# because intermediate results may be stored with insufficient precision.
92+
# The imprecision when using 8-bit data will be platform dependent, leading
93+
# to test failures.
94+
image=copy(image.astype(float))
8995
if blursize>0:
9096
image.values = gaussian_filter(image.values, blursize)
9197
col_deriv, row_deriv = image_gradient(image)

holopy/core/tests/test_process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from holopy.core.tests.common import get_example_data, assert_obj_close
3030

3131
#Test centerfinder
32-
gold_location = np.array([ 48.5729142, 50.23217416])
32+
gold_location = np.array([48.02525655, 50.22414601])
3333

3434

3535
def check_copied_dataarrays(arr1, arr2):

0 commit comments

Comments
 (0)