In the previous section, we described the uniform property of the noise generation. We apply the property as a part of terms in the optimization process. We will describe how we set the objective function for the optimization (section 3.4.1) and extend the optimization to the multi-level hierarchical framework (section 3.4.2).
3.4.1 Objective Function
We applying Kolmogorov-Smirnov goodness of fit test introduced in the section 3.3.2 as a mechanism for preserving the gradient vectors to be uniformly distributed when modifying the gradient vectors. It is a part of terms in our objective function named 𝐸𝐾.𝑆 defined below:
𝐸𝐾.𝑆 = 𝐾𝑆 𝑋𝑖𝑑𝑒𝑎𝑙, 𝑋𝑜𝑏𝑠 = 𝑀𝑎𝑥 𝐹𝑖𝑑𝑒𝑎𝑙 𝑥 − 𝐹𝑜𝑏𝑠(𝑥)
where 𝑋𝑖𝑑𝑒𝑎𝑙 is the ideal uniform sample set used to compare with the observed 𝑋𝑜𝑏𝑠 samples. In 2D case, we collect the set 𝑋𝑖𝑑𝑒𝑎𝑙 from the uniform samples in 𝑅2. Since the length of all gradient vectors is 1, we can represent a vector X = (𝑥, 𝑦) by (𝑐𝑜𝑠𝜃, s𝑖𝑛𝜃). This reduces the dimension of variables in the optimization process.
In order to control the noise value, we require applying some controls on the gradient vectors. We simply extract the control information from the user input pattern. As shown in Figure 3.7, black color and red color denote noise value of 0 and 1, respectively. In this thesis, we focus on the 2D case. Thus, the noise function can represent as Equation 3.2. Let 𝑉𝑖= 𝑁𝑜𝑖𝑠𝑒 𝑥𝑖, 𝑦𝑖 and 𝐷𝑖 be the noise value to be optimized and user-specified noise value, respectively. The user-control term in our objective function is defined as follows.
𝐸𝐶𝑜𝑛 = (𝑉𝑖 − 𝐷𝑖)2
𝐼
𝑖=0
(3.7)
(3.8)
18
Figure 3.7: User control pattern.
where 𝐼 denotes the total number of user-specified noise values. Therefore, we can define our objective function 𝐸 as below:
𝐸 = 𝑤1𝐸𝐾.𝑆+ 𝑤2𝐸𝐶𝑜𝑛
where 𝑤1 and 𝑤2 are the control weight of these two terms to achieve not only the gradient vectors uniformly distributed but user-demanded control. As our experiment result, we set the 𝑤1 as 0.995 and 𝑤2 as 0.005 as the weight value. The Simulated Annealing algorithm that is a method for solving unconstrained optimization problems and it is often used when the search space is discrete. Hence, we apply this algorithm to solve our optimization problem.
3.4.2 Multi-Level Optimization
As described in section 3.2, fractal sum which used to express the natural-looking phenomenon is composed of several frequencies of noise from low frequency noise with higher amplitude and high frequency with lower amplitude.
However, we can divide the optimization process into several stages based on this property. As shown in Figure 3.8, low frequency noise controls the global shape of the fractal noise appearance. The low frequency noise uses the fewer gradient vectors due to the grid points contains in low frequency noise are fewer than those in high frequency noise. In low frequency noise, the range of hashing indices ( 𝑓𝑙𝑥 , 𝑓𝑙𝑦 ) is
(3.9)
19
(a) (b)
(c) (d)
Figure 3.8: (a) Low frequency noise controls the global shape of the noise appearance and the (b) high frequency noise controls the detail.
two times smaller than that in high frequency. That is, in low frequency noise the number of the grid points hashing by ( 𝑓𝑙𝑥 , 𝑓𝑙𝑦 ) is fewer than in high frequency noise. We simply classify the gradient vectors in accordance with which are shared by low frequency noise and the rest gradient vectors are classified into high frequency noise for our optimizing order. Besides, the gradient vectors corresponding to lower frequency noise will propagate the optimized gradient vectors to the higher frequency level as its initial guess. In this paper, we set the octaves 𝐹 = 4, the start amplitude 𝑎1 = 4 , 𝑓1 = 8 , 𝑓𝑙+1= 2𝑓𝑙 and 𝑎𝑙+1 = 2𝑎𝑙. Therefore, the fractal sum noise function can be expanded as follow:
𝐹𝑠𝑢𝑚 = 𝑁𝑜𝑖𝑠𝑒(𝑓𝑙𝑥, 𝑓𝑙𝑦) largest weight of this component. Our strategy is that satisfying the lowest frequency (3.10)
20
noise value which is prior to higher ones and propagate the gradient vectors to the next higher noise function. Besides, the number of gradient vectors shared by lower level is smaller than the higher one. Pseudo code 3.1 summarizes our hierarchy framework.
Assume that the frequency in the higher level is two times larger than the lower level, we list the gradient vectors shared by the two levels 𝑙 and 𝑙 + 1 as
𝑁𝑜𝑖𝑠𝑒 𝑓𝑙𝑥, 𝑓𝑙𝑦 → 𝐺[𝑃[𝑃 𝑓𝑙𝑥 + 𝑓𝑙𝑦 ]]
𝑁𝑜𝑖𝑠𝑒 𝑓𝑙+1𝑥, 𝑓𝑙+1𝑦) = 𝑁𝑜𝑖𝑠𝑒 2𝑓𝑙𝑥, 2𝑓𝑙𝑦) → 𝐺[𝑃[𝑃 2𝑓𝑙𝑥 + 2𝑓𝑙𝑦 ]]
we can derive the relation between the adjacent two levels and propagate the gradient vectors as this rule:
𝐺 𝑃 𝑃 𝑓𝑙+1𝑥 + 𝑓𝑙+1𝑦 = 𝐺[𝑃[𝑃 (𝑓𝑙+1𝑥)/2 + (𝑓𝑙+1𝑦)/2 ]
Figure 3.9 shows the schematic diagram of the propagation concept. Since the fractal noise value is cumulated from lower to higher frequency noise, satisfying the lower
Pseudo code 3.1: The algorithm of multi-level optimization //step 1: Classify the gradient vectors according to frequency.
//step 2: Assign random value to the lowest level for each gradient vector in lowest level{
assign a random value as initial guess.
}
//step 3:Multi-level optimization process for( l=0; 𝑙 < 𝐹 ; l++){
optimize the gradient vectors of current level l.
propagate the gradient to the next level i+1 as the initial guess.
}
(3.12) (3.11)
(3.13)
21
level ensured that the error between 𝑉𝑖 − 𝐷𝑖 might be reduced immensely. Since we propagate the gradient vectors to the higher level as its initial guess, the initial error value is usually smaller than that of the random initial guess. The optimization converges faster due to the more reasonable initial guess.
Figure 3.9: Propagate the gradient from low-freq level to high-freq level as the initial guess.
In each level, we simply modified the KS term and user-control term as below:
𝐸𝑙𝐾.𝑆 = 𝐾𝑆 𝑋𝑖𝑑𝑒𝑎𝑙, 𝑋𝑙𝑜𝑏𝑠
𝐸𝑙𝐶𝑜𝑛 = (𝑉𝑙𝑖 − 𝐷𝑖)2
𝐼
𝑖=0
where 𝑋𝑜𝑏𝑠𝑙 is the gradient vectors in the 𝑙 level and 𝑉𝑙𝑖 is the noise value we want to optimize in the 𝑙𝑡 level.