A method for detecting the facial symmetry axis of a face image based on a genetic algorithm
Through the genetic algorithm-based method, the detection of the symmetry axis of facial images is optimized, and the problems of unstable detection results and large calculations are solved, and efficient and accurate detection under different conditions is achieved, which is suitable for facial detection and aesthetic evaluation.
Patent Information
- Application Number
- CN202210326100.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-03-29
AI Technical Summary
The existing method of detecting the axis of symmetry of facial images is easily affected by skin color, background and lighting conditions, resulting in unstable detection results, large calculation amount and low efficiency, and failure to fully consider the characteristics of the axis of symmetry of the facial.
Using a genetic algorithm-based method, the search process is optimized through image preprocessing, chromosome encoding, population initialization, fitness function design and genetic operator operation, including selection, crossover and variation operations, the prospect is extracted using HSV color space, the fitness function is defined, and the detection algorithm is optimized to consider symmetry, perpendicularity and proximity factors.
It realizes stable detection under different skin tones, backgrounds and lighting conditions, reduces the amount of calculation, improves detection speed and accuracy, and is suitable for facial detection and aesthetic evaluation.
Smart Images

Figure CN115018757B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing and image understanding, and particularly relates to a method for detecting the facial symmetry axis of a face image based on a genetic algorithm. Background Art
[0002] Symmetry is a very important property and feature in the description of visual features. The symmetry axis detection technology has extremely wide applications in fields such as feature extraction, target recognition, and defect detection. In the process of detecting the symmetry axis of a facial image, many challenges are faced, such as high complexity, poor result stability, and many interference factors (skin color, background, lighting conditions). Currently, there are mainly three types of methods available for detecting the symmetry axis of a facial image: one type is the symmetry axis detection method based on a mathematical model, such as the pattern matching method, the optimization search method, etc. The problem with this type of method is that it is easily affected by irrelevant factors in the image during the detection process, thus affecting the detection result; one type of method is the detection method based on statistics, such as the detection method based on wavelet texture and color histogram. The problem with this type of method during the detection process is that the amount of calculation is extremely large, and a large amount of memory and time are required when detecting images with a high detection resolution; another type is the detection method based on deep learning, such as PRS-Net, SRN, etc. The problem with this type of method is that a large amount of prior knowledge is required, and the characteristics of the facial symmetry axis are not taken into account. The large search space results in low detection efficiency. There are many problems and deficiencies in the existing methods when the symmetry axis detection method is applied to the detection of the facial symmetry axis, such as being affected by factors such as skin color, background, and lighting conditions, resulting in very unstable detection results; or the calculation amount of the method is too large, leading to large memory consumption, long detection time, or even program crashes; or the detection method does not fully consider some characteristics of the facial symmetry axis, resulting in a large search space and low detection efficiency. Therefore, the effects of these methods in detecting the symmetry axis of a facial image are not satisfactory. Summary of the Invention
[0003] The purpose of the present invention is to overcome the unsatisfactory effect of the symmetry axis detection algorithm in detecting the facial symmetry axis, and provide a method for detecting the facial symmetry axis based on a genetic algorithm.
[0004] The purpose of the present invention is achieved through the following technical solutions:
[0005] Step 1. Image preprocessing;
[0006] Step 2. Design chromosome coding;
[0007] Step 3. Establish an initial population;
[0008] Step 4. Design a fitness function;
[0009] Step 5. Define genetic operators.
[0010] Further, in step 1, the standard RGB format facial image is used as the input, and it needs to be converted into the HSV color space for subsequent operations. The conversion formula is as follows:
[0011]
[0012]
[0013]
[0014]
[0015] Where H, S, V, R, G, and B represent the values of each corresponding channel of the image; the obtained image is subjected to foreground extraction according to the H channel, and then the image is cropped to prevent interference from irrelevant regions to the detection result.
[0016] Further, in step 2, the population of the genetic algorithm is a series of straight lines intersecting the upper and lower ends of the image, an individual is one of these straight lines, and the chromosome of the individual adopts a real number coding method, taking the abscissa values of the intersection points of the individual with the upper and lower ends of the image.
[0017] Further, in step 3, a randomly generated range, that is, the active interval, denoted as startvalue and stopvalue, is set for the initialized population to improve the quality of the initialized population and obtain the optimal axis of symmetry with the least number of iterations.
[0018] Further, the specific steps in step 4 are as follows:
[0019] Step 4.1: When the current individual is the axis of symmetry, the symmetry of the entire facial image, and its calculation formula is:
[0020]
[0021] Where symmetry represents the lip symmetry, total represents the total number of pixels in the lip area, and match represents the number of pixels in the lip symmetric area;
[0022] Step 4.2: The verticality of the individual, that is, the deviation angle, is represented by the cosine value of the angle between the individual and the y-axis of the image;
[0023] Step 4.3: The deviation distance of the individual. Here, the proximity of the midpoint of the individual to the center point of the image is defined, and the value range is [0, 1]. The greater the proximity, the stronger the adaptability of the individual. The formula is:
[0024] nearness = 1 - distance / (stopvalue - startvalue) / 2
[0025] Among them, the proximity is denoted as nearness, and the distance between the midpoint of the line segment and the center point of the image is denoted as distance;
[0026] Step 4.4: According to Steps 4.1 - 4.3, the fitness function formula is designed as:
[0027] fitness = sym * w_sym + verticality * w_verticality + nearness * w_nearness
[0028] Among them, fitness represents the individual fitness, sym, verticality, and nearness respectively represent symmetry, verticality, and proximity, and w_sym, w_verticality, and w_nearness respectively represent the weights of the three.
[0029] Furthermore, the genetic operations in Step 5 include selection operation, crossover operation, and mutation operation;
[0030] Among them, the selection operation includes roulette wheel strategy, tournament strategy, and elitist retention strategy;
[0031] The crossover methods include one - point crossover, two - point crossover, multi - point crossover, uniform crossover, and shuffle crossover;
[0032] The mutation operation is divided into 3 types: (1) The mutation operation is translation mutation. Randomly generate the number of translation pixels x, and add or subtract x to the two abscissas of the current optimal solution simultaneously to complete the translation mutation; (2) The mutation operation is rotation mutation of the current individual. Randomly generate the number of translation pixels x, and add x to one abscissa and subtract x from the other abscissa of the current optimal solution to complete the rotation mutation; (3) The mutation operation is random mutation, that is, randomly generate an abscissa value within the active interval of the abscissa as the chromosome encoding of the mutant individual; By defining the mutation operation in this way, the diversity of the population is maintained and the convergence to the optimal solution is accelerated.
[0033] Furthermore, the selection operation uses the elitist retention strategy, adding the several individuals with the highest fitness in each generation of the population to the next generation to continue the genetic operation, so as to improve the quality of the individuals in the population and search for the optimal axis of symmetry with the least number of iterations;
[0034] The crossover method uses one - point crossover, and the results of the crossover respectively take a constant in the chromosome encoding of the parent generation and form its own chromosome encoding.
[0035] The beneficial effects of the present invention are as follows:
[0036] The present invention transforms the problem of symmetry axis detection into the problem of population evolution, mutation, and searching for the optimal solution. The search process is determined by defining the genetic operators in the algorithm, and the optimization of the search process is completed. By defining the adaptive function of the algorithm, three factors, namely image symmetry, the perpendicularity of the symmetry axis, and the offset distance of the symmetry axis, are fully considered, thereby optimizing the selection process of the algorithm. Through the genetic evolution of the population, the optimal facial symmetry axis is obtained, thus solving the problem of facial symmetry axis detection.
[0037] The present invention uses a genetic algorithm to globally search for the facial symmetry axis of a face image. Only the iterative search method of the algorithm needs to be preset in advance, and there is no need to understand the specific process of population evolution iteration, that is, searching for the optimal facial symmetry axis. At the same time, this method has stability in the detection results of facial symmetry axes of different types of facial images (different skin colors, different backgrounds, different light intensities, etc.). In terms of detection accuracy and detection speed, this method also has certain advantages.
[0038] The present invention does not require a large amount of data for training, avoids large-scale calculations, and at the same time ensures the accuracy, robustness, and timeliness of facial symmetry axis detection. It has good detection performance and has a relatively wide range of applications in facial detection, facial aesthetics evaluation, etc. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 is a flowchart of the method for detecting the facial symmetry axis of a face image based on the genetic algorithm of the present invention;
[0040] Figure 2 is a symmetry axis scanning area diagram of the method for detecting the facial symmetry axis of a face image based on the genetic algorithm of the present invention;
[0041] Figure 3 is an effect diagram of the crossover operation of the method for detecting the facial symmetry axis of a face image based on the genetic algorithm of the present invention;
[0042] Figure 4 is an effect diagram of the mutation operation of the method for detecting the facial symmetry axis of a face image based on the genetic algorithm of the present invention;
[0043] Figure 5 is an effect diagram of the detection result of the method for detecting the facial symmetry axis of a face image based on the genetic algorithm of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0044] The following further describes the present invention with reference to the accompanying drawings.
[0045] The method for detecting the facial symmetry axis of a face image based on the genetic algorithm of the present invention has the following specific implementation steps:
[0046] Step 1: For the input face image in RGB format, first convert it to the HSV color space. The purpose of the conversion is to extract the foreground of the image, that is, the face part, for symmetry calculation. Then extract the facial foreground according to the H channel. Through experiments, it is found that when the setting is [1, 8], the foreground extraction result is relatively stable.
[0047] Step 2: When initializing the population, set the activity interval for individuals. For the activity interval, the smaller the interval range, the smaller the computational amount of the entire algorithm. However, if the interval range is too small, the optimal solution may be missed. Since most faces in the image are relatively regular and there are almost no cases with too large a skew angle, according to the analysis of the results of multiple experiments, set the activity interval of the abscissas of the upper and lower endpoints to 1 / 3 of the image width, that is, the range of 1 / 6 of the image width to the left and right of the intersection of the vertical axis of the image and the x-axis. Such a setting ensures that the algorithm can detect the optimal symmetry axis and, at the same time, reduces the computational amount of the algorithm to a certain extent. The left and right endpoint values of this range are used as the starting number startvalue and the ending number stopvalue of the chromosome encoding.
[0048] Step 3: When calculating the individual fitness, the symmetry, verticality, and proximity corresponding to the individual need to be calculated first. The calculation process of symmetry is as follows: First, calculate the number of foreground pixels in the image, denoted as total, calculate the angle between the axis of symmetry and the x-axis direction of the image, denoted as theta1, and calculate the complementary angle theta2 of theta1; calculate the rotation matrix of the image, set the rotation center as the center point of the image, the rotation degree as theta2, and the scaling ratio of the image as 1; perform a rotation transformation on the image, with the rotation angle being theta1. At this time, the axis of symmetry rotates to the position of the original image's y-axis, and denote the image at the end of this transformation as pic1; perform a horizontal flip of the rotated image along the y-axis to obtain the horizontal mirror image of pic1, denoted as pic2; perform a pixel-by-pixel AND operation on the image pic1 before flipping and the image pic2 after flipping to obtain the area of the symmetric region, scan the image to obtain the total number of pixels in the symmetric region, denoted as match; divide the total number of pixels match in the symmetric region by the total number of pixels total in the foreground of the image to obtain the symmetry of the face, denoted as symmetry. The verticality is the deviation angle, represented by the cosine value of the angle between the individual and the y-axis of the image. The proximity is the proximity between the midpoint of the individual and the center point of the image. First, the distance between the midpoint of the line segment and the center point of the image needs to be calculated. This distance can be obtained by taking the difference between the abscissa of the midpoint of the individual line segment and the center point of the image, denoted as distance. Since there are range limitations for the two endpoints of the individual line segment, that is, the range of the abscissas of the two endpoints is in [startvalue, stopvalue], it can be analyzed that the abscissa of the midpoint of the line segment must also be in [startvalue, stopvalue]. Further analysis shows that the value range of distance is [0, (stopvalue - startvalue) / 2], and thus the proximity is calculated. For the setting of weights, for face images with foreground pixels in the order of 100,000, set w_verticality and w_nearness to 0.0001, which is equivalent to a fluctuation range of 10 pixels.
[0049] Step 4: During the genetic operation process, selection operation, crossover operation, and mutation operation are performed. The selection operation adopts the elitist retention strategy, and the number of retained individuals is set to 2, that is, the two individuals with the largest fitness values are added to the next generation. During the crossover operation, since the gene composition of the individuals in this article is relatively simple, a single-point crossover can be used to complete the optimization task, that is, the results of the crossover respectively take a constant in the chromosome encoding of the parent generation to form their own chromosome encoding. During the mutation operation, to maintain the stability of the method, the occurrence probabilities of translation mutation, rotation mutation, and random mutation are set to be equal and do not occur simultaneously. The number of pixels x for translation mutation and rotation mutation changes randomly within 0 - 10, and the value of random mutation is randomly generated within the activity range of the individual.
[0050] Step 5: In terms of parameter settings, in this paper, the chromosome length is set to 2, the population size is set to 10, the crossover probability is set to 0.9, the mutation probability is set to 0.4, the number of genetic generations is set to 100, and the forced stop condition (stopping evolution when the fitness value does not increase continuously for more than a certain number of generations) is set to 10.
[0051] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for detecting the facial symmetry axis of a face image based on a genetic algorithm, characterized in that: Step 1. Image preprocessing; Step 2. Design chromosome encoding; Step 3. Establish an initial population; Set a randomly generated range for the initial population, that is, the active interval, denoted as: startvalue and stopvalue, to improve the quality of the initial population and obtain the optimal symmetry axis with the least number of iterations; Step 4. Design a fitness function; Step 4.1: When the current individual is the symmetry axis, the symmetry of the entire facial image, and its calculation formula is: where symmetry represents lip symmetry, total represents the total number of pixels in the lip area, and match represents the number of pixels in the lip symmetric area; Step 4.2: The verticality of the individual, that is, the offset angle, is represented by the cosine value of the angle between the individual and the y-axis of the image; Step 4.3: The offset distance of the individual. Here, the proximity between the midpoint of the individual and the center point of the image is defined, and the value range is [0,1]. The greater the proximity, the stronger the adaptability of the individual. The formula is: nearness = 1 - distance / (stopvalue - startvalue) / 2 where the proximity is denoted as nearness, and the distance between the midpoint of the line segment and the center point of the image is denoted as distance; Step 4.4: According to Steps 4.1 - 4.3, the fitness function formula is designed as: fitness = sym * w_sym + verticality * w_verticality + nearness * w_nearness where fitness represents the individual fitness, sym, verticality, and nearness represent symmetry, verticality, and proximity respectively, and w_sym, w_verticality, and w_nearness represent the weights of the three; Step 5. Define genetic operators; The genetic operations include selection operation, crossover operation, and mutation operation; Among them, the selection operation includes roulette wheel strategy, tournament strategy, and elitist retention strategy; The crossover methods include single-point crossover, two-point crossover, multi-point crossover, uniform crossover, and shuffle crossover; The mutation operation is divided into 3 types: (1) The mutation operation is translation mutation. Randomly generate the number of translation pixels x, and add or subtract x to the two abscissas of the current optimal solution to complete the translation mutation; (2) The mutation operation is rotation mutation of the current individual. Randomly generate the number of translation pixels x, and add and subtract x to the two abscissas of the current optimal solution to complete the rotation mutation; (3) The mutation operation is random mutation, that is, randomly generate an abscissa value within the active interval of the abscissa as the chromosome encoding of the mutant individual; By defining the mutation operation in this way, the diversity of the population is maintained and the convergence to the optimal solution is accelerated.
2. The method for detecting the facial symmetry axis of a face image based on a genetic algorithm according to claim 1, wherein: In Step 1, the standard RGB format face facial image is used as the input, and it needs to be converted into the HSV color space for subsequent operations. The conversion formula is: Among them, H, S, V, R, G, and B represent the values of each corresponding channel of the image; the obtained image is subjected to foreground extraction according to the H channel, and then the image is cropped to prevent the interference of irrelevant regions on the detection result.
3. A method for detecting the facial symmetry axis of a face image based on a genetic algorithm according to claim 1, characterized in that: In step 2, the population of the genetic algorithm is a series of straight lines intersecting the upper and lower ends of the image, the individual is one of these straight lines, and the chromosome of the individual adopts a real number coding method, taking the abscissa values of the intersection points of the individual and the upper and lower ends of the image.
4. A method for detecting the facial symmetry axis of a face image based on a genetic algorithm according to claim 1, wherein: The selection operation uses the elitist retention strategy, adding the several individuals with the highest fitness in each generation of the population to the next generation to continue the genetic operation, so as to improve the quality of the individuals in the population and search for the optimal symmetry axis with the least time iteration; The crossover method uses single-point crossover, and the results of the crossover respectively take a constant in the chromosome coding of the parent generation and form its own chromosome coding.
Citation Information
Patent Citations
Three-dimensional grid surface model integral approximate axisymmetric judgment algorithm based on genetic algorithm
CN110070620A