Common: added verbose parameter to focus_measure_edges function so print statement doesnt pollute the GUI Log by default.

This commit is contained in:
2026-02-24 11:29:57 +01:00
parent 5444ee97e3
commit 47d3b7934e
+5 -5
View File
@@ -1,7 +1,7 @@
import cv2
import numpy as np
def focus_measure_edges(gray: np.ndarray, mask: np.ndarray | None = None) -> float:
def focus_measure_edges(gray: np.ndarray, mask: np.ndarray | None = None, verbose: bool = False) -> float:
# mild denoise (optional but usually stabilizes the curve)
gray = cv2.GaussianBlur(gray, (3, 3), 0)
@@ -19,10 +19,10 @@ def focus_measure_edges(gray: np.ndarray, mask: np.ndarray | None = None) -> flo
if strong.size == 0:
return 0.0
print(f"mask pixels: {mask.sum()}, "
f"focus={strong.mean():.2f}"
f"strong_size={strong.size}")
if verbose:
print(f"mask pixels: {mask.sum()}, "
f"focus={strong.mean():.2f}"
f"strong_size={strong.size}")
return float(strong.mean()) # higher = sharper