In this assignment, you will clean up an image that has lost information due to noise leveraging pairwise Markov Random Fields (MRF).
Please read through all of the files associated with this Lab Assignment before you start the assignment.
The figure above shows (a) a clean image, (b) the same image, corrupted by noise, and (c) a pairwise MRF. There are two layers of nodes. The upper layer corresponds to values
The goal of this problem is to recover the clean image (a) from a noisy input (b). Of course, we cannot recover (a) exactly since information has been lost in the noise. The graphical model we use is a pairwise MRF as shown in (c). A pixel has four neighbors. We are going to use Markov Random Fields (MRFs) to model the distribution of natural images and restore the clean image given an noisy input image. Observed image
There are two types of cliques in this MRF. For
The final energy function for the model takes the form
which defines a joint distribution over
Now implement Coordinate-descent algorithm as below on this:
- Initialize
${x_i} (x_i = y_i)$ - Loop over
${x_i}$ . For each$x_i$ , fix the neighborhood and see whether$−x_i$ would decrease the energy. If so, then flip$x_i$ ; otherwise, continue. - Stop when no changes can be made for
$x$ .
Now make some initial guess for the parameters
Save the recovered image and submit it along with your code. The clean image and noisy image are included in this repository: ./figures/Bayes.png and ./figures/Bayes-noise.png.
Begin by running the notebook image-preprocessing.ipynb to generate the a workable black and white image from the given color image.
Then, clean up a noise contaminated image using parwise MRF with a cooridinate-descent algorithm in assignment5.ipynb.
We are asking you to complete this assignment because we want you to:
- Gain experience constructing and analyzing graphical models like MRF.
- Continue to practice implementing machine learning algorithms from first principles (we'll need this in hardware).
- Practice writing succinct reports with clear figures on a complex topic.
You should implement your solution by hand. Please do not use high-level libraries unless otherwise directed to.
All lab submissions are individual and every item you submit should be a reflection of your own work. You should have ownership over the entirety of any lab you submit in this course. While your work is your own, we understand that it can be helpful in learning machine learning to collaborate with your peers, which can range from high-level discussion of a problem to debugging. Having others look at our code encourages us to write code with readability in mind. In practice, we will never work in a silo, and being able to discuss these topics with others well is a valuable skill. When you collaborate with another student, please cite them appropriately and be respectful of sharing too much. The Academic Honor Principle applies.
We respectfully ask that in the interest in furthering your own understanding of the material, that you refrain from using generative AI to code for you. Your work should be your own and you should feel comfortable justifying each design decision you make.
Please cite any outside sources you reference.
Important
Finally, you will get the most out of this assignment if you give yourself time to be playful and curious in your experimentation.
You will be evaluated on the quality of your code and report.
Please submit the following:
-
A brief post-lab write-up that contains the following for this assignment:
a. Any paper design that you have.
b. A brief description of your model/algorithm. Justify your design/selection of model parameters as appropriate.
c. An evaluation of your model, including evidence as appropriate.
d. A brief (couple of sentences) reflection on your take-aways from this lab exercise.
