Fixed type annotations in autofocus and mock stage
I don't know why these didn't fail before - possibly because of incomplete type information from old numpy... I removed a few annotations because they were failing (e.g. np.sum can return a scalar or an array), but I don't think this should be a problem - the function inputs and return values are still typed.
This commit is contained in:
parent
cd5e32b843
commit
e73ee8875c
2 changed files with 10 additions and 7 deletions
|
|
@ -129,18 +129,21 @@ def monitor_sharpness(microscope: Microscope):
|
|||
|
||||
def sharpness_sum_lap2(rgb_image: np.ndarray) -> float:
|
||||
"""Return an image sharpness metric: sum(laplacian(image)**")"""
|
||||
image_bw: float = np.mean(rgb_image, 2)
|
||||
image_lap: float = ndimage.filters.laplace(image_bw)
|
||||
return np.mean(image_lap.astype(float) ** 4)
|
||||
image_bw = np.mean(rgb_image, 2)
|
||||
image_lap = ndimage.filters.laplace(image_bw)
|
||||
return float(np.mean(image_lap.astype(float) ** 4))
|
||||
|
||||
|
||||
def sharpness_edge(image: np.ndarray) -> float:
|
||||
"""Return a sharpness metric optimised for vertical lines"""
|
||||
gray: float = np.mean(image.astype(float), 2)
|
||||
gray = np.mean(image.astype(float), 2)
|
||||
n: int = 20
|
||||
edge: np.ndarray = np.array([[-1] * n + [1] * n])
|
||||
return np.sum(
|
||||
[np.sum(ndimage.filters.convolve(gray, W) ** 2) for W in [edge, edge.T]]
|
||||
return float(
|
||||
np.sum(
|
||||
[np.sum(ndimage.filters.convolve(gray, W) ** 2)
|
||||
for W in [edge, edge.T]]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue