I want single YCbCr-channels that are smaller or bigger that 128 of a picture set to 0. But I keep getting the error "can't assign to comparison" and I don't really know what I am doing wrong.
This is the code:
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
And this picture shows the different modes I implemented:
you can use np.where: