Disclosure of Invention
In view of the above problems, an object of the present invention is to provide an image compression method and system for maintaining face recognition accuracy, which aims to reduce the influence of high compression ratio of image on face recognition accuracy and solve the defects still existing in the technical fields of image compression and face recognition.
In order to realize the purpose of the invention, the invention is realized by the following technical scheme: an image compression method with maintained face recognition precision comprises the following steps:
step one, highlighting image face area
Processing an input initial face image, firstly taking a face as a center, expanding the size of the image, calculating the distance from the center point to the upper, lower, left and right boundaries of the image, then obtaining the maximum distance, then obtaining the size of the expanded image, then recording the initial position information of the initial face image in the expanded image, creating a mask image with the size being the same as that of the expanded image, and calculating the numerical value of the mask image;
step two, generating and processing lines of the face image
Performing secondary processing on the initial face image input in the first step, calculating a global image texture mutation signal of the initial face image, acquiring a mutation signal image, performing pixel-by-pixel multiplication on the mutation signal image and the mask image obtained in the first step to obtain a mutation signal image with a prominent face, further calculating a histogram of the mutation signal image, calculating a value of an accumulated histogram on the basis of the histogram, calculating a selected data volume of the accumulated histogram according to the numerical value of the mask image in the first step, searching the accumulated histogram according to the data volume to obtain a line generation threshold, and performing binarization on the mutation signal image by adopting the threshold to generate a line image;
step three, face image information coding processing
Processing the line image obtained in the step two, and coding the line image by recording the position of the non-0 coordinate of the line image, wherein the row data of the non-0 is recorded by a method of (line number, column number 1, column number 2, column number 3, …)', wherein the column number 1 represents the column coordinate value of the 1 st non-0 pixel coordinate of the line, the column number 2 represents the column coordinate value of the 2 nd non-0 pixel coordinate, and so on, generating final line image coding information, performing sparse color coding processing on the line image obtained in the step two to obtain color image coding information, and then forming the coding information of the initial face image by the color image coding information, the line image coding information and the size of the initial face image;
step four, image decoding processing of face recognition model constraint
Generating a binary image according to the coding information obtained in the third step, initializing all pixels of the binary image to 0, reading the coding information data of the line image, interpreting the data into line data according to the "()" sign in the data, assigning values to the binary image according to the line number and the column number information in the line data, obtaining a recovered line image, generating a color image with the same size, initializing all pixels, recovering according to the coding information of the color image, obtaining a recovered color image, and then superposing the recovered line image and the recovered color image into a four-channel image as input data to be input into an image reconstruction network to generate a reconstructed face image.
The further improvement lies in that: in the first step, when a plurality of faces exist in the input initial face image, corresponding mask images are generated for the faces in the initial face image according to the first step, that is, the mask image corresponding to the initial face image is the pixel-by-pixel sum of all the mask images, and then normalization is performed to obtain the final mask image.
The further improvement lies in that: and in the third step, scanning and coding the line image from top to bottom in a line unit, and recording the data of the line image if the number of non-0 pixel points is greater than 0, otherwise, discarding the data.
The further improvement lies in that: in the fourth step, in the process of restoring the color image, the data of the color image coding information is read, the data is interpreted into line data according to the "()" mark in the data, and then the pixels in the image area are assigned with values according to the line number and the column number information in the line data.
The further improvement lies in that: in the fourth step, the image reconstruction network is composed of an image recovery network and a discrimination network, wherein the image recovery network is composed of ten layers of full convolution networks, and the discrimination network is composed of five layers of full convolution networks.
The further improvement lies in that: in the fourth step, the pixel is initialized to (255 ).
The image compression system with the maintained face recognition precision comprises an image coding module and an image decoding module, wherein the output end of the image coding module is connected with the input end of the image decoding module, the image coding module comprises a highlighting processing module, a line generating module and an image information coding module, and the image decoding module comprises a line color decoding module and a reconstruction network processing module.
The further improvement lies in that: and a face recognition similarity penalty item is also preset in the reconstruction network processing module.
The invention has the beneficial effects that: the image compression method and the image compression system for maintaining the face recognition precision enable an algorithm to pay more attention to image characteristics of a face region through highlighting the face region of an image, then generate a face line image and a sparse color image by adopting the highlighted face image, conduct targeted coding on the face line image and the sparse color image, improve the precision of the face line image and train a face image reconstruction network, and can effectively reduce the influence of image compression on the face recognition precision through embedding a face recognition similarity punishment item in a trained loss function.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
As shown in fig. 1, the present embodiment provides an image compression method with maintained face recognition accuracy, which includes the following steps:
step one, highlighting image face area
Processing an input initial face image I, expanding the size of the image by taking one face as a center, calculating the distance from the center point to the upper, lower, left and right boundaries of the image, then obtaining the maximum distance d, then obtaining the size of the expanded image, wherein the size is (2d +1) × (2d +1), and then recording the initial position information(s) of the initial face image I in the expanded imagel,sr,st,sb) A mask image having the same size as the image after expansion is created, and the numerical value of the mask image is calculated by the formula shown below:
wherein omega is a face region based on the initial position information(s)l,sr,st,sb) Cutting the mask image E to obtain a mask image M with the same size as the original image I;
when a plurality of faces exist in the input initial face image I, respectively generating corresponding mask images M for the faces in the initial face image I according to the mode of the step oneKThat is, the mask image M corresponding to the initial face image I is all the mask images MKIs formulated as follows:
M(x,y)=∑kMk(x,y)
then, normalization is carried out according to a formula to obtain a final mask image M, wherein the formula is as follows:
step two, generating and processing lines of the face image
Performing secondary processing on the initial face image I input in the step one, in order to obtain a line image B, firstly calculating a global image texture mutation signal of the initial face image I, and obtaining a mutation signal image S, wherein the formula is as follows:
c represents RGB three channels of the initial face image I;
and then, multiplying the mutation signal image S and the mask image M obtained in the step one pixel by pixel to obtain a mutation signal image U with a prominent human face, so that the algorithm focuses more on the image characteristics of the human face region, and the formula is expressed as follows:
U(x,y)=S(x,y)·M(x,y)
then, a histogram of the abrupt signal image U is further calculated, and the formula is expressed as:
H(k)=∑I(U(x,y),k)
in the formula, the indication function I (means) indicates that when the value of U (x, y) is k, the result is 1, otherwise, the result is 0;
the cumulative histogram values are calculated on the basis of the histogram, and the formula is expressed as:
A(k)=A(k-1)+H(k)
and then, calculating the selected data quantity M of the cumulative histogram according to the numerical value of the mask image M in the first step so that the generation parameters of the line image B can be self-adapted to the characteristics of the face region of the image, and the formula expression is as follows:
m=0.05×∑I(M(x,y),1)
the indication function I () in the formula indicates that when the value of M (x, y) is 1, the result is 1, otherwise, the result is 0;
searching the cumulative histogram according to the data volume example to obtain a line generation threshold t, wherein the formula is expressed as:
t*=arg mintA(t)>m
carrying out binarization on the mutation signal image U by adopting a threshold value t to generate a line image B, wherein a formula is expressed as;
step three, face image information coding processing
Processing the line image B obtained in the step two, coding by recording the position of the non-0 coordinate of the line image B, scanning and coding the image B from top to bottom by a row unit, recording the ith row data of the image B if the number of the non-0 pixel points is more than 0, otherwise discarding the ith row data, and recording all the non-0 pixel point coordinates of the row by using a method of (row number, column number 1, column number 2, column number 3, …)', wherein the column number 1 represents the row coordinate value of the 1 st non-0 pixel point coordinate of the row, the column number 2 represents the row coordinate value of the 2 nd non-0 pixel point coordinate, and so on to generate final line image coding information br;
and secondly, performing sparse color coding processing on the line image obtained in the second step, namely, equally dividing the line image B into 32 multiplied by 32 image blocks, counting the number of non-0 pixel points in each image block, and recording the number as ni,jMeanwhile, the original face image I is equally divided into 32 × 32 image blocks in the same manner, and the color mean c of each image block is calculatedi,jThen, an image C with the same size as the original face image I is generated, all pixels are initialized to (255 ), color thinning is carried out from top to bottom and from left to left, and when n corresponding to the image block is in the imagei,jIf the color mean value is more than 0, the color mean value c corresponding to the image block is usedi,jReplacing the values of all the pixel points of the block, judging the image block of the coded image C from top to bottom and from left to left during coding, and judging the color C of the image blocki,jWhen not equal to (255,255,255), the term "(block row number, block column number, c)i,j) The format record of' is recorded, otherwise, abandon, until getting the coded information cr of the color picture, then form the coded information E of the original facial image I by coded information cr of the color picture and coded information br of the line picture and size (w, h) of the original facial image I;
step four, image decoding processing of face recognition model constraint
Generating a binary image according to the coding information E obtained in the third step, namely, using the size data (w, h) of the coding information E to initialize all pixels of the binary image to 0, reading the line image coding information data br, deconstructing the data into line data according to the "()" mark in the data, then assigning values to the binary image according to the line number and the column number information in the line data, and then obtaining the restored line image

Then, a color image of the same size is generated, all pixels are initialized to (255 ), and restored according to the color image coding information crIn the process, the data of the color image coding information cr is read firstly, the data is deconstructed into block row-column records according to the "()" mark in the data, and the pixel in the area with the row (i-1) multiplied by 32 more than ii < i multiplied by 32 and the column (j-1) multiplied by 32 more than jj < j multiplied by 32 in the image is assigned with the value c according to the block row number i and the block column number j in the row data
i,j,Obtaining a restored color image
Line image to be restored later
And three channel color image
The image F superposed into four channels is input into an image reconstruction network N as input data to generate a reconstructed face image, wherein the image reconstruction network N is composed of an image recovery network R and a discrimination network D, the image recovery network R is composed of ten layers of full convolution networks, and the discrimination network D is composed of five layers of full convolution networks.
Example two
According to fig. 2, this embodiment provides an image compression system with maintained face recognition accuracy, which includes an image encoding module and an image decoding module, wherein an output end of the image encoding module is connected to an input end of the image decoding module, the image encoding module includes a highlighting processing module, a line generating module and an image information encoding module, the image decoding module includes a line color decoding module and a reconstruction network processing module, wherein an image is encoded as an input end, an initial face image I enters the image encoding module, is processed by the highlighting processing module, the line generating module and the image information encoding module, then enters the image decoding module, and finally a restored face image is output, a face recognition similarity penalty item is preset in the reconstruction network processing module, and by embedding the face recognition similarity penalty item, the influence of image compression on the face recognition precision can be effectively reduced.
The training loss function of the image reconstruction network N is as follows:
in the formula, R (right) represents an image F of four channels input by an image recovery network R, and a reconstructed face image is output
Phi () is an evaluation function of the human eye visual similarity of the image, and is used for judging the initial human face image I and the reconstructed human face image
The visual similarity is realized by a mean square error function, and psi () is an image face recognition similarity evaluation function used for evaluating an initial face image I and a reconstructed face image I
The degree of similarity on the face recognition model.
The foregoing illustrates and describes the principles, general features, and advantages of the present invention. It will be understood by those skilled in the art that the present invention is not limited to the embodiments described above, which are described in the specification and illustrated only to illustrate the principle of the present invention, but that various changes and modifications may be made therein without departing from the spirit and scope of the present invention, which fall within the scope of the invention as claimed. The scope of the invention is defined by the appended claims and equivalents thereof.