我想要单个 YCbCr 通道小于或大于 128 的图片设置为 0。但我不断收到错误“无法分配给比较”,我真的不知道我做错了什么。
这是代码:
def calc_coloursplash(image_data, modus):
ycbcr = image_data.convert('YCbCr')
if modus == 1:
ycbcr[:,:,1] <= 128 = 0
ycbcr[:,:,2] <= 128 = 0
elif modus == 2:
ycbcr[:,:,1] >= 128 = 0
ycbcr[:,:,2] <= 128 = 0
elif modus == 3:
ycbcr[:,:,1] >= 128 = 0
ycbcr[:,:,2] >= 128 = 0
elif modus == 4:
ycbcr[:,:,1] <= 128 = 0
ycbcr[:,:,2] >= 128 = 0
else:
print("There are only modes 1-4")
return ycbcr
这张图显示了我实现的不同模式: