Skip to content

Commit

Permalink
Use Lanczos interpolation for affine warp
Browse files Browse the repository at this point in the history
The Bicubic interpolation algorithm is not great for astronomy image subtraction; Lanczos is better. However, scikit does not support this, so I used the OpenCV implementation.
  • Loading branch information
Messier-16 authored Mar 12, 2024
1 parent 6aba41b commit efeb8de
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions astroalign.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,21 +461,20 @@ def apply_transform(
information.
"""
from skimage.transform import warp
import cv2

source_data = _data(source)
target_shape = _data(target).shape

aligned_image = warp(
aligned_image = cv2.warpAffine(
source_data,
inverse_map=transform.inverse,
output_shape=target_shape,
order=3,
mode="constant",
cval=_default_median(source_data),
clip=True,
preserve_range=True,
transform.params[:2, :3],
target_shape[:2],
borderMode=cv2.BORDER_CONSTANT,
borderValue=_default_median(source_data),
flags=cv2.INTER_LANCZOS4,
)

footprint = warp(
_np.zeros(_shape(source_data), dtype="float32"),
inverse_map=transform.inverse,
Expand Down

0 comments on commit efeb8de

Please sign in to comment.