update calibration
This commit is contained in:
parent
80d259e519
commit
35b039a39a
|
|
@ -28,7 +28,7 @@ def calibrate(input_dir: str):
|
||||||
|
|
||||||
# Camera parameters
|
# Camera parameters
|
||||||
nu, nv, nc = images[0].shape
|
nu, nv, nc = images[0].shape
|
||||||
nspheres = 5
|
nspheres = 4
|
||||||
focal_mm = 35
|
focal_mm = 35
|
||||||
matrix_size = 24
|
matrix_size = 24
|
||||||
focal_pix = nu * focal_mm / matrix_size
|
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))
|
pixels = np.reshape(max_image / 255.0, (-1, 3))
|
||||||
|
|
||||||
# Initialize parameters for GMM
|
# 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
|
# Estimate GMM parameters and classify pixels
|
||||||
estimated_params = math_utils.gaussian_mixture_estimation(pixels, init_params, it=10)
|
# estimated_params = math_utils.gaussian_mixture_estimation(pixels, init_params, it=10)
|
||||||
classif = np.asarray(math_utils.maximum_likelihood(pixels, estimated_params), dtype=bool)
|
# classif = np.asarray(math_utils.maximum_likelihood(pixels, estimated_params), dtype=bool)
|
||||||
|
|
||||||
# Refine classification to select the appropriate binary mask
|
# 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
|
# Identify the largest connected components (spheres) and extract their borders
|
||||||
sphere_masks = math_utils.get_greatest_components(np.reshape(rectified_classif, (nu, nv)), nspheres)
|
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
|
# Load grey values from images for the identified sphere regions
|
||||||
def to_grayscale(image):
|
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)
|
grey_values = np.asarray(list(map(to_grayscale, images)), dtype=object)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue