Geekly Articles each Day

A memory with nonlinear approximation inside data clusters is developed. Clusters are proposed to be allocated using the k-means method. The approximation should be carried out using the training of an ensemble of neural networks. Cluster memory is tested using an adaptive filter to convert image colors. According to the results of computer experiments, this type of memory showed good selective learning ability. By the example of an adaptive filter, it is possible to train the memory to change the entire color palette of the image.

A significant drawback of perceptron neural networks is their poor ability to generalize multicluster data. In particular, the XOR task for learning a logical function cannot be solved with a single perceptron, since two conflicting trends can be traced in one direction of the data points for an increase and decrease in the decisive function of a neural network. Such contradictory dependencies within the same training data array cannot be generalized by a single neural network of the form of a multidimensional perceptron. Therefore, it is proposed to divide the array of training data into clusters within which to approximate individual neural networks. A computer experiment is conducted in the article to test this type of memory for the task of an adaptive image filter for the selective conversion of a color palette.

The k-means method is one of the most popular clustering methods. Its purpose is to obtain such data centers that would correspond to the hypothesis of compactness of data classes with their symmetric radial distribution. One way to determine the positions of such centers, for a given number of

In this method, two procedures are performed sequentially.

- Definition for each data object $$${X}_{i}$the nearest center $$${C}_{j}$, and assigning a class label to this object $$${X}_{i}^{j}$. Further, for all objects, their belonging to different classes becomes determined.
- Calculation of the new position of the centers of all classes.

Repeating iteratively these two procedures from the initial random position of the centers of

A new author's classification algorithm will be compared with the k-means method.

The k-means method applied to the color space of pixels in an image allows you to highlight the basic tones. To do this, it is proposed to convert the colors of

$$$dist\text{}left({X}_{i},{X}_{j}\text{}right)=\text{}sqrt{H}_{i}\text{}cdot{B}_{i}-{H}_{j}\text{}cdot{B}_{j}$

The initial arrangement of cluster centers is proposed to be calculated as follows.

- Find
*min*and*max*values $$${H}_{i}\text{}cdot{B}_{i}$for all pixels. - Divide the interval [
*min*,*max*] into*k*parts. - Calculate pixel frequencies in each sub-interval by value $$${H}_{i}\text{}cdot{B}_{i}$.
- Sort the intervals by the number of pixels in descending order.
- Calculate pixel centers in subintervals.

The approach for conducting cluster analysis based on the k-means method has the disadvantage that there is no influence of the output image indices. To take into account the change in the indicators of the output image, depending on the change in the indicators of the input image, the following algorithm is proposed.

- Sort all input vectors by size $$${H}_{i}\text{}cdot{B}_{i}$
- When moving from one input vector to another in a sorted array, view the change in the monotonicity of the quantity $$${H}_{i}\text{}cdot{B}_{i}$corresponding output vectors.
- Monotonic input vectors $$${H}_{i}\text{}cdot{B}_{i}$assign the corresponding output vectors not larger than the selected threshold
*p*to one class. - The threshold
*p*can be varied to divide the vectors into the desired number of clusters.

To implement image conversion, neural networks are possible. The main advantage of neural networks is their automatic learning ability. In this case, it is proposed to train an adaptive filter [Shovin 2018] based on a neural network to use a pair of images in which the original image is a sample, and the second is changed from a sample by any existing filter or transformation. The adaptive filter needs to restore this conversion. For this, a window of size

After the basic tones of the image are found, an adaptive filter is constructed for the pixels of each tone with a window width and height of 1 pixel. Filters are trained for each cluster separately. Thus, using neural networks of adaptive filters, the approximation of pixel colors within their cluster (tone) is carried out.

The cluster memory was trained using adaptive filters as an example for transforming a color palette.

An adaptive filter requires learning to selectively whiten skin colors without changing other colors.

As a result of applying an adaptive filter with cluster memory (9 clusters-tones and clusters according to the gradient map) to the original palette, the following images were obtained:

An approach is proposed for learning complex functions based on cluster memory with approximation using a family of neural networks and conducting cluster analysis of the source data. Using the adaptive filter as an example, the possibility of selective conversion of palette colors is shown. The use of cluster memory with approximation is relevant when conflicting trends in the same directions of changes in the indicators of the source data are traced in the training data set. In particular, it is possible to solve the XOR problem for learning a logical function.

*Shovin V.A.*Adaptive image filter based on a neural network. // Mathematical and computer modeling: a collection of materials of the VI International Scientific Conference. 2018 .-- 198 p.

Source: https://habr.com/ru/post/462303/