# Computer Multimedia Art Pattern Creation Based on P-Filling Algorithm

Authors: Wenli Lian
Journal: Advances in Multimedia
 (2021)

---

## Abstract

Art education is an important part of quality education in China. It undertakes the important responsibility of cultivating students' aesthetic ability, art appreciation ability, art perception ability, and expression ability. In junior middle school art teaching, the skill of pattern creation is an ability that needs to be focused on cultivating students. The computer multimedia art patterns are currently created mainly relying on manual drawing. A computer multimedia art pattern production model is proposed based on the P-filling algorithm in this paper. After using the P-filling algorithm to quickly generate a large number of fake images and retrieve the code of the most recent damaged image, the code estimates the missing content by generating a model. On this basis, the semantic P-filling algorithm and the perceptual P-filling algorithm are combined, and the unsaturated region is enlarged by improving the activation function sigmoid function, which solves the problem that the gradient is easy to disappear. Experimental results show that, through this production model, users can produce a large number of computer multimedia art patterns with hand-drawn style features through very little interaction and parameter control.


---

## Body

## 1. Introduction

With the development of artificial intelligence, the creation of computer multimedia art patterns has become an important task in computer vision [1, 2]. The creation of the computer multimedia art model is an image processing technology that uses the undamaged information in the image to correct the missing information in the image and remove the specific information in the image on the premise that the image quality and its natural effects will not be damaged. [3, 4]. That is, the core subject of creative activities is to synthesize visually realistic and semantically reasonable pixels to be consistent with existing pixels [5]. Due to the widespread existence of images, the computer multimedia art pattern creation technology protects the works of art, the information lost in old photos, or damaged in the creation; hides errors in pictures and videos; removes text in videos and image-based rendering; and many applications in computer photography [6, 7]. Therefore, the creation of computer multimedia art mode has become a hot spot in image processing technology [8].Computer multimedia pattern design is widely used, involving wallpaper, carpet, printing and dyeing, and other fields. At present, the most important problem for designers is to solve the quality and speed of pattern design. Computer-aided pattern design can be adopted to achieve the rapid time effect of design patterns. Regarding the model of P-filling calculation method, a creation system of composition knowledge is studied. The composition of the subproducts in this model, the spatial angle, and the knowledge of creative composition are the basis of computer simulation image design.


## 2. Shape Structure Analysis and System Framework of Multimedia Art Pattern

Figure1(a) is a simple computer multimedia art pattern drawn by hand, which can be divided into three parts: cloud head, cloud body, and cloud tail. Among other things, the cloud body is mainly formed by connecting multiple similar arc lines with different lengths, while the cloud head is mainly composed of involuted lines. For a multimedia art pattern, there are generally at most 2 cloud heads, and the cloud tail part mainly has a flat head and a pointed end. The flat head shape is used to express the connection effect between clouds, and the pointed shape expresses the direction of cloud movement (Figure 1(b)). Figure 1(b) is the complex computer multimedia art pattern obtained by superimposing and combining 5 simple multimedia art patterns, so the system decomposes the computer multimedia art pattern into a hierarchical structure of “multimedia art pattern-cloud, cloud head, cloud body and cloud tail.” The pattern of multimedia art is composed of clouds in a certain distribution mode, and each flaky clouds are composed of cloud head, the cloud body, and the cloud tail.Figure 1
The composition of multimedia art patterns. (a) Cloud pattern decomposition. (b) Complex structure.
(a)(b)In view of the various limitations of the current algorithms, an algorithm for making traditional computer multimedia art patterns based on the P-filling algorithm is proposed in this paper (Figure2). In the feature extraction stage, three Bezier curves are used to extract the feature lines of cloud head, cloud body, and cloud tail from the hand-painted P-filling algorithm work and normalize them to form a multimedia art pattern feature library. The produced feature library can be reused; the production stage is mainly divided into 4 steps. First, the sketch of the computer multimedia art pattern to be created is obtained through an interactive method. The sketch mainly expresses the general shape of the cloud body, the position and size of the cloud head and tail, etc. [9]; The production algorithm divides the cloud sketch according to simple parameter settings to obtain a broken line graph. AS for the feature selection and installation algorithm, the appropriate feature line is selected for installation according to each broken line and cloud head line in the feature library through the selection algorithm. The procedural methods are used to make the cloud tail part. Finally, a variety of styles of computer multimedia art patterns are obtained by drawing by stylized line drawing methods.Figure 2
Algorithm framework.


