# Genetic Programming to Remove Impulse Noise in Color Images
## 4 Methodology
### Genetic Programming Design  
We use genetic programming to generate the binary classification model for detecting noisy pixels in a color image. In a typical machine learning workflow, the training stage involves using a dataset to produce the classification model, whereas only a single image is required in the proposed evolutionary approach. This approach leverages the versatility and adaptability of the genetic programming design, allowing it to effectively learn and adapt to complex noise patterns using only a single training instance. This training image \(I\) has a noised version \(I_{N}\) perturbed by the impulse noise models described in Section 3.1. In this context, an individual is a classification model used to evaluate any pixel \(\vec{x}_{i}\) of an image \(I\) to decide whether \(\vec{x}_{i}\) is noisy. An individual is represented by a parse tree structure with \(O(m)\) nodes selected from a set of primitives consisting of functions and terminals. The internal nodes of the tree consist of a set of functions \(F=\{\texttt{add(x,y)}\), sub(x,y), mul(x,y), mydiv(x,y), mysigmoid(x)\(\}\). Four elements of the set of functions denote the basic arithmetic operations of addition, subtraction, multiplication, and division. In particular, the division operator mydiv(x,y) is protected in the sense that it does not signal \"division by zero\". The sigmoid function mysigmoid(x) \(=\frac{1}{1+e^{-x}}\) guarantees that the results range between 0 and 1. Additionally, the leaves of the tree consist of a set of terminals \(T=\{\texttt{pc\_dist,mu\_dist, median\_dist, sd\_dist, pxc}\}\) that apply statistics operations to the set of neighboring pixels \(\mathcal{N}(\vec{x}_{i})\) of pixel \(\vec{x}_{i}\) in image \(I\). Given a fixed \(3\times 3\) window size, the computations of these statistics take \(O(1)\) time. Table 1 describes the set of terminals. It should be noted that the selection of the set of primitives (functions and terminals) was mainly carried out through some preliminary experimental tests. On the other hand, an individual's fitness represents its ability to correctly detect noisy pixels in an image. For this aim, an image \(I_{O}\) is perturbed using the three impulse noise models, each with a density of \(10\%\), as described in Section 3.1. The produced noisy image \begin{table}
\begin{tabular}{l l} \hline \hline
**Primitive** & **Description** \\ \hline pc\_dist & The differences among pixel intensities around \(\vec{x}_{i}\), i.e., \(d_{i}^{\mathcal{N}(\vec{x}_{i})}\). \\ mu\_dist & Average of the set \(D(\vec{x}_{i})\). \\ median\_dist & Median of the set \(D(\vec{x}_{i})\). \\ sd\_dist & Standard deviation of the set \(D(\vec{x}_{i})\). \\ pxc & The RGB values of pixel \(\vec{x}_{i}\). \\ \([-1\ldots 1]\) & Random values within the range of \(-1\) to \(1\). \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Description of the set of terminal primitives \(T\) representing the different features of neighboring pixels. Figure 1: The sequence of the adaptive filter’s stages: the detection stage takes as input a noised image \(I_{N}\), splitting it into its color channels, and then it uses a classification model to detect noisy pixels; the correction stage uses a vector median filter to repair only the detected noisy pixels. \(I_{N}\) is used as input for each individual of the initial population. Each individual of the population independently evaluates each pixel \(\vec{x}_{i}\) of \(I_{N}\) to decide whether \(\vec{x}_{i}\) is perturbed by noise. Evaluating any pixel requires \(O(m)\) time for any individual; therefore, the detection process requires \(O(mN)\) time to complete. The output generated by each individual is a binary mask indicating which pixels are identified as noisy in \(I_{N}\). This binary mask is used in the correction stage to produce the filtered image \(I_{F}\), which is compared to \(I_{O}\) via the image quality metrics PSNR and MAE described in Section 3.2. The results of these metrics are used to compute the individual's fitness in the detection stage.