Illumination simulation data enhancement method
Through the data enhancement method of simulating lighting, simulated lighting images are generated, which solves the problem of poor face recognition effect caused by lighting changes in the prior art, and achieves a significant improvement in the face recognition effect.
Patent Information
- Application Number
- CN202310736944.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-20
- Publication Date
- 2024-12-24
AI Technical Summary
In the prior art, it is difficult to generate sufficient training samples with different lighting conditions based on the illumination subspace model, resulting in poor facial recognition effect and time-consuming and ineffective.
Through the data enhancement method of simulating light, a mask similar to the darkness around the center of the real light is generated, and the real light situation is simulated by multiplying the picture with the mask, including calculating the image size, creating a random size mask, defining the spot brightness and Position and multiply the picture with the mask to generate a simulated light image.
It significantly improves the facial recognition effect, the method is simple and efficient, and does not affect the face details of the existing training set, and is suitable for pictures of various imaging quality.
Smart Images

Figure CN119180901A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image processing, and in particular relates to a data enhancement method for simulating illumination. Background Art
[0002] In the prior art, the arbitrary illumination image data generation method based on the illumination subspace model is used to generate multiple training samples under different illumination conditions. However, there are too few pictures that can be used as sample databases, and a large number of faces under different illuminations are required. The demand is huge, and it is difficult to accurately establish an illumination submodel. In addition, it is time-consuming and impractical.
[0003] In addition, commonly used technical terms include:
[0004] 1. Data enhancement: It is used to enhance the generalization performance of the model. By preprocessing the training data and simulating the lighting, blur, noise and other conditions of the face in real scenes, the generalization performance of the model training can be better.
[0005] 2. Image mask: Use selected images, graphics or objects to block the processed image (all or part) to control the area of image processing.
[0006] 3. The illumination subspace model uses images of the same face under different lighting conditions and restores the texture and three-dimensional shape of the face through the principle of photometric stereology, thereby establishing a three-dimensional model of the face, and then uses the three-dimensional face model to synthesize postures and face images under various lighting conditions. Summary of the invention
[0007] In order to solve the above problems, the purpose of this application is to:
[0008] At present, since the changes brought about by different lighting to face images exceed the changes between images of different faces, the face recognition effect is poor. This method generates simulated lighting as data enhancement, which significantly improves the effect of face recognition.
[0009] Specifically, the present invention provides a data enhancement method for simulating illumination, wherein a mask similar to real illumination with bright center and dark surrounding is generated, and a situation simulating real illumination is generated by multiplying a picture by the mask, that is, multiplying a pixel value at a corresponding position of the picture by a pixel value at a corresponding position of the mask; the method comprises the following steps:
[0010] S1. Calculate the size of the image, expressed as: imgsize = img.shape[0], where img is the input image;
[0011] S2. Create a mask smaller than the image size, whose size is size; the mask is a binary image that partially blocks another image. The size of the mask is in the range of [30, imgsize],
[0012] Create an image of size imgsize*imgsize with a pixel value of 0, expressed as:
[0013] mask=np.ones((imgsize,imgsize),dtype=np.float32);
[0014] Randomly generate a value between [30, imgsize] as the size of the mask, expressed as:
[0015] size=np.random.randint(30,imgsize);
[0016] S3. Randomly define the size of the light spot. The value of the light spot is a monotonically increasing sequence of [0,π], defined as x, expressed as:
[0017] x=np.linspace(0,np.pi,size);
[0018] S4. Set the brightness of the light spot to sin(x)*brightness value; the brightness value is set to [0.8,1.2], defined as y, expressed as:
[0019] y=np.sin(x)*np.random.choice([0.8,1.2]),
[0020] Among them, the larger the brightness value, the brighter the light spot;
[0021] S5. Convert the one-dimensional y into a vector kernel of size (size, size), and use reshape to force the size of the vector to be the size in step S2; the kernel is a bright spot, which is expressed as: kernel = y.reshape (size, 1) * y.reshape (1, size);
[0022] S6. Define the position of the bright spot on the mask and superimpose the two.
[0023] In the range of [0, imgsize-size], take two values, 2 means take two values; expressed as: offset_x, offset_y = np.random.randint(0, imgsize-size, (2));
[0024] In the wide value range of the mask [offset_y:offset_y+size] and the high value range [offset_x:offset_x+size], the mask and the pixel value of the bright spot are superimposed, where this part of the area is the area of interest, which is expressed as:
[0025] mask[offset_y:offset_y+size,offset_x:offset_x+size]+=kernel;
[0026] S7. Multiply the pixels of the image by the mask to obtain an image simulating illumination.
[0027] Scale the size of the mask to (imgsize, imgsize, 1) and multiply the image by the mask, and multiply the pixel values at the corresponding positions, expressed as:
[0028] img=img*mask.reshape(imgsize,imgsize,1);
[0029] The pixel value range of the image is (0, 255). Each pixel value in img is truncated to prevent it from crossing the range, which is expressed as: img = np.clip(img, 0, 255).astype(np.uint8);
[0030] Among them, img is the input image, and mask contains the mask of the bright spot, and the two have the same size.
[0031] The size of the picture in step S1 is any value, including: 96*96, 112*112, 1024*10214.
[0032] The size of the picture is 96*96 or 112*112.
[0033] In step S7, the image is multiplied by the mask: in step S6 of mask, the pixels in the region of interest are multiplied with the pixel values at the same position of img, so that the pixel values of the non-interested regions are not changed at the same time.
[0034] Therefore, the advantages of this application are:
[0035] This method is simple and efficient, and has the same effect on images of various imaging qualities. It will not affect the facial details of the existing training set. Experiments have shown that using this method as data enhancement can significantly improve the face recognition effect under different lighting conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.
[0037] Figure 1 is a schematic diagram of the process of this method. DETAILED DESCRIPTION
[0038] In order to more clearly understand the technical content and advantages of the present invention, the present invention is now further described in detail in conjunction with the accompanying drawings.
[0039] like Figure 1 As shown, the present application provides a data enhancement method for simulating illumination, comprising the following steps:
[0040] S1. Calculate the size of the image, expressed as: imgsize = img.shape[0], img is the input image; the size of the image can be any value, including: 96*96, 112*112, 1024*10214. The value used in general implementation is 96*96 or 112*112;
[0041] S2. Create a mask smaller than the image size, whose size is size; the mask is a binary image that partially blocks another image. The size of the mask is in the range of [30, imgsize] (empirical value), expressed as:
[0042] mask = np.ones((imgsize, imgsize), dtype = np.float32); Create an image with a size of imgsize*imgsize and a pixel value of 0;
[0043] size = np.random.randint(30,imgsize); randomly generate a value between [30,imgsize] as the size of the mask;
[0044] S3. Randomly define the size of the light spot. The value of the light spot is a monotonically increasing sequence of [0,π], defined as x, expressed as:
[0045] x=np.linspace(0,np.pi,size);
[0046] S4. Set the brightness of the light spot to sin(x)*brightness value; the brightness value is set to [0.8,1.2], defined as y, expressed as:
[0047] y=np.sin(x)*np.random.choice([0.8,1.2]),
[0048] Among them, the larger the brightness value, the brighter the light spot;
[0049] S5. Convert the one-dimensional y into a vector kernel of size (size, size), and use reshape to force the size of the vector to be the size in step S2; the kernel is a bright spot, which is expressed as: kernel = y.reshape (size, 1) * y.reshape (1, size);
[0050] S6. Define the position of the bright spot on the mask and superimpose the two.
[0051] In the range of [0, imgsize-size], take two values, 2 means take two values; expressed as: offset_x, offset_y = np.random.randint(0, imgsize-size, (2));
[0052] In the wide value range of the mask [offset_y:offset_y+size] and the high value range [offset_x:offset_x+size], the mask and the pixel value of the bright spot are superimposed, where this part of the area is the area of interest, which is expressed as:
[0053] mask[offset_y:offset_y+size,offset_x:offset_x+size]+=kernel;
[0054] S7. Multiply the pixels of the image by the mask to obtain an image simulating illumination.
[0055] Scale the size of the mask to (imgsize, imgsize, 1) and multiply the image by the mask, and multiply the pixel values at the corresponding positions, expressed as:
[0056] img=img*mask.reshape(imgsize,imgsize,1);
[0057] The pixel value range of the image is (0, 255). Each pixel value in img is truncated to prevent it from crossing the range, which is expressed as: img = np.clip(img, 0, 255).astype(np.uint8);
[0058] Where img is the input image, and mask contains a mask of bright spots, and the two are of the same size. The image is multiplied by the mask: Step S6 of mask performs multiplication operation on the pixels in the region of interest and the pixel values at the same position of img, which will not change the pixel values of the non-interested regions.
[0059] In summary, the method uses sin(x) in Monotonically increasing, The monotonically decreasing characteristic generates a mask similar to the real illumination, which is bright in the center and dark around. That is, the size number of step S2 is randomly generated in an increasing manner between [0, π]. Here, π is 3.1415926, and these values are saved in the list X. For each value in the list, the corresponding sin(x) is calculated in turn. According to the monotonicity of sin(x), a new list M can be obtained. Among them, the value of M is monotonically increasing in the first half and monotonically decreasing in the second half, that is, the middle value is large and the values on both sides are small. This characteristic of list M conforms to the characteristic of real illumination, which is bright in the middle and dark on both sides. The situation of simulating real illumination is generated by multiplying the image and the mask, that is, multiplying the pixel value at the corresponding position of the image with the pixel value at the corresponding position of the mask.
[0060] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data enhancement method for simulating illumination, characterized in that: The method generates a mask similar to real lighting with bright center and dark surroundings, and generates a simulated real lighting situation by multiplying the image with the mask, that is, multiplying the pixel value of the corresponding position of the image with the pixel value of the corresponding position of the mask; the method includes the following steps: S1. Calculate the size of the image, expressed as: imgsize = img.shape[0], where img is the input image; S2. Create a mask smaller than the image size, whose size is size; the mask is a binary image that partially blocks another image. The size of the mask is in the range of [30, imgsize], Create an image of size imgsize*imgsize with a pixel value of 0, expressed as: mask=np.ones((imgsize,imgsize),dtype=np.float32); Randomly generate a value between [30, imgsize] as the size of the mask, expressed as: size=np.random.randint(30,imgsize); S3. Randomly define the size of the light spot. The value of the light spot is a monotonically increasing sequence of [0,π], defined as x, expressed as: x=np.linspace(0,np.pi,size); S4. Set the brightness of the light spot to sin(x)*brightness value; the brightness value is set to [0.8,1.2], defined as y, expressed as: y=np.sin(x)*np.random.choice([0.8,1.2]), Among them, the larger the brightness value, the brighter the light spot; S5. Convert the one-dimensional y into a vector kernel of size (size, size), and use reshape to force the size of the vector to become the size in step S2; the kernel is a bright spot, expressed as: kernel=y.reshape(size,1)*y.reshape(1,size); S6. Define the position of the bright spot on the mask and superimpose the two. In the range of [0, imgsize-size], take two values, 2 means take two values; expressed as: offset_x, offset_y = np.random.randint(0, imgsize-size, (2)); In the wide value range of the mask [offset_y:offset_y+size] and the high value range [offset_x:offset_x+size], the mask and the pixel value of the bright spot are superimposed, where this part of the area is the area of interest, which is expressed as: mask[offset_y:offset_y+size,offset_x:offset_x+size]+=kernel; S7. Multiply the pixels of the image by the mask to obtain an image simulating illumination. Scale the size of the mask to (imgsize, imgsize, 1) and multiply the image by the mask, and multiply the pixel values at the corresponding positions, expressed as: img=img*mask.reshape(imgsize,imgsize,1); The pixel value range of the image is (0, 255). Each pixel value in img is truncated to prevent it from crossing the range, which is expressed as: img = np.clip(img, 0, 255).astype(np.uint8); Among them, img is the input image, and mask contains the mask of the bright spot, and the two have the same size.
2. The data enhancement method for simulating illumination according to claim 1, characterized in that: The size of the picture in step S1 is any value, including: 96*96, 112*112, 1024*10214.
3. The data enhancement method for simulating illumination according to claim 2, characterized in that: The size of the picture is 96*96 or 112*112.
4. The data enhancement method for simulating illumination according to claim 1, characterized in that: In step S7, the image is multiplied by the mask: in step S6 of mask, the pixels in the region of interest are multiplied with the pixel values at the same position of img, so that the pixel values of the non-interested regions are not changed at the same time.
