slmsuite.holography.toolbox.lloyds_algorithm#

lloyds_algorithm(grid, vectors, iterations=10, plot=False)[source]#

Implements Lloyd’s Algorithm on a set of seed vectors to promote even vector spacing using the helper function voronoi_windows(). This iteratively forces a set of vectors away from each other until they become more evenly distributed over a space. This function could be made much more computationally efficient by using analytic methods to compute Voronoi cell area, rather than the current numerical approach.

Parameters:
  • grid ((array_like, array_like) OR SLM OR (int, int)) – See voronoi_windows().

  • vectors (array_like) – See voronoi_windows().

  • iterations (int) – Number of iterations to apply Lloyd’s Algorithm.

  • plot (bool) – Whether to plot each iteration of the algorithm.

Returns:

The result of Lloyd’s Algorithm.

Return type:

numpy.ndarray