From 35b039a39a43de4c5edb9d152fa6345629b25423 Mon Sep 17 00:00:00 2001 From: Nicolas Bertrand Date: Thu, 9 Oct 2025 19:39:28 +0200 Subject: [PATCH] update calibration --- src/nenuscanner/calibration.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/nenuscanner/calibration.py b/src/nenuscanner/calibration.py index 8ef749c..63e1a07 100755 --- a/src/nenuscanner/calibration.py +++ b/src/nenuscanner/calibration.py @@ -28,7 +28,7 @@ def calibrate(input_dir: str): # Camera parameters nu, nv, nc = images[0].shape - nspheres = 5 + nspheres = 4 focal_mm = 35 matrix_size = 24 focal_pix = nu * focal_mm / matrix_size @@ -41,14 +41,15 @@ def calibrate(input_dir: str): pixels = np.reshape(max_image / 255.0, (-1, 3)) # Initialize parameters for GMM - init_params = np.ones(2), np.broadcast_to(np.eye(3) * 0.1, (2, 3, 3)), np.asarray([[0, 0, 0], [1, 1, 1]]) + # init_params = np.ones(2), np.broadcast_to(np.eye(3) * 0.1, (2, 3, 3)), np.asarray([[0, 0, 0], [1, 1, 1]]) # Estimate GMM parameters and classify pixels - estimated_params = math_utils.gaussian_mixture_estimation(pixels, init_params, it=10) - classif = np.asarray(math_utils.maximum_likelihood(pixels, estimated_params), dtype=bool) + # estimated_params = math_utils.gaussian_mixture_estimation(pixels, init_params, it=10) + # classif = np.asarray(math_utils.maximum_likelihood(pixels, estimated_params), dtype=bool) # Refine classification to select the appropriate binary mask - rectified_classif = math_utils.select_binary_mask(classif, lambda mask: np.mean(pixels[mask])) + # rectified_classif = math_utils.select_binary_mask(classif, lambda mask: np.mean(pixels[mask])) + rectified_classif = np.mean(pixels, axis=-1) > 0.03 # Identify the largest connected components (spheres) and extract their borders sphere_masks = math_utils.get_greatest_components(np.reshape(rectified_classif, (nu, nv)), nspheres) @@ -79,7 +80,7 @@ def calibrate(input_dir: str): # Load grey values from images for the identified sphere regions def to_grayscale(image): - return [np.mean(image, axis=-1)[sphere_geometric_masks[i]] / 255.0 for i in range(nspheres)] + return [np.power(np.mean(image, axis=-1)[sphere_geometric_masks[i]] / 255.0, 1.0) for i in range(nspheres)] grey_values = np.asarray(list(map(to_grayscale, images)), dtype=object)