Skip to content

Commit

Permalink
Performance improvement for autocenter
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Jan 14, 2021
1 parent 440104e commit 7a67a3f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions skued/image/center.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,19 @@ def _center_of_intensity(im, mask=None):
rr, cc = np.indices(im.shape)
r_rough = np.average(rr, weights=weights)
c_rough = np.average(cc, weights=weights)
return r_rough, c_rough
return int(r_rough), int(c_rough)


def _fast_radial_inversion(im, center, cval):
arr_center = np.array(im.shape) / 2
shifted = shift(im, shift=arr_center - np.asarray(center))
shifted = shift(
im, shift=arr_center - np.asarray(center), order=1, mode="constant", cval=cval
)
shifted = shifted[::-1, ::-1]
return shift(
shifted, shift=np.asarray(center) - arr_center, mode="constant", cval=cval
shifted,
shift=np.asarray(center) - arr_center,
order=1,
mode="constant",
cval=cval,
)

0 comments on commit 7a67a3f

Please sign in to comment.