GithubHelp home page GithubHelp logo

chenhuaizhen / image_denoising_segmentation Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 617 KB

Use Gibbs sampling and variational inference to denoise the image and use EM to segment the image

Python 100.00%
gibbs-sampling variational-inference em-algorithm image-denoising image-segmentation

image_denoising_segmentation's Introduction

Image_denoising_segmentation

Use Gibbs sampling and variational inference to denoise the image and use EM to segment the image

Requirements

python 3-6
scipy
cv2

Image_denoising

Gibbs sampling

Algorithm

image

where the ๐‘›๐‘๐‘Ÿ(๐‘–) means all connected nodes (neighbors) of node ๐‘ฅ๐‘–. Due to use the Ising model, the pairwise potential term ๐›นs๐‘– (๐‘ฅ๐‘–, ๐‘ฅs)=exp(๐ฝ๐‘ฅ๐‘–๐‘ฅs), and the local evidence term ๐›น๐‘–(๐‘ฅ๐‘–)=๐’ฉ(๐‘ฆ๐‘–|๐‘ฅ๐‘–, ๐œŽ^2) where the ๐‘ฆ๐‘– is the observed state. So the final term of p in the pseudo-code is:
image

And the ๐‘๐‘’๐‘ฅ๐‘ก๐‘†๐‘–๐‘ก๐‘’(๐‘—) function can just return j. But this may cause artifacts as the pixels left and above of ๐‘ฅ๐‘– will change before it does, while the pixels right and below will not have changed. Instead, first pass over all of the "even" pixels (i is even) and then make a pass over all of the "odd" pixels will help a lot, which can also simplify the iterations into two matrix operations(instead of n times iterations).
And when meet the boundary pixels, can try to "wrap" the boundary to deal with this problem, which means that the neighbors wrap around to the other side of the image.

Result

image

Variational Inference

Algorithm

image

where the ๐‘›๐‘๐‘Ÿ(๐‘–) means all connected nodes (neighbors) of node ๐‘ฅ๐‘–. ๐œ‡๐‘– is mean value of node i. And the main update rule is: image

Based on the ๐œ‡, it will be iterated until convergence.
The ๐‘๐‘’๐‘ฅ๐‘ก๐‘†๐‘–๐‘ก๐‘’(๐‘—) function and boundary problem are the same as the Gibbs sampling algorithm.

Result

image

Image_segmentation

Expectation-Maximization

Algorithm

image

where
image

Result

image

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.