# How to calculate real pixel color from a blurred image using $n$ equations in $n$ unknowns?

I've been dealing with a big image de-blurrying issue for past months and now I'm stuck with this issue that I want to get original sharp image from a blurred image by using some extra data and math. Assume these two as 5px*5px images. First one is sharp image and second one is burred by camera shake (or object movement). In right image the color is lighter because its mixture with white background.

Assume that we know how much the original pixel had been shifted and became the blurred image (which is $$3$$ pixels in our case). My assumption is that the original red pixel $$(255,0,0)$$ were spread into $$3$$ pixels (its own position and two top of it) with $$\frac13$$ of its color. So the pink pixels are mixture of a white background and a part of red pixel.

Now I want to create an n equation and n unknowns from these mixtures and the blurred image that we have in order to get that origin image.

I just write the equation for columns and only for the 3rd one which is important for our case.

I also should write these equations for R G and B separately, but for simplicity I just write it for G here.

For 1st pixel of the 3rd column we know that there is no mixture and only its own color determines the final color. So for pixel $$(3,1)$$: $$x_1=255$$ For 2nd row pixel: $$x_2+\frac13x_4=190$$ We know that the pixel of 4th row had a $$\frac13$$ effect on this pixel so its coefficient was applied. With same approach we have: $$x_3+\frac13x_4=190$$ $$\frac13x_4+x_5=190$$ $$x_5=255$$ So we have $$5$$ equations and $$5$$ unknowns that seems be solvable. But the defined equations do not give the right answer. I'm not sure how should I change the coefficients to make it give me correct answer. However the correct math form is this: $$\begin{bmatrix} 1&0&0&0&0\\ 0&1&0&\frac13&0\\ 0&0&1&\frac13&0\\ 0&0&0&\frac13&0\\ 0&0&0&0&1\end{bmatrix}$$ And the answers are: $$(255,191,191,191,255)^T$$ I just should do some normalization in coefficients or answers in order to make it give the correct original pixel values for the $$G$$ of 3rd column which are $$(255,255,255,0,255)^T$$.

I don't know how clear my question was, but any clue can help me with it...

• $x \ast h = H x$ with $H$ the circulant matrix corresponding to your filter, your equation is $Hx = y$ whose solution is $x = H^+y$ where $H^+ =(H^\top H + \epsilon I)^{-1} H$ is the pseudo inverse. – reuns May 25 at 23:00