预备知识

Z-score 标准化方法

Z-score 标准化方法是一种数据标准化方法,这种方法给定原始数据的均值(mean)和标准差(standard deviation) 进行数据的标准化,经过处理的数据均值为 0 ,方差为 1 。

X=XμσX^* = \frac{X-\mu}{\sigma}

其中,μ\mu 为原始数据的均值,σ\sigma 为原始数据的标准差。

其效果如下图所示:

image-20210224132901531原始数据的分布直方图

image-20210224133055886原始数据的均值和标准差分别为 0.25 和 0.1

image-20210224133248643处理后的数据直方图分布

image-20210224133432339处理后数据的均值和标准差分别为 0 和 1

Sigmoid 函数

Sigmoid 函数是一个具有 S 形曲线的函数,是良好的阈值函数,在(0 , 0.5)处中心对称,在(0,0.5)附近具有较大的斜率,而当数据趋向于正无穷和负无穷的时候,映射出来的值会无限趋近于 1 和 0 。

Y=Sigmoid(X)=11+exp(X)Y = Sigmoid(X) = \frac{1}{1+exp(-X)}

Sigmoid 函数的曲线如图:

image-20210224133829583

Prerequisites

Z-score Standardization Method

The Z-score standardization is a data standardization method. Given the mean and standard deviation of the original data, it standardizes the data; the processed data has a mean of 0 and a variance of 1.

X=XμσX^* = \frac{X-\mu}{\sigma}

where μ\mu is the mean of the original data and σ\sigma is the standard deviation of the original data.

Its effect is shown in the following figures:

image-20210224132901531Histogram of the original data distribution

image-20210224133055886The mean and standard deviation of the original data are 0.25 and 0.1, respectively

image-20210224133248643Histogram distribution of the processed data

image-20210224133432339The mean and standard deviation of the processed data are 0 and 1, respectively

Sigmoid Function

The Sigmoid function is a function with an S-shaped curve and is a good threshold function. It is centrally symmetric about (0, 0.5), has a relatively large slope near (0, 0.5), and when the data tends to positive and negative infinity, the mapped values infinitely approach 1 and 0.

Y=Sigmoid(X)=11+exp(X)Y = Sigmoid(X) = \frac{1}{1+exp(-X)}

The curve of the Sigmoid function is shown in the figure:

image-20210224133829583

算法简介

首先对输入图像分通道进行 Z-score 数据标准化:

Zc=inputcμcσcZ_c = \frac{input_c - \mu_c}{\sigma_c}

其中 cR,G,Bc \in {R , G , B}μ\mu 为输入数据的均值,σ\sigma 为输入数据的标准差。

将此标准化数据输入 Sigmoid 函数实现数据的归一化。

Nc=Sigmoid(Zc)=11+exp(Zc)N_c = Sigmoid(Z_c) = \frac{1}{1+exp(-Z_c)}

我们根据此标准化图像 N 计算 γ\gamma 值,用于对原图像进行非线性的颜色校正。

outputc=inputcγcoutput_c = input_c^{\gamma_c}

其中:

γc=mean(inputcNc)\gamma_c = mean(\frac{input_c}{N_c})

Algorithm Overview

First, apply Z-score standardization to the input image channel by channel:

Zc=inputcμcσcZ_c = \frac{input_c - \mu_c}{\sigma_c}

where cR,G,Bc \in {R , G , B}, μ\mu is the mean of the input data, and σ\sigma is the standard deviation of the input data.

Feed this standardized data into the Sigmoid function to normalize the data.

Nc=Sigmoid(Zc)=11+exp(Zc)N_c = Sigmoid(Z_c) = \frac{1}{1+exp(-Z_c)}

Based on this standardized image N, we compute the γ\gamma values, which are used to perform nonlinear color correction on the original image.

outputc=inputcγcoutput_c = input_c^{\gamma_c}

where:

γc=mean(inputcNc)\gamma_c = mean(\frac{input_c}{N_c})

Matlab 算法实现

数据归一化