## 3. Structure Analysis and Feature Data Extraction of Computer Multimedia Art Pattern

The Bezier curve is a basic tool for making computer graphic image shapes, and it is one of the basic lines that use graphic shapes the most. The line segment with node realizing the curve production is like the stretchable rubber band, which can fit various modeling curves well. The system uses the segmented third-order Bezier curve to fit the cloud body and cloud head curve of the sample pattern. Suppose P0, P1, P2, and P3 are 4 control points in the plane (Figure3(a)), and use equation (1) to calculate a smooth curve, namely,(1)Bt=P01−t3+3P1t21−t+3P2t1−t2+P3t3,t∈0,1.Figure 3
Feature extraction. (a) Cubic bexier curve, (b) sample fitting, (c) feature library.
(a)(b)(c)As shown in Figure3(b), the user can easily set the end point and move the control point position sample curve for fitting in the tool interface. For the cloud body, each sample feature (1 arc) is fitted by a 3rd Bezier curve. Due to the complex structure of cloud heads, the characteristics of cloud head samples are fitted with multisegment Bezier curves.In order to normalize the control point coordinates of each characteristic curve to the [0, 1] space, the normalization process is divided into two steps. Assuming that the control points P0, P1, P2, and P3 are to be normalized, rotate the tilt anglee clockwise around P0 for the 4 points, then calculate the length and height of the minimum bounding box of the 4 points, and transform the coordinates of the control points into the [0, 1] space. Figure 3(c) shows the normalized sample curve, which contains 6 cloud body samples and 2 cloud head sample curves. For the cloud body feature line, calculate ρi=LPiPi+1/PiPi+10≤i≤n−1; this parameter ρi is used to approximate the closeness of the arc and the corresponding chord. The data that needs to be saved for each segment of cloud body feature line are 4 normalized point coordinates {P0, P1, P2, P3} and ρi, the cloud head part only saves all the segmented Bezier control points after normalization. These data are stored permanently in the form of library files and can be loaded and used when needed. Since each segment of the curve only saves the coordinates of 4 points, when the curve is needed, it can be dynamically produced by formula (1), so the data volume is very small. The normalization process is shown in Figure 4.Figure 4
Normalization process.By using the semantic P-filling algorithm to create an image, although the damaged area can be created, the created image will have a blurred boundary. The generatorG and the discriminator D are mainly used, both of which are used to train with undamaged image data. The generator G uses the inverse convolutional neural network to transform the random noise sequence into a high-dimensional image through random noise z, as shown in Figure 5. Through the confrontation training of the generator and the discriminator, the image that imitates the sample is generated [10, 11]. For an image, the image is coded first, y is used to represent the damaged image, and M to represent the binary code of the defect area. For a damaged image, the representations of images y and M are shown in Figure 6. Therefore, the goal of this paper is to find the code z^ closest to the damaged image, so that the damaged image can be created and is semantically consistent with the surrounding images.(2)z^=argminzℓcz|y,M.Figure 5
Implementation of inverse convolutional neural network.Figure 6
Damaged imagey and binary mask image M. (a) y, (b) M.
(a)(b)Among them,ℓc is the semantic P-filling algorithm, which is used to constrain the relationship between the input damage image y and the binary mask M corresponding to the generated image. Since the defect area of the image occupies a large proportion of the original image, the remaining undamaged part is fully utilized, but for the large damaged area in the center of the image, it is obviously not the best choice to treat each pixel equally.In order to fill in the missing content in the image, the pixels in the undamaged area need to be fully utilized, and the distance relationship between the pixels in the undamaged part and the damaged area shall be considered [12, 13]. Obviously, the pixels closer to the damaged area are more related to the filled pixels. Therefore, it is disadvantageous to the production result of the instruction book that only the remaining pixels is used, blacking out each pixel equally. In order to find a better encoding, you should be more interested in pixels close to the missing area. In order to achieve this goal, most of the pixels playing the role of pixels close to the missing area in the image creation process use the weighting methods to make the pixels far away from the missing area in the image creation process play fewer roles in the image creation process.(3)Wi=∑j∈Ni1−MjNi,Mi≠0,0,Mi=0.In the formula:i represents the pixel; Wi represents the weight of the pixel i; N(i) is the set of neighboring pixels of the pixel i; |N(i)| represents a base number of N(i). In the experiment, in order to solve the problem of overfitting problem caused by too many training parameters, L1 regularization is introduced here, and the text P-filling algorithm is defined as the L1 norm between the created image and the undamaged part. The number is defined as follows:(4)ℓcz|y,M=WΘGz−y1.In the formula, Θ represents the multiplication operation between elements.


