Skip to content

Commit

Permalink
Reverse sign of Jacobian values
Browse files Browse the repository at this point in the history
This doesn't seem to affect anything, since both the linearized
transform and the Hann window are symmetric, but this buts the Jacobian
values in the normal finite-difference form of [f(x+dx) - f(x)] / dx
  • Loading branch information
svank committed May 21, 2022
1 parent 0187ad6 commit 3153721
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions reproject/adaptive/deforest.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,17 @@ def map_coordinates(double[:,:] source, double[:,:] target, Ci, int max_samples_
Jy = np.empty((target.shape[0] + 1, target.shape[1], 2))
for yi in range(target.shape[0]):
for xi in range(target.shape[1]):
Jx[yi, xi, 0] = pixel_source[yi+1, xi, 0] - pixel_source[yi+1, xi+1, 0]
Jx[yi, xi, 1] = pixel_source[yi+1, xi, 1] - pixel_source[yi+1, xi+1, 1]
Jy[yi, xi, 0] = pixel_source[yi, xi+1, 0] - pixel_source[yi+1, xi+1, 0]
Jy[yi, xi, 1] = pixel_source[yi, xi+1, 1] - pixel_source[yi+1, xi+1, 1]
Jx[yi, xi, 0] = -pixel_source[yi+1, xi, 0] + pixel_source[yi+1, xi+1, 0]
Jx[yi, xi, 1] = -pixel_source[yi+1, xi, 1] + pixel_source[yi+1, xi+1, 1]
Jy[yi, xi, 0] = -pixel_source[yi, xi+1, 0] + pixel_source[yi+1, xi+1, 0]
Jy[yi, xi, 1] = -pixel_source[yi, xi+1, 1] + pixel_source[yi+1, xi+1, 1]
xi = target.shape[1]
Jx[yi, xi, 0] = pixel_source[yi+1, xi, 0] - pixel_source[yi+1, xi+1, 0]
Jx[yi, xi, 1] = pixel_source[yi+1, xi, 1] - pixel_source[yi+1, xi+1, 1]
Jx[yi, xi, 0] = -pixel_source[yi+1, xi, 0] + pixel_source[yi+1, xi+1, 0]
Jx[yi, xi, 1] = -pixel_source[yi+1, xi, 1] + pixel_source[yi+1, xi+1, 1]
yi = target.shape[0]
for xi in range(target.shape[1]):
Jy[yi, xi, 0] = pixel_source[yi, xi+1, 0] - pixel_source[yi+1, xi+1, 0]
Jy[yi, xi, 1] = pixel_source[yi, xi+1, 1] - pixel_source[yi+1, xi+1, 1]
Jy[yi, xi, 0] = -pixel_source[yi, xi+1, 0] + pixel_source[yi+1, xi+1, 0]
Jy[yi, xi, 1] = -pixel_source[yi, xi+1, 1] + pixel_source[yi+1, xi+1, 1]

# Now trim the padding we added earlier. Since `delta` was used above,
# the value at (0,0) will now truly represent (0,0) and so on. After
Expand Down Expand Up @@ -302,10 +302,10 @@ def map_coordinates(double[:,:] source, double[:,:] target, Ci, int max_samples_
if center_jacobian:
# Compute the Jacobian for the transformation applied to
# this pixel, as finite differences.
Ji[0,0] = offset_source_x[yi, xi, 0] - offset_source_x[yi, xi+1, 0]
Ji[1,0] = offset_source_x[yi, xi, 1] - offset_source_x[yi, xi+1, 1]
Ji[0,1] = offset_source_y[yi, xi, 0] - offset_source_y[yi+1, xi, 0]
Ji[1,1] = offset_source_y[yi, xi, 1] - offset_source_y[yi+1, xi, 1]
Ji[0,0] = -offset_source_x[yi, xi, 0] + offset_source_x[yi, xi+1, 0]
Ji[1,0] = -offset_source_x[yi, xi, 1] + offset_source_x[yi, xi+1, 1]
Ji[0,1] = -offset_source_y[yi, xi, 0] + offset_source_y[yi+1, xi, 0]
Ji[1,1] = -offset_source_y[yi, xi, 1] + offset_source_y[yi+1, xi, 1]
else:
# Compute the Jacobian for the transformation applied to
# this pixel, as a mean of the Jacobian a half-pixel
Expand Down

0 comments on commit 3153721

Please sign in to comment.