HSV变换
import random
import math
import cv2
import numpy as np
from pathlib import Path
from PIL import Image
from matplotlib import pyplot as plt
f = "./tmp/Cats_Test49.jpg"
f2 = "./tmp/golf.jpg"
im = plt.imread(f)
im2 = plt.imread(f2)
# plt.subplot(1,2,1)
# plt.imshow(im)
# plt.title("dogs")
# plt.subplot(1,2,2)
# plt.imshow(im2)
# plt.title("golf")
# plt.show()
"""
HSV变换
"""
hgain=0.5
sgain=0.5
vgain=0.5
# np.random.uniform(-2,2,3) 产生-2到2 范围内的3个随机数
r = np.random.uniform(-2, 2, 3) * [hgain, sgain, vgain] + 1
hue, sat, val = cv2.split(cv2.cvtColor(im, cv2.COLOR_BGR2HSV))
dtype = im.dtype # uint8
x = np.arange(0, 256, dtype=r.dtype)
plt.figure(figsize=(20, 100))
plt.subplot(1,5,1)
plt.imshow(im)
plt.title("origin")
# 调整色调
lut_hue = ((x * r[0]) % 180).astype(dtype)
hue_image = cv2.merge(
(