# Local pixel grouping

In image Noise reduction, local pixel grouping is the algorithm to remove noise from images using principal component analysis (PCA).

## Image denoising

Sensors such as CCD, CMOS or ultrasonic probe may encapsulate noise signal. Noise reduction is commonly used to improve quality of the image. However, techniques such as smoothing filters and many other algorithms may lose local structure of image while denoising the image. More over, efficiency is also taken into consideration.

## Principal component analysis

PCA was invented in 1901 by Karl Pearson, to transform original dataset into linearly uncorrelated PCA domain. PCA works in the way that principal components with larger possible variance are preserved while discarding low variance components.
Image denoising by principal component analysis with local pixel grouping(LPG-PCA) was developed by Lei et. in 2010. It is based on the assumption that the energy of a signal will concentrate on a small subset of the PCA transformed dataset, while the energy of noise will evenly spread over the whole dataset. Assume original image is denoted by $I$ and noise is denoted by $v$, then the measured image will be $I_{v}=I+v$. In order to denoising $I_{v}$, first a train dataset $X_{v}$ must be constructed using local pixel group. Using this $X_{v}$ and apply PCA the noise in the image can be reduced.

### Construct local pixel group

For each pixel $px$ in the image, select a $K\times K$ window centered at $px$ denoted by
    $x=[x_{1}...x_{m}]^{\rm {T}},m=K^{2}$
and a training window centered at $px$. The training window is $L\times L,L>K$. Take the pixels in each possible $K\times K$ block within the $L\times L$ training block yields $(L-K+1)^{2}$ samples ${\overrightarrow {x_{i}}}^{\rm {v}}$. If the distance between a sample and the center window ${\overrightarrow {x_{0}}}^{\rm {v}}$ is smaller than some threshold, then accept the sample. So the train dataset $X_{v}$ is acquired by put all the accepted sample together as column vectors into a matrix.

### Denoising using local pixel group

First step of this part is centralize $X_{v}$ and ${\overline {X_{v}}}$ is obtained. By computing the covariance matrix of ${\overline {X_{v}}}$ denoted by $\Omega _{\overline {x}}$, the PCA transformation matrix $P_{\overline {x}}$ can be obtained. Apply $P_{\overline {x}}$ to ${\overline {X_{v}}}$ we have
    ${\overline {Y_{v}}}=P_{\overline {x}}{\overline {X_{v}}}$
The covariance matrix of ${\overline {Y_{v}}}$ can also be calculated by
    $\Omega _{\overline {y_{v}}}={\frac {1}{n}}{\overline {Y_{v}}}\ {\overline {Y_{v}}}^{\rm {T}}$
Shrink the coefficient of $\Omega _{{\overline {y}}_{v}}$ by
    ${\hat {\overrightarrow {\overline {Y}}}}_{k}=w_{k}\ {\overrightarrow {\overline {Y}}}_{v}^{k}$
    $w_{k}={\frac {\Omega _{\overline {y}}(k,k)}{\Omega _{\overline {y}}(k,k)+\Omega _{v_{y}}(k,k)}}$
and transform back to ${\hat {\overline {X}}}$, the noise in that pixel is reduced. Apply this to all the pixels in the image and the denoised image can be obtained. Experiments by Lei show that LGP-PCA can effectively preserve the image fine structures while smoothing noise. The solution is competitive compared with other algorithms such as Block-matching algorithm.