## 4. Computer Multimedia Art Pattern Production

### 4.1. Production and Process of Computer Multimedia Art Pattern

In the pattern making mode, the mouse movement track is captured to quickly obtain the cloud body, cloud head, and cloud tail sketch of the computer multimedia art pattern after selecting the three different options of cloud body, cloud head, and cloud tail on the production interface. Figure7(a) shows a sketch production line style [13, 14]. The curve between points B1 and B2 is the cloud body production line Cb, the curve between H1 and H2 is the cloud head production line Ch, and the curve Ct between T1 and T2 is the cloud tail production line. Among them, H1 can be located at any position on Cb, and one cloud head production line represents the production of one cloud head, and there can be none or there be more according to needs. According to the algorithm, the nonuniform broken line (unclosed) or polygon (closed) on the cloud body production line Cb obtains n division points Pi1≤i≤N (Figure 7(b)), and a random process model is used to make n division points, and the division points satisfy the condition:(5)LPiPi+1=Δ+12×T,1≤i≤n−1.Figure 7
Sketch composition. (a) Sketch. (b) Generation line divis of cloud body.
(a)(b)In the formula:LPiPi+1 represents the arc length; Δ is a random number in the range of 0 to 1; and T is a control parameter set by the system, so that the length of each arc can be controlled between 0.5 and 1.5 times the basic length. When the distance between the start point and the end point of Cb is less than a certain threshold, a closed polygon is divided. In the following text, Cb, Ch, and Ct become the sketch line, and the corresponding {Pi}, {Hi}, and {Ti} are called the vertices of the production line. The head and tail of the cloud are not divided, and the production line is composed of fixed points from Ch and Ct. The density of the points can be controlled by changing the control parameter T, and the introduction of the random variable Δ can make the division more abundant, which is in line with the style of hand painting.


### 4.2. Sample Installation

