赞
踩
- import cv2
- import numpy as np
-
- def dehaze(image):
- """简单去雾算法,使用直方图均衡化来增强图像"""
- # 将图像转换为YUV颜色空间
- yuv_image = cv2.cvtColor(image, cv2.COLOR_BGR2YUV)
-
- # 对Y通道(亮度)进行直方图均衡化
- yuv_image[:, :, 0] = cv2.equalizeHist(yuv_image[:, :, 0])
-
- # 将YUV图像转换回BGR
- dehazed_image = cv2.cvtColor(yuv_image, cv2.COLOR_YUV2BGR)
-
- return dehazed_image
-
- def derain(image):
- """简单去雨算法,使用高通滤波器去除细小的雨滴噪声"""
- # 转换为灰度图像
- gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
-
- # 使用高通滤波器去除雨滴
- high_pass_filter = cv2.GaussianBlur(gray_image, (21, 21), 0)
- derained_image = cv2.subtract(gray_image, high_pass_filter)
-
- # 增强对比度
- derained_image = cv2.equalizeHist(derained_image)
-
- # 将灰度图转换回BGR格式
- derained_image = cv2.cvtColor(derained_image, cv2.COLOR_GRAY2BGR)
-
- return derained_image
-
- # 加载图像
- image = cv2.imread('
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。