Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/vstarstack/tool/image_processing/drop_unsharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,21 @@ class EstimationMethod(Enum):
LAPLACE = 1

def measure_sharpness_sobel(img : np.ndarray, mask : np.ndarray | None) -> float:
if mask is not None:
img = img * mask
sx = scipy.ndimage.sobel(img, axis=0, mode='constant')
sy = scipy.ndimage.sobel(img, axis=1, mode='constant')
sobel = np.sqrt(sx**2 + sy**2)
if mask is not None:
sobel = sobel * mask
img = img * mask
metric = np.sum(sobel)
summ = np.sum(img)
return metric / summ

def measure_sharpness_laplace(img : np.ndarray, mask : np.ndarray | None) -> float:
if mask is not None:
img = img * mask
laplace = cv2.Laplacian(img, cv2.CV_64F).var()
if mask is not None:
laplace = laplace * mask
img = img * mask
metric = np.sum(laplace)
summ = np.sum(img)
return metric / summ
Expand Down