# Neural Network System for Recognizing Images Affected by Random-Valued Impulse Noise
## 3 Proposed Method and Results
### Proposed Method
The set of pixels, the coordinates of which are removed from the central pixel by a distance not greater than the specified R, represent the local window \(\Omega\) of the detector. The distance \(R(p_{k,l},p_{m,o})\) between pixels \(p_{k,l}\) and \(p_{m,o}\) in the \(L_{2}\) metric is determined according to:  
\[R(p_{k,l},p_{m,o})=\sqrt{(k-m)^{2}+(l-o)^{2}}. \tag{11}\]  
In Figure 2, for a local window \(\Omega\) with a radius of 4, the distance between the central and selected pixels is \(\sqrt{13}\). For the convenience of visual perception of the result of cleaning the image from noise, the Euclidean metric \(L_{2}\) was used. The \(L_{2}\) metric is sufficiently suitable for calculating filter masks for cleaning images from impulse noise using adaptive median filtering [46]. When using pixel values from the previous and next frames, it was possible to create a mask to clean video data from random-valued impulse noise using the same metric \(L_{2}\)[47]. The function of the absolute difference between the processed pixel and other pixels in the local window \(\Omega\) is used to estimate the difference in brightness values between pixels:  
\[U(p_{k,l},p_{m,o})= \begin{cases}1,\ if\ p_{k,l}=p_{m,o},\ \ p_{m,o}\in\Omega_{p_{k,l}}\\ 1-\frac{1}{q}\log_{2}\lvert p_{k,l}-p_{m,o}\rvert,\ if\ p_{k,l}\
eq p_{m,o},\ \ p_{m,o}\in\Omega_{p_{k,l}}\end{cases}  \tag{12}\]  
where \(q\)--is the bit depth of the image pixels. The smaller the value of \(U\) is, the greater the brightness difference. Dividing by \(q\) keeps \(U\) non-negative. The logarithmic function indicates the most significant bit of the difference between pixels and is well suited to explain the digital nature of the data and to align with the visual perception of the human eye [48]. The second step is to sort the array \(U\) in ascending order and sum the first \(\frac{b}{2}\) elements of the sorted array, where \(m\) is the number of elements in the local window \(\Omega\):  
\[V(p_{k,l},p_{m,o})=\sum_{k=1}^{m/2}U_{b}(p_{k,l},p_{m,o}) \tag{13}\]  
The similarity score between pixels W is calculated from (5) and (12):  
\[W(p_{k,l},p_{m,o})=\eta(p_{k,l},p_{m,o})\cdot V(p_{k,l},p_{m,o}) \tag{14}\]  
Figure 2: The distance squared between the central pixel x and its neighbors. Lines mark local windows \(\Omega\) with different radii. To determine the presence of pixel distortion, a threshold is introduced:  
\[G_{k,l}= \begin{cases}0,\text{ {if }}W_{k,l}\geq T;\\ 1,\text{ {if }}W_{k,l}<T.\end{cases}  \tag{15}\]  
If the array \(G\) is a map of noisy pixels and if an element in \(G\) is 1, the corresponding pixel in the image is noisy. The size of the local window \(\Omega\) depends on the noise level. Experiments carried out within the framework of the proposed work showed that the direct relationship between the intensity of impulse noise and the size of the mask for its purification is the most effective. For the recognition task, a neural network with a pretrained VGG16 architecture was used [49]. The 16-layer model, pretrained on the ImageNet data set, showed high results in the recognition accuracy of the CIFAR10 base, which is inferior to ImageNet in the amount of training data, that is 60,000 images versus 14,000,000 images. The model is an improved version of the first convolutional network AlexNet [50], in which large filters (sizes 11 and 5 in the first and second convolutional layers, respectively) are replaced by several filters of size 3 \(\times\) 3, one after the other. Despite significant drawbacks, such as the heavy weight of the architecture and the low learning rate, the network is easily implemented and surpasses many other models in accuracy. Let us present the results of the experiment of the influence of image cleaning methods from random-valued impulse noise on the accuracy of recognition of objects in the image by a neural network.