Image denoising with Gibbs sampler I have a question regarding image denoising.
The setup:
Consider the lattice $L:=\{1,...,m\}^2$ and a process $X=\{x_a\}_{a\in L}$ with $x_a = \pm 1$. Let the observed image be $Y = \{y_a\}_{a\in L}$ and let
$$
P(Y=y|X=x) = \prod_{a \in L} P(Y_a = y_a|X_a = x_a) = p^{\#\{a\in L: x_a \neq y_a\}}(1-p)^{\#\{a\in L:x_a = y_a\}}
$$
We want to use the Ising model as a prior distribution for a black/white image for which we observe a noise corrupted version only. The Ising model is determined by
$$
P(X=x) = \frac{1}{C(\alpha \beta)} \exp\left\{ \alpha \sum_{a \in L} x_a + \beta \sum_{(a,b) \in \mathcal{N}} x_a x_b\right\}
$$
where $(a,b)\in\mathcal{N}$ is the set of all neighbouring a and b. I have a problem calculating $P(X_a=1|X_b,b\neq a)$. I know I have to use Bayes rule but I cannot end up with the result
$$
    P(X_a = 1|X_b, b\neq a) = \frac{1}{1+\exp(-2(\alpha + \beta \sum_{b\in N(a)} x_b))}
$$
The Gibbs sampler for the posterior distribution of $X$ given $Y$ uses
$$
    \mathbb{P}(X_a = 1|X_b, b\neq a) = \frac{1}{1+\exp(-2(\alpha + \beta \sum_{b\in N(a)} x_b + \eta y_a))}, \quad \eta = \frac{1}{2}\log\left(\frac{1-p}{p}\right) 
$$
I am also not sure about the above result.
Thanks!

The key is that you can partition $P(X = x)$ into a part that depends on $x_a$ and another part that does not depend on $x_a$
$$P(X=x) = \frac{1}{C(\alpha \beta)} \exp\left\{ \alpha \sum_{a \in L} x_a + \beta \sum_{(a,b) \in \mathcal{N}} x_a x_b\right\} = C(x_b, b\neq a) \cdot f(x_a, x_b, b\neq a)$$
To compute the density of $x_a$ given $x_b$ you can discard the part that depends on $x_b$, which is a constant (since you condition on $x_b$ which means that $x_b$ is kept fixed)
$$P(X_a = x_a | X_b, b\neq a) = \frac{ C(x_b, b\neq a) \cdot f(x_a, x_b, b\neq a)}{\sum_{\forall x_a}  C(x_b, b\neq a) \cdot f(x_a, x_b, b\neq a)} =   \frac{  f(x_a, x_b, b\neq a)}{\sum_{\forall x_a}  f(x_a, x_b, b\neq a)} $$
This part $f(x_a)$ is relatively simple and contains the term for $x_a$ and the interaction terms with the four neighbours.
$$f(x_a) = \exp \left(\alpha x_a + \beta x_a \sum_{b \in \mathcal{N}_a} x_b \right) = \exp\left(c x_a\right)$$
where $b \in \mathcal{N}_a$ means to sum only over all $b$ that are a neighbour of $a$, and $c = \alpha + \beta\sum_{b \in \mathcal{N}_a} x_b$.
Then
$$ P(X_a = x_a | X_b, b\neq a)  = \frac{e^{c x_a}}{e^c + e^{-c}} $$
