Markov Random Fields and Gibbs Sampling for Image Denoising

Markov Random Fields and Gibbs Sampling for Image Denoising

Markov Random Fields and Gibbs Sampling for Image Denoising Chang Yue Electrical Engineering Stanford University [email protected] Abstract MRF model. Therefore, a seemingly high-value pixel might find itself improves the whole picture’s loss after it got a This project applies Gibbs Sampling based on different chance to be sampled to a low-value. It is proved that after Markov Random Fields (MRF) structures to solve the im- enough iteration passes, Gibbs Sampling will converge to age denoising problem. Compared with methods like gra- the stationary distribution of the Markov Chain, no matter dient ascent, one important advantage that Gibbs Sampling what the initialization is. This is shared by all Metropolis- has is that it provides balances between exploration and ex- Hastings algorithms, but Gibbs Sampling, a special case of ploitation. This project also tested behaviors of different Metropolis-Hastings, has a big advantage in image denois- MRF structures, such as the high-order MRFs, various loss ing applications, when the conditional distribution of each functions when defining energy, different norms for sparse variable is known and is easy to sample from. gradient prior, and the idea of ’window-wise product’. I Markov Random Field (MRF) is a set of random vari- finally generated an output which is an ensemble of many ables (i.e., pixel values) having a Markov property de- structures. It is visually good, and comparable to some scribed by an undirected graph [8]. It represents undirected state-of-art methods. dependencies between nodes. For a single node, we can compute its probability distribution given evidence of its neighbors (named Markov Blanket). Different MRF will 1. Introduction yield different distributions, and therefore, different sam- pling results. The second part of this project is to explore Image denoising has been a popular field of research for the effectiveness of different MRF. decades, and lots of methods have been developed. A typ- ical approach would be going through an image pixel by pixel, and, at each pixel, by applying some Math models, set that pixel’s value based on the evidence of its neighbors’ 2. Related Work values. Gaussian smoothing is the result of blurring an im- age by a Gaussian function, typically to reduce image noise. Markov Random Field Models (MRF) theory is a tool to Mathematically, applying a Gaussian blur to an image is encode contextual constraints into the prior probability [5]. the same as convolving the image with a Gaussian function S. Z. Li presented an unified approach for MRF modeling [2]. Gradient ascent is another widely used method, where in low and high level computer vision. Roth and Black de- it iteratively assigns pixels values such that they bring im- signed a framework for learning image priors, named fields provement on the pre-defined function (usually called loss of experts (FoE) [7]. McAuley et al. used large neigh- function). It will converge to a suboptimal state, and dif- borhood MRF to learn rich prior models of color images, ferent initializations give different results in general. The which expands the approach of FoE [6]. Barbu observed drawback of these methods is that they are too determin- considerable gains in speed and accuracy by training the istic: assign pixel value based on the current state with a MRF/CRF model together with a fast and suboptimal infer- probability of 1. And, methods like gradient ascent need ence algorithm, and defined it as active random field (ARF) careful initialization. [1]. Gibbs Sampling is a widely used tool for computing Gibbs Sampling is a Markov chain Monte Carlo maximum a posteriori (MAP) estimation (inference), and it (MCMC) algorithm for obtaining a sequence of observa- is applied in various domains. There are lots of research tions which are approximated from a specified multivariate going on, either on training MRF priors or on speeding up probability distribution [4]. It provides exploration by sam- the inference. Some recent researches combine Bayesian pling a pixel’s value based on probabilities computed from a inference and convolutional neural network (CNN). 3. Methods Given a noisy image X, where X(i; j) (also denoted as xi;j) is the pixel value at row i and column j. Assume the original image is Y . Denoising can be treated as a proba- bilistic inference, where we perform maximum a posteriori (MAP) estimation by maximizing the a posteriori distribu- tion p(yjx). By Bayes Theorem, p(xjy)p(y) p(yjx) = : p(x) By taking logarithm on both sides, we get log p(yjx) = log p(xjy) + log p(y) − log p(x): X is given, so MAP estimation corresponds to minimizing − log p(xjy) − log p(y): 3.1. Markov Random Field A Markov Random Field (MRF) is a graph G = (V; E), Figure 1. Pairwise MRF. where V = v1; v2; :::; vN is the set of nodes, each of which is associated with a random variable v . The neighborhood i Initialize starting values of y for i = 1; :::; M and of node v , denoted N(v ), is the set of nodes to which v is i;j i i i j = 1; :::; N; adjacent, i.e., v 2 N(v ) and (v ; v ) 2 E. In a MRF, j i i j while not at convergence do given N(v ), v is independent on the rest of the nodes. i i Pick an order of the M × N variables; Therefore, N(v ) is often called the Markov blanket of node i for each variable y do v . i;j i Sample y based on P (y jN(y )); A classic structure used in image denoising domain is the i;j i;j i;j Update y to Y ; pairwise MRF, shown in Figure 1. The yellow nodes (orig- i;j end inal image Y ) are what we want to find, but we only have information about the green nodes (noisy image X). Each end Algorithm 1: Gibbs Sampling node y is only connected with its corresponding output x and four direct neighbors (up, down, left, right). Therefore, y given a pixel its 5 neighbors, we can determine the prob- nary images. Figure 2 shows the work. The original image y ability distribution of without looking into other pixels. contains a clean formula. Then, I generated an noisy image such that each pixel from the original has a 20% chance of 3.2. Gibbs Sampling been flipped. I set the sampling probability of each pixel using the Ising model. After only a few iterations, I got the In its basic version, Gibbs sampling is a special case output which recovered most part of the original image with of the MetropolisHastings algorithm. It is a Markov chain an error rate of 0.8%. Monte Carlo (MCMC) algorithm that samples each random variable of a graphical model, one at a time. The point of 3.3. Energy Gibbs sampling is that given a multivariate distribution it The distribution over random variables can be expressed is simpler to sample from a conditional distribution than to in terms of an energy function E. Here we define the energy marginalize by integrating over a joint distribution. In our E for variable y as a sum of loss (L), sparse gradient prior case, we sample one value of a single pixel y at a time, i;j i;j (R) and window-wise products (W) while keeping everything else fixed. Assume the input im- M × N age has a size of . The algorithm is as shown in E(yi;jjX) = E(yi;jjN(yi;j)) Algorithm 1. = L(yi;jjN(yi;j))+λrR(yi;jjN(yi;j))−λwW (yi;jjN(yi;j)) 3.2.1 Gibbs Sampling for binary images The probability distributions of yi;j is defined as As a warn-up and small test on the efficiency of Gibbs Sam- 1 p(y jN(y )) = exp(−E(y jX)); pling and pairwise MRF, I implemented an algorithm for bi- i;j i;j Z i;j σ is a hyper parameter here, it controls the bandwidth. 3.3.2 Sparse gradient prior We can also add our assumptions about images as a prior term here. I assumed the image has sparse gradient. There- fore, we also penalize for large gradients. The prior term is: z − y X i;j n2 R(yi;jjX) = jj jj : z n2 z2N(yi;j )nxi;j Where here I approximated the gradient between yi;j and z as the ratio of their difference to value of z, because this makes vectorization easy. Again, there is a trade-off be- tween L-1 and L-2 norms. 3.3.3 Window-wise product Inspired from the Non-local Means (NL-means) method [3] and Fields of Experts [7], I thought it could be help- ful to derive common patterns within an image, instead of training on some dataset. The advantage of doing this is Figure 2. Using Gibbs Sampling and Pairwise MRF for binary im- it saves time, and could be scene-specific. Although the age denoising. From top to bottom: original image, noisy image disadvantage is also obvious: could be biased. If we can with a flip rate of 20%, de-noised image with an error of 0.8% find ’patterns’ within a m × n window, then dot product these patterns with the window the Gibbs sampler is cur- rently looking at could yield some useful information. The where Z is the normalization factor. Therefore, higher en- most straight forward pattern is just the mean: go through ergy means lower chance of getting sampled, the way we the image with a m×n sliding window and then average the compute the energy depends on MRF.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us