在图像的随机变换中,使用cvtCOLOR()h函数实现图像色彩的变换。
实例代码:
import numpy as np
import cv2
import matplotlib.pyplot as plt

img = cv2.imread(“C:\lena.jpg”)
plt.subplot(2,3,1)
plt.imshow(img)
img_bgr_hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
plt.subplot(2,3,2)
plt.imshow(img_bgr_hsv)
img_bgr_hsv_copy = img_bgr_hsv.copy()
img_bgr_hsv_copy[:,:,0] = (img_bgr_hsv_copy[:,:,0]+np.random.random()) % 180
plt.subplot(2,3,3)
plt.imshow(img_bgr_hsv_copy)
img_bgr_hsv_copy[:,:,1] = (img_bgr_hsv_copy[:,:,1]+np.random.random()) % 180
plt.subplot(2,3,4)
plt.imshow(img_bgr_hsv_copy)
img_bgr_hsv_copy[:,:,2] = (img_bgr_hsv_copy[:,:,2]+np.random.random()) % 180
plt.subplot(2,3,5)
plt.imshow(img_bgr_hsv_copy)
img_bgr_hsv_bgr = cv2.cvtColor(img_bgr_hsv_copy,cv2.COLOR_HSV2BGR)
plt.subplot(2,3,6)
plt.imshow(img_bgr_hsv_bgr)
plt.show()

显示结果:
图像处理中图像色彩的随机变换

相关文章:

  • 2021-11-05
  • 2021-11-10
  • 2021-08-09
  • 2021-12-11
  • 2022-01-19
  • 2021-12-15
猜你喜欢
  • 2021-11-15
  • 2022-12-23
  • 2022-01-07
  • 2022-01-14
  • 2021-12-16
相关资源
相似解决方案