下面是一个简单的Python代码片段,实现了对水下图像的简单增强:
import cv2
import numpy as np
# 读取图像
img = cv2.imread("underwater_image.jpg")
# 通过对色调的修改来增强图像
img_hls = cv2.cvtColor(img, cv2.COLOR_BGR2HLS)
img_hls[:,:,1] = np.where(img_hls[:,:,1] <= 150, img_hls[:,:,1] * 1.5, img_hls[:,:,1])
img = cv2.cvtColor(img_hls, cv2