The paper describes an algorithm for restoring a damaged image, based on the use of maximum and minimum Lipschitz function defined in a flat area.
Namely, we will assume that the image is given by the function $u=f(x,y)$, where $x=0,...,M$, $y=0,...,N$, and its value is a brightness level of point $ (x, y) $, which varies in the range of $ u = 0, ..., U $. We consider the current window of the size $ (2n + 1) \times (2n + 1) $ with center at the point $ (x, y) $, where $ n = 1,2, ... $ As the output luminance of the point corresponding to the center of the window, take the value
$$
F_{\alpha}^{n}(x,y,z)=\min\{f(i,j)+\alpha\sqrt{(x-i)^2+(y-j)^2+z^2}:|x-i|\leq n, |y-j|\leq n\},
$$
where $x=n,...,M-n$, $y=n,...,N-n$. To suppress the local minima we can use the dual function that looks like this
$$
G_{\alpha}^{n}(x,y,z)=\max\{f(i,j)-\alpha\sqrt{(x-i)^2+(y-j)^2+z^2}:|x-i|\leq n, |y-j|\leq n\}.
$$
Next, it is necessary to define for each current point $(x,y)$ which of these functions must be applied. To do this, we proceed as follows. In one pass through all the points
$(x,y)$ are determined by the image of a local maximum and local minimum points. Repeated passage of this information is taken into account for the determination of the function used.
Response $H(x,y,z)$ of our filter is calculated according to the rule
$$
H(x,y,z)=
\begin{cases}
F_{\alpha,n}(x,y,z), if\ (x,y)\ is\ point\ of\ local\ maximum,\\
G_{\alpha,n}(x,y,z), if\ (x,y)\ is\ point\ of\ local\ minimum,\\
f(x,y), otherwise.
\end{cases}
$$ We show examples of operation of this algorithm for images with varying degrees of damage. We consider images having $20\%$–$75\%$ of the defects. Presented algorithm quite well restores the image with different types of lesions: how random nature with a uniform distribution over the entire image (impulse noise), and concentrated in certain areas.