Matlab Algorithm Implementation

Data Normalization

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function [outputs] = Normalize(arg,str)
if nargin == 1
str = 'Line';
end
if strcmp(str,'Line')
MAX = max(arg(:));
MIN = min(arg(:));
outputs = (arg - MIN)./ (MAX - MIN);
end
if strcmp(str,'sigmoid')
u = mean(arg(:));
s = std(arg(:));
tmp = (arg - u)./ s;
outputs = 1 ./ (1 + exp(-tmp));
end
if strcmp(str,'log')
alpha = max(arg(:)) + 1;
outputs = log(arg + 1) ./ log(alpha);
end
end

颜色校正

Color Correction

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function output = MyCC(input)
I = im2double(input);
R = I(:,:,1);
G = I(:,:,2);
B = I(:,:,3);

NR = Normalize(R,'sigmoid');
NG = Normalize(G,'sigmoid');
NB = Normalize(B,'sigmoid');

gammar = mean2(R ./ NR);
gammag = mean2(G ./ NG);
gammab = mean2(B ./ NB);

output(:,:,1) = R .^ gammar;
output(:,:,2) = G .^ gammag;
output(:,:,3) = B .^ gammab;
end

实验结果

Li-Chongyi 的图片

左为原图,右为结果图。


























































WB Images

左为原图,右为结果图。







Experimental Results

Li-Chongyi’s Images

Left is the original image, right is the result image.


























































WB Images

Left is the original image, right is the result image.







小声说ฅʕ•̫͡•ʔฅ

这个方法其实就是融合了最近刚刚发现的一种归一化方法和小红师姐现在的颜色校正算法。这个归一化是真的好用,我还要再用。😁

从实验结果上看和小红师姐原来方法的结果也极其相似,我试了一些原方法会毁掉的一些图片,现在依然会毁掉,大概就是那种图片要谨慎使用伽马校正吧。

把这个方法可以作为图像增强框架的预处理步骤,这些图片应该已经足够发一篇 高水 平论文了吧。

最后还要说一个可怕的事实:

这个 Sigmoid 归一化实在是太牛逼了,很多时候归一化后的图像 N 就已经很优秀了(起码从 Color Cast 的角度看)。

左为原图 input;中为本算法结果图 output;右为中间结果 N

那么问题来了,如果不加伽马校正,就一个归一化算创新吗?可是多数情况加了还不如不加,难受😭

本着“没有最水,只有更水”的写论文原则,就暂且忽略这个事实吧。

但是根据我对另一句名言的理解,即总有一张图片适合你的算法,我要强行解释我伽马校正的意义,对于下图来说,N 是不是存在着过度的增强呢?

左为原图 input;中为本算法结果图 output;右为中间结果 N

A Whisper ฅʕ•̫͡•ʔฅ

This method is actually a fusion of a normalization method I recently discovered and Senior Sister Xiao Hong’s current color correction algorithm. This normalization is really useful, and I will keep using it. 😁

In terms of experimental results, it is also extremely similar to the results of Senior Sister Xiao Hong’s original method. I tried some images that the original method would ruin, and they are still ruined now. I guess those are the kind of images where gamma correction should be used with caution.

This method can be used as a preprocessing step in an image enhancement framework, and these images should already be enough to publish a high-lev…el paper, right?

Finally, let me mention a terrible fact:

This Sigmoid normalization is simply too awesome. In many cases, the normalized image N is already excellent (at least from the perspective of Color Cast).

Left is the original input image; middle is the output result of this algorithm; right is the intermediate result N

So here is the question: without gamma correction, is just a normalization innovative? But in most cases, adding it is worse than not adding it. How sad😭

Following the paper-writing principle of “no most watery, only more watery”, let’s just ignore this fact for now.

But based on my understanding of another famous saying, namely “there is always an image that fits your algorithm”, I want to force an explanation of the significance of my gamma correction: for the image below, doesn’t N exhibit over-enhancement?

Left is the original input image; middle is the output result of this algorithm; right is the intermediate result N