Skip to content

Commit

Permalink
0.1.3 version up
Browse files Browse the repository at this point in the history
  • Loading branch information
csaybar committed May 25, 2024
1 parent dd25083 commit eccd43f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "satalign"
version = "0.0.7"
version = "0.1.3"
description = "Methods for spatial alignment of satellite imagery"
authors = ["Cesar Aybar <[email protected]>"]
repository = "https://github.com/csaybar/satalign"
Expand Down
2 changes: 1 addition & 1 deletion satalign/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from satalign import utils
from satalign.ecc import ECC
from satalign.lightglue import LightGlue
from satalign.lgm import LGM
from satalign.pcc import PCC
1 change: 1 addition & 0 deletions satalign/ecc.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ def find_warp(
except cv2.error as cv2err:
warnings.warn(f"Could not calculate the warp matrix: {cv2err}")
warp_matrix = np.eye(*self.warp_matrix_size, dtype=np.float32)
self.warning_status = True
return warp_matrix
2 changes: 2 additions & 0 deletions satalign/lgm.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def find_warp(
feats0 = self.feature_model.extract(moving_image_torch, resize=None)
if feats0["keypoints"].shape[1] == 0:
warnings.warn("No keypoints found in the moving image")
self.warning_status = True
return self.warp_matrix

# Run the matcher model
Expand All @@ -109,6 +110,7 @@ def find_warp(

if thres.sum().item() == 0:
warnings.warn("No matching points found")
self.warning_status = True
return self.warp_matrix

p0 = points0[thres]
Expand Down
8 changes: 8 additions & 0 deletions satalign/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(
num_threads: int = 4,
max_translations: int = 5.0,
border_value: int = 0,
warning_status: bool = False,
):
"""
Expand Down Expand Up @@ -71,6 +72,11 @@ def __init__(
max_translations (int, optional): Estimated transformations are considered
incorrect when the norm of the translation component is larger than
this parameter. Defaults to 5.0.
border_value (int, optional): Value used to fill the border of the
image when the warp matrix affects the border of the image. Defaults
to 0.
warning_status (bool, optional): The warning status of the alignment
method. Defaults to False.
"""

# Set the class attributes (REQUIRED)
Expand All @@ -90,6 +96,7 @@ def __init__(
# We do no support homography for now (AUTOMATIC)
self.warp_matrix_size = (2, 3)
self.warp_matrix: np.ndarray = np.eye(*self.warp_matrix_size, dtype=np.float32)
self.warning_status = warning_status

@abstractmethod
def find_warp(
Expand Down Expand Up @@ -232,6 +239,7 @@ def get_warped_image(
if self.is_translation_large(warp_matrix):
warnings.warn("Estimated translation is too large")
warp_matrix = self.warp_matrix
self.warning_status = True

# Warp the image using the estimated warp matrix
warped_image = self.warp_feature(img=moving_image, warp_matrix=warp_matrix)
Expand Down
1 change: 1 addition & 0 deletions satalign/pcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@ def find_warp(
except Exception as err:
warnings.warn(f"Could not calculate the warp matrix: {err}")
warp_matrix = np.eye(*self.warp_matrix_size, dtype=np.float32)
self.warning_status = True

return warp_matrix

0 comments on commit eccd43f

Please sign in to comment.