TUSR-Net: Triple Unfolding Single Image Dehazing With Self-Regularization and Dual…
- User
TUSR-Net: Triple Unfolding Single Image Dehazing With Self-Regularization and Dual Feature to Pixel Attention这篇文章的损失函数如何计算的
- Assistant
在TUSR-Net论文中,损失函数包含两个部分:感知损失和自正则化损失。
感知损失: TUSR-Net使用感知损失来测量还原图像和原始清晰图像之间的差异。感知损失是使用预训练的VGG-16网络计算的。具体地,在VGG-16网络中选择了多个层作为特征提取器,然后通过计算生成图像和原始清晰图像在这些层的特征之间的L1损失来计算感知损失,其中生成图像是通过TUSR-Net从输入图像中去除雾气得到的。
自正则化损失: TUSR-Net还使用自正则化损失来鼓励生成图像能够具有平滑的结构,以避免过度去除雾气导致细节损失或产生虚假纹理。自正则化损失计算生成图像的梯度平方和,即对生成图像的每个像素点计算其梯度在x和y方向上的平方和,并将其作为自正则化损失。
总损失: 最终,将感知损失和自正则化损失加权加和,得到总损失。具体来说,总损失由感知损失和自正则化损失之间的加权和组成,其中感知损失由预先定义的权重乘以感知损失计算得到,自正则化损失也由预先定义的权重乘以自正则化损失计算得到。同时,还添加了一个平均背景亮度惩罚项,以减少生成图像的背景亮度。总损失的计算方式如下:
Total Loss = λ1 * Perception Loss + λ2 * Self-regularization Loss + λ3 * Background Luminance Penalty Loss
其中,λ1、λ2和λ3是预先定义的权重。
- User
function out = wls_optimization(in, data_weight, guidance, lambda) %Weighted Least Squares optimization solver. % Given an input image IN, we seek a new image OUT, which, on the one hand, % is as close as possible to IN, and, at the same time, is as smooth as % possible everywhere, except across significant gradients in the hazy image. % % Input arguments: % ---------------- % in - Input image (2-D, double, N-by-M matrix). % data_weight - High values indicate it is accurate, small values % indicate it's not. % guidance - Source image for the affinity matrix. Same dimensions % as the input image IN. Default: log(IN) % lambda - Balances between the data term and the smoothness % term. Increasing lambda will produce smoother images. % Default value is 0.05 % % This function is based on the implementation of the WLS Filer by Farbman, % Fattal, Lischinski and Szeliski, "Edge-Preserving Decompositions for % Multi-Scale Tone and Detail Manipulation", ACM Transactions on Graphics, 2008 % The original function can be downloaded from: %
- Assistant
该函数实现了加权最小二乘(Weighted Least Squares)优化求解器,用于对输入图像进行优化处理,使其在保持与原始图像接近的同时尽可能平滑。
参数:
- in: 输入图像,2维double类型的N×M矩阵。
- data_weight: 数据权重,高值表示数据准确性高,小值表示数据不准确。
- guidance: 亲和矩阵的源图像,与输入图像in具有相同的尺寸。默认情况下,为log(IN)。
- lambda: 数据项和平滑项之间的平衡参数。增加lambda会产生更平滑的图像。默认值为0.05。
函数首先根据亲和性图像计算相邻像素之间的亲和性。然后,构建一个基于梯度的五点空间非均匀拉普拉斯矩阵。通过将数据权重归一化并构建数据项矩阵Adata和平滑项矩阵Asmoothness,最后将二者相加得到总的矩阵A和向量b。然后使用线性方程组求解器对方程Ax=b进行求解,得到优化后的图像out。
最后,将输出向量out重新reshape成与输入图像相同尺寸的矩阵,作为优化后的图像。