diff --git a/pylabrobot/plate_reading/biotek_backend.py b/pylabrobot/plate_reading/biotek_backend.py index 059cc388c4b..e6867243e5a 100644 --- a/pylabrobot/plate_reading/biotek_backend.py +++ b/pylabrobot/plate_reading/biotek_backend.py @@ -920,9 +920,15 @@ async def evaluate_focus(focus_value): f"cv2 needs to be installed for auto focus. Import error: {_CV2_IMPORT_ERROR}" ) + # cut out 25% on each side + np_image = np.array(image, dtype=np.float64) + height, width = np_image.shape[:2] + crop_height = height // 4 + crop_width = width // 4 + np_image = np_image[crop_height : height - crop_height, crop_width : width - crop_width] + # NVMG: Normalized Variance of the Gradient Magnitude # Chat invented this i think - np_image = np.array(image, dtype=np.float64) sobel_x = cv2.Sobel(np_image, cv2.CV_64F, 1, 0, ksize=3) sobel_y = cv2.Sobel(np_image, cv2.CV_64F, 0, 1, ksize=3) gradient_magnitude = np.sqrt(sobel_x**2 + sobel_y**2)