Image vignetting processing method, device, equipment and readable storage medium
By detecting the vignetting range and establishing pixel position correspondence during the device production and testing phase, and performing interpolation calculations, the problems of image deformation and image quality degradation during image vignetting processing are solved, achieving adaptable and high-quality image vignetting processing.
Patent Information
- Application Number
- CN202510933729.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-07-08
AI Technical Summary
When processing image vignetting, existing technologies are unable to effectively eliminate large vignetting, which affects the back-end module of the image signal processor, resulting in overall image distortion and degradation of image quality.
By detecting the vignetting range during the device production and testing phase, a pixel position correspondence is established between the image to be processed and the original image, and interpolation calculations are performed and pixel values are replaced to eliminate vignetting.
It is suitable for devices with various degrees of vignetting, avoids affecting the back-end module of the image signal processor, ensures that the center area of the image is not deformed, and improves image quality.
Smart Images

Figure CN120450948B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image vignetting processing method, device, equipment and readable storage medium. Background Art
[0002] Current cameras lack a perfect match between image sensors and lenses. Especially when using wide-angle lenses, peripheral light cannot reach the sensor, causing vignetting at all angles. Furthermore, due to differences in the assembly of printed circuit boards (PCBs) and lens mounting holes, the degree of vignetting varies from camera to camera.
[0003] Currently, vignetting is typically mitigated using the Lens Shading Correction (LSC) module on the Image Signal Processor (ISP) or eliminated using a distortion algorithm. Both of these methods have drawbacks: the LSC module cannot completely eliminate vignetting and cannot handle large vignetting angles. Furthermore, each device must be calibrated in the lab, which impacts the performance of ISP backend modules such as the Automatic White Balance (AWB) and Color Correction Matrix (CCM). Using a distortion algorithm to eliminate vignetting can cause overall image distortion, affecting image quality.
[0004] In summary, how to effectively solve the problems of the current image vignetting processing method, which cannot process larger vignetting, affects the back-end module of the image signal processor, causes the overall image to be deformed, and affects the image quality, is an issue that technical personnel in this field urgently need to solve. Summary of the Invention
[0005] The purpose of this application is to provide an image vignetting processing method, which is suitable for various devices with different degrees of vignetting, avoids the impact on the back-end module of the image signal processor, ensures that the middle area of the image is not deformed, and ensures the image quality; another purpose of this application is to provide an image vignetting processing device, equipment and computer-readable storage medium.
[0006] To solve the above technical problems, this application provides the following technical solutions:
[0007] A method for processing image vignetting, comprising:
[0008] Obtain the image to be processed and the preset vignetting range;
[0009] Obtaining first pixel positions corresponding to respective pixel points within the dark corner range in the image to be processed;
[0010] Calculating each second pixel position according to each first pixel position and a pre-established pixel position correspondence between the image to be processed and the original image;
[0011] Performing interpolation calculations on the pixel points at each second pixel position in the image to be processed to obtain target interpolation values;
[0012] Calculate target pixel values corresponding to the first pixel positions according to the pixel values corresponding to the first pixel positions and the target interpolation values, and use the target pixel values to replace the pixel values of the first pixel positions in the image to be processed.
[0013] In a specific embodiment of the present application, a process of setting the vignetting range is further included, and the process of setting the vignetting range includes:
[0014] Generate a mask of the four corner areas of the target image according to the target image collected during the equipment production and testing phase; wherein the four corner areas are areas divided according to a preset aspect ratio;
[0015] Obtaining the detection range of the target image using the mask marks of the four corner areas;
[0016] Calculating the grayscale mean of each pixel in the target image, and determining the grayscale threshold according to the grayscale mean;
[0017] Determine pixels within the detection range whose grayscale values are less than the grayscale threshold as dark corner pixels;
[0018] Determine the vertex where the detection range and the target image overlap as the center of the dark corner range;
[0019] Determine the maximum radius extending from the center of the circle to each dark corner pixel in the detection range as the radius of the dark corner range;
[0020] The dark corner range is determined according to the center of the dark corner range, the radius of the dark corner range, and the detection range.
[0021] In a specific embodiment of the present application, a process of establishing the pixel position correspondence relationship is further included, and the process of establishing the pixel position correspondence relationship includes:
[0022] Get the global scaling factor;
[0023] Obtaining the vignetting weight function and displacement direction corresponding to each pixel position within the vignetting range in the target image collected during the equipment production test phase;
[0024] The pixel position correspondence is established according to the global scaling factor, the dark angle weight function and the displacement direction.
[0025] In a specific embodiment of the present application, obtaining the vignetting weight function and displacement direction corresponding to each pixel position within the vignetting range in the target image collected during the device production test phase includes:
[0026] Calculating respectively the normalized distance between each pixel position within the dark corner range in the target image and the center of the circle of the dark corner range;
[0027] Calculating the vignetting weight function corresponding to each pixel position within the vignetting range in the target image according to each normalized distance;
[0028] The displacement directions corresponding to the respective pixel positions in the dark corner range are calculated according to the coordinates of the respective pixel positions in the dark corner range in the target image and the coordinates of the center of the circle in the dark corner range.
[0029] In a specific embodiment of the present application, interpolation calculation is performed on each pixel point at each second pixel position in the image to be processed to obtain each target interpolation value, including:
[0030] Selecting a second pixel point whose horizontal coordinate and vertical coordinate are both integer values from the pixel points at each second pixel position in the image to be processed, and determining the pixel value of the selected second pixel point as the target interpolation value corresponding to the second pixel point;
[0031] Selecting a second pixel point whose abscissa and / or ordinate is a small value from the pixel points at each second pixel position in the image to be processed;
[0032] Calculating a horizontal offset according to the horizontal coordinate of the second pixel point, and calculating a vertical offset according to the vertical coordinate of the second pixel point;
[0033] Find the nearest neighbor pixel of the second pixel in the image to be processed;
[0034] A target interpolation value corresponding to the second pixel point is calculated according to the pixel value of the nearest neighbor pixel point, the horizontal offset, and the vertical offset.
[0035] In a specific embodiment of the present application, calculating the target pixel values corresponding to the first pixel positions according to the pixel values corresponding to the first pixel positions and the target interpolation values includes:
[0036] Obtaining the dark corner weight function corresponding to each first pixel position;
[0037] Determine the dark corner weight function corresponding to each first pixel position as the interpolation intensity corresponding to each first pixel position;
[0038] A weighted calculation is performed on the pixel values corresponding to the first pixel positions and the target interpolation values according to the interpolation strengths corresponding to the first pixel positions to obtain the target pixel values corresponding to the first pixel positions.
[0039] In a specific embodiment of the present application, replacing the pixel value of each first pixel position in the image to be processed with each target pixel value includes:
[0040] Before encoding the image to be processed, the pixel values at the first pixel positions in the image to be processed are replaced by the target pixel values.
[0041] An image vignetting processing device, comprising:
[0042] A vignetting range acquisition module is used to acquire the image to be processed and the preset vignetting range;
[0043] A first pixel position acquisition module is used to acquire first pixel positions corresponding to respective pixel points within the dark corner range in the image to be processed;
[0044] A second pixel position acquisition module, configured to calculate each second pixel position according to each first pixel position and a pre-established pixel position correspondence between the image to be processed and the original image;
[0045] An interpolation calculation module, configured to perform interpolation calculations on the pixel points at each second pixel position in the image to be processed to obtain target interpolation values;
[0046] The pixel value replacement module is used to calculate the target pixel values corresponding to each first pixel position according to the pixel values corresponding to each first pixel position and each target interpolation value, and use each target pixel value to replace the pixel value of each first pixel position in the image to be processed.
[0047] An image vignetting processing device, comprising:
[0048] Memory for storing computer programs;
[0049] The processor is configured to implement the steps of the image vignetting processing method as described above when executing the computer program.
[0050] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the image vignetting processing method as described above.
[0051] The image vignetting processing method provided in the present application obtains an image to be processed and a preset vignetting range; obtains first pixel positions corresponding to each pixel point within the vignetting range in the image to be processed; calculates each second pixel position based on each first pixel position and a pre-established pixel position correspondence between the image to be processed and the original image; performs interpolation calculations on the pixel points at each second pixel position in the image to be processed to obtain each target interpolation value; calculates target pixel values corresponding to each first pixel position based on the pixel values corresponding to each first pixel position and each target interpolation value, and uses each target pixel value to replace the pixel value of each first pixel position in the image to be processed.
[0052] It can be seen from the above technical solution that by allowing the device to detect the dark angle range of each corner during the image detection process during the device production test, the pixel position correspondence between the image to be processed and the original image is established. In subsequent use, the second pixel positions corresponding to each first pixel position in the image to be processed are determined based on the pixel position correspondence between the image to be processed and the original image within the dark angle range, and the pixel points of each second pixel position are interpolated and calculated, and then the target pixel values corresponding to each first pixel position are calculated based on the target interpolation value of each second pixel position and the pixel value corresponding to each first pixel position, and the pixel value of each first pixel position is replaced by each target pixel value. The dark angle processing method provided by the present application can perform dark angle processing based on the dark angle range obtained in the device production test stage, and is suitable for various devices with different degrees of dark angle. It also avoids the impact on the back-end module of the image signal processor, ensures that the middle area of the image is not deformed, and ensures image quality.
[0053] Correspondingly, the present application also provides an image vignetting processing device, equipment and computer-readable storage medium corresponding to the above-mentioned image vignetting processing method, which have the above-mentioned technical effects and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0055] Figure 1 This is a flowchart of an implementation of the image vignetting processing method in an embodiment of the present application;
[0056] Figure 2 This is another implementation flow chart of the image vignetting processing method in the embodiment of the present application;
[0057] Figure 3A schematic diagram of displacement intensity and displacement direction in an embodiment of the present application;
[0058] Figure 4 This is a structural block diagram of an image vignetting processing device according to an embodiment of the present application;
[0059] Figure 5 This is a structural block diagram of an image vignetting processing device in an embodiment of the present application;
[0060] Figure 6 A schematic diagram of the specific structure of an image vignetting processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the embodiments described are only a part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making any creative efforts are within the scope of protection of the present application.
[0062] See also Figure 1 , Figure 1 This is a flowchart of an implementation method of an image vignetting processing method in an embodiment of the present application. The method may include the following steps.
[0063] S101: Acquire an image to be processed and a preset vignetting range.
[0064] When an image that needs to be processed has vignetting, the image to be processed is obtained. During the device production test, a vignetting range corresponding to the device that captures the image to be processed is pre-set to obtain the preset vignetting range.
[0065] It should be noted that since vignetting generally exists in pairs, for example, both upper two corners of a rectangular image captured by a device have vignetting, an appropriate vignetting range may be set for each vignetting corner.
[0066] S102: Obtain first pixel positions corresponding to respective pixel points within a dark corner range in the image to be processed.
[0067] After the image to be processed and the preset dark corner range are acquired, first pixel positions corresponding to respective pixel points within the dark corner range in the image to be processed are acquired.
[0068] S103: Calculating each second pixel position according to each first pixel position and a pre-established pixel position correspondence between the image to be processed and the original image.
[0069] A pixel position correspondence between the image to be processed and the original image is established in advance. After obtaining the first pixel positions corresponding to each pixel point within the dark corner range of the image to be processed, the second pixel positions are calculated based on each first pixel position and the pre-established pixel position correspondence between the image to be processed and the original image.
[0070] S104: performing interpolation calculations on the pixel points at each second pixel position in the image to be processed respectively to obtain target interpolation values.
[0071] After calculating each second pixel position, interpolation calculation is performed on the pixel points at each second pixel position in the image to be processed, such as using a bilinear interpolation method to interpolate the pixel points at each second pixel position in the image to be processed to obtain each target interpolation value.
[0072] S105: Calculating target pixel values corresponding to the first pixel positions according to the pixel values corresponding to the first pixel positions and the target interpolation values, and replacing the pixel values of the first pixel positions in the image to be processed with the target pixel values.
[0073] After calculating each target interpolation value, the target pixel value corresponding to each first pixel position is calculated according to the pixel value corresponding to each first pixel position in the image to be processed and each target interpolation value, and the pixel value of each first pixel position in the image to be processed is replaced by each target pixel value, thereby achieving the elimination of dark corners of the image to be processed.
[0074] It can be seen from the above technical solution that by allowing the device to detect the dark angle range of each corner during the image detection process during the device production test, the pixel position correspondence between the image to be processed and the original image is established. In subsequent use, the second pixel positions corresponding to each first pixel position in the image to be processed are determined based on the pixel position correspondence between the image to be processed and the original image within the dark angle range, and the pixel points of each second pixel position are interpolated and calculated, and then the target pixel values corresponding to each first pixel position are calculated based on the target interpolation value of each second pixel position and the pixel value corresponding to each first pixel position, and the pixel value of each first pixel position is replaced by each target pixel value. The dark angle processing method provided by the present application can perform dark angle processing based on the dark angle range obtained in the device production test stage, and is suitable for various devices with different degrees of dark angle. It also avoids the impact on the back-end module of the image signal processor, ensures that the middle area of the image is not deformed, and ensures image quality.
[0075] It should be noted that, based on the above embodiment, the present application also provides corresponding improved solutions. In subsequent embodiments, the same steps or corresponding steps as those in the above embodiment can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, and will not be described in detail in the following improved embodiments.
[0076] See also Figure 2 , Figure 2 This is another implementation flow chart of the image vignetting processing method in an embodiment of the present application. The method may include the following steps.
[0077] S201: Generate masks of the four corner areas of the target image according to the target image collected during the device production and testing phase.
[0078] The four corner areas are areas divided according to a preset width-to-height ratio.
[0079] During device production testing, the device is used to capture images and obtain a target image. Based on the size of the dark corner areas in the target image, the target image is divided into four corner areas with corresponding aspect ratios. A mask for the four corner areas of the target image is generated based on the captured target image.
[0080] S202: Obtain the detection range of the target image using the mask marks of the four corner areas.
[0081] After generating the masks of the four corner areas of the target image, the detection range of the target image is obtained using the mask marks of the four corner areas.
[0082] S203: Calculate the grayscale mean of each pixel in the target image, and determine the grayscale threshold according to the grayscale mean.
[0083] The grayscale values of each pixel in the target image vary. The grayscale values of each pixel in the target image are obtained, and the grayscale mean of each pixel in the target image is calculated based on the obtained grayscale values. After calculating the grayscale mean of each pixel in the target image, a grayscale threshold can be set based on the grayscale mean. For example, the grayscale threshold can be set between 0.6 and 0.8 of the grayscale mean to obtain a preset grayscale threshold.
[0084] S204: Determine pixels within the detection range whose grayscale values are less than the grayscale threshold as dark corner pixels.
[0085] After the grayscale threshold is determined, the pixel value of each pixel in the detection range is compared with the grayscale threshold, and the pixel with a grayscale value less than the grayscale threshold within the detection range is determined as a dark corner pixel.
[0086] S205: Determine the vertex where the detection range and the target image overlap as the center of the dark corner range.
[0087] See also Figure 3 , Figure 3 This is a schematic diagram of displacement intensity and displacement direction in an embodiment of the present application. After marking the detection range of the target image, the vertex where the detection range and the target image overlap is determined as the center of the dark angle range. , the center of the circle is the vertex of the dark corner in the target image.
[0088] S206: Determine the maximum radius extending from the center of the circle to each dark corner pixel in the detection range as the radius of the dark corner range.
[0089] After the center of the dark corner range is determined, the maximum radius R extending from the center to each dark corner pixel in the detection range is determined as the radius of the dark corner range.
[0090] S207: Determine the vignetting range according to the center of the vignetting range, the radius of the vignetting range, and the detection range.
[0091] After the radius of the dark corner range is determined, the dark corner range is determined according to the center of the dark corner range, the radius of the dark corner range and the detection range, that is, the dark corner range is divided from the detection range according to the center of the dark corner range and the radius of the dark corner range.
[0092] S208: Obtain a global scaling factor.
[0093] Preset the global scaling factor and get the global scaling factor.
[0094] S209: Obtaining the vignetting weight function and displacement direction corresponding to each pixel position within the vignetting range in the target image collected during the equipment production test phase.
[0095] Each pixel position within the vignetting range has its own corresponding vignetting weight function and displacement direction. The vignetting weight function and displacement direction corresponding to each pixel position within the vignetting range in the target image collected during the equipment production and testing phase are obtained.
[0096] In a specific implementation of the present application, step S209 may include the following steps:
[0097] Step 1: Calculate the normalized distance between each pixel position in the dark corner range of the target image and the center of the dark corner range;
[0098] Step 2: Calculate the vignetting weight function corresponding to each pixel position within the vignetting range in the target image according to each normalized distance;
[0099] Step 3: Calculate the displacement direction corresponding to each pixel position within the dark corner range according to the coordinates of each pixel position within the dark corner range in the target image and the coordinates of the center of the circle within the dark corner range.
[0100] For the convenience of description, the above three steps can be combined for explanation.
[0101] Calculate the normalized distance d from each pixel position (x, y) within the dark corner range of the target image to the center of the dark corner range. The calculation formula is as follows:
[0102] .
[0103] According to each normalized distance, the vignetting weight function corresponding to each pixel position in the vignetting range of the target image is calculated. The calculation formula is as follows:
[0104] .
[0105] Based on the coordinates of each pixel position within the vignetting range in the target image and the coordinates of the center of the vignetting range, the displacement direction corresponding to each pixel position within the vignetting range is calculated. By calculating the vignetting weight function corresponding to each pixel position based on the normalized distance from each pixel position to the center of the vignetting range, the farther each pixel position is from the center of the vignetting range, the smaller the corresponding vignetting weight function, and the closer each pixel position is to the center of the vignetting range, the larger the corresponding vignetting weight function, thereby greatly improving the accuracy of the vignetting weight function calculation results. The calculated vignetting weight function can also be written to the device storage area. By calculating the displacement direction corresponding to each pixel position within the vignetting range based on the coordinates of each pixel position and the coordinates of the center of the vignetting range, the accuracy of the displacement direction calculation of each pixel position is greatly improved.
[0106] S210: Establishing a pixel position correspondence relationship according to the global scaling factor, the vignetting weight function, and the displacement direction.
[0107] After obtaining the vignetting weight function and displacement direction corresponding to each pixel position within the vignetting range in the target image captured during the device production test phase, a pixel position correspondence relationship is established based on the global scaling factor, vignetting weight function, and displacement direction. By pre-establishing the pixel position correspondence relationship based on the global scaling factor, vignetting weight function, and displacement direction during the device production test phase, it is convenient to obtain the pixel values at the corresponding coordinate positions based on the established pixel position correspondence relationship during the subsequent image vignetting processing application process for vignetting processing.
[0108] For example, the first pixel position in the image to be processed is represented as , each second pixel position in the original image is represented by , define the displacement field:
[0109] ;
[0110] ;
[0111] in, is the horizontal component of the displacement field, is the vertical component of the displacement field, is the displacement strength, is the displacement direction, and the center of the dark angle range (i.e. the dark angle vertex) Point to the first pixel position .
[0112] ;
[0113] in, is the global scaling factor, is the dark corner weight function at the first pixel position.
[0114] .
[0115] Pixel position correspondence:
[0116] ;
[0117] .
[0118] like Figure 3 As shown, AC is the first pixel position The displacement intensity at , AB is the vertical component of displacement intensity, , BC is the horizontal component of displacement intensity, .
[0119] S211: Acquire the image to be processed and the preset vignetting range.
[0120] S212: Obtain first pixel positions corresponding to respective pixel points within the dark corner range of the image to be processed.
[0121] S213: Calculating each second pixel position according to each first pixel position and a pre-established pixel position correspondence between the image to be processed and the original image.
[0122] S214: Select a second pixel point whose horizontal coordinate and vertical coordinate are both integer values from the pixel points at each second pixel position in the image to be processed, and determine the pixel value of the selected second pixel point as the target interpolation value corresponding to the second pixel point.
[0123] After calculating each second pixel position, the calculated horizontal and vertical coordinates of the pixel points at each second pixel position may both be integers, or one or both of them may be decimals. A second pixel point whose horizontal and vertical coordinates are both integer values is selected from the pixel points at each second pixel position in the image to be processed, and the pixel value of the selected second pixel point is determined as the target interpolation value corresponding to the second pixel point. By directly determining the pixel value of the selected second pixel point as the target interpolation value corresponding to the second pixel point when the horizontal and vertical coordinates of the pixel point at the selected second pixel position are both integers, the interpolation calculation process is simplified and the interpolation calculation efficiency is improved.
[0124] S215: Selecting a second pixel point whose abscissa and / or ordinate is a small value from the pixel points at each second pixel position in the image to be processed.
[0125] After calculating each second pixel position, a second pixel point whose horizontal coordinate and / or vertical coordinate is a decimal value is selected from the pixel points at each second pixel position in the image to be processed, that is, a second pixel point whose horizontal coordinate is only a decimal value, a second pixel point whose vertical coordinate is only a decimal value, and a second pixel point whose horizontal coordinate and vertical coordinate are both decimal values are selected from the pixel points at each second pixel position in the image to be processed.
[0126] S216: Calculate the horizontal offset according to the horizontal coordinate of the second pixel point, and calculate the vertical offset according to the vertical coordinate of the second pixel point.
[0127] After selecting the second pixel point, the horizontal offset is calculated based on the horizontal coordinate of the second pixel point, and the decimal part of the horizontal coordinate is used as the horizontal offset. The vertical offset is calculated based on the vertical coordinate of the second pixel point, and the decimal part of the vertical coordinate is used as the vertical offset.
[0128] S217: Find the nearest neighboring pixel of the second pixel in the image to be processed.
[0129] After calculating the horizontal and vertical offsets, the nearest neighboring pixels of the second pixel are found in the image to be processed. For example, if the second pixel is an edge pixel in the non-vignetting range, the number of its nearest neighboring pixels is 4. If the second pixel is an edge pixel in the vignetting range, the number of its nearest neighboring pixels is less than 4.
[0130] S218: Calculate a target interpolation value corresponding to the second pixel point according to the pixel value, the horizontal offset, and the vertical offset of the nearest neighboring pixel point.
[0131] After finding the nearest neighboring pixel of the second pixel in the image to be processed, a target interpolation value corresponding to the second pixel is calculated according to the pixel value, horizontal offset, and vertical offset of the nearest neighboring pixel.
[0132] S219: Obtain the vignetting weight function corresponding to each first pixel position.
[0133] Each pixel in the image to be processed has a corresponding dark corner weight function, and the dark corner weight function corresponding to each first pixel position is obtained.
[0134] S220: Determine the dark corner weight function corresponding to each first pixel position as the interpolation intensity corresponding to each first pixel position.
[0135] After obtaining the dark corner weight functions corresponding to the first pixel positions, the dark corner weight functions corresponding to the first pixel positions are determined as the interpolation intensities S(x, y) corresponding to the first pixel positions.
[0136] S221: performing weighted calculation on the pixel values corresponding to the first pixel positions and the target interpolation values according to the interpolation strengths corresponding to the first pixel positions, to obtain the target pixel values corresponding to the first pixel positions.
[0137] After determining the interpolation strengths corresponding to the first pixel positions, weighted calculations are performed on the pixel values corresponding to the first pixel positions and the target interpolation values according to the interpolation strengths corresponding to the first pixel positions to obtain the target pixel values corresponding to the first pixel positions. The calculation formula may be:
[0138] ;
[0139] in, 、 、 、 The second pixel position The four nearest pixel values around The final interpolation result is dy, which is the vertical offset and dx, which is the horizontal offset.
[0140] Consider that the coordinates of the second pixel position may be calculated as a small value, for example , then dx=2.3-2=0.3, dy=3.7-3=0.7, and the coordinates of the four adjacent pixels are , , , If the sampling pixel coordinates are integer values, dx=dy=0, .
[0141] The interpolation strength S(x, y) is equal to the vignetting weight function M(x, y). For the pixel point (x, y) at the first pixel position, there is a corresponding vignetting weight function. The larger the value, the more serious the vignetting is, and the corresponding interpolation strength S(x, y) is also stronger. The final result is The smaller the value, the milder the vignetting, and the smaller the corresponding interpolation strength S(x, y). The pixel value at the first pixel position is The higher the ratio, for example, S(x, y) = 0.8, the greater the degree of vignetting.
[0142] .
[0143] S222: Before encoding the image to be processed, replace the pixel values at the first pixel positions in the image to be processed with the target pixel values.
[0144] After calculating the target pixel values corresponding to each first pixel position, before encoding the image to be processed, the pixel values of each first pixel position in the image to be processed are replaced with the target pixel values. Specifically, the image to be processed can be subjected to vignetting after YUV domain processing and before encoding. Each target pixel value is obtained by performing weighted calculation on the pixel values corresponding to each first pixel position and each target interpolation value, and the pixel values of each first pixel position in the image to be processed are replaced with the target pixel values, thereby ensuring the smoothness of the pixel transition of the restored image. By performing vignetting on the image to be processed, it is expected that most of the middle area of the image will maintain its original state, and only the four angular vignetting areas will be stretched to eliminate the vignetting.
[0145] Corresponding to the above method embodiment, the present application further provides an image vignetting processing device. The image vignetting processing device described below and the image vignetting processing method described above can refer to each other.
[0146] See also Figure 4 , Figure 4 This is a structural block diagram of an image vignetting processing device according to an embodiment of the present application. The device may include:
[0147] A vignetting range acquisition module 41 is used to acquire an image to be processed and a preset vignetting range;
[0148] A first pixel position acquisition module 42 is used to acquire first pixel positions corresponding to respective pixel points within a dark corner range in the image to be processed;
[0149] A second pixel position acquisition module 43 is configured to calculate each second pixel position based on each first pixel position and a pre-established pixel position correspondence between the image to be processed and the original image;
[0150] An interpolation calculation module 44 is configured to perform interpolation calculations on the pixel points at each second pixel position in the image to be processed to obtain target interpolation values;
[0151] The pixel value replacement module 45 is used to calculate the target pixel values corresponding to each first pixel position according to the pixel values corresponding to each first pixel position and each target interpolation value, and replace the pixel values of each first pixel position in the image to be processed with each target pixel value.
[0152] It can be seen from the above technical solution that by allowing the device to detect the dark angle range of each corner during the image detection process during the device production test, the pixel position correspondence between the image to be processed and the original image is established. In subsequent use, the second pixel positions corresponding to each first pixel position in the image to be processed are determined based on the pixel position correspondence between the image to be processed and the original image within the dark angle range, and the pixel points of each second pixel position are interpolated and calculated, and then the target pixel values corresponding to each first pixel position are calculated based on the target interpolation value of each second pixel position and the pixel value corresponding to each first pixel position, and the pixel value of each first pixel position is replaced by each target pixel value. The dark angle processing method provided by the present application can perform dark angle processing according to the dark angle range obtained in the device production test stage, and is suitable for various devices with different degrees of dark angle. It also avoids the impact on the back-end module of the image signal processor, improves the middle area of the image from deformation, and ensures image quality.
[0153] In a specific embodiment of the present application, the device may further include a vignetting range setting module, which may include:
[0154] The mask generation submodule is used to generate a mask of the four corner areas of the target image based on the target image collected during the equipment production and testing phase; wherein the four corner areas are areas divided according to a preset width-to-height ratio;
[0155] The detection range marking submodule is used to obtain the detection range of the target image using the mask marks of the four corner areas;
[0156] Grayscale threshold determination submodule, used to calculate the grayscale mean of each pixel in the target image and determine the grayscale threshold based on the grayscale mean;
[0157] A dark corner pixel determination submodule is used to determine pixels within the detection range whose grayscale values are less than the grayscale threshold as dark corner pixels;
[0158] A circle center determination submodule is used to determine the vertex where the detection range coincides with the target image as the circle center of the dark corner range;
[0159] A radius determination submodule, configured to determine the maximum radius extending from the center of the circle to each dark corner pixel in the detection range as the radius of the dark corner range;
[0160] The vignetting range determination submodule is used to determine the vignetting range according to the center of the vignetting range, the radius of the vignetting range and the detection range.
[0161] In a specific embodiment of the present application, the device may further include a pixel position correspondence relationship establishment module, which may include:
[0162] A global scaling factor acquisition submodule is used to obtain a global scaling factor;
[0163] The weight function and displacement direction acquisition submodule is used to obtain the vignetting weight function and displacement direction corresponding to each pixel position within the vignetting range in the target image collected during the equipment production test phase;
[0164] The pixel position correspondence establishment submodule is used to establish the pixel position correspondence according to the global scaling factor, the vignetting weight function and the displacement direction.
[0165] In a specific embodiment of the present application, the weight function and displacement direction acquisition submodule may include:
[0166] A normalized distance calculation unit, used to calculate the normalized distance from each pixel position in the dark corner range of the target image to the center of the dark corner range;
[0167] A vignetting weight function calculation unit is used to calculate the vignetting weight function corresponding to each pixel position within the vignetting range in the target image according to each normalized distance;
[0168] The displacement direction calculation unit is used to calculate the displacement direction corresponding to each pixel position in the dark corner range according to the coordinates of each pixel position in the dark corner range in the target image and the coordinates of the center of the dark corner range.
[0169] In a specific embodiment of the present application, the interpolation calculation module 44 may include:
[0170] an interpolation determination submodule, configured to select a second pixel point whose horizontal coordinate and vertical coordinate are both integer values from the pixel points at each second pixel position in the image to be processed, and determine the pixel value of the selected second pixel point as the target interpolation value corresponding to the second pixel point;
[0171] A second pixel point selection submodule is used to select a second pixel point whose horizontal coordinate and / or vertical coordinate is a small value from the pixel points at each second pixel position in the image to be processed;
[0172] an offset calculation submodule, configured to calculate a horizontal offset according to the horizontal coordinate of the second pixel point, and calculate a vertical offset according to the vertical coordinate of the second pixel point;
[0173] A nearest neighbor pixel search submodule, used to search the nearest neighbor pixel of the second pixel in the image to be processed;
[0174] The interpolation calculation submodule is used to calculate the target interpolation value corresponding to the second pixel point according to the pixel value, horizontal offset and vertical offset of the nearest neighboring pixel point.
[0175] In a specific embodiment of the present application, the pixel value replacement module 45 may include:
[0176] A vignetting weight function acquisition submodule is used to acquire vignetting weight functions corresponding to each first pixel position;
[0177] an interpolation intensity determination submodule, configured to determine the dark corner weight function corresponding to each first pixel position as the interpolation intensity corresponding to each second pixel position;
[0178] The target pixel value determination submodule is used to perform weighted calculation on the pixel values corresponding to each first pixel position and each target interpolation value according to the interpolation strength corresponding to each first pixel position, so as to obtain the target pixel value corresponding to each first pixel position.
[0179] In a specific embodiment of the present application, the pixel value replacement module 45 is a module that replaces the pixel value of each first pixel position in the image to be processed with each target pixel value before encoding the image to be processed.
[0180] Corresponding to the above method embodiment, see Figure 5 , Figure 5 This is a schematic diagram of the image vignetting processing device provided by this application, which may include:
[0181] Memory 332, for storing computer programs;
[0182] The processor 322 is configured to implement the steps of the image vignetting processing method of the above method embodiment when executing a computer program.
[0183] For details, please refer to Figure 6 , Figure 6 This is a schematic diagram of the specific structure of an image vignetting processing device provided in this embodiment. This image vignetting processing device may vary significantly depending on its configuration or performance. It may include a processor (central processing unit, CPU) 322 (e.g., one or more processors) and a memory 332. The memory 332 stores one or more computer programs 342 or data 344. The memory 332 may be either transient or persistent storage. The program stored in the memory 332 may include one or more modules (not shown), each of which may include a series of instructions for operating on the data processing device. Furthermore, the processor 322 may be configured to communicate with the memory 332, executing the series of instructions stored in the memory 332 on the image vignetting processing device 301.
[0184] The image vignetting processing device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0185] The steps in the image vignetting processing method described above can be implemented by the structure of the image vignetting processing device.
[0186] Corresponding to the above method embodiment, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps can be implemented:
[0187] Acquire an image to be processed and a preset dark corner range; obtain first pixel positions corresponding to each pixel point within the dark corner range in the image to be processed; calculate each second pixel position based on each first pixel position and a pre-established pixel position correspondence between the image to be processed and the original image; perform interpolation calculations on the pixel points at each second pixel position in the image to be processed to obtain each target interpolation value; calculate target pixel values corresponding to each first pixel position based on the pixel values corresponding to each first pixel position and each target interpolation value, and use each target pixel value to replace the pixel value of each first pixel position in the image to be processed.
[0188] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which can store program codes.
[0189] For an introduction to the computer-readable storage medium provided in this application, please refer to the above method embodiment, and this application will not go into details here.
[0190] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. References to the same or similar parts between the various embodiments are sufficient. The devices, apparatuses, and computer-readable storage media disclosed in the embodiments are described briefly because they correspond to the methods disclosed in the embodiments. For relevant details, refer to the description of the methods.
[0191] Specific examples are used herein to illustrate the principles and implementation methods of this application. The description of the above embodiments is only intended to help understand the technical solution and core ideas of this application. It should be noted that, for those skilled in the art, without departing from the principles of this application, various improvements and modifications may be made to this application, and such improvements and modifications also fall within the scope of protection of this application.
Claims
1. A method for processing image vignetting, characterized in that: include: Obtain the image to be processed and the preset vignetting range; Obtaining first pixel positions corresponding to respective pixel points within the dark corner range in the image to be processed; Calculating each second pixel position according to each first pixel position and a pre-established pixel position correspondence between the image to be processed and the original image; Performing interpolation calculations on the pixel points at each second pixel position in the image to be processed to obtain target interpolation values; Calculating target pixel values corresponding to the first pixel positions according to the pixel values corresponding to the first pixel positions and the target interpolation values, and replacing the pixel values of the first pixel positions in the image to be processed with the target pixel values; The method further includes a process for setting the vignetting range, wherein the process for setting the vignetting range includes: Generate a mask of the four corner areas of the target image according to the target image collected during the equipment production and testing phase; wherein the four corner areas are areas divided according to a preset aspect ratio; Obtaining the detection range of the target image using the mask marks of the four corner areas; Calculating the grayscale mean of each pixel in the target image, and determining the grayscale threshold according to the grayscale mean; Determine pixels within the detection range whose grayscale values are less than the grayscale threshold as dark corner pixels; Determine the vertex where the detection range and the target image overlap as the center of the dark corner range; Determine the maximum radius extending from the center of the circle to each dark corner pixel in the detection range as the radius of the dark corner range; Determine the dark corner range according to the center of the dark corner range, the radius of the dark corner range and the detection range; The method further includes a process for establishing the pixel position correspondence relationship, wherein the process for establishing the pixel position correspondence relationship includes: Get the global scaling factor; Obtaining the vignetting weight function and displacement direction corresponding to each pixel position within the vignetting range in the target image collected during the equipment production test phase; Establishing the pixel position correspondence relationship according to the global scaling factor, the dark angle weight function and the displacement direction; Obtaining the vignetting weight function and displacement direction corresponding to each pixel position within the vignetting range in the target image collected during the equipment production test phase, including: Calculating respectively the normalized distance between each pixel position within the dark corner range in the target image and the center of the circle of the dark corner range; Calculating the vignetting weight function corresponding to each pixel position within the vignetting range in the target image according to each normalized distance; The displacement directions corresponding to the respective pixel positions in the dark corner range are calculated according to the coordinates of the respective pixel positions in the dark corner range in the target image and the coordinates of the center of the circle in the dark corner range.
2. The image vignetting processing method according to claim 1, characterized in that: Performing interpolation calculations on the pixel points at each second pixel position in the image to be processed to obtain target interpolation values, including: Selecting a second pixel point whose horizontal coordinate and vertical coordinate are both integer values from the pixel points at each second pixel position in the image to be processed, and determining the pixel value of the selected second pixel point as the target interpolation value corresponding to the second pixel point; Selecting a second pixel point whose abscissa and / or ordinate is a small value from the pixel points at each second pixel position in the image to be processed; Calculating a horizontal offset according to the horizontal coordinate of the second pixel point, and calculating a vertical offset according to the vertical coordinate of the second pixel point; Find the nearest neighbor pixel of the second pixel in the image to be processed; A target interpolation value corresponding to the second pixel point is calculated according to the pixel value of the nearest neighbor pixel point, the horizontal offset, and the vertical offset.
3. The image vignetting processing method according to any one of claims 1 to 2, characterized in that: Calculating target pixel values corresponding to the first pixel positions according to the pixel values corresponding to the first pixel positions and the target interpolation values includes: Obtaining the dark corner weight function corresponding to each first pixel position; Determine the dark corner weight function corresponding to each first pixel position as the interpolation intensity corresponding to each first pixel position; A weighted calculation is performed on the pixel values corresponding to the first pixel positions and the target interpolation values according to the interpolation strengths corresponding to the first pixel positions to obtain the target pixel values corresponding to the first pixel positions.
4. The image vignetting processing method according to claim 1, wherein: Replacing the pixel values at the first pixel positions in the image to be processed with the target pixel values includes: Before encoding the image to be processed, the pixel values at the first pixel positions in the image to be processed are replaced by the target pixel values.
5. An image vignetting processing device, characterized in that: include: A vignetting range acquisition module is used to acquire the image to be processed and the preset vignetting range; A first pixel position acquisition module is used to acquire first pixel positions corresponding to respective pixel points within the dark corner range in the image to be processed; A second pixel position acquisition module, configured to calculate each second pixel position according to each first pixel position and a pre-established pixel position correspondence between the image to be processed and the original image; An interpolation calculation module, configured to perform interpolation calculations on the pixel points at each second pixel position in the image to be processed to obtain target interpolation values; a pixel value replacement module, configured to calculate target pixel values corresponding to the first pixel positions according to the pixel values corresponding to the first pixel positions and the target interpolation values, and replace the pixel values of the first pixel positions in the image to be processed with the target pixel values; It also includes a vignetting range setting module, which includes: The mask generation submodule is used to generate a mask of the four corner areas of the target image based on the target image collected during the equipment production and testing phase; wherein the four corner areas are areas divided according to a preset width-to-height ratio; The detection range marking submodule is used to obtain the detection range of the target image using the mask marks of the four corner areas; Grayscale threshold determination submodule, used to calculate the grayscale mean of each pixel in the target image and determine the grayscale threshold based on the grayscale mean; A dark corner pixel determination submodule is used to determine pixels within the detection range whose grayscale values are less than the grayscale threshold as dark corner pixels; A circle center determination submodule is used to determine the vertex where the detection range coincides with the target image as the circle center of the dark corner range; A radius determination submodule, configured to determine the maximum radius extending from the center of the circle to each dark corner pixel in the detection range as the radius of the dark corner range; A vignetting range determination submodule is used to determine the vignetting range according to the center of the vignetting range, the radius of the vignetting range and the detection range; The device may further include a pixel position correspondence relationship establishment module, which may include: A global scaling factor acquisition submodule is used to obtain a global scaling factor; The weight function and displacement direction acquisition submodule is used to obtain the vignetting weight function and displacement direction corresponding to each pixel position within the vignetting range in the target image collected during the equipment production test phase; A pixel position correspondence establishment submodule is used to establish a pixel position correspondence according to a global scaling factor, a vignetting weight function, and a displacement direction; The weight function and displacement direction acquisition submodule may include: A normalized distance calculation unit, used to calculate the normalized distance from each pixel position in the dark corner range of the target image to the center of the dark corner range; A vignetting weight function calculation unit is used to calculate the vignetting weight function corresponding to each pixel position within the vignetting range in the target image according to each normalized distance; The displacement direction calculation unit is used to calculate the displacement direction corresponding to each pixel position in the dark corner range according to the coordinates of each pixel position in the dark corner range in the target image and the coordinates of the center of the dark corner range.
6. An image vignetting processing device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the image vignetting processing method according to any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image vignetting processing method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Dark corner eliminating method and system in digital image
CN101292519A
Dark image corner cutting scope determining method, dark image corner compensating method and apparatus
CN106815846A