Skip to content

Commit

Permalink
reconfigure type-ignore comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zigaLuksic committed Jan 3, 2024
1 parent b3f5595 commit ca2e340
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions eolearn/coregistration/coregistration.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def register(
"""Method that estimates the transformation between source and target image"""
criteria = (cv2.TERM_CRITERIA_COUNT, self.max_iter, 0)
warp_matrix_size = (3, 3) if warp_mode == cv2.MOTION_HOMOGRAPHY else (2, 3)
warp_matrix = np.eye(*warp_matrix_size, dtype=np.float32)
warp_matrix: np.ndarray = np.eye(*warp_matrix_size, dtype=np.float32)

try:
cv2.setNumThreads(self.num_threads)
Expand All @@ -114,7 +114,7 @@ def register(
warp_matrix,
warp_mode,
criteria,
valid_mask,
valid_mask, # type: ignore[arg-type]
self.gauss_kernel_size,
)
except cv2.error as cv2err:
Expand Down Expand Up @@ -163,15 +163,15 @@ def execute(self, eopatch: EOPatch) -> EOPatch:
def warp(self, img: np.ndarray, warp_matrix: np.ndarray, shape: tuple[int, int], flags: int) -> np.ndarray:
"""Transform the target image with the estimated transformation matrix"""
if warp_matrix.shape == (3, 3):
return cv2.warpPerspective(
return cv2.warpPerspective( # type: ignore[call-overload]
img.astype(np.float32),
warp_matrix,
shape,
flags=flags,
borderMode=self.border_mode,
borderValue=self.border_value,
)
return cv2.warpAffine(
return cv2.warpAffine( # type: ignore[call-overload]
img.astype(np.float32),
warp_matrix,
shape,
Expand Down Expand Up @@ -213,8 +213,8 @@ def get_gradient(src: np.ndarray) -> np.ndarray:
"""
# Calculate the x and y gradients using Sobel operator
src = src.astype(np.float32)
grad_x = cv2.Sobel(src, cv2.CV_32F, 1, 0, ksize=3) # type: ignore[attr-defined]
grad_y = cv2.Sobel(src, cv2.CV_32F, 0, 1, ksize=3) # type: ignore[attr-defined]
grad_x = cv2.Sobel(src, cv2.CV_32F, 1, 0, ksize=3)
grad_y = cv2.Sobel(src, cv2.CV_32F, 0, 1, ksize=3)

# Combine and return the two gradients
return cv2.addWeighted(np.absolute(grad_x), 0.5, np.absolute(grad_y), 0.5, 0)

0 comments on commit ca2e340

Please sign in to comment.