INNER CODE UNIT · Python
new_size
KennethJAllen/proper-pixel-art · proper_pixel_art/colors.py:136
new_size = (alpha_img.width * scale_factor, alpha_img.height * scale_factor)
scaled_alpha_img = alpha_img.resize(new_size, Image.Resampling.NEAREST)
return np.array(scaled_alpha_img)
else:
return alpha_channel
def get_opaque_cell_color(cell_pixels: np.ndarray) -> RGBA:
"""
cell_pixels: shape (height_cell, width_cell, 3), dtype=uint8
returns the most frequent RGB tuple in the cell_pixels block, with 255 in fourth entry for opaque alpha.
"""
flat = list(map(tuple, cell_pixels.reshape(-1, 3)))
cell_color = Counter(flat).most_common(1)[0][0]
return (*cell_color, 255)
def get_cell_color_with_alpha(