Master undirected graph probability models. Learn how cliques, potential functions, and Markov properties enable spatial correlation modeling for image processing and computer vision.
Markov Random Fields (MRF) are probability models based on undirected graphs. Nodes represent variables, edges represent correlation relationships between variables, and the joint probability distribution is defined through "cliques" and "potential functions".
A clique is a subset of nodes where every pair of nodes is connected by an edge (fully connected subgraph). For example, if has an edge, it's a clique.
Maximal Clique:
A clique that cannot be extended by adding more nodes while maintaining the clique property. It is not contained in any larger clique.
Example:
In a graph with nodes and edges connecting all pairs except : Cliques: , , . Maximal clique: .
A potential function is a non-negative real function defined on clique , used to quantify the association strength of variables in the clique.
Common Form:
Where is the energy function. The exponential form ensures non-negativity. Lower energy = higher potential = more likely configuration.
Example:
For clique , if (same value), energy H = 0, potential ψ = 1 (high). If , energy H = 1, potential ψ = ≈ 0.37 (lower). This encourages similar values.
The joint probability distribution is based on clique (or maximal clique) decomposition, normalized by a partition function to ensure probabilities sum to 1.
Where:
Where:
The partition function ensures probabilities sum to 1, but computing it requires summing over all possible variable assignments, which can be computationally intractable for large graphs.
This is why MRF inference often requires approximation methods (MCMC, variational inference).
The core property of MRF is conditional independence, which can be expressed through three equivalent Markov properties. All three are equivalent for positive distributions.
If variable sets and are separated by set (all paths from A to B must pass through C), then:
This means (A and B are conditionally independent given C).
Given a variable's neighbors (directly connected variables), the variable is conditionally independent of all other non-neighbor variables:
Where is the set of neighbors of variable , and is all variables except .
Given all other variables, two non-adjacent variables are conditionally independent:
If there's no edge between and , they are conditionally independent given all other variables.
Apply MRF to denoise a 3×3 grayscale image. Each pixel is a variable, and neighboring pixels are connected by edges. The MRF encourages similar values for neighboring pixels while preserving observed noisy values.
| Pixel ID | Position | Noisy Value | Clean Value | Neighbors |
|---|---|---|---|---|
| 1 | (1, 1) | 0.8 | 1 | 2,4 |
| 2 | (1, 2) | 0.2 | 0 | 1,3,5 |
| 3 | (1, 3) | 0.3 | 0 | 2,6 |
| 4 | (2, 1) | 0.7 | 1 | 1,5,7 |
| 5 | (2, 2) | 0.4 | 0 | 2,4,6,8 |
| 6 | (2, 3) | 0.1 | 0 | 3,5,9 |
| 7 | (3, 1) | 0.9 | 1 | 4,8 |
| 8 | (3, 2) | 0.6 | 1 | 5,7,9 |
| 9 | (3, 3) | 0.5 | 0 | 6,8 |
Values: 0 = black, 1 = white. Neighbors are connected by edges in the MRF graph. Goal: Infer clean values from noisy observations using spatial smoothness.
Each pixel is a node. Edges connect neighboring pixels (4-connected: up, down, left, right). Cliques: all pairs of neighboring pixels.
For clique (neighboring pixels):
Encourages similar values for neighbors (smoothness prior).
Use belief propagation or Gibbs sampling to compute . Result: Denoised image with smooth regions while preserving edges.
MRF successfully denoises the image by balancing observed noisy values with spatial smoothness. Pixels 1, 4, 7, 8 correctly inferred as white (1), pixels 2, 3, 5, 6, 9 as black (0).