I am able to convert an image from the RGB to HSV colorspace, but how can I then manipulate those values using the HSV scale as outlined in the PIL documentation?
img = Image.open("assets/image.png")
img = img.convert('HSV')
img.show()
You can convert the image to a NumPy array and manipulate it from there.
For example, to shift the hue:
import numpy as np
from PIL import image
def hue_shift(img, amount):
hsv_img = img.convert('HSV')
hsv = np.array(hsv_img)
hsv[..., 0] = (hsv[..., 0]+amount) % 360
new_img = Image.fromarray(hsv, 'HSV')
return new_img.convert('RGB')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With