Giter Site home page Giter Site logo

praveenpankaj / markov-random-field-project Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alimorty/markov-random-field-project

0.0 0.0 0.0 11.84 MB

This project has two parts. In part one, we use markov random field to denoise an image. In Part two, we use similar model for image segmentation.

Jupyter Notebook 100.00%

markov-random-field-project's Introduction

Markov Random Field For Image Segmentation and Denoising

This project has two parts. In part one, we use markov random field to denoise an image. In Part two, we use similar model for image segmentation.

For a brief read me, click on Brief Read me
For checking the code, click on Codes

Update As some people asked me some questions, I felt it might be helpful to add some notes here:

The reference that I have used can be found here. I have also used the PGMs book from Daphne Koller and Nir Friedman
The potential function is equivalent to log(Probability(x)) for any particular image x. We want to find x that maximizes this probability. This image x would be our prediction. We do search for this x using Simulated annealing.

Markov Random Field Models provide a simple and effective way to model the spatial dependencies in image pixels.
So we useed them to model the connection between two neighbour pixels.
In our problem we have to define an energy function on hidden states corresponding to true values of each pixels, then we minimize this function to obtain the best prediction.
Our energy function is defined as below:

formula

Denoising

a_complete_set_for_part_1(arr, max_iter=1e7, var=1e4, betha=1e4)

png

a_complete_set_for_part_1_some_pixels_known(arr,  known_index, max_iter=1e6, var=1e4, betha=bta)

png

Image Segmentation

In this part, we used Markov Random Field for image segmentation.
We used different image color space:

  • Gray Scale
  • HSV
  • RGB Format

Gray Scale

a_complete_set_for_part_2(arr,class_info, max_iter=1e7, betha=1e6)

png

HSV color space

Now we want to use HSV color space for training our data.

a_complete_set_for_part_2(arr_h,class_info, max_iter=1e6, betha=1e6)

png

RGB color space

In this part, we used RGB color format in training since there is some information that can be captured by pixels colors.
We used RGB values in potential function.

a_complete_set_for_part_2_3_color(max_iter=1e6, betha=1e6)

png

a_complete_set_for_part_2_3_color(max_iter=1e6, betha=1e6,
                                 schedule=linear_multiplicative_cooling_schedule, temprature_function_constant=0.5)

png

Conclusion

Grayscale image format didn't have sufficient information for CRF models in this task.
The value H in HSV image format had better information for segmentation using CRF models. And the result was better.
The RGB format also had good information for segmenting the image. Because these three segments have different colors. So if a CRF model considers colors of the image for classification, then the result is going to be better compared to Grayscale images.

markov-random-field-project's People

Contributors

alimorty avatar

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.