A grayscale image data augmentation method based on pixel processing
The data augmentation of grayscale images through pixel processing technology solves the problem that existing methods are difficult to generate rich picture sets and improves the generalization ability of the model.
Patent Information
- Application Number
- CN202111128256.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-26
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2041-09-26
AI Technical Summary
Existing data augmentation methods are difficult to generate rich picture collections, resulting in insufficient generalization capabilities of the model.
Through pixel processing technology, the part to be expanded in the grayscale image is marked, the mean difference of pixel values is calculated, and the annotated pixels are randomly placed and adjusted in the pure background image to generate a new picture.
It realizes efficient generation of rich content images and improves the generalization ability of the model.
Smart Images

Figure CN114092365B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a grayscale image data augmentation method based on pixel processing, belonging to the technical field of image data augmentation. Background Art
[0002] When computer vision algorithms are applied to real-world scenarios, they often encounter the problem of lack of image data of a certain category. A common solution is to augment the data, that is, to generate more images that can be used for training from the original real images. Traditional data augmentation methods perform random rotation, random cropping, random color jittering and other operations on the original images. It is difficult to generate a richer set of images, and accordingly it is difficult to improve the generalization ability of the trained model. Summary of the invention
[0003] Purpose of the invention: In view of the problems and shortcomings existing in the data augmentation methods in the prior art, the present invention provides a grayscale image data augmentation method based on pixel processing that is efficient and can enrich the image.
[0004] Technical solution: A grayscale image data augmentation method based on pixel processing, comprising:
[0005] Step 1: Label the part of the grayscale image to be augmented (usually a complete object);
[0006] Step 2: Calculate the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set, and find the difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set. The difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set is referred to as the difference.
[0007] Step 3: Select a pure background image without foreground, randomly scale and rotate the marked pixel set, and then randomly place it at a certain position of the pure background image. The resulting image is called the background image;
[0008] Step 4: Calculate the average pixel value of the pixels around the pixel set marked in the background image, add the difference, and then subtract the average pixel value of the pixel set marked in the current background image to obtain the adjustment value of the pixel value of the marked pixel in the background image;
[0009] Step 5: Add the adjustment value to each annotated pixel in the set of annotated pixels in the background image to obtain a new image.
[0010] Preferably, the step 1 is specifically:
[0011] The part of the grayscale image to be augmented is annotated at the pixel level to obtain a set of annotated pixels. For example, if you want to augment a defect in a packaging box image, you need to annotate the pixels belonging to the defect.
[0012] Preferably, the step 2 is specifically:
[0013] First, the mean pixel value of the annotated pixel set is calculated, and then the mean pixel value of the pixels around the annotated pixel set is calculated; then the difference between the two means is calculated. The pixels around the annotated pixel set refer to the pixels outside the annotated pixel set whose distance from the annotated pixel set is less than a preset range (for example, 10 pixels).
[0014] The distance between the pixels outside the annotated pixel set and the annotated pixel set is specifically:
[0015] The minimum value of the distance between the pixel outside the labeled pixel set and all the pixels in the labeled pixel set is taken as the distance between the pixel outside the labeled pixel set and the labeled pixel set.
[0016] Preferably, the step 3 is specifically:
[0017] First, find a background image without foreground. For example, in the packaging box defect detection task, find a packaging box image without defects as the background image. Then randomly scale and rotate the annotated pixel set, and then randomly place it at a certain position of the pure background image. If the placement position exceeds the range of the background image, reselect the position.
[0018] Preferably, the step 4 is specifically:
[0019] Calculate the mean pixel value of the pixels around the marked pixel set in the background image, record it as mean1, record the difference as difference, record the mean pixel value of the marked pixel set in the background image as mean2, record the reasonable pixel value mean of the marked pixel set in the background image as mean3, then mean3 = difference + mean1, the adjusted value of the pixel value of the marked pixel in the background image = mean3 - mean2.
[0020] Preferably, the step 5 is specifically:
[0021] An adjustment value is added to each annotated pixel in the background image. After brightness adjustment, the brightness difference of the annotated pixel set relative to its surrounding pixels is close to that of the original image, so it can show a similar pattern.
[0022] A system for implementing the above-mentioned grayscale image data augmentation method based on pixel processing, comprising:
[0023] Annotation module: used to annotate the part to be augmented in the grayscale image and obtain annotated pixel set;
[0024] Calculation module: Calculate the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set, and find the difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set. The difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set is referred to as the difference.
[0025] Background image processing module: select a pure background image without foreground, randomly scale and rotate the marked pixel set, and then randomly put it in a certain position of the pure background image. The resulting image is called the background image;
[0026] Background image adjustment module: calculate the average pixel value of the pixels around the pixel set marked in the background image, add the difference, and then subtract the average pixel value of the pixel set marked in the current background image to obtain the adjustment value of the pixel value of the marked pixel in the background image;
[0027] Image generation module: An adjustment value is added to each annotated pixel in the set of annotated pixels in the background image to obtain a new image.
[0028] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the grayscale image data augmentation method based on pixel processing as described above is implemented.
[0029] A computer-readable storage medium stores a computer program for executing the grayscale image data augmentation method based on pixel processing as described above.
[0030] Beneficial effect: Compared with the traditional data augmentation method, the grayscale image data augmentation method based on pixel processing provided by the present invention can efficiently generate images with rich content. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 Schematic diagram of the process of a grayscale image data augmentation method based on pixel processing in an embodiment of the present invention;
[0032] Figure 2 Provides a schematic diagram of a defective packaging box in an embodiment of the present invention;
[0033] Figure 3 is a schematic diagram of a packaging box used as a background image in an embodiment of the present invention;
[0034] Figure 4 This is a schematic diagram of a packaging box obtained by data augmentation in an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The present invention is further explained below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.
[0036] The grayscale image data augmentation method based on pixel processing has the following process: Figure 1 As shown, including:
[0037] Step 1: Label the part of the grayscale image to be augmented (usually a complete object), specifically:
[0038] Annotate the part of the grayscale image to be augmented at the pixel level to obtain a set of annotated pixels. For example, if you want to augment the defects in the packaging box image, you need to annotate the pixels belonging to the defect. Figure 2 .
[0039] Step 2: Calculate the mean pixel value of the annotated pixel set and the mean pixel value of the pixels around the annotated pixel set, and find their difference, specifically:
[0040] First, the mean pixel value of the annotated pixel set is calculated, and then the mean pixel value of the pixels outside the annotated pixel set whose distance from the annotated pixel set is less than a set range (for example, 10 pixels) is calculated. Then the difference between the two means is calculated.
[0041] The distance between the pixels outside the annotated pixel set and the annotated pixel set is specifically:
[0042] The minimum value of the distance between the pixel outside the labeled pixel set and all the pixels in the labeled pixel set is taken as the distance between the pixel outside the labeled pixel set and the labeled pixel set.
[0043] Step 3: Select a pure background image without foreground (reference Figure 3 ), randomly scale and rotate the labeled pixel set, and then randomly place it at a certain position of the pure background image. The resulting image is called the background image. Specifically:
[0044] First, find a background image without foreground. For example, in the packaging box defect detection task, find a packaging box image without defects as the background image. Then randomly scale and rotate the annotated pixel set, and then randomly place it at a certain position of the pure background image. If the placement position exceeds the range of the background image, reselect the position.
[0045] Step 4: Calculate the mean pixel value of the pixels around the marked pixel set in the background image, add the difference, and then subtract the mean pixel value of the marked pixel set in the current background image to obtain the adjustment value of the pixel value of the marked pixel in the background image, specifically:
[0046] Calculate the mean pixel value of the pixels around the marked pixel set in the background image, record it as mean1, record the difference as difference, the mean pixel value of the pixel set in the background image is mean2, and the reasonable pixel value mean of the marked pixel set in the background image is record as mean3, then mean3 = difference + mean1, the adjusted value of the pixel value of the marked pixel in the background image = mean3 - mean2.
[0047] Step 5: Add the adjustment value to each annotated pixel in the background image, specifically:
[0048] Each annotated pixel in the background image is added with an adjustment value. After brightness adjustment, the brightness difference of the annotated pixel set relative to its surrounding pixels is close to that of the original image, so it can show a similar pattern. Figure 4 .
[0049] A system for implementing the above-mentioned grayscale image data augmentation method based on pixel processing comprises:
[0050] Annotation module: used to annotate the part to be augmented in the grayscale image and obtain annotated pixel set;
[0051] Calculation module: Calculate the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set, and find the difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set. The difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set is referred to as the difference.
[0052] Background image processing module: select a pure background image without foreground, randomly scale and rotate the marked pixel set, and then randomly put it in a certain position of the pure background image. The resulting image is called the background image;
[0053] Background image adjustment module: calculate the average pixel value of the pixels around the pixel set marked in the background image, add the difference, and then subtract the average pixel value of the pixel set marked in the current background image to obtain the adjustment value of the pixel value of the marked pixel in the background image;
[0054] Image generation module: An adjustment value is added to each annotated pixel in the set of annotated pixels in the background image to obtain a new image.
[0055] Obviously, those skilled in the art should understand that the various steps of the grayscale image data augmentation method based on pixel processing or the various modules of the grayscale image data augmentation system based on pixel processing of the above-mentioned embodiment of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented with executable program codes of the computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that here, or they can be made into individual integrated circuit modules respectively, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.
Claims
1. A grayscale image data augmentation method based on pixel processing, characterized in that: include: Step 1: Mark the part of the grayscale image to be augmented; Step 2: Calculate the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set, and find the difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set. The difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set is referred to as the difference. Step 3: Select a pure background image without foreground, randomly scale and rotate the marked pixel set, and then randomly place it at a certain position of the pure background image. The resulting image is called the background image; Step 4: Calculate the average pixel value of the pixels around the pixel set marked in the background image, add the difference, and then subtract the average pixel value of the pixel set marked in the current background image to obtain the adjustment value of the pixel value of the marked pixel in the background image; Step 5: Add the adjustment value to each annotated pixel in the set of annotated pixels in the background image to obtain a new image.
2. The grayscale image data augmentation method based on pixel processing according to claim 1, characterized in that: The step 1 is specifically as follows: annotating the part to be augmented in the grayscale image at the pixel level to obtain a set of annotated pixels.
3. The grayscale image data augmentation method based on pixel processing according to claim 1, characterized in that: The step 2 is specifically as follows: First, the mean pixel value of the annotated pixel set is calculated, and then the mean pixel value of the pixels around the annotated pixel set is calculated; then the difference between the two means is calculated; the pixels around the annotated pixel set refer to pixels outside the annotated pixel set whose distance from the annotated pixel set is less than a preset range.
4. The grayscale image data augmentation method based on pixel processing according to claim 3, characterized in that: The distance between the pixels outside the annotated pixel set and the annotated pixel set is: The minimum value of the distance between the pixel outside the labeled pixel set and all the pixels in the labeled pixel set is taken as the distance between the pixel outside the labeled pixel set and the labeled pixel set.
5. The grayscale image data augmentation method based on pixel processing according to claim 1, characterized in that: The step 3 is specifically as follows: First, find a background image without foreground; then randomly scale and rotate the set of labeled pixels, and then randomly place them at a certain position on the pure background image. If the placement position exceeds the range of the background image, reselect the position.
6. The grayscale image data augmentation method based on pixel processing according to claim 1, characterized in that: The step 4 is specifically as follows: Calculate the mean pixel value of the pixels around the marked pixel set in the background image, record it as mean1, record the difference as difference, record the mean pixel value of the marked pixel set in the background image as mean2, record the reasonable pixel value mean of the marked pixel set in the background image as mean3, then mean3 = difference + mean1, the adjusted value of the pixel value of the marked pixel in the background image = mean3 - mean2.
7. A grayscale image data augmentation system based on pixel processing, characterized in that: include: Annotation module: used to annotate the part to be augmented in the grayscale image and obtain annotated pixel set; Calculation module: Calculate the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set, and find the difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set. The difference between the mean pixel value of the labeled pixel set and the mean pixel value of the pixels around the labeled pixel set is referred to as the difference. Background image processing module: select a pure background image without foreground, randomly scale and rotate the marked pixel set, and then randomly put it in a certain position of the pure background image. The resulting image is called the background image; Background image adjustment module: calculate the average pixel value of the pixels around the pixel set marked in the background image, add the difference, and then subtract the average pixel value of the pixel set marked in the current background image to obtain the adjustment value of the pixel value of the marked pixel in the background image; Image generation module: An adjustment value is added to each annotated pixel in the set of annotated pixels in the background image to obtain a new image.
8. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the grayscale image data augmentation method based on pixel processing as described in any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the grayscale image data augmentation method based on pixel processing as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method for generating license plate character grey-scale map
CN108573254A
Object spatial data augmentation method and system based on three-dimensional reconstruction
CN111932673A