Skip to content

The code regenerates a black and white image of any image input using Metropolis Hastings algorithm.

Notifications You must be signed in to change notification settings

tresnjo/metropolis-hastings-image-regeneration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

Image regeneration using Metropolis Hastings algorithm

The code regenerates a black and white image of any image input using Metropolis Hastings algorithm.

Usage

  1. Place the desired input image (image.png) in the directory specified in the code: C:\Users\username\Desktop\image.png. Replace username with your actual username.
  2. Open the MHA.py script and run it using Python.

The script will perform the following steps:

  1. Read the input image.
  2. Convert the color image to a black and white image.
  3. Create a matrix representing the normalized probability distribution over the image's pixel positions.
  4. Use the Metropolis Hastings algorithm to sample from this distribution.
  5. Generate a histogram-based visualization of the sampled positions.

The resulting plot will display the generated black and white image, representing the normalized probability distribution from the input image.

How it Works

The script converts a color image to black and white by first converting the color channels to grayscale. Then, it creates a matrix T representing the normalized probability distribution over the image's pixel positions. The Metropolis Hastings algorithm is employed to sample from this distribution, generating a sequence of pixel positions.

Contributing

Contributions are welcome! If you find any issues or ways to improve this script, feel free to create a pull request.

About

The code regenerates a black and white image of any image input using Metropolis Hastings algorithm.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages