CEng 583 Computer Vision Term-ProjectShape From Shading: Deterministic and Stochastic OptimizationEmre Ugur, Emre Akbasemre.{akbas|ugur}@ceng.metu.edu.tr Department of Computer Engineering Middle East Technical University Table of contents
Project ProposalHere is our project proposal:ImplementationThe source code of the project (as a single C++ source file): View | DownloadTested on a Linux 2.4 box with gcc-3.2.2, compile with: g++ -lm Deterministic OptimizationIn the first part of the project, deterministic optimization method is applied to the problem. Energy function is defined by the combination two different error measures. First is the brightness error, which is defined as the different between the image brightness value and the reflectance value of corresponding pixel. Minimization of brigthness error is not sufficient for the solution of the problem, therefore smoothness measure of the gradient space, as a regulization term is inserted into the energy function. The discussion about minimization of energy functional can be found in project proposal. Experiments and ResultsMainly the following two images are used for experiments:
Deterministic methods are extremely sensitive to initial conditions where iterations start. Since gradient space is the unknown of the SFS problem, we should take extra care on initial values of gradient values, namely p and q. The following figures shows three different initial configurations for gradient space.
Since there is no proof of convergence of deterministic minimization method in SfS, with different random configurations, solution seems to be stucked in local minima. Figures 9,10 and 11 below were obtained using image irradiance equation. Each different random initialization results in different gradient values which are stuck in local minima. Since reflectance value in each cell should equal to the irradiance of corresponding pixel, each pixel's gray level value can be computed. By both examining the brightness error and by comparing resulting image and original image, gradient space seems to be very close to the solution. However, constructed surfaces of each randomly initialized experiment shows that the resulting 3D surface is not similar to the original one.
Above experiments showed that starting from different initial configurations may result in different results which minimize brightness error. In figure 3, initial gradient space is given as a good starting point for the sphere example. Thus, reconstructed shape, which is given in Figure 12 below is the correct solution.
And deterministic optimization method with random initial configuration(borders): deterministic2.gif (animated gif) Following two images are the last scenes (the converged needle maps) of the animations above. The lambda parameter which specifies the change rate in each iteration is another important parameter. Lambda is the coefficient of the term involving the image irradiance equation. In order to obtain successful results, lambda parameter should be set carefully. In experiments performed, best results obtained when lambda is in the range [0.6,0.9]. Figures 13,14,15 and 16 show from-gradient-reconstructed images (i.e. from the p-q values using the image irradiance equation) with different lambda values. When lambda is low, the effect of the brightness error in minimization decreases, thus obtained reflectance values become smoother. However, when lambda is higher, reflectance values are minimized according to image irradiance values.
Another set of experiments were conducted for the Beethoven image (Figure 2 above), The reconstructed 3D shape of the given image is shown in Figures 17 and 18 below. The unexpected height values in Figure 17 is the result of shadows which appear in the image. However, when seen from top, although all image is composed of discontinuous regions, the shape of the Beethoven statue is extracted.
Last set of experiments are made for understanding dynamics of the iterative scheme and determining the stopping point. In each iteration, total brightness error is computed. Figure 19 shows that after some time, brightness error converges to a constant value. If the shape of the reconstructed surface is examined, it can be seen that after the time where error becomes constant, there is no qualitative change in the resulting surface.
Stochastic OptimizationStochastic vs. Deterministic Optimization: A brief discussionNatural phenomena consist of various uncertantities. As vision processes are no exception to this fact, optimization modeling in computational vision problems is a rational and useful paradigm. In their survey Zhang et al. found out that the most accurate results were produced by optimization methods. Optimization methods can be divided into two:
The first family of optimization methods consist of two main strategies: directly minimizing the discrete version of the energy function, and discrete solution of the corresponding Euler-Lagrange equations. Szeliski, in <--!TODO--> his paper Fast Shape From Shading, quoted that solving the discrete version of Euler equations do not strictly correspond to minimizing energy, since all local extrema of the energy functional are solutions of these Euler equations. Furthermore, deterministic optimization methods have the problem of high dependance to the initial configuration. This problem is clearly illustrated in figures 6,7, and 8 above. However, deterministic optimization methods are fast (when compared to stochastic methods) and give good results if initial configuration and boundary conditions are given correctly. Stochastic optimization methods, on the other hand, finds a global minimum of the underlying energy functional. Initial configuration has no effect on the solution. However, the drawback of these methods is their extreme slowness. A Bayesian FrameworkShape from shading(SFS) is a classical labeling problem in computational vision and it belongs to the regular sites with continuous labels group of labeling problems as described in [2].
SFS can be re reformulated in a Bayesian framework. Let
The term Click here for a definition of Markov Random Fields adapted from [2] A Markov Model for the SfS ProblemAs mentioned above, by Bayes rule we can write the maximum a posteriori probability in terms of the likelihood and prior distributions (see equation (1)). We can encode the contextual constraint in the prior termIn the deterministic optimization approach we derived the energy functional:
The above equation embeds the image irradiance equation, the smoothing constraint and the integrability constraint. The fact that this energy can be interpreted as a sum of local functions which depend only on neighboring pixels satisfies the Markovian property. By The Hammersley-Clifford theorem we can write a MRF as a Gibbs field, thus:
where
Prior on p-q state spaceThe prior on the p-q distribution
The bounds of the state space of p-q is of great importance. They can be computed using the image irradiance
equation and
For the
which gives us the boundary of the state space of p-q.
Simulated Annealing AlgorithmTo optimize the derived Markov model, the following simulated annealing algorithm is proposed:1. Initialize a random configuration and the starting temperature 2. For each pixel (i,j) in the image 2.1 Choose a random new label (i.e. a p-q pair) in the p-q state space 2.2 Compute the acceptance ratio R 2.3 Accept the new label with probability min(1,R) 3. If the stopping criteria is reached stop, else decrement T and go to step 2 During each iteration, random changes are made in the current configuration(i.e. complete labeling of all sites with p-q values). The new state is then compared to the current state. If its new energy is lower than the current, this new state is immediately accepted. However, if the new state's energy is higher than the current's, it is accepted probabilistically. This probability depends upon the energy and the temperature value at that iteration. Generally, at high temperatures, many states will be accepted, while at low temperatures, the majority of these probabilistic moves will be rejected. Acceptance ratio RThis ratio is computed for deciding whether the newly proposed label will be accepted or not. It is simply the ratio of the energy of the new configuration to the energy of the current configuration. In addition, this value embeds the ratio of the proposal distribution of the new label to the current label. According to these, the acceptance ratio is:
where
Cooling scheme
The cooling scheme is Experiments and ResultsWatch the animation of the stochastic optimization method: stochastic.gif (animated gif). The following figure is the last scene of this animation:Temperature(T) is very important in the computation of the acceptance ratio (9). In the simulated annealing algorithm, if the randomly generated new value for a site imposes a negative change in the energy function (3), it is accepted, otherwise it is accepted with a propability equal to the acceptance ratio. When the temperature is high, the rate of accepted bad moves is high. However, as the temperature decreases, system begins to stabilize and the rate of accepted bad moves approaches to zero.
Initial temperature If it is too high, the algorithm conducts a random walk until an appropriate
temperature is reached. This random walk has no useful effect on the result. The high initial temperature,
in addition makes the execution time longer than necessary.
Stopping temperature If it is too high, the system cannot iterate enough to reach the correct solution and a needle map similar to that in Figure 20 is obtained. If it is lower than needed, only the execution time is affected negatively.
Cooling rate coefficient ( The result obtained using Beethoven's image is surprizingly good. The needle map corresponding to Beethoven's image (in Figure 2) is below in Figure 21.
Future Work
ReferencesIn addition to the references we listed in our proposal , we referred to the following documents in the implementation phase:
![]() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||