Professional Documents
Culture Documents
4.2 Motivation
In the introduction to this chapter, we considered the problems inherent in using
the MSE (Mean Square Error) and SNR (Signal to Noise Ratio) to compare
two images. It was seen that the MSE and SNR have little relationship to
the way that humans perceive the differences between two images. Although
incorporating concepts involved in human perception may seem a difficult task, a
new image error measure was presented in Chapter 1 which, despite its simplicity,
incorporates some concepts involved in human appraisal of images.
In Chapter 3, the basic neural network restoration algorithm described in
Chapter 2 was expanded to restore images adaptively using simple human visual
concepts. These adaptive algorithms obtained superior results when compared to
the non-adaptive algorithm, and were shown to produce a more robust restora-
tion when errors occurred due to insufficient knowledge of the degrading function.
Despite the improved performance of the adaptive algorithms, it is still not sim-
ple to choose the correct values of the constraint parameter, λ. In the case of
the adaptive algorithms described in Chapter 3, the problem is compounded by
the fact that many values of λ must be selected, rather than just one value as
in the non-adaptive case. In addition, the selected λ values must be related to
local variance levels.
We desire to create an algorithm which can adaptively restore an image, using
simple concepts involved in human perception, with only a few free parameters
to be set. Such an algorithm would be more robust and easier to use than the
N −1 M −1
1 2
LVMSE = (σ (f (x, y)) − σA
2
(g(x, y)))2 (4.1)
N M x=0 y=0 A
2
where σA (f (x, y)) is the variance of the local region surrounding pixel (x, y) in
2
the first image and σA (g(x, y)) is the variance of the local region surrounding
pixel (x, y) in the image with which we wish to compare the first image.
Hence the new cost function we suggest is:
N −1 M −1
1 λ θ 2
E= g − Hf̂ 2 + Df̂ 2 + (σ (f̂ (x, y)) − σA
2
(g(x, y)) )2 (4.2)
2 2 N M x=0 y=0 A
2
In this case, σA (f̂ (x, y)) is the variance of the local region surrounding pixel
2
(x, y) in the image estimate and σA (g(x, y)) is the variance of the local region
surrounding pixel (x, y) in the degraded image scaled to predict the variance in
the original image. The comparison of local variances rather than local standard
deviations was chosen for the cost function since it is easier and more efficient
to calculate. The first two terms in (4.2) ensure a globally balanced restoration,
2
whereas the added LVMSE term enhances local features. In (4.2), σA (g(x, y))
is determined as follows. Since the degraded image has been blurred, image
variances in g will be lower than the corresponding variances in the original
2
image. In this case, the variances σA (g(x, y)) would be scaled larger than
2
σA (g(x, y)) to reflect the decrease in variance due to the blurring function. In
general, if we consider an image degraded by a process which is modeled by (2.2),
then we find that a useful approximation is:
2
σA 2
(g(x, y)) = K(x, y)(σA (g(x, y)) − J(x, y)) (4.3)
i = x + yN (4.4)
Define xk and y k as the two-dimensional x and y values associated with pixel
k by (4.4).
Define the two-dimensional distance between pixels i and j as:
Let f i = Φi f (4.6)
then
0, A−1
dis2́(i, j) >
i
[f ]j = 2 (4.7)
A−1
fj , dis2́(i, j) ≤
2
Φi has the effect of setting to zero all pixels not within the A by A neighbor-
hood centered on the pixel with coordinates xi , y i . As a shortened notation we
will denote [f i ]j as fji . Using this notation, the average pixel value in the A by
A region surrounding pixel i is given by:
1 M N i
MA (i) = f
A2 j=1 j
N M N M
Let βi = j=1 (fji )2 and γi = j=1 fji . Then the estimated variance of the
A by A region surrounding pixel i is given by:
βi γi2
Vi = − (4.8)
A2 A4
Note that, strictly speaking, V i is an estimate of the variance of this region
given the available pixel values. The true variance of this region is the expecta-
tion of the second moment. However, (4.8) is a suitable approximation given the
available data. In the rest of this analysis, (4.8) will be called the local variance
2
and the term estimated local variance will be used to refer to σA (g(x, y)) .
The LVMSE between the image estimate, f̂ , and the original image, f , may
then be written as:
1 i
NM
LVMSE(f̂ , f ) = (V (f̂ ) − V i (f ))2 (4.9)
N M i=1
δ 2 δ
LVMSE = (V i (f̂ ) − V f i ) (V i (f̂ ) − V f i ) (4.10)
δ fˆi NM δ fˆi
Note that this formula is an approximation of the gradient which ignores
the contributions of the local variances of the pixels adjacent to i to the overall
LVMSE of the image.
δ 4 fˆi βi fˆi γi2 3
ˆi V f i − βi γi + γ + γi V f
i
LVMSE = − − f (4.12)
ˆ
δ fi N M A2 A2 A4 A4 A6 A2
Multiplying (4.12) by θ and subtracting it from the input to the neuron gives
us the negative gradient of the cost function. Given a change in the value of
pixel i, the resultant change in energy is the previous change in energy given by
(2.12) plus θ times the change in LVMSE. The change in LVMSE is given by:
1
i 2 i 2
∆LVMSE = Vnew − V f i − Vold − V fi (4.13)
NM
where
Algorithm 4.1.
repeat
{
for i = 1, . . . , L do
{
L
ui = bi + j=1 wij fˆj
L
2
βiold = j=1 fˆji
L
γiold = j=1 fˆji
old 2
β old γ
i
Vold = i2 − i 4
A A
δE
− = ui
δ fˆi
2 old 3
4θ fˆi βiold fˆi γiold β old old
γ γ γ old
V f i
− − − fˆi V f −
i i i
+ i
+ i
N M A2 A2 A4 A4 A6 A2
1, u>0
ˆ δE
∆fi = G − where G(u) = 0, u=0
δ fˆi
−1, u < 0
2
2
∆fˆi ˆ
2fi ∆fi ˆ old
2γ ∆fi ˆ ∆ ˆi
f
i
Vnew = Vold i
+ 2
+ 2
− i 4 −
A
2 A
A A4
1 θ 2 i 2
∆E = − wii ∆fi − ui ∆fi + ˆ ˆ Vnew − V f i − Vold
i
− V fi
2 NM
repeat
{
fˆi (t + 1) = K(f ˆi (t) + ∆fˆi )
0, u < 0
where K(u) = u, 0 ≤ u ≤ S
S, u > S
ui = ui + wii ∆fi ˆ
Note that Algorithm 4.1 still utilizes some features of Algorithm 2.3, specifi-
cally the use of bias inputs and interconnection strength matrices.
4.3.2 Analysis
It is important to verify that Algorithm 4.1 acts upon a pixel in the intended
manner. To verify this, we must examine the LVMSE term in Algorithm 4.1
more closely.
According to (4.12), the gradient of the LVMSE term of the cost function,
when all pixels except fˆi are held constant, is given by:
δ 2 βi γi2 2fˆi 2γi
LVMSE = − 4 −Vf i
− 4
δ fˆi N M A2 A A2 A
L L
Note that βi = j=1 (fji )2 and γi = j=1 fji can be rewritten as βi = β́i + fˆi2
ˆ L L
i 2
and γi = γ́i + fi where β́i = j=1,j=i (fj ) and γ́i = j=1,j=i fji . In this way,
ˆ
we can extract the elements of (4.12) that depend on fi . Hence we obtain:
δ 2 fˆi2 β́i (fˆi + γ́i )2 2fˆi 2 ˆi
f 2γ́ i
LVMSE = + 2− − V fi − 4 − 4
δ fˆi N M A2 A A4 A2 A A
2 fˆi2 fˆi2 2fˆi γ́i β́i γ́i2 2fˆi 2fˆi 2γ́i
= − − + − − V fi − − 4 (4.15)
NM A2 A4 A4 A2 A4 A 2 A 4 A
γ́ 2
Observe that Aβ́i2 − Ai4 is an approximation to the local variance at pixel i
γ́ 2
neglecting the contribution of the value of pixel i itself. Let V́ = Aβ́i2 − Ai4 . As
A increases in value, V́ approaches the value of the local variance at pixel i.
Similarly, we can define an approximation to the local mean of pixel i as:
1
N M
γ́i
Ḿ = fˆji = 2 (4.16)
A2 A
j=1,j=i
δ 4 1 1 2fˆi Ḿ ˆi 1 − 1 − Ḿ
LVMSE = fˆi2 − − + J f
ˆ
δ fi N M A2 A2 A4 A2 A2
(4.17)
where J = V́ − V f i .
The points for which (4.17) is equal to zero are the stationary points of the
LVMSE term in (4.2). Equation (4.17) is zero when fˆi = Ḿ /(1 − A12 ). This cor-
responds to the case where fˆi is approximately equal to its local mean. Equation
(4.17) also has zeroes when fˆi satisfies:
2Ḿ 4Ḿ 2 1 1
± − 4J −
A2 A4 A2 A4
fˆi =
1 1
2 − 4
A2 A
If A is greater than or equal to 5, then the error resulting from approximating
1/A2 − 1/A4 as 1/A2 is less than 4%. Therefore, if we assume that A is large
enough that 1/A2 1/A4 then (4.17) has zeroes at:
Ḿ 2
fˆi ≈ Ḿ ± A −J (4.18)
A2
Note that (4.18) indicates that if J > 0, (4.18) may not have a real-valued
solution. There are three cases to examine.
CASE 1: J < 0
When J < 0, then local variance of the region surrounding pixel i is less than the
estimated local variance. Equations (4.18) and (4.17) indicate that the LVMSE
term in the cost function will have three stationary points. The function will then
appear as Figure 4.1. The stationary point given by fˆi = Ḿ /(1 − A12 ) becomes
a maximum and the function has two minimum given by (4.18). At least one of
these minimum will be in the domain fˆi > 0, and so as long as J is not excessively
negative it is possible to minimize the LVMSE term in the cost function in this
case.
This is as one would expect since if J < 0, then the variance of the local region
surrounding pixel i needs to be increased to meet the target variance estimate. It
is always possible to increase the local variance of pixel i by moving that pixel’s
value further from the mean. This is why the stationary point fˆi = Ḿ /(1 − A12 ),
which is the point where fˆi is approximately equal to the mean of the local
region, becomes a maximum.
1.5
LVMSE term
0.5
0
0 50 100 150 200 250 300
Pixel value
Ḿ 2
CASE 2: 0 < J ≤ A2
2
When 0 < J ≤ Ḿ A2 , then the local variance of region surrounding pixel i is greater
than the estimated local variance, but the difference is not great. Equations
(4.18) and (4.17) indicate that the LVMSE term in the cost function will again
have three stationary points. The function will then appear as Figure 4.2.
The stationary point given by fˆi = Ḿ /(1 − A12 ) becomes a maximum and the
function has two minimum given by (4.18). At least one of these minima will be
in the domain fˆi > 0, and it is again possible to minimize the LVMSE term in
the cost function in this case.
When J > 0, the local variance of pixel i needs to be decreased to match the
2
target variance estimate. If J ≤ Ḿ A2 , it is possible to match the local variance
of pixel i with the target variance estimate by moving that pixel’s value toward
the mean pixel value in the local region. The stationary point fˆi = Ḿ /(1 − A12 ),
which is the point where fˆi is approximately equal to the mean of the local
2
Ḿ 2
region, is again a maximum, unless J = Ḿ A2 . When J = A2 , all three station-
ary points correspond to the same value and the function has one minimum at
fˆi = Ḿ /(1 − A12 ) ≈ Ḿ .
2.5
2
LVMSE term
1.5
0.5
0
0 50 100 150 200 250 300
Pixel value
Ḿ 2
CASE 3: J > A2
2
When J > Ḿ A2 , then the local variance of region surrounding pixel i is greater
than the estimated local variance, but the difference is too large for equality to be
reached by changing a single pixel’s value. Equation (4.18) will have no solutions
and the LVMSE term in the cost function will have one stationary point. The
function will then appear as Figure 4.3.
The stationary point given by fˆi = Ḿ /(1 − A12 ) becomes a minimum, where
Ḿ > 0 since all pixel values are constrained to be positive. So the minimum will
be in the domain fˆi > 0, and it is possible to minimize the LVMSE term in the
cost function in this case.
2
When J > Ḿ A2 , the local variance of pixel i needs to be decreased to match the
target variance estimate. The minimum local variance is obtained by decreasing
the value of the current pixel to the mean value of the local region. In this
case, the minimum local variance obtainable by altering one pixel’s value is still
greater than the estimate. The stationary point fˆi = Ḿ /(1 − A12 ) is the point
where fˆi is approximately equal to the mean of the local region. Thus, the pixel
will move toward the mean value of the local region, hence reducing the local
variance as much as possible.
By examining each of the three cases above we can see that the LVMSE term
in the cost function is well behaved despite its non-linear nature. In all cases a
minimum exists and the local variance of the current pixel’s region will always
move closer to the target variance estimate.
12
10
LVMSE term
0
0 50 100 150 200 250 300
Pixel value
−1 M −1
2
1 λ θ
N σA2
(f̂ (x, y))
E = g − Hf̂ 2 + Df̂ 2 + ln 2 (g(x, y)) (4.19)
2 2 N M x=0 y=0 σA
We will denote this new term in (4.19) the Log Local Variance Ratio (Log
LVR) term.
βi γi2
Vi = −
A2 A4
L L
where βi = j=1 (fji )2 and γi = j=1 fji .
The gradient of the Log LVR term in (4.19) is given by:
i
δ 1 V V fi 1 2fˆi 2γi
Log LVR = 2 ln − 4
δ fˆi NM Vf i V i V fi A2 A
βi γi2 γi
− fˆi −
4 2 A4 A2
= ln A (4.20)
NM V fi γi2
βi −
A2
Similarly, given a change in the value of pixel i, the resultant change in energy
is the previous change in energy given by (2.12) plus θ times the change in Log
LVR. The change in Log LVR is given by:
i 2 i 2
1 Vnew V
∆ Log LVR = ln i
− ln oldi (4.21)
NM Vf Vf
Algorithm 4.2.
repeat
{
for i = 1, . . . , L do
{
L
ui = bi + j=1 wij fˆj
L
2
βiold = j=1 fˆji
L
γiold = j=1 fˆji
old 2
βiold γ
Vold = 2 − i 4
i
A A
βi γi2 γi
− fˆi − 2
δE 4θ 2 A
4
− = ui − ln A A
δ fˆi NM V fi γ2
βi − i2
A
1, u>0
δE
∆fˆi = G − where G(u) = 0, u=0
δ fˆi
−1, u < 0
2
2
∆fˆi ˆ
2fi ∆fi ˆ old
2γ ∆fi ˆ ∆ ˆi
f
i
Vnew i
= Vold + + − i 4 −
A2 A2 i 2
A 4
i
2A
1 2 θ V V
∆E = − wii ∆fˆi − ui ∆fˆi + ln new
− ln oldi
2 NM V fi Vf
repeat
{
fˆi (t + 1) = K(f ˆi (t) + ∆fˆi )
0, u < 0
where K(u) = u, 0 ≤ u ≤ S
S, u > S
ui = ui + wii ∆fi ˆ
Note that Algorithm 4.2 is almost identical to Algorithm 4.1 and still utilizes
some features of Algorithm 2.3, specifically the use of bias inputs and intercon-
nection strength matrices.
4.4.2 Analysis
As in the previous section, we will verify the correct operation of Algorithm 4.2.
To verify this, we must examine the Log LVR term in (4.19) more closely.
The gradient of the Log LVR term of the cost function when all pixels except
fˆi are held constant is given by:
ˆ
βi γi2 fi γi
− 4 2 − 4
δ 4 2 A
Log LVR = ln A A
βi
A (4.22)
δ fˆi NM V fi γi2
− 4
A2 A
L L
Note that βi = j=1 (fji )2and γi = j=1 fji can be rewritten as βi = β́i + fˆi2
ˆ L L
i 2
and γi = γ́i + fi where β́i = j=1,j=i (fj ) and γ́i = j=1,j=i fji . In this way,
ˆ
we can extract the elements of (4.22) that depend on fi . Hence we obtain:
δ
Log LVR =
δ fˆi
1 1 2fˆi γ́i β́i γ́ 2
fˆi γ́i fˆi
ln fˆi ( 2 − 4 ) −
2
+ 2 − 4 − ln(V f )
i i
− 4− 4
4 A A A4 A A A2 A A
NM 1 1 2fˆi γ́i β́i γ́ 2
fˆi2 ( 2 − 4 ) − 4
+ 2 − i4
A A A A A
If we assume that A is large enough so that A2 A4 , then:
1 1
δ
Log LVR =
δ fˆi