An image flat-field correction method, device, and computer-readable storage medium
By obtaining the grayscale mean ratio of the calibration image and the target image, calculating the difference value and generating correction coefficient diagrams, and automatically performing image flat field correction, solving the problems of complex processes and difficult parameter debugging in traditional methods, and improving image brightness uniformity and correction effect are achieved.
Patent Information
- Application Number
- CN202510066292.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-01-16
AI Technical Summary
The traditional flat field correction method requires shooting multiple sets of flat field calibration images. The process is complex and the parameter debugging is difficult to achieve efficient and accurate image brightness uniformity correction.
By obtaining the ROI area grayscale mean ratio of the calibration image and the target image, calculating the difference value and generating correction coefficient diagrams, the image flat field correction is automated, reducing manual intervention, and improving debugging efficiency and accuracy.
It realizes a more uniform image brightness distribution, simplifies the parameter debugging process, improves the inhomogeneity correction effect, and reduces the difficulty and complexity of manual intervention.
Smart Images

Figure CN119515754B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of image processing, and in particular, to an image flat field correction method, apparatus, and computer-readable storage medium. Background Art
[0002] Lens shadow is a common phenomenon in the fields of photography and optics, referring to the fact that the brightness or saturation of the edge part of an image is lower than that of the central area, and there is a deviation between the output value of each pixel in the image and the expected value. This phenomenon is usually caused by the limiting factors of the camera's aperture and lens, and is considered an undesirable effect. It is necessary to study a precise calibration and correction method for the flat field to generate high-quality images.
[0003] Traditional flat field correction methods require taking multiple groups of flat field calibration images, calculating grid coefficients for each group of images, and finally generating a coefficient map with the same size as the current image through interpolation calculation. This method needs to consider various shooting factors (exposure time, shooting temperature, etc.), and the calibration process is complex. Summary of the Invention
[0004] The embodiments of the present application provide an image flat field correction method, apparatus, and computer-readable storage medium, which can reduce the difficulty of parameter debugging.
[0005] In a first aspect of the embodiments of the present application, an image flat field correction method is provided, including:
[0006] Obtain a calibration image and a target image, where the saturation of the calibration image is within a preset saturation range, the target image is an image to be corrected for the flat field, and the resolution of the target image is the same as that of the calibration image;
[0007] Calculate a first non-uniform value of the calibration image according to a first ROI of the calibration image, where the first ROI includes a first central ROI and a first edge ROI, the first central ROI is located at the center of the calibration image, the first edge ROI is located at the four corners of the calibration image, the first central ROI and the first edge ROI have the same size and shape, and the first non-uniform value represents the non-uniformity degree between each first edge ROI and the first central ROI;
[0008] Calculate a second non-uniform value of the target image according to a second ROI of the target image, where the second ROI includes a second central ROI and a second edge ROI, the second central ROI is located at the center of the target image, the second edge ROI is located at the four corners of the target image, the second central ROI and the second edge ROI have the same size and shape, and the second non-uniform value represents the non-uniformity degree between each second edge ROI and the second central ROI;
[0009] Calculate a difference value based on the first non-uniform value and the second non-uniform value, where the difference value is the ratio of the second non-uniform value to the first non-uniform value;
[0010] Generate a target correction coefficient map based on the difference value;
[0011] Perform flat-field correction on the target image according to the target correction coefficient map.
[0012] Optionally, the calculating the first non-uniform value of the calibration image according to the first ROI of the calibration image includes:
[0013] Calculate the gray-scale means of the first central ROI and the first edge ROI respectively;
[0014] Take the ratio of the gray-scale mean of the first edge ROI to the gray-scale mean of the first central ROI as the first non-uniform value;
[0015] The calculating the second non-uniform value of the target image according to the second ROI of the target image includes:
[0016] Calculate the gray-scale means of the second central ROI and the second edge ROI respectively;
[0017] Take the ratio of the gray-scale mean of the second edge ROI to the gray-scale mean of the second central ROI as the second non-uniform value.
[0018] Optionally, the generating a target correction coefficient map based on the difference value includes:
[0019] Calculate the correction ratio of each pixel in the calibration image, where the correction ratio is the ratio of the gray-scale value to the gray-scale mean of the first central ROI;
[0020] Combine the correction ratios of all pixels in the calibration image into a calibration correction coefficient map;
[0021] Generate a target correction coefficient map based on the difference value and the calibration correction coefficient map.
[0022] Optionally, the generating a target correction coefficient map based on the difference value and the calibration correction coefficient map includes:
[0023] Generate a basic coefficient map based on the difference value, where the pixel values in a quarter region corresponding to the difference value in the basic coefficient map are all the difference value, and the pixel values in the remaining three-quarters region of the basic coefficient map are all 1;
[0024] Calculate a target correction coefficient map based on the basic coefficient map and the calibration correction coefficient map.
[0025] Optionally, performing flat-field correction on the target image according to the target correction coefficient map includes:
[0026] Multiplying the target image by the target correction coefficient map to obtain a corrected target image.
[0027] Optionally, before calculating the first non-uniform value of the calibration image according to the first ROI of the calibration image, the method further includes:
[0028] Determining the shape and size of the first central ROI according to the resolution of the calibration image.
[0029] Optionally, before obtaining the calibration image and the target image, the method further includes:
[0030] Determining the camera for shooting the calibration image and the shooting scene;
[0031] Determining the saturation of the calibration image according to the camera and the shooting scene
[0032] A second aspect of the embodiments of the present application provides an image flat-field correction device, including:
[0033] An acquisition unit, configured to acquire a calibration image and a target image, where the saturation of the calibration image is within a preset saturation range, the target image is an image to be flat-field corrected, and the resolution of the target image is the same as the resolution of the calibration image;
[0034] A first calculation unit, configured to calculate a first non-uniform value of the calibration image according to a first ROI of the calibration image, where the first ROI includes a first central ROI and a first edge ROI, the first central ROI is located at the center of the calibration image, the first edge ROI is located at the four corners of the calibration image, the first central ROI and the first edge ROI have the same size and shape, and the first non-uniform value represents the non-uniform degree between each first edge ROI and the first central ROI;
[0035] A second calculation unit, configured to calculate a second non-uniform value of the target image according to a second ROI of the target image, where the second ROI includes a second central ROI and a second edge ROI, the second central ROI is located at the center of the target image, the second edge ROI is located at the four corners of the target image, the second central ROI and the second edge ROI have the same size and shape, and the second non-uniform value represents the non-uniform degree between each second edge ROI and the second central ROI;
[0036] A third calculation unit, configured to calculate a difference value according to the first non-uniformity value and the second non-uniformity value, where the difference value is a ratio of the second non-uniformity value to the first non-uniformity value;
[0037] A generation unit, configured to generate a target correction coefficient map according to the difference value;
[0038] An execution unit, configured to perform flat-field correction on the target image according to the target correction coefficient map.
[0039] Optionally, the first calculation unit is specifically configured to:
[0040] Calculate the gray-scale means of the first central ROI and the first edge ROI respectively;
[0041] Take the ratio of the gray-scale mean of the first edge ROI to the gray-scale mean of the first central ROI as the first non-uniformity value;
[0042] The second calculation unit is specifically configured to:
[0043] Calculate the gray-scale means of the second central ROI and the second edge ROI respectively;
[0044] Take the ratio of the gray-scale mean of the second edge ROI to the gray-scale mean of the second central ROI as the second non-uniformity value.
[0045] The generation unit includes:
[0046] A calculation module, configured to calculate a correction ratio of each pixel in the calibration image, where the correction ratio is a ratio of the gray-scale value to the gray-scale mean of the first central ROI;
[0047] A merging module, configured to merge the correction ratios of all pixels in the calibration image into a calibration correction coefficient map;
[0048] A generation module, configured to generate a target correction coefficient map according to the difference value and the calibration correction coefficient map.
[0049] Optionally, the generation module is specifically configured to:
[0050] Generate a basic coefficient map according to the difference value, where pixel values in a quarter area corresponding to the difference value in the basic coefficient map are all the difference value, and pixel values in the remaining three quarters area in the basic coefficient map are all 1;
[0051] Calculate a target correction coefficient map according to the basic coefficient map and the calibration correction coefficient map.
[0052] Optionally, the execution unit is specifically configured to:
[0053] The target image is multiplied by the target correction coefficient map to obtain a corrected target image.
[0054] Optionally, the device further comprises:
[0055] The first determining unit is used to determine the shape and size of the first central ROI according to the resolution of the calibration image.
[0056] Optionally, the device further includes a second determining unit, wherein the second unit is configured to:
[0057] Determine the camera and shooting scene for taking the calibration image;
[0058] The saturation of the calibration image is determined according to the camera and the shooting scene.
[0059] A third aspect of the embodiment of the present application provides an image flat field correction device, comprising:
[0060] Processor, memory, input-output unit, and bus;
[0061] The processor is connected to the memory, the input and output unit, and the bus;
[0062] A program is stored in the memory, and the processor calls the program to execute the method in the first aspect and any possible implementation manner of the first aspect.
[0063] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the computer executes the method in the first aspect and any possible implementation of the first aspect.
[0064] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0065] The embodiments of the present application provide quantified non-uniformity data and accurate correction coefficients, making the flat field correction process more automated and data-driven. It reduces manual intervention, simplifies the debugging process, reduces the difficulty that may be encountered when adjusting parameters, and improves debugging efficiency and accuracy. At the same time, it is also possible to generate an accurate correction coefficient map based on the difference value, making the flat field correction process more accurate and able to accurately eliminate non-uniformities in the image. By comparing the non-uniformity differences between the calibration image and the target image, and generating correction coefficients in a targeted manner, the final target image is more uniform in brightness distribution than the uncorrected image, thereby greatly improving the non-uniformity correction effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1Schematic flowchart of an embodiment of the image flat field correction method in an embodiment of the present application;
[0067] Figure 2 Generating a target correction coefficient according to the difference value in an embodiment of the present application Figure 1 Schematic flowchart of an embodiment;
[0068] Figure 3 Schematic flowchart of an embodiment of determining the shape and size of the first central ROI in an embodiment of the present application;
[0069] Figure 4 Schematic flowchart of an embodiment of determining the saturation of a calibration image in an embodiment of the present application;
[0070] Figure 5 Schematic structural diagram of an embodiment of an image flat field correction device in an embodiment of the present application;
[0071] Figure 6 Schematic structural diagram of an embodiment of an image flat field correction device in an embodiment of the present application. Detailed implementation manners
[0072] The embodiments of the present application provide an image flat field correction method, device and computer-readable storage medium, which can reduce the difficulty of parameter debugging.
[0073] The method of the present application can be applied to a server, a terminal or other devices with logical processing capabilities, and the present application does not make any limitation thereto. For the sake of convenience of description, the following description is made by taking the execution subject as a server as an example.
[0074] The embodiments in the present application will be described below with reference to the accompanying drawings.
[0075] Please refer to Figure 1 , an embodiment of the image flat field correction method in an embodiment of the present application includes:
[0076] 101. Obtain a calibration image and a target image. The saturation of the calibration image is within a preset saturation range, the target image is an image to be flat field corrected, and the resolution of the target image is the same as that of the calibration image;
[0077] The server first obtains a calibration image and a target image. The saturation of the calibration image should be within the preset saturation range to ensure moderate image brightness. The target image is the image to be flat field corrected, and the resolution of the target image is the same as that of the calibration image. This ensures consistency in subsequent processing and avoids increasing additional debugging complexity due to mismatched image resolutions.
[0078] 102. Calculate the first non-uniformity value of the calibration image according to the first ROI of the calibration image. The first ROI includes a first central ROI and a first edge ROI. The first central ROI is located at the center of the calibration image, and the first edge ROI is located at the four corners of the calibration image. The first central ROI and the first edge ROI have the same size and shape. The first non-uniformity value represents the non-uniformity degree between each first edge ROI and the first central ROI;
[0079] The server calculates the first non-uniformity value according to the first ROI of the calibration image. The first ROI includes a first central ROI and a first edge ROI. The first central ROI is located at the center of the image, and the first edge ROI is located at the four corners of the image, and both have the same size and shape. The calculated first non-uniformity value can quantify the non-uniformity of the image, reduce the possible subjective deviation during manual adjustment, and thus simplify the debugging work.
[0080] 103. Calculate the second non-uniformity value of the target image according to the second ROI of the target image. The second ROI includes a second central ROI and a second edge ROI. The second central ROI is located at the center of the target image, and the second edge ROI is located at the four corners of the target image. The second central ROI and the second edge ROI have the same size and shape. The second non-uniformity value represents the non-uniformity degree between each second edge ROI and the second central ROI;
[0081] The server calculates the second non-uniformity value according to the second ROI of the target image. The second ROI also includes a second central ROI and a second edge ROI, and has the same size and shape as the first ROI. The second non-uniformity value quantifies the non-uniformity of the target image by comparing the differences between the central and edge ROIs, providing accurate data, so that subsequent debugging can rely more on data rather than manual intervention.
[0082] 104. Calculate the difference value according to the first non-uniformity value and the second non-uniformity value. The difference value is the ratio of the second non-uniformity value to the first non-uniformity value;
[0083] The server calculates the difference value according to the first non-uniformity value and the second non-uniformity value. The difference value is the ratio of the second non-uniformity value to the first non-uniformity value. This ratio reflects the non-uniformity difference between the calibration image and the target image.
[0084] 105. Generate a target correction coefficient map according to the difference value;
[0085] The server generates a target correction coefficient map according to the calculated difference value. This coefficient map provides a correction coefficient for each pixel of the target image to compensate for the non-uniformity in the image.
[0086] 106. Perform flat-field correction on the target image according to the target correction coefficient map.
[0087] The server performs flat-field correction on the target image according to the target correction coefficient map. Flat-field correction eliminates the non-uniformity in the target image by applying these correction coefficients, thereby improving the quality of the image.
[0088] In this embodiment, the server provides quantified non-uniformity data and accurate correction coefficients, making the flat-field correction process more automated and data-driven. It reduces manual intervention, simplifies the debugging process, reduces the difficulties that may be encountered during parameter adjustment, and improves the debugging efficiency and accuracy. At the same time, it can also generate an accurate correction coefficient map according to the difference value, making the flat-field correction process more precise and capable of accurately eliminating the non-uniformity in the image. By comparing the non-uniformity differences between the calibrated image and the target image and generating correction coefficients accordingly, the final target image is more uniform in brightness distribution than the uncorrected image, thus greatly improving the non-uniformity correction effect.
[0089] Further, in some embodiments of the present application, step 102 in the above embodiment of calculating the first non-uniformity value of the calibrated image according to the first ROI of the calibrated image may include the following steps:
[0090] 1021. Calculate the gray-scale means of the first central ROI and the first edge ROI respectively;
[0091] The server calculates the gray-scale means of the first central ROI and the first edge ROI in the calibrated image respectively, quantifies the brightness information of different regions of the image, and provides data support for subsequent non-uniformity analysis.
[0092] 1022. Take the ratio of the gray-scale mean of the first edge ROI to the gray-scale mean of the first central ROI as the first non-uniformity value;
[0093] By calculating the ratio of the gray-scale means of the two, the first non-uniformity value of the calibrated image is obtained. This ratio directly reflects the non-uniformity of the image, helps to quantify the brightness changes in the image, and facilitates subsequent processing and adjustment.
[0094] Step 103 in the above embodiment of calculating the second non-uniformity value of the target image according to the second ROI of the target image may include the following steps:
[0095] 1031. Calculate the gray-scale means of the second central ROI and the second edge ROI respectively;
[0096] The server calculates the gray-scale means of the second central ROI and the second edge ROI in the target image, further quantifies the brightness conditions of different regions of the target image, and ensures that subsequent steps can be processed based on accurate data.
[0097] 1032. Use the ratio of the gray - scale mean value of the second edge ROI to the gray - scale mean value of the second center ROI as the second non - uniformity value.
[0098] By calculating the ratio of the gray - scale means of the two, the second non - uniformity value of the target image is obtained. This ratio can effectively quantify the non - uniformity of the target image and ensure the pertinence during processing.
[0099] Please refer to Figure 2 , in some embodiments of the present application, step 105 in the above - mentioned embodiments of generating a target correction coefficient map according to the difference value may include the following steps:
[0100] 201. Calculate the correction ratio of each pixel in the calibration image. The correction ratio is the ratio of the gray - scale value to the gray - scale mean value of the first center ROI.
[0101] The server first calculates the correction ratio of each pixel in the calibration image. The correction ratio is the ratio of the gray - scale value of the pixel to the gray - scale mean value of the first center ROI. This ratio reflects the brightness difference of each pixel relative to the brightness of the central region of the calibration image and is used to quantify the non - uniformity of the image.
[0102] 202. Combine the correction ratios of all pixels in the calibration image into a calibration correction coefficient map.
[0103] The server combines the calculated correction ratios of each pixel in the calibration image to generate a calibration correction coefficient map. This coefficient map reflects the relative brightness difference of each pixel in the calibration image with respect to the central region and provides the basic data for subsequent correction.
[0104] 203. Generate a basic coefficient map according to the difference value. Among them, the pixel values in a quarter of the region corresponding to the difference value in the basic coefficient map are all the difference value, and the pixel values in the remaining three - quarters of the region in the basic coefficient map are all 1.
[0105] The server generates a basic coefficient map according to the difference value. The pixel values in a quarter of the region in the basic coefficient map are set as the difference value, indicating the correction requirements of the image region; while the pixel values in the remaining three - quarters of the region are set as 1, indicating no adjustment is needed or to remain the same. This design provides a preliminary coefficient map for the flat - field correction of the target image.
[0106] 204. Calculate the target correction coefficient map according to the basic coefficient map and the calibration correction coefficient map.
[0107] The server combines the basic coefficient map and the calibration correction coefficient map to calculate the target correction coefficient map. The target correction coefficient map is generated by combining the correction ratios in the calibration image with the basic coefficient map, and finally provides an accurate correction coefficient for each pixel. This coefficient map will be used for subsequent flat - field correction processing to ensure that the non - uniformity of the target image is effectively corrected.
[0108] In this embodiment, the server can generate an accurate target correction coefficient map, automatically generate a correction coefficient based on the difference value and the gray value difference of the calibration image, so as to ensure that the target image can be effectively flat-field corrected. This process reduces manual intervention, improves the efficiency and accuracy of correction, reduces the difficulty of parameter debugging in practical applications, and improves the automation level of the system.
[0109] Please refer to Figure 3 , in some embodiments of the present application, before step 102 in the above embodiment calculates the first non-uniform value of the calibration image according to the first ROI of the calibration image, the image flat-field correction method may further include the following steps:
[0110] 301. Determine the shape and size of the first central ROI according to the resolution of the calibration image.
[0111] The server determines the shape and size of the first central ROI according to the resolution of the calibration image. When the resolution is high, the server may select a larger ROI to cover more pixels, and vice versa. This step ensures that the shape and size of the first central ROI are adapted to the image resolution, thereby providing a reasonable reference area for subsequent non-uniformity calculation and ensuring the accuracy and applicability of the calculation results.
[0112] Please refer to Figure 4 , in some embodiments of the present application, before step 101 in the above embodiment acquires the calibration image and the target image, the image flat-field correction method may further include the following steps:
[0113] 401. Determine the camera for shooting the calibration image and the shooting scene;
[0114] Before acquiring the calibration image, the server first determines the camera type and shooting scene for shooting the calibration image. The sensor characteristics of different cameras and the shooting environment (such as lighting conditions) will affect the overall quality of the image, especially in terms of image saturation and contrast. By understanding the camera characteristics and shooting scene, the server can provide a more accurate saturation setting and image adjustment strategy for subsequent steps.
[0115] 402. Determine the saturation of the calibration image according to the camera and the shooting scene.
[0116] The server sets the saturation of the calibration image according to the camera type and shooting scene determined in step 401. The dynamic range of the camera and the lighting conditions of the shooting scene will affect the performance of brightness and color in the image. Therefore, it is necessary to select a suitable saturation range to ensure that the image will not be overexposed or underexposed. Setting an appropriate saturation can ensure the brightness uniformity and detail clarity of the image, providing a good foundation for subsequent flat-field correction.
[0117] In this embodiment, the server first ensures that the impacts of the camera and the shooting scene on the calibration image are effectively controlled, especially in terms of the saturation of the image. This can avoid image quality problems caused by improper camera settings or insufficient ambient light, ensure that the quality of the calibration image meets the expectations, and provide a stable and reliable foundation for subsequent flat-field correction. This significantly reduces the complexity caused by image quality problems during debugging and simplifies the difficulty of overall parameter debugging.
[0118] Please refer to Figure 5 , an embodiment of the image flat-field correction device in the embodiment of the present application includes:
[0119] An acquisition unit 501, configured to acquire a calibration image and a target image. The saturation of the calibration image is within a preset saturation interval, the target image is an image to be flat-field corrected, and the resolution of the target image is the same as that of the calibration image;
[0120] A first calculation unit 502, configured to calculate a first non-uniformity value of the calibration image according to a first ROI of the calibration image. The first ROI includes a first central ROI and a first edge ROI. The first central ROI is located at the center of the calibration image, the first edge ROI is located at the four corners of the calibration image, the first central ROI and the first edge ROI have the same size and shape, and the first non-uniformity value represents the non-uniformity degree between each first edge ROI and the first central ROI;
[0121] A second calculation unit 503, configured to calculate a second non-uniformity value of the target image according to a second ROI of the target image. The second ROI includes a second central ROI and a second edge ROI. The second central ROI is located at the center of the target image, the second edge ROI is located at the four corners of the target image, the second central ROI and the second edge ROI have the same size and shape, and the second non-uniformity value represents the non-uniformity degree between each second edge ROI and the second central ROI;
[0122] A third calculation unit 504, configured to calculate a difference value according to the first non-uniformity value and the second non-uniformity value. The difference value is the ratio of the second non-uniformity value to the first non-uniformity value;
[0123] A generation unit 505, configured to generate a target correction coefficient map according to the difference value;
[0124] An execution unit 506, configured to perform flat-field correction on a target image according to a target correction coefficient map.
[0125] In this embodiment, the server provides quantified non-uniformity data and accurate correction coefficients, making the flat-field correction process more automated and data-driven. It reduces manual intervention, simplifies the debugging process, reduces the difficulty that may be encountered during parameter adjustment, and improves the debugging efficiency and accuracy. At the same time, the server can also generate an accurate correction coefficient map according to the difference value, making the flat-field correction process more precise and capable of accurately eliminating the non-uniformity in the image. By comparing the non-uniformity difference between the calibrated image and the target image and generating correction coefficients accordingly, the finally obtained target image is more uniform in brightness distribution than the uncorrected image, thus greatly improving the non-uniformity correction effect.
[0126] Optionally, the first calculation unit 502 is specifically configured to:
[0127] Calculate the gray-scale means of the first central ROI and the first edge ROI respectively;
[0128] Take the ratio of the gray-scale mean of the first edge ROI to the gray-scale mean of the first central ROI as the first non-uniformity value;
[0129] The second calculation unit 503 is specifically configured to:
[0130] Calculate the gray-scale means of the second central ROI and the second edge ROI respectively;
[0131] Take the ratio of the gray-scale mean of the second edge ROI to the gray-scale mean of the second central ROI as the second non-uniformity value.
[0132] The generation unit 505 includes:
[0133] A calculation module, configured to calculate the correction ratio of each pixel in the calibrated image, where the correction ratio is the ratio of the gray-scale value to the gray-scale mean of the first central ROI;
[0134] A merging module, configured to merge the correction ratios of all pixels in the calibrated image into a calibrated correction coefficient map;
[0135] A generation module, configured to generate a target correction coefficient map according to the difference value and the calibrated correction coefficient map.
[0136] Optionally, the generation module is specifically configured to:
[0137] Generate a basic coefficient map according to the difference value, where the pixel values in a quarter area corresponding to the difference value in the basic coefficient map are all the difference value, and the pixel values in the remaining three quarters area of the basic coefficient map are all 1;
[0138] Calculate the target correction coefficient map according to the basic coefficient map and the calibrated correction coefficient map.
[0139] Optionally, the execution unit 506 is specifically configured to:
[0140] Multiply the target image by the target correction coefficient map to obtain the corrected target image.
[0141] Optionally, the device further includes:
[0142] The first determination unit is configured to determine the shape and size of the first central ROI according to the resolution of the calibration image.
[0143] Optionally, the device further includes a second determination unit, and the second unit is configured to:
[0144] Determine the camera and shooting scene for shooting the calibration image;
[0145] Determine the saturation of the calibration image according to the camera and the shooting scene.
[0146] In this embodiment, the functions of each unit and module correspond to the steps in the foregoing Figure 1 Embodiment shown in FIG. 4, and details are not described herein again.
[0147] Please refer to Figure 6 , another embodiment of the image flat-field correction device in the embodiment of the present application includes:
[0148] A processor 601, a memory 602, an input / output unit 603, and a bus 604;
[0149] The processor 601 is connected to the memory 602, the input / output unit 603, and the bus 604;
[0150] The memory 602 stores a program, and the processor 601 calls the program to execute the Figures 1 to 4 Steps in the embodiment shown in FIG.
[0151] In this embodiment, the function of the processor 601 corresponds to the steps in the foregoing Figures 1 to 4 Embodiment shown in FIG., and details are not described herein again.
[0152] The embodiment of the present application further provides a computer-readable storage medium, on which a program is stored, and when the program is executed on a computer, the computer is caused to execute the method in any one of the foregoing Figures 1 to 4 Possible implementation manners.
[0153] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and details are not described herein again.
[0154] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, and the indirect couplings or communication connections of devices or units can be in electrical, mechanical or other forms.
[0155] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0156] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0157] If the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, read-only memory), random access memories (RAM, random access memory), magnetic disks or optical discs that can store program codes.
Claims
1. An image flat-field correction method, characterized in that, Including: Obtain a calibration image and a target image, where the saturation of the calibration image is within a preset saturation range, the target image is an image to be flat-field corrected, and the resolution of the target image is the same as that of the calibration image; Calculate a first non-uniformity value of the calibration image according to a first ROI of the calibration image. The first ROI includes a first central ROI and a first edge ROI. The first central ROI is located at the center of the calibration image, the first edge ROI is located at the four corners of the calibration image, the first central ROI and the first edge ROI have the same size and shape, and the first non-uniformity value represents the non-uniformity degree between each first edge ROI and the first central ROI; Calculate a second non-uniformity value of the target image according to a second ROI of the target image. The second ROI includes a second central ROI and a second edge ROI. The second central ROI is located at the center of the target image, the second edge ROI is located at the four corners of the target image, the second central ROI and the second edge ROI have the same size and shape, and the second non-uniformity value represents the non-uniformity degree between each second edge ROI and the second central ROI; Calculate a difference value according to the first non-uniformity value and the second non-uniformity value. The difference value is the ratio of the second non-uniformity value to the first non-uniformity value; Generate a target correction coefficient map according to the difference value; Perform flat-field correction on the target image according to the target correction coefficient map; The calculating the first non-uniformity value of the calibration image according to the first ROI of the calibration image includes: Calculate the gray-scale means of the first central ROI and the first edge ROI of the calibration image respectively; take the ratio of the gray-scale mean of the first edge ROI to the gray-scale mean of the first central ROI as the first non-uniformity value; The calculating the second non-uniformity value of the target image according to the second ROI of the target image includes: Calculate the gray-scale means of the second central ROI and the second edge ROI of the target image respectively; take the ratio of the gray-scale mean of the second edge ROI to the gray-scale mean of the second central ROI as the second non-uniformity value; The generating the target correction coefficient map according to the difference value includes: Calculate a correction ratio of each pixel in the calibration image. The correction ratio is the ratio of the gray-scale value to the gray-scale mean of the first central ROI; Combine the correction ratios of all pixels in the calibration image into a calibration correction coefficient map; Generate a target correction coefficient map according to the difference value and the calibration correction coefficient map; The generating the target correction coefficient map according to the difference value and the calibration correction coefficient map includes: Generate a basic coefficient map according to the difference value. Among them, the pixel values in a quarter area corresponding to the difference value in the basic coefficient map are all the difference value, and the pixel values in the remaining three-quarters area of the basic coefficient map are all 1; Calculate the target correction coefficient map according to the basic coefficient map and the calibration correction coefficient map.
2. The method according to claim 1, wherein Performing flat-field correction on the target image according to the target correction coefficient map includes: Multiplying the target image by the target correction coefficient map to obtain a corrected target image.
3. The method according to any one of claims 1 to 2, characterized in that, Before calculating the first non-uniform value of the calibration image according to the first ROI of the calibration image, the method further includes: Determining the shape and size of the first central ROI according to the resolution of the calibration image.
4. The method according to any one of claims 1 to 2, characterized in that Before acquiring the calibration image and the target image, the method further includes: Determining the camera and shooting scene for shooting the calibration image; Determining the saturation of the calibration image according to the camera and the shooting scene.
5. An image flat-field correction device, characterized in that, Including: An acquisition unit configured to acquire a calibration image and a target image, where the saturation of the calibration image is within a preset saturation range, the target image is an image to be flat-field corrected, and the resolution of the target image is the same as that of the calibration image; A first calculation unit configured to calculate a first non-uniform value of the calibration image according to a first ROI of the calibration image, where the first ROI includes a first central ROI and a first edge ROI, the first central ROI is located at the center of the calibration image, the first edge ROI is located at the four corners of the calibration image, the first central ROI and the first edge ROI have the same size and shape, and the first non-uniform value represents the non-uniformity degree between each first edge ROI and the first central ROI; A second calculation unit configured to calculate a second non-uniform value of the target image according to a second ROI of the target image, where the second ROI includes a second central ROI and a second edge ROI, the second central ROI is located at the center of the target image, the second edge ROI is located at the four corners of the target image, the second central ROI and the second edge ROI have the same size and shape, and the second non-uniform value represents the non-uniformity degree between each second edge ROI and the second central ROI; A third calculation unit configured to calculate a difference value according to the first non-uniform value and the second non-uniform value, where the difference value is the ratio of the second non-uniform value to the first non-uniform value; A generation unit configured to generate a target correction coefficient map according to the difference value; An execution unit configured to perform flat-field correction on the target image according to the target correction coefficient map; The first calculation unit is specifically configured to: Calculate the gray-scale means of the first central ROI and the first edge ROI respectively; Taking the ratio of the gray-scale mean of the first edge ROI to the gray-scale mean of the first central ROI as the first non-uniform value; The second calculation unit is specifically configured to: Calculate the gray-scale means of the second central ROI and the second edge ROI respectively; Taking the ratio of the gray-scale mean of the second edge ROI to the gray-scale mean of the second central ROI as the second non-uniform value; The generation unit includes: A calculation module configured to calculate a correction ratio of each pixel in the calibration image, where the correction ratio is the ratio of the gray-scale value to the gray-scale mean of the first central ROI; A merging module, configured to merge the correction ratios of all pixels in the calibrated image into a calibrated correction coefficient map; A generating module, configured to generate a target correction coefficient map according to the difference value and the calibrated correction coefficient map; Specifically, the generating module is configured to: Generate a basic coefficient map according to the difference value, wherein pixel values in a quarter area corresponding to the difference value in the basic coefficient map are all set to the difference value, and pixel values in the remaining three - quarter areas in the basic coefficient map are all 1; Calculate the target correction coefficient map according to the basic coefficient map and the calibrated correction coefficient map.
6. An image flat field correction device, characterized in that, Comprising: A processor, a memory, an input - output unit, and a bus; The processor is connected to the memory, the input - output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method according to any one of claims 1 to 4.
7. A computer - readable storage medium, on which a program is stored. When the program is executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Lens shadow correction method, system and electronic device
CN109068025A
Light source design and production method and device of optical system and electronic equipment
CN117647885A