# Understand about maximum a posteriori probability (MAP) in classfication task

I have a 2D image defined on a region $\Omega$. Let $I: \Omega \to R$ be a gray image. Assume that the region can be separated into $N$ sub-regions $\Omega_i$ such that $$\forall i,j=1,\ldots ,N:\Omega_i \cap\Omega_j=\emptyset$$ and $$\bigcup_{n=1}^{N}\Omega_n =\Omega$$

To simplify, we assume $N=3$ and it shows in below figure.

We denotes $p(x \in \Omega_i|I(x))$ is posteriori probability of region $\Omega_i$ given $I(x)$. Based on the Bayesian rules, we have

$$p\left(x \in \Omega_i|I(x)\right)=\frac{p\left(I(x)|x\in \Omega_i\right)p(x\in \Omega_i)}{p(I(x))}$$

The segmentation try to assign pixel $x$ to each region based on posteriori probability. That goal is that finds maximum a posteriori probability (MAP) of pixel $x$ in each region. It can express by formula

$$\left\{ \Omega_{i,x} \right\}_{i=1}^{N}=\arg \max_{\Omega_i} \left\{\prod_{i=1}^{N} p(I(x)|x \in \Omega_i)p(x \in \Omega_i )\right\} \tag{*}$$

Assuming that the pixels within each region are independent , the MAP will be achieved over all image domain $\Omega$ $$\left\{ \Omega_i \right\}_{i=1}^{N}=\arg \max_{\Omega_i} \left\{\prod_{i=1}^{N}\prod_{x \in \Omega_i} p(I(x)|x \in \Omega_i)p(x \in \Omega_i )\right\} \tag{**}$$

• Are my formulas $(*)$ and $(**)$ correct?
• If not, Could you help me to correct them?

The reference link is http://vision.mas.ecp.fr/pub/ijcv02-01.pdf

## 1 Answer

I will try to give you some intuition into it by a different example.

Think we have 3 machines which can generate the numbers 1, 2, 3.
The first machine generates the number 1 with 80% and the numbers 2, 3 with 10% each.
The second machine generates the number 2 with 80% and the numbers 1, 3 with 10% each.
The third machine generates the number 3 with 80% and the numbers 1, 2 with 10% each.

One of the machines is chosen, you don't know which and the generated number is 2.
What machine would you bet it would?

The question above is the likelihood with no prior knowledge.
Hence, given the number 2 the most likely is the second machine.

Yet, What happens if you are told that the chosen machine would be chosen following this rules - 98% the first machine, 1% the second and 1% the third.

Now, what are the chances?

Seeing 2 from machine 1 are 0.1 * 0.98 = 0.098.
Seeing 2 from machine 2 are 0.8 * 0.01 = 0.008.
Seeing 2 from machine 3 are 0.1 * 0.01 = 0.001.

Now a better choice would be machine 1.
This is the MAP, because we took into account both the likelihood and the prior knowledge.

• Thank Drazick for a clear example. Based on your example, I corrected my question. Could you careful check equation () and (*) about their correction? – John Sep 8 '15 at 15:14
• It seems OK if you understand that the function is partitioned. Namely you check each hypothesis on it own and see what are the chances. You chose the one which the largest chances. Namely you're looking for the max of a family of functions. – Royi Sep 9 '15 at 12:52
• Thank Drazick for your comment. I accepted it. Anw, I make a final explanation of above problem. Could you look at the more detail in below link and let me know any mistake (if it has)? I highlight the range of argmax by yellow color. Is it correct? dropbox.com/s/9pxxh25wfk2qol3/MAP.JPG?dl=0 – John Sep 11 '15 at 6:09
• It seems the link is broken. – Royi Mar 24 '16 at 17:18