Skip to content

Commit

Permalink
Fix critical bugs in apply_subpixel_distortion and apply_subpixel_geo…
Browse files Browse the repository at this point in the history
…metry_distortion. (#44)

The arrays returned from Lensfun are ordered as Height x Width x Channels x (x,y) coordinates, not  Height x Width x (x,y) coordinates x Channels.
  • Loading branch information
KoykL authored Feb 26, 2023
1 parent dc1c7e5 commit 38ac82a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lensfunpy/_lensfun.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -949,10 +949,10 @@ cdef class Modifier:
:return: per-channel coordinates for subpixel distortion correction,
or None if calibration data missing
:rtype: ndarray of shape (height, width, 2, 3) or None
:rtype: ndarray of shape (height, width, 3, 2) or None
"""
width, height = self._widthHeight(width, height)
cdef np.ndarray[DTYPE_t, ndim=4, mode='c'] res = np.empty((height, width, 2, 3), dtype=DTYPE)
cdef np.ndarray[DTYPE_t, ndim=4, mode='c'] res = np.empty((height, width, 3, 2), dtype=DTYPE)
if lf_modifier_apply_subpixel_distortion(self.lf, xu, yu, width, height, &res[0,0,0,0]):
return res
else:
Expand All @@ -963,10 +963,10 @@ cdef class Modifier:
:return: per-channel coordinates for combined distortion and subpixel distortion correction,
or None if calibration data missing
:rtype: ndarray of shape (height, width, 2, 3) or None
:rtype: ndarray of shape (height, width, 3, 2) or None
"""
width, height = self._widthHeight(width, height)
cdef np.ndarray[DTYPE_t, ndim=4, mode='c'] res = np.empty((height, width, 2, 3), dtype=DTYPE)
cdef np.ndarray[DTYPE_t, ndim=4, mode='c'] res = np.empty((height, width, 3, 2), dtype=DTYPE)
if lf_modifier_apply_subpixel_geometry_distortion(self.lf, xu, yu, width, height, &res[0,0,0,0]):
return res
else:
Expand Down

0 comments on commit 38ac82a

Please sign in to comment.