|
1 | 1 | import numpy as np |
2 | 2 | from skimage.registration import phase_cross_correlation |
3 | 3 |
|
| 4 | +from sunpy import log |
| 5 | + |
4 | 6 | from sunkit_image.coalignment.interface import AffineParams, register_coalignment_method |
5 | 7 |
|
6 | 8 | __all__ = ["phase_cross_correlation_coalign"] |
@@ -36,8 +38,14 @@ def phase_cross_correlation_coalign(target_array, reference_array, **kwargs): |
36 | 38 | """ |
37 | 39 | if target_array.shape != reference_array.shape: |
38 | 40 | raise ValueError("Input and target arrays must be the same shape.") |
| 41 | + if "upsample_factor" not in kwargs: |
| 42 | + kwargs["upsample_factor"] = 20 |
39 | 43 | shift, _, _ = phase_cross_correlation(reference_array, target_array, **kwargs) |
40 | | - x_shift, y_shift = shift[1], shift[0] |
| 44 | + # Shift has axis ordering which is consistent with the axis order of the input arrays, so y, x |
| 45 | + # These are negative based on the example provided in the scikit-image documentation |
| 46 | + # https://scikit-image.org/docs/stable/auto_examples/registration/plot_register_translation.html |
| 47 | + x_shift, y_shift = -shift[1], -shift[0] |
| 48 | + log.debug(f"Phase cross correlation shift: x: {x_shift}, y: {y_shift}") |
41 | 49 | # Particularly for this method, there is no change in the rotation or scaling, |
42 | 50 | # hence the hardcoded values of scale to 1.0 & rotation to identity matrix |
43 | 51 | scale = np.array([1.0, 1.0]) |
|
0 commit comments