Skip to content

Commit 38ac82a

Browse files
authored
Fix critical bugs in apply_subpixel_distortion and apply_subpixel_geometry_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.
1 parent dc1c7e5 commit 38ac82a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lensfunpy/_lensfun.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,10 +949,10 @@ cdef class Modifier:
949949
950950
:return: per-channel coordinates for subpixel distortion correction,
951951
or None if calibration data missing
952-
:rtype: ndarray of shape (height, width, 2, 3) or None
952+
:rtype: ndarray of shape (height, width, 3, 2) or None
953953
"""
954954
width, height = self._widthHeight(width, height)
955-
cdef np.ndarray[DTYPE_t, ndim=4, mode='c'] res = np.empty((height, width, 2, 3), dtype=DTYPE)
955+
cdef np.ndarray[DTYPE_t, ndim=4, mode='c'] res = np.empty((height, width, 3, 2), dtype=DTYPE)
956956
if lf_modifier_apply_subpixel_distortion(self.lf, xu, yu, width, height, &res[0,0,0,0]):
957957
return res
958958
else:
@@ -963,10 +963,10 @@ cdef class Modifier:
963963
964964
:return: per-channel coordinates for combined distortion and subpixel distortion correction,
965965
or None if calibration data missing
966-
:rtype: ndarray of shape (height, width, 2, 3) or None
966+
:rtype: ndarray of shape (height, width, 3, 2) or None
967967
"""
968968
width, height = self._widthHeight(width, height)
969-
cdef np.ndarray[DTYPE_t, ndim=4, mode='c'] res = np.empty((height, width, 2, 3), dtype=DTYPE)
969+
cdef np.ndarray[DTYPE_t, ndim=4, mode='c'] res = np.empty((height, width, 3, 2), dtype=DTYPE)
970970
if lf_modifier_apply_subpixel_geometry_distortion(self.lf, xu, yu, width, height, &res[0,0,0,0]):
971971
return res
972972
else:

0 commit comments

Comments
 (0)