计算图片中各种颜色的百分比
def cal_percent(image):
'''计算图像各颜色百分比'''
rgb = {
}
name = ade20k_labels.ade20K_color2lable #这个是颜色列表,自行创建一个即可
for row in range(image.shape[0]):
for col in range(image.shape[1]):
if (name[tuple(image[row, col])] not in rgb) or (row == 0 and col == 0):
rgb[name[tuple(image[row, col])]] = [1, tuple(image[row, col])]
else:
rgb[name[tuple(image[row, col])]][<