# Neural Network System for Recognizing Images Affected by Random-Valued Impulse Noise
## 2 Methods  
A neural network is a sequence of neurons connected by synapse connections. Neural network systems are mainly used for three tasks: classification, prediction, and pattern recognition [40]. In this case, the image is a complete or partial reflection of the properties of the object, while the result of recognition is the assignment of these initial data to a certain class, which means the establishment of the subject. An important indicator of the accuracy of the neural network is the error. The error is the percentage of discrepancy between the expected and actual results of calculations [41]. Most often, \(MSE\) is used to maintain balance in the error calculation:  
\[MSE=\frac{\left(i_{1}-a_{1}\right)^{2}+\left(i_{2}-a_{2}\right)^{2}+\ldots+ \left(i_{n}-a_{n}\right)^{2}}{n} \tag{1}\]  
where \(i\)--is an expected network response, \(a\)--is an actual answer, and \(n\)--is the number of training sets. The Convolutional Neural Network (CNN) showed its best results in the field of recognition. Unlike a multilayer perceptron, this type of network takes into account the two-dimensional topology of the image and provides invariance to scaling, rotation, shifts, and spatial distortions [42]. The structure of the network is based on the implementation of a mathematical operation for extracting a feature map (convolution). If there are multiple convolutions in a layer \(\Upsilon\), each operation has an output dimension:  
\[Y=n\cdot(w-k_{x}+1)\cdot(h-k_{y}+1) \tag{2}\]  
where \(w\times h\)--input image dimension, \(n\)--the number of convolutions in the layer, and \(k_{x}\times k_{y}\)--is kernel size. Convolution kernels can be three-dimensional, in which case the dimension convolution \(3\times w\times h\) is used on the first layer, and the output will be one image instead of three. Thus, the convolution operation reduces the image, while the outer pixels participate in fewer convolutions, which causes the need to complement the image at the edges. When applying the shift parameter, the output \(\mu\) will look like:  
\[\mu=\left|\frac{w-k_{x}}{s}+1\right|\cdot\left|\frac{h-k_{y}}{s}+1\right| \tag{3}\]  
When transmitting an image, various errors such as noise or loss of quality may occur. Most often, under these conditions, the image suffers from impulse noise. Impulse noise is characterized by the replacement of a part of the pixels in the image with the values of a fixed or random variable. Impulse noise is divided into fixed (\"salt and pepper\") and random-valued [43]. In the second type of impulse noise, the distortions and their location are random and uniformly distributed in brightness and spatial arrangement. In an image noisy with random-valued impulse noise, the brightness value of some pixels is replaced by a random one [44]. Mathematically, this noise is described as:  
\[p_{x,y}=\left\{ \begin{array}{l}i_{x,y}\text{ {with probability}}\;1-P,\\ n_{x,y}\text{ {with probability}}\;P,\end{array} \right. \tag{4}\]  
where \(p_{x,y}\)--image pixel, \(i_{x,y}\)--original image, \(n_{x,y}\)--noise value in the range [0,255]. Median filtering is used to eliminate impulse noise. This non-linear filtering handles the non-Gaussian distribution of real noise better than linear filters. When the differences in signal values are large compared to the variance of the Gaussian noise, the median filter gives a smaller value of the RMS error of the output signal with respect to the input, i.e., the non-noisy signal, with comparison to optimal linear filters. It is a window that sequentially slides over an array of image pixels and, at each step, returns one of the elements that fell into the aperture. The output signal \(y_{k}\) of the moving median filter of width \(n\) for the current sample k is formed from the input time series \(\ldots,\ x_{k}-1,\ x_{k},\ x_{k}+1,\ldots\) in accordance with the formula:  
\[y_{k}=Median\Big{(}x_{k-\frac{n-1}{2}},\ldots,\ x_{k},\ldots,x_{k+\frac{n-1}{2} }\Big{)} \tag{5}\]  
where \(Median(x_{1},\ldots,x_{n})=x_{\frac{n+1}{2}}\)--elements of the variation series.