This tutorial explains the processing of the annealing machine in the demonstration application image noise reduction".

### Overview

This is a problem of estimating the original image from a black and white image with noises.

Generally, assuming that the following conditions hold, expect it to work properly on an annealing
machine.

- (a) (If the noise is small) the pixel values of the input image and the output image are
approximately the same.
- (b) In output images after noise reduction, adjacent pixel values are often the same.

##### Image with noise (Input)

##### Denoised image (Output)

### Create a cost function

In this problem, since the color of the pixel is binary black or white, we correspond it to the spin
value -1 or +1 of CMOS annealing machine.

From (a) above, here we set the value of the i-th pixel of the input image as $y_i$ and the value of
the ith pixel of the noise-reduced image as $s_i$.

To make the pixel values of the input image and output image roughly the same, we use the following
cost function.

####
$$
-\sum_{i \in V} y_i s_i
$$

Here $V$ represents a set of pixels. Since $y_i s_i$ becomes +1 when the i-th pixel value of the
input and output image is the same and becomes -1 when the pixel value is different, add the signed
$-$ to all pixels so that the cost is reduced when the pixel values are the same.

Additionally considering the condition that "(b) In output images after noise reduction, adjacent
pixel values are often the same.", the cost function is as follows.

####
$$
-\sum_{(i,j) \in E} s_i s_j
$$

Here $E$ represents a collection of adjacent pixel pairs. When these are added together, the following
final cost function is obtained.

####
$$
-\sum_{(i,j) \in E} s_i s_j-\eta\sum_{i \in V} y_i s_i
$$

We introduced the parameter $\eta (>0)$ before the second term. This is to adjust the strength of the
two conditions.

If $\eta=0$, the cost function is in the form of only the first term. In this case, the cost is the
smallest when all the pixel values of the output image are the same. Conversely, if $\eta$ is made very
large, it is practically the form of only the second term, so the cost is minimal if the input image and
the output image are exactly the same.

In the demo of this site, it is $\eta=2$ or $3$.