INNER CODE UNIT · Python
opaque_count
KennethJAllen/proper-pixel-art · proper_pixel_art/colors.py:171
opaque_count = np.sum(cell_alpha >= alpha_threshold)
# If enough of the cell is transparent (see majority_fraction), return fully transparent
if _is_majority_transparent(opaque_count, total_pixels, majority_fraction):
return (0, 0, 0, 0)
# Otherwise return most common color with full opacity
cell_color = get_opaque_cell_color(cell_pixels)
return cell_color
def dominant_rgb_by_binning(
rgb_pixels: np.ndarray, bin_size: int = _DEFAULTS.bin_size
) -> RGB:
"""
Find the dominant color of ``rgb_pixels`` using offset binning.
RGB space is split into bins of width ``bin_size`` along two grids: a