计算机视觉中的图像去雾技术
图像去雾技术是计算机视觉领域的重要研究方向,旨在消除雾、霾等天气条件对图像质量的影响,恢复清晰的场景内容。该技术在自动驾驶、视频监控、遥感成像等领域有广泛应用。
图像去雾的基本原理
雾天图像退化模型通常表示为: I(x) = J(x)t(x) + A(1 - t(x)) 其中I(x)是观测到的有雾图像,J(x)是待恢复的无雾图像,t(x)是透射率,A是大气光值。去雾的目标是从I(x)估计J(x)。
基于暗通道先验的去雾方法
暗通道先验是一种有效的去雾方法,基于统计观察发现:在无雾图像的局部区域中,至少有一个颜色通道的像素值非常低。
import cv2
import numpy as np
def dark_channel(img, patch_size=15):
min_channel = np.min(img, axis=2)
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (patch_size, patch_size))
dark = cv2.erode(min_channel, kernel)
return dark
def estimate_atmospheric_light(img, dark, top_percent=0.1):
img_flat = img.reshape(-1, 3)
dark_flat = dark.ravel()
num_pixels = int(dark_flat.shape[0] * top_percent)
indices = np.argpartition(-dark_flat, num_pixels)[:num_pixels]
atmospheric_light = np.max(img_flat[indices], axis=0)
return atmospheric_light
def estimate_transmission(img, atmospheric_light, omega=0.95, patch_size=15):
normalized_img = img / atmospheric_light
transmission = 1 - omega * dark_channel(normalized_img, patch_size)
return transmission
def guided_filter(I, p, r, eps):
mean_I = cv2.boxFilter(I, cv2.CV_64F, (r, r))
mean_p = cv2.boxFilter(p, cv2.C
图像去雾技术原理解析
411

被折叠的 条评论
为什么被折叠?



