I have this optimization problem:

> [![Blockquote][1]][1]


Where $X$ is the output image and $Y$ is the input image.

Let's say the input image is $y$ and the output image is $x$ (transform image to vector) then the problem can be rewritten:

> [![Blockquote][2]][2]


  [1]: https://i.sstatic.net/lruY1.gif
  [2]: https://i.sstatic.net/keyDU.gif

Where $D_h$ is the horizontal Derivative Operator, $D_v$ is the vertical Derivative Operator and $1$ is vector of ones.

Then the solution is given by:

> $\hat{x} = { \left( I + \lambda {D}_{h}^{T} {D}_{h} + \lambda {D}_{v}^{T} {D}_{v} \right) }^{-1} \left( \lambda {D}_{h}^{T} {D}_{h} y + \lambda {D}_{v}^{T} {D}_{v} y + 255 \cdot \boldsymbol{1} \right)$


Thanks for your reply.