P-filling algorithm (generative adversarial networks, P-filling) is now a very popular research direction in artificial intelligence circles. P-filling is structurally inspired by the two zero-sum games of game theory. In other words, the sum of the interests of two people is zero. The income of one party is the loss of the other party. The system consists of a generatorG and a discriminator D, which are trained in the form of adversarial learning. The generator G is used to capture the potential distribution of actual data samples and generate new data samples G(x) through random noise z. The discriminator D is a separator that determines whether the input is true data x or a generated sample. The generator G and the discriminator D are, respectively, composed of deep neural networks, and the P-filling algorithm is optimized through continuous confrontation training.(6)minGmaxDfD,G=Ex−pxlogDx+Ez−pzzlog1−DGz.P-filling algorithm (generative adversarial networks, P-filling) is a very popular research direction in the current artificial intelligence industry. P-filling is structurally inspired by the two-person zero-sum game of game theory, that is, the sum of interests of two people is 0, and one party gains exactly what the other party loses. The system is composed of a generatorG and a discriminator D and is trained through adversarial learning. The generator G is used to capture the potential distribution of real data samples and generate new data samples F(X) through random noise z; the discriminator D is a two-classifier that judges whether the input is real data x or a generated sample. The generator G and the discriminator D are, respectively, composed of deep neural networks and through continuous confrontation training to optimize the confrontation P-filling algorithm (Figure 8).Figure 8
P-filling calculation process and structure.The P-filling algorithm learns the feature distribution of training samples and can generate real-looking samples through the training of generators and antagonists. Therefore, the P-filling algorithm suitable for interactive image editing cannot be directly applied to image creation tasks. Just the samples are learned, some new samples will be generated. An image that is completely unrelated to the image to be created will be generated. The most suitable image for the undamaged part is found from the generated samples through continuous iteration, and the image creation task is performed.A pattern usually contains a huge amount of information. If each pixel has 16 gray levels (or colors), it contains bit information. In this paper, the filling algorithm is used to compress the information and make full use of the time and space of machine processing. During pattern generation, you need to find the image of the undamaged part. The core problem of filling algorithm is to judge whether each pixel on the drawing is inside or outside the filled polygon. Here, there is a most commonly used judgment rule, parity judgment: if the lineL is led from a point 0 outside the polygon p to the direction P, it will enter f after the edge line of L and P intersects odd times and exit f after intersecting even times (as shown in Figure 9). The image creation task can be performed according to the parity judgment rule.Figure 9
Continuous iterative algorithm is most suitable for undamaged image creation.Cloud tail is made using a procedural method. The system produces two styles of cloud tails, including flat and pointed. According to the number of cloud tail lines to be made (N), several segment points are obtained through dividing equally the cloud head's B1B2 line, and then the cloud tail sketch curve T1T2 is translated to several segment points to draw the flat cloud tail (in the middle of Figure 10); the linear gradation of the distance between the corresponding points on the two edge lines of the flat cloud tail is reduced to 0 to create a pointed cloud tail (right of Figure 10).Figure 10
The production process of cloud tail.


### 4.3. Stylized Line Drawing

Lines that vary in thickness are also an important feature of traditional computer multimedia art patterns. The arcs of many multimedia art patterns present a thick stroke style at the middle and thin ends. At first, the Bezier curve are drawn three times through the control points (P0, …, P3) to get the inner edge C1 of the line (Figure11(a)), and then a random value between P0P1′=λP0P1, P3P3′=λP3P2, λ of [1.1,1.2], respectively. The Bezier curves are drawn three times by P0P1'P2'P3 to obtain the outer edge of the line C2 (Figure 11(b)), and then the area formed by the inner and outer edges is filled in to get this stroke style line (Figure 11(c)).Figure 11
Brush style line making. (a) Inner borders. (b) Outer borders. (c) Filling.
(a)(b)(c)The activation function is used to add nonlinear components to the neural network to enhance the network's expressive ability. The activation function used in the P-filling algorithm is the sigmoid function (S-type function), and its function formula is expressed by formula (7) in this paper.(7)Sigmoidx=11+e−x.The original P-filling is obtained based on information theory, the concept of entropy is reviewed first.(8)H=−k∑i=1npilogpi.In the formula,k represents a positive constant. In the P-filling algorithm, pi is always required to be a valid value, not close to 0 or 1. The sigmoid activation function can make the input value meet pi, but the sigmoid function has a narrow unsaturated region. The maximum value of the derivative of the sigmoid function is 0.35. When the multilayer neural network performs the parameter product operation, the final result will definitely drop exponentially, thus causing the loss of the gradient.Therefore, an improved sigmoid activation function is proposed to expand the unsaturated region in this paper, as follows:(9)ReSigmoidlogits=11+e−α⋅logits.In the formula,α is a hyperparameter. By adjusting the parameters, the positive part of the derivative of the improved sigmoid function is maintained near 1, so the gradient disappearance problem is improved, and α = 0.1 is set in the experiment.


## 4.1. Production and Process of Computer Multimedia Art Pattern

In the pattern making mode, the mouse movement track is captured to quickly obtain the cloud body, cloud head, and cloud tail sketch of the computer multimedia art pattern after selecting the three different options of cloud body, cloud head, and cloud tail on the production interface. Figure7(a) shows a sketch production line style [13, 14]. The curve between points B1 and B2 is the cloud body production line Cb, the curve between H1 and H2 is the cloud head production line Ch, and the curve Ct between T1 and T2 is the cloud tail production line. Among them, H1 can be located at any position on Cb, and one cloud head production line represents the production of one cloud head, and there can be none or there be more according to needs. According to the algorithm, the nonuniform broken line (unclosed) or polygon (closed) on the cloud body production line Cb obtains n division points Pi1≤i≤N (Figure 7(b)), and a random process model is used to make n division points, and the division points satisfy the condition:(5)LPiPi+1=Δ+12×T,1≤i≤n−1.Figure 7
Sketch composition. (a) Sketch. (b) Generation line divis of cloud body.
(a)(b)In the formula:LPiPi+1 represents the arc length; Δ is a random number in the range of 0 to 1; and T is a control parameter set by the system, so that the length of each arc can be controlled between 0.5 and 1.5 times the basic length. When the distance between the start point and the end point of Cb is less than a certain threshold, a closed polygon is divided. In the following text, Cb, Ch, and Ct become the sketch line, and the corresponding {Pi}, {Hi}, and {Ti} are called the vertices of the production line. The head and tail of the cloud are not divided, and the production line is composed of fixed points from Ch and Ct. The density of the points can be controlled by changing the control parameter T, and the introduction of the random variable Δ can make the division more abundant, which is in line with the style of hand painting.


## 4.2. Sample Installation

P-filling algorithm (generative adversarial networks, P-filling) is now a very popular research direction in artificial intelligence circles. P-filling is structurally inspired by the two zero-sum games of game theory. In other words, the sum of the interests of two people is zero. The income of one party is the loss of the other party. The system consists of a generatorG and a discriminator D, which are trained in the form of adversarial learning. The generator G is used to capture the potential distribution of actual data samples and generate new data samples G(x) through random noise z. The discriminator D is a separator that determines whether the input is true data x or a generated sample. The generator G and the discriminator D are, respectively, composed of deep neural networks, and the P-filling algorithm is optimized through continuous confrontation training.(6)minGmaxDfD,G=Ex−pxlogDx+Ez−pzzlog1−DGz.P-filling algorithm (generative adversarial networks, P-filling) is a very popular research direction in the current artificial intelligence industry. P-filling is structurally inspired by the two-person zero-sum game of game theory, that is, the sum of interests of two people is 0, and one party gains exactly what the other party loses. The system is composed of a generatorG and a discriminator D and is trained through adversarial learning. The generator G is used to capture the potential distribution of real data samples and generate new data samples F(X) through random noise z; the discriminator D is a two-classifier that judges whether the input is real data x or a generated sample. The generator G and the discriminator D are, respectively, composed of deep neural networks and through continuous confrontation training to optimize the confrontation P-filling algorithm (Figure 8).Figure 8
P-filling calculation process and structure.The P-filling algorithm learns the feature distribution of training samples and can generate real-looking samples through the training of generators and antagonists. Therefore, the P-filling algorithm suitable for interactive image editing cannot be directly applied to image creation tasks. Just the samples are learned, some new samples will be generated. An image that is completely unrelated to the image to be created will be generated. The most suitable image for the undamaged part is found from the generated samples through continuous iteration, and the image creation task is performed.A pattern usually contains a huge amount of information. If each pixel has 16 gray levels (or colors), it contains bit information. In this paper, the filling algorithm is used to compress the information and make full use of the time and space of machine processing. During pattern generation, you need to find the image of the undamaged part. The core problem of filling algorithm is to judge whether each pixel on the drawing is inside or outside the filled polygon. Here, there is a most commonly used judgment rule, parity judgment: if the lineL is led from a point 0 outside the polygon p to the direction P, it will enter f after the edge line of L and P intersects odd times and exit f after intersecting even times (as shown in Figure 9). The image creation task can be performed according to the parity judgment rule.Figure 9
Continuous iterative algorithm is most suitable for undamaged image creation.Cloud tail is made using a procedural method. The system produces two styles of cloud tails, including flat and pointed. According to the number of cloud tail lines to be made (N), several segment points are obtained through dividing equally the cloud head's B1B2 line, and then the cloud tail sketch curve T1T2 is translated to several segment points to draw the flat cloud tail (in the middle of Figure 10); the linear gradation of the distance between the corresponding points on the two edge lines of the flat cloud tail is reduced to 0 to create a pointed cloud tail (right of Figure 10).Figure 10
The production process of cloud tail.


## 4.3. Stylized Line Drawing

Lines that vary in thickness are also an important feature of traditional computer multimedia art patterns. The arcs of many multimedia art patterns present a thick stroke style at the middle and thin ends. At first, the Bezier curve are drawn three times through the control points (P0, …, P3) to get the inner edge C1 of the line (Figure11(a)), and then a random value between P0P1′=λP0P1, P3P3′=λP3P2, λ of [1.1,1.2], respectively. The Bezier curves are drawn three times by P0P1'P2'P3 to obtain the outer edge of the line C2 (Figure 11(b)), and then the area formed by the inner and outer edges is filled in to get this stroke style line (Figure 11(c)).Figure 11
Brush style line making. (a) Inner borders. (b) Outer borders. (c) Filling.
(a)(b)(c)The activation function is used to add nonlinear components to the neural network to enhance the network's expressive ability. The activation function used in the P-filling algorithm is the sigmoid function (S-type function), and its function formula is expressed by formula (7) in this paper.(7)Sigmoidx=11+e−x.The original P-filling is obtained based on information theory, the concept of entropy is reviewed first.(8)H=−k∑i=1npilogpi.In the formula,k represents a positive constant. In the P-filling algorithm, pi is always required to be a valid value, not close to 0 or 1. The sigmoid activation function can make the input value meet pi, but the sigmoid function has a narrow unsaturated region. The maximum value of the derivative of the sigmoid function is 0.35. When the multilayer neural network performs the parameter product operation, the final result will definitely drop exponentially, thus causing the loss of the gradient.Therefore, an improved sigmoid activation function is proposed to expand the unsaturated region in this paper, as follows:(9)ReSigmoidlogits=11+e−α⋅logits.In the formula,α is a hyperparameter. By adjusting the parameters, the positive part of the derivative of the improved sigmoid function is maintained near 1, so the gradient disappearance problem is improved, and α = 0.1 is set in the experiment.


## 5. Result Analysis

Figure12 shows the results of the algorithm. The box on the left is the hand-drawn sample data, which only contains the cloud part, from which the system can extract 6 sample lines; the right is the drawing result of the algorithm, and the first row on the right is the result of several drawing under the same situation of making polygons. The second row on the right is the result of several productions in the case of different divisions to make polygons. The first and second rows are the results of the drawing under the same sketch, and the value of T is 40 pixels (the value is mainly set to between 0.5 and 1.5 times the average length of the sample arc length, so the style of making is similar to the sample). The third line is the drawing results under different sketches, different production lines and different T situations. It can be seen from the experimental results that, as long as a small sample data and few interactive operations are required, a variety of drawing results with similar styles can be produced, which greatly improves the efficiency of creation.Figure 12
The production results of cloud body under different parameters.Figure13 shows some of the production results of the system. These results include the cloud body, cloud head, and cloud tail, and the use of different line styles. Through the combination of different parameters, you can quickly produce a variety of user-satisfied results. In Figures 12 and 13, within the box is a hand-drawn computer multimedia art pattern, and outside the box on the right is the calculation result. It can be seen that the system production result maintains the style characteristics of hand-drawn samples and meanwhile can produce a variety of computer multimedia art patterns with rich changes in shape and structure.Figure 13
The system makes various computer multimedia art patterns.


## 6. Conclusions

The P-filling calculation method is proposed for the production and rendering of computer multimedia art images in this paper. The image with the p-filling calculation method retains the handmade characteristics of the multimedia beautiful image design. The p-filling algorithm can be used to complete the drawing of computer multimedia art images in various forms and personality with simple sketch and parameter value. The shape, size, line characteristics, and cloud tail style of the multimedia image can be completed with a few parameters and interactions of the system, which saves time and effort compared with the previous manual drawing method and can achieve the effect of saving resources. This system can be used in pattern design, animation production, gaming, and advertising production.



---

*Source: 8143000-2021-12-07.xml*