GithubHelp home page GithubHelp logo

salimandre / markov-random-fields Goto Github PK

View Code? Open in Web Editor NEW
7.0 0.0 2.0 1.7 MB

Image denoising using Markov random fields.

Shell 1.31% Python 98.69%
bayesian-inference icm potts-model metropolis-hastings-algorithm gibbs-sampling image-denoising undirected-graph probabilistic-graphical-models markov-random-fields

markov-random-fields's Introduction

Markov Random Fields

We studied undirected probabilistic graphical models and here we provide some result in image processing.

We sampled Markov Random Fields models (Ising model, Potts model) using the following algorithm:

  • Gibbs sampling
  • Metropolis sampling
  • Iterated Conditional Modes (ICM)

Finally we applied these methods to solve a task of image denoising.

Ising model

We aim to sample the following distribution on state space {0,1}^n where

We achieved sampling Ising model by using 3 different algorithms: Gibbs sampling, Metropolis sampling, ICM.

Example with beta = 1. :

Example with beta = 3. :

While MCMC algorithms Gibbs and Metropolis have theorical guarantee to converge to the designed distribution, ICM converge quickly to a local minimum. On the following graph we compare convergence of these algorithms by measuring how fast they minimize the global energy of the distribution.

If ICM is faster it requires to start from a suitable initial solution and if not it may not converge at all. On the following plots we compare the ability of respectively ICM, Gibbs and Metropolis algorithms to converge to Ising model distribution starting from a all white image.

Potts model

We also sample the Potts model, a more generalized version of Ising model as the state space {0,1,2,...,q}^n is no more binary.

In the following we sampled:

In the following we sampled:

Image denoising

In order to perform image denoising using Markov Random Fields we added some random gaussian noise to an original binary image. We then aim to recover the original image. We show that the use of an Ising prior achieves better result than a naive independancy prior.

We performed image denoising in the bayesian framework using a naive prior assumption of independancy between pixels then using a prior following Ising distribution with 4 connexity.

Naive prior:

Ising prior with 4 connexity:

The Likelhood (data attachment) is modelled by a gaussian. Hence we have:

We use MAP in order to recover original image:

First we estimated parameters of gaussian by computing empirical mean and standard deviation on random patches of the image. We also computed confidence intervals to ensure of the accuracy of the estimators.

We then applied ICM algorithm to solve MAP. Actually with naive prior it is equivalent to simple thresholding.

We then applied ICM algorithm to solve MAP with Ising prior and we see that the final image obtained is closer to the orginal image than in the previous case.

This observation is confirmed by the following plot which highlights how the two models converge to original image.

markov-random-fields's People

Contributors

salimandre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

hfyer rakeshr10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.