pyaesthetics.colordetection.get_colors

pyaesthetics.colordetection.get_colors(img, plot=False, plotncolors=5, clusterfactor=50)

Extracts and optionally plots the most frequent colors in an image.

This function reshapes the image to a list of RGB values, clusters these colors based on the specified cluster factor to reduce the number of unique colors, and returns the most common colors. Optionally, it can plot the top plotncolors colors as rectangles.

Parameters: - img (numpy.ndarray): The input image as a NumPy array of shape (height, width, 3). - plot (bool): If True, a plot of the top plotncolors colors is displayed. Default is False. - plotncolors (int): The number of top colors to plot. Default is 5. - clusterfactor (int): The factor by which to cluster similar colors. Default is 50.

Returns: - numpy.ndarray: An array of RGB values representing the most frequent colors.