A method and apparatus for adaptive vignette correction
By using an adaptive vignetting correction method, which combines a preliminary correction gain table and a secondary correction gain table, the accuracy and matching degree of image vignetting correction are improved. This method is applicable to various scenarios and camera modules, and solves the problem of inaccurate vignetting correction in existing technologies.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2026-03-24
AI Technical Summary
Existing image vignetting correction methods have low accuracy in correcting image vignetting and are difficult to adapt to image vignetting correction under the influence of various factors.
The adaptive vignetting correction method uses a pre-determined preliminary correction gain table to perform preliminary correction on the target image, filters out multiple candidate correction gain tables, selects a secondary correction gain table from the preliminary vignetting correction image, and updates the preliminary correction gain table to determine the target vignetting correction image.
It improves the accuracy of image vignetting correction and the matching degree between image content and target environment, and is suitable for anisotropic camera modules and various scenarios, solving the color shift problem.
Smart Images

Figure CN115797204B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and in particular to a method and device for adaptive vignetting correction. BACKGROUND
[0002] Vignetting is a common problem in image shooting, which refers to the situation that the image brightness gradually decreases from the optical center to the edge, and the color offset may also occur.
[0003] The current method for correcting image vignetting is to give a certain gain to the pixels affected by vignetting to correct the brightness loss and color offset of the image edge. However, in real life, the generation of vignetting is affected by many factors, and the current vignetting correction method has low accuracy in correcting image vignetting. Therefore, it is particularly important to improve the accuracy of image vignetting correction. SUMMARY
[0004] The technical problem to be solved by the present application is to provide a method and device for intelligently controlling the circulation of recyclable containers, thereby improving the accuracy of image vignetting correction and improving the matching degree of the determined target vignetting correction image and the target environment.
[0005] To solve the above technical problem, the first aspect of the present application discloses a method for adaptive vignetting correction, which comprises:
[0006] preliminary correction according to a preliminary correction gain table to obtain a preliminary vignetting correction image; the preliminary correction gain table comprises a gain value obtained after the pixel value of each channel of each pixel point in all pixel points of a calibration image is calibrated according to a first preset light source;
[0007] determining a plurality of candidate correction gain tables of the target image, and selecting a secondary correction gain table of the target image from all the candidate correction gain tables according to the preliminary vignetting correction image;
[0008] determining a target vignetting correction image corresponding to the target image according to the preliminary correction gain table and the secondary correction gain table.
[0009] As an optional implementation manner, in the first aspect of the present application, the determination of the plurality of candidate correction gain tables of the target image comprises:
[0010] Multiple first-channel correction gain tables are obtained; each first-channel correction gain table has a corresponding calibration light source; each first-channel correction gain table includes multiple gain values obtained after calibrating the pixel values of the first channel of each pixel in the calibration image according to the calibration light source corresponding to the first-channel correction gain table;
[0011] Based on all the first channel correction gain tables, a plurality of candidate correction gain tables for the target image are determined;
[0012] The step of determining multiple candidate correction gain tables for the target image based on all the first channel correction gain tables includes:
[0013] A mixing operation is performed on all the first channel correction gain tables according to a first preset ratio to obtain a mixed correction gain table;
[0014] Based on each first channel correction gain table and the hybrid correction gain table, calculate the initial correction gain table corresponding to the first channel correction gain table;
[0015] All the initial correction gain tables are mixed according to multiple second preset ratios to obtain multiple candidate correction gain tables for the target image, and each second preset ratio has a unique corresponding candidate correction gain table.
[0016] As an optional implementation, in the first aspect of the present invention, the step of selecting a secondary correction gain table for the target image from all candidate correction gain tables based on the preliminary vignetting correction image includes:
[0017] Based on the preliminary vignetting correction image, calculate the total standard deviation of each of the candidate correction gain tables;
[0018] From all the candidate correction gain tables, the candidate correction gain table with the smallest total standard deviation is selected as the secondary correction gain table of the target image;
[0019] The step of calculating the total standard deviation corresponding to each candidate correction gain table based on the preliminary vignetting correction image includes:
[0020] Determine the ratio image between the first channel and the second channel of the preliminary vignetting correction image;
[0021] Calculate the gradient image corresponding to the ratio image based on the ratio image, and determine all target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image;
[0022] Based on the ratio image and all target connected sets, calculate the total standard deviation corresponding to all candidate correction gain tables.
[0023] As an optional implementation, in a first aspect of the present invention, determining the ratio image corresponding to the first channel and the second channel of the preliminary vignetting correction image includes:
[0024] Obtain the grayscale value of the first channel and the grayscale value of the second channel of each pixel in the preliminary vignetting correction image.
[0025] The grayscale value of the first channel of each pixel is compared with the grayscale value of the second channel to obtain the ratio processing result of the pixel.
[0026] Based on the ratio processing results of all the pixels, the ratio image corresponding to the first channel and the second channel of the preliminary vignetting correction image is determined.
[0027] As an optional implementation, in the first aspect of the present invention, determining the plurality of target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image includes:
[0028] The gradient image is subjected to thresholding to obtain a thresholding result; the thresholding result includes a first type of pixel and a second type of pixel, and the gray values of the first type of pixel and the second type of pixel are different.
[0029] All the pixels in the second type of pixels included in the threshold processing result are grouped to obtain multiple initial connected sets;
[0030] From all the initial connected sets, select all first alternative connected sets whose number of pixels is greater than or equal to the first preset number of pixels;
[0031] For any first backup connected set, each pixel in all the pixels included in the first backup connected set is sorted according to the ratio processing result of the pixel based on a predetermined sorting method to obtain all sorted pixels. Smoothing difference processing is then performed on all sorted pixels to obtain the first sequence corresponding to the first backup connected set.
[0032] When the ratio of any pixel in the first sequence is greater than the preset ratio value, the pixel and other pixels within the preset range of the pixel are deleted to obtain the second backup connected set corresponding to the first backup connected set.
[0033] For any second backup connected set, each pixel in all the pixels included in the second backup connected set is sorted according to the ratio of the pixel based on a predetermined sorting method to obtain the second sequence corresponding to the second backup connected set;
[0034] Based on the current maximum value in the second sequence and the value corresponding to the first preset position of the second sequence, determine the target maximum value of the second sequence; based on the current minimum value in the second sequence and the value corresponding to the second preset position of the second sequence, determine the target minimum value of the second sequence; based on the target maximum value and the target minimum value of the second sequence, determine the third backup connected set corresponding to the second backup connected set.
[0035] Based on all the third backup connected sets and the preset retention conditions, multiple target connected sets corresponding to the preliminary vignetting correction image are determined.
[0036] As an optional implementation, in the first aspect of the present invention, determining the target maximum value of the second sequence based on the value corresponding to the current maximum value in the second sequence and the first preset position of the second sequence includes:
[0037] If the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, delete the current maximum value in the second sequence, and repeat the operation of deleting the current maximum value in the second sequence when the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, until the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is less than or equal to the first preset difference. Then, the current maximum value in the second sequence obtained after stopping the repetition of this operation is determined as the target maximum value of the second sequence.
[0038] And, determining the target minimum value of the second sequence based on the value corresponding to the current minimum value in the second sequence and the second preset position of the second sequence includes:
[0039] If the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, delete the current minimum value in the second sequence, and repeat the operation of deleting the current minimum value in the second sequence when the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, until the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is less than or equal to the second preset difference. The current minimum value in the second sequence obtained after stopping the repetition of this operation is determined as the target minimum value of the second sequence.
[0040] As an optional implementation, in the first aspect of the present invention, determining the target vignetting correction image corresponding to the target image based on the preliminary correction gain table and the secondary correction gain table includes:
[0041] Based on the secondary correction gain table, the gain values in the channels in the preliminary correction gain table that match the channels in the secondary correction gain table are updated to obtain the updated preliminary correction gain table.
[0042] Based on the updated preliminary correction gain table, the target vignetting correction image corresponding to the target image is determined.
[0043] As an optional implementation, in the first aspect of the invention, before performing preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting-corrected image, the method further includes:
[0044] The target image is scaled according to a preset scaling ratio to obtain a scaled target image, and the operation of performing preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image is triggered.
[0045] And, the step of performing preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image includes:
[0046] The predetermined preliminary correction gain table is scaled according to the preset scaling ratio to obtain a scaled preliminary correction gain table. The scaled target image is then preliminarily corrected based on the scaled preliminary correction gain table to obtain a scaled preliminary vignetting correction image.
[0047] A second aspect of the present invention discloses an adaptive vignetting correction apparatus, the apparatus comprising:
[0048] The preliminary correction module is used to perform preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image; the preliminary correction gain table includes the gain value obtained after calibrating the pixel value of each channel of each pixel in all pixels of the calibration image according to a first preset light source;
[0049] A determination module is used to determine multiple candidate correction gain tables for the target image;
[0050] The filtering module is used to filter the secondary correction gain table of the target image from all the candidate correction gain tables based on the preliminary vignetting correction image;
[0051] The secondary correction module is used to determine the target vignetting correction image corresponding to the target image based on the preliminary correction gain table and the secondary correction gain table.
[0052] As an optional implementation, in a second aspect of the present invention, the determining module determines the plurality of candidate correction gain tables for the target image in a manner that specifically includes:
[0053] Multiple first-channel correction gain tables are obtained; each first-channel correction gain table has a corresponding calibration light source; each first-channel correction gain table includes multiple gain values obtained after calibrating the pixel values of the first channel of each pixel in the calibration image according to the calibration light source corresponding to the first-channel correction gain table;
[0054] Based on all the first channel correction gain tables, a plurality of candidate correction gain tables for the target image are determined;
[0055] Specifically, the method by which the determining module determines multiple candidate correction gain tables for the target image based on all the first channel correction gain tables includes:
[0056] A mixing operation is performed on all the first channel correction gain tables according to a first preset ratio to obtain a mixed correction gain table;
[0057] Based on each first channel correction gain table and the hybrid correction gain table, calculate the initial correction gain table corresponding to the first channel correction gain table;
[0058] All the initial correction gain tables are mixed according to multiple second preset ratios to obtain multiple candidate correction gain tables for the target image, and each second preset ratio has a unique corresponding candidate correction gain table.
[0059] As an optional implementation, in a second aspect of the present invention, the filtering module selects the secondary correction gain table of the target image from all candidate correction gain tables based on the preliminary vignetting correction image, specifically including:
[0060] Based on the preliminary vignetting correction image, calculate the total standard deviation of each of the candidate correction gain tables;
[0061] From all the candidate correction gain tables, the candidate correction gain table with the smallest total standard deviation is selected as the secondary correction gain table of the target image;
[0062] Specifically, the method by which the screening module calculates the total standard deviation corresponding to each candidate correction gain table based on the preliminary vignetting correction image includes:
[0063] Determine the ratio image between the first channel and the second channel of the preliminary vignetting correction image;
[0064] Calculate the gradient image corresponding to the ratio image based on the ratio image, and determine all target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image;
[0065] Based on the ratio image and all target connected sets, calculate the total standard deviation corresponding to all candidate correction gain tables.
[0066] As an optional implementation, in a second aspect of the present invention, the method by which the filtering module determines the ratio image corresponding to the first channel and the second channel of the preliminary vignetting correction image specifically includes:
[0067] Obtain the grayscale value of the first channel and the grayscale value of the second channel of each pixel in the preliminary vignetting correction image.
[0068] The grayscale value of the first channel of each pixel is compared with the grayscale value of the second channel to obtain the ratio processing result of the pixel.
[0069] Based on the ratio processing results of all the pixels, the ratio image corresponding to the first channel and the second channel of the preliminary vignetting correction image is determined.
[0070] As an optional implementation, in a second aspect of the present invention, the method by which the filtering module determines the multiple target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image specifically includes:
[0071] The gradient image is subjected to thresholding to obtain a thresholding result; the thresholding result includes a first type of pixel and a second type of pixel, and the gray values of the first type of pixel and the second type of pixel are different.
[0072] All the pixels in the second type of pixels included in the threshold processing result are grouped to obtain multiple initial connected sets;
[0073] From all the initial connected sets, select all first alternative connected sets whose number of pixels is greater than or equal to the first preset number of pixels;
[0074] For any first backup connected set, each pixel in all the pixels included in the first backup connected set is sorted according to the ratio processing result of the pixel based on a predetermined sorting method to obtain all sorted pixels. Smoothing difference processing is then performed on all sorted pixels to obtain the first sequence corresponding to the first backup connected set.
[0075] When the ratio of any pixel in the first sequence is greater than the preset ratio value, the pixel and other pixels within the preset range of the pixel are deleted to obtain the second backup connected set corresponding to the first backup connected set.
[0076] For any second backup connected set, each pixel in all the pixels included in the second backup connected set is sorted according to the ratio of the pixel based on a predetermined sorting method to obtain the second sequence corresponding to the second backup connected set;
[0077] Based on the current maximum value in the second sequence and the value corresponding to the first preset position of the second sequence, determine the target maximum value of the second sequence; based on the current minimum value in the second sequence and the value corresponding to the second preset position of the second sequence, determine the target minimum value of the second sequence; based on the target maximum value and the target minimum value of the second sequence, determine the third backup connected set corresponding to the second backup connected set.
[0078] Based on all the third backup connected sets and the preset retention conditions, multiple target connected sets corresponding to the preliminary vignetting correction image are determined.
[0079] As an optional implementation, in a second aspect of the present invention, the filtering module determines the target maximum value of the second sequence based on the value corresponding to the current maximum value in the second sequence and the first preset position of the second sequence, specifically including:
[0080] If the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, delete the current maximum value in the second sequence, and repeat the operation of deleting the current maximum value in the second sequence when the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, until the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is less than or equal to the first preset difference. Then, the current maximum value in the second sequence obtained after stopping the repetition of this operation is determined as the target maximum value of the second sequence.
[0081] Furthermore, the filtering module determines the target minimum value of the second sequence based on the value corresponding to the current minimum value in the second sequence and the second preset position of the second sequence in the following specific ways:
[0082] If the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, delete the current minimum value in the second sequence, and repeat the operation of deleting the current minimum value in the second sequence when the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, until the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is less than or equal to the second preset difference. The current minimum value in the second sequence obtained after stopping the repetition of this operation is determined as the target minimum value of the second sequence.
[0083] As an optional implementation, in a second aspect of the present invention, the method by which the secondary correction module determines the target vignetting correction image corresponding to the target image based on the preliminary correction gain table and the secondary correction gain table specifically includes:
[0084] Based on the secondary correction gain table, the gain values in the channels in the preliminary correction gain table that match the channels in the secondary correction gain table are updated to obtain the updated preliminary correction gain table.
[0085] Based on the updated preliminary correction gain table, the target vignetting correction image corresponding to the target image is determined.
[0086] As an optional implementation, in a second aspect of the invention, the apparatus further includes:
[0087] The scaling module is used to scale the target image according to a preset scaling ratio before the preliminary correction module performs preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image, thereby obtaining a scaled target image, and triggering the execution of the operation of performing preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image.
[0088] Furthermore, the preliminary correction module performs preliminary correction on the target image according to a pre-determined preliminary correction gain table to obtain a preliminary vignetting correction image, specifically including the following methods:
[0089] The predetermined preliminary correction gain table is scaled according to the preset scaling ratio to obtain a scaled preliminary correction gain table. The scaled target image is then preliminarily corrected based on the scaled preliminary correction gain table to obtain a scaled preliminary vignetting correction image.
[0090] A third aspect of the present invention discloses another apparatus for adaptive vignetting correction, the apparatus comprising:
[0091] Memory containing executable program code;
[0092] A processor coupled to the memory;
[0093] The processor calls the executable program code stored in the memory to execute the adaptive vignetting correction method disclosed in the first aspect of the present invention.
[0094] The fourth aspect of the present invention discloses a computer-storable medium storing computer instructions, which, when invoked, are used to execute the adaptive vignetting correction method disclosed in the first aspect of the present invention.
[0095] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0096] In this embodiment of the invention, a preliminary correction gain table is used to perform preliminary correction on the target image to obtain a preliminary vignetting correction image. The preliminary correction gain table includes gain values obtained by calibrating the pixel values of each channel of each pixel in the calibration image according to a first preset light source. Multiple candidate correction gain tables for the target image are determined, and a secondary correction gain table for the target image is selected from all candidate correction gain tables based on the preliminary vignetting correction image. The target vignetting correction image corresponding to the target image is determined based on the preliminary correction gain table and the secondary correction gain table. As can be seen, implementing this invention can determine the preliminary vignetting correction image of the target image based on a pre-determined preliminary correction gain table, and intelligently analyze multiple candidate correction gain tables based on the preliminary vignetting correction image. Based on the analysis results, a secondary correction gain table is selected from all candidate correction gain tables, improving the accuracy of the selected secondary correction gain table. Furthermore, the accurate secondary correction gain table is used to update the preliminary correction gain table, and the target vignetting correction image of the target image is determined based on the updated preliminary correction gain table, further improving the accuracy of the determined target vignetting correction image. This improves the matching degree between the image content of the target vignetting correction image and the target environment. Additionally, it is applicable to situations with anisotropic camera modules, and can be applied to various scenarios and solve color shift problems. Attached Figure Description
[0097] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0098] Figure 1 This is a flowchart illustrating an adaptive vignetting correction method disclosed in an embodiment of the present invention;
[0099] Figure 2 This is a flowchart illustrating another adaptive vignetting correction method disclosed in an embodiment of the present invention;
[0100] Figure 3 This is a schematic diagram of the structure of an adaptive vignetting correction device disclosed in an embodiment of the present invention;
[0101] Figure 4 This is a schematic diagram of another adaptive vignetting correction device disclosed in an embodiment of the present invention;
[0102] Figure 5 This is a schematic diagram of the structure of another adaptive vignetting correction device disclosed in an embodiment of the present invention. Detailed Implementation
[0103] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0104] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or end that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or ends.
[0105] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0106] This invention discloses an adaptive vignetting correction method and apparatus. It can determine a preliminary vignetting correction image of a target image based on a pre-determined preliminary correction gain table, intelligently analyze multiple candidate correction gain tables based on the preliminary vignetting correction image, and select a secondary correction gain table from all candidate correction gain tables based on the analysis results, improving the accuracy of the selected secondary correction gain table. Furthermore, it updates the preliminary correction gain table using the accurate secondary correction gain table and determines the target vignetting correction image of the target image based on the updated preliminary correction gain table, further improving the accuracy of the determined target vignetting correction image. This improves the matching degree between the image content of the target vignetting correction image and the target environment. It is also applicable to situations with anisotropic camera modules, suitable for various scenarios, and solves color shift problems. Detailed descriptions follow.
[0107] Example 1
[0108] Please see Figure 1 , Figure 1 This is a flowchart illustrating an adaptive vignetting correction method disclosed in an embodiment of the present invention.Figure 1 The described adaptive vignetting correction method can be applied to an adaptive vignetting correction device, which may include a correction equipment or a correction server. The correction server may include a cloud server or a local server; this embodiment of the invention is not limited thereto. Figure 1 As shown, the adaptive vignetting correction method may include the following operations:
[0109] 101. Perform preliminary correction on the target image according to the predetermined preliminary correction gain table to obtain a preliminary vignetting correction image.
[0110] The preliminary correction gain table includes gain values obtained after calibrating the pixel values of each channel of each pixel in the calibration image based on the pixel values of each channel of each pixel in the calibration image using a first preset light source. Optionally, the first preset light source can be a commonly used light source. Further optionally, the calibration image can be the target image or any other image with vignetting issues; this embodiment of the invention does not impose any limitations.
[0111] It should be noted that calibration refers to taking a special image with a camera under a specific light source (such as photographing a white sheet of paper, which makes it relatively easy to analyze vignetting), resulting in an image with vignetting. This image is called a calibration image. By analyzing the calibration image, the corresponding correction gain table under that light source can be obtained. Preliminary correction can be performed by multiplying the pixel value of each pixel in the target image by the gain value of that pixel in the preliminary correction gain table.
[0112] 102. Determine multiple candidate correction gain tables for the target image.
[0113] 103. Based on the preliminary vignetting correction image, select the secondary correction gain table for the target image from all candidate correction gain tables.
[0114] 104. Based on the preliminary correction gain table and the secondary correction gain table, determine the target vignetting correction image corresponding to the target image.
[0115] The secondary correction gain table is used to update the preliminary correction gain table to obtain the updated preliminary correction gain table. The updated preliminary correction gain table is then used to perform secondary correction on the target image to obtain the target vignetting correction image corresponding to the target image.
[0116] As can be seen, the adaptive vignetting correction method described in this invention can determine a preliminary vignetting correction image of the target image based on a pre-determined preliminary correction gain table, and intelligently analyze multiple candidate correction gain tables based on the preliminary vignetting correction image. It then selects a secondary correction gain table from all candidate correction gain tables based on the analysis results, improving the accuracy of the selected secondary correction gain table. Furthermore, it updates the preliminary correction gain table using the accurate secondary correction gain table and determines the target vignetting correction image of the target image based on the updated preliminary correction gain table, further improving the accuracy of the determined target vignetting correction image. This improves the matching degree between the image content of the target vignetting correction image and the target environment. Additionally, it is applicable to situations with anisotropic camera modules, suitable for various scenarios, and can solve color shift problems.
[0117] Example 2
[0118] Please see Figure 2 , Figure 2 This is a flowchart illustrating another adaptive vignetting correction method disclosed in an embodiment of the present invention. Figure 2 The described adaptive vignetting correction method can be applied to an adaptive vignetting correction device, which may include a correction equipment or a correction server. The correction server may include a cloud server or a local server; this embodiment of the invention is not limited thereto. Figure 2 As shown, the adaptive vignetting correction method may include the following operations:
[0119] 201. Scale the target image according to the preset scaling ratio to obtain the scaled target image.
[0120] For example, when the target image's width and height are greater than 32×32, the target image is reduced to 32×32, and then vignetting correction is performed on the reduced target image; when the target image's width and height are less than 32×32, the target image is enlarged to 32×32, and then vignetting correction is performed on the enlarged target image; and when the target image's width and height are equal to 32×32, vignetting correction is performed directly on the target image. This approach balances accuracy and speed when correcting vignetting in the target image.
[0121] 202. Scale the predetermined preliminary correction gain table according to the preset scaling ratio to obtain the scaled preliminary correction gain table. Perform preliminary correction on the scaled target image according to the scaled preliminary correction gain table to obtain the scaled preliminary vignetting correction image.
[0122] 203. Determine multiple candidate correction gain tables for the scaled target image.
[0123] 204. Based on the preliminary vignetting correction image, select the secondary correction gain table of the scaled target image from all candidate correction gain tables.
[0124] 205. Based on the scaled initial correction gain table and the scaled secondary correction gain table, determine the target vignetting correction image corresponding to the scaled target image.
[0125] In this embodiment of the invention, the specific technical details and explanations of technical terms for steps 202-205 can be found in the description of steps 101-104 in Embodiment 1, and will not be repeated here.
[0126] As can be seen, the adaptive vignetting correction method described in the embodiments of the present invention can determine a preliminary vignetting correction image of the target image based on a pre-determined preliminary correction gain table, and intelligently analyze multiple candidate correction gain tables based on the preliminary vignetting correction image. It then selects a secondary correction gain table from all candidate correction gain tables based on the analysis results, improving the accuracy of the selected secondary correction gain table. Furthermore, it updates the preliminary correction gain table using the accurate secondary correction gain table and determines the target vignetting correction image of the target image based on the updated preliminary correction gain table, further improving the accuracy of the determined target vignetting correction image. This improves the matching degree between the image content of the target vignetting correction image and the target environment. It is also applicable to situations with anisotropic camera modules, and can be applied to various scenarios and solve color shift problems. In addition, by scaling the target image using a preset scaling ratio and performing a series of processes based on the scaled target image to achieve vignetting correction, it can balance accuracy and speed when correcting vignetting in the target image.
[0127] In an optional embodiment, step 203 above, determining multiple candidate correction gain tables for the scaled-down target image, may include:
[0128] Multiple first-channel correction gain tables are obtained; each first-channel correction gain table has a corresponding calibration light source; each first-channel correction gain table includes multiple gain values obtained after calibrating the pixel value of the first channel of each pixel in all pixels of the calibration image according to the calibration light source corresponding to the first-channel correction gain table.
[0129] Based on all the first-channel correction gain tables, determine multiple candidate correction gain tables for the scaled-down target image.
[0130] It should be noted that all calibration light sources are different, and each calibration light source can calibrate images with different degrees of vignetting.
[0131] As can be seen, this optional embodiment can determine multiple candidate correction gain tables based on the determined multiple first channel correction gain tables (each first channel correction gain table has a corresponding calibration light source), thereby improving the diversity and accuracy of determining multiple candidate correction gain tables.
[0132] In this optional embodiment, as an optional implementation, determining multiple candidate correction gain tables for the scaled-down target image based on all first channel correction gain tables may include:
[0133] A mixing operation is performed on all first channel correction gain tables according to a first preset ratio to obtain a mixed correction gain table;
[0134] Based on each first channel correction gain table and the hybrid correction gain table, calculate the initial correction gain table corresponding to the first channel correction gain table;
[0135] All initial correction gain tables are mixed according to multiple second preset ratios to obtain multiple candidate correction gain tables for the scaled-down target image. Each second preset ratio has a unique corresponding candidate correction gain table.
[0136] Optionally, the aforementioned first preset ratio is a ratio that allows the resulting mixed correction gain table to be as close as possible to the initial correction gain table calibrated by the first preset light source. Further optionally, the initial correction gain table corresponding to each first channel correction gain table can be a correction gain table obtained by dividing the channel correction gain table by the mixed correction gain table. As another optional step, for example, the calculation formula for mixing N initial correction gain tables according to the Mth second preset ratio to obtain the Mth candidate correction gain table is as follows:
[0137] W M =A M1 ×T M1 +A M2 ×T M2 +…+A MN ×T MN ;
[0138] Among them, W M This refers to the Mth candidate correction gain table, T M1 T M2 ... T MN Each of the N initial correction gain tables refers to an initial correction gain table, A. M1 A M2 A MN These refer to the proportions corresponding to each of the N initial correction gain tables.
[0139] As can be seen, this optional embodiment can perform a mixing operation on all first channel correction gain tables based on a first preset ratio to obtain a mixed correction gain table, which improves the matching degree between the determined mixed correction gain table and the preliminary correction gain table. Based on the mixed correction gain table, an initial correction gain table corresponding to each first channel correction gain table is calculated, and a mixing operation is performed on all initial correction gain tables based on multiple second preset ratios to obtain multiple candidate correction gain tables, which improves the matching degree between each determined candidate correction gain table and the preliminary correction gain table, thereby helping to improve the reliability and accuracy of the determined multiple candidate correction gain tables.
[0140] In an optional embodiment, step 204 above, which involves selecting a secondary correction gain table for the scaled target image from all candidate correction gain tables based on the initial vignetting correction image, may include:
[0141] Based on the preliminary vignetting correction image, calculate the total standard deviation of each candidate correction gain table;
[0142] From all candidate correction gain tables, select the candidate correction gain table with the smallest total standard deviation as the secondary correction gain table for the scaled-down target image.
[0143] It should be noted that the total standard deviation of each candidate correction gain table is used to determine the degree of matching between the candidate correction gain table and the preliminary correction gain table. In addition to the total standard deviation, variance, range, or mean deviation can also be used to determine the degree of matching between each candidate correction gain table and the preliminary correction gain table. This embodiment of the invention does not limit the method.
[0144] As can be seen, this optional embodiment can calculate the total standard deviation of each candidate correction gain table based on the initial vignetting correction image, and select the candidate correction gain table with the smallest total standard deviation from all candidate correction gain tables as the secondary correction gain table, thereby improving the reliability and accuracy of the selected secondary correction gain table.
[0145] In this optional embodiment, as an optional implementation, calculating the total standard deviation corresponding to each candidate correction gain table based on the preliminary vignetting correction image may include:
[0146] Determine the ratio image between the first and second channels of the preliminary vignetting correction image;
[0147] Calculate the gradient image corresponding to the ratio image based on the ratio image, and determine all target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image.
[0148] Calculate the total standard deviation of all candidate correction gain tables based on the ratio image and all target connected sets.
[0149] As can be seen, this optional implementation can determine the ratio image corresponding to the first channel and the second channel based on the preliminary vignetting correction image, and determine all target connected sets based on the ratio image. By using the ratio image and all target connected sets, the total standard deviation corresponding to all candidate correction gain tables is calculated, which improves the accuracy of the total standard deviation of each candidate correction gain table, and thus improves the accuracy of the determined secondary correction gain table.
[0150] In this optional embodiment, as an optional implementation, determining the ratio image corresponding to the first channel and the second channel of the preliminary vignetting correction image may include:
[0151] Obtain the grayscale value of the first channel and the grayscale value of the second channel of each pixel in the initial vignetting correction image.
[0152] The grayscale value of the first channel of each pixel is compared with the grayscale value of the second channel of the same pixel to obtain the ratio processing result of the pixel.
[0153] Based on the ratio processing results of all pixels, the ratio images corresponding to the first and second channels of the preliminary vignetting correction image are determined.
[0154] It should be noted that when the grayscale value of the second channel of any pixel in the preliminary vignetting correction image is zero, the grayscale value of each channel of every pixel in the preliminary vignetting correction image is incremented by one to ensure that the ratio processing for each pixel can proceed smoothly. Specifically, this ratio processing can be either dividing the grayscale value of the first channel of each pixel by the grayscale value of the second channel of that pixel, or dividing the incremented grayscale value of the first channel of each pixel by the incremented grayscale value of the second channel of that pixel.
[0155] As can be seen, this optional implementation can smoothly and accurately determine the ratio image of the first channel and the second channel of the preliminary vignetting correction image by processing the gray value of the first channel and the gray value of the second channel of each pixel in all pixels.
[0156] In this optional embodiment, as an optional implementation, determining multiple target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image may include:
[0157] The gradient image is thresholded to obtain the thresholding result; the thresholding result includes first-class pixels and second-class pixels, and the gray values of the first-class pixels are different from those of the second-class pixels.
[0158] All pixels in the second category of pixels included in the threshold processing result are grouped to obtain multiple initial connected sets;
[0159] Select all first alternative connected sets from all initial connected sets, where the number of pixels is greater than or equal to the first preset number of pixels;
[0160] For any first backup connected set, each pixel in the first backup connected set is sorted according to the ratio of the pixel based on a predetermined sorting method to obtain all sorted pixels. Smoothing difference processing is then performed on all sorted pixels to obtain the first sequence corresponding to the first backup connected set.
[0161] When the ratio of any pixel in the first sequence is greater than the preset ratio value, the pixel and other pixels within the preset range of the pixel are deleted to obtain the second backup connected set corresponding to the first backup connected set.
[0162] For any second backup connected set, each pixel in all pixels included in the second backup connected set is sorted according to the ratio of the pixel based on a predetermined sorting method, to obtain the second sequence corresponding to the second backup connected set;
[0163] Based on the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence, determine the target maximum value of the second sequence; based on the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence, determine the target minimum value of the second sequence; based on the target maximum value and the target minimum value of the second sequence, determine the third backup connected set corresponding to the second backup connected set.
[0164] Based on all third-backup connected sets and preset retention conditions, determine multiple target connected sets corresponding to the initial vignetting correction image.
[0165] Specifically, based on all third backup connected sets and preset retention conditions, multiple target connected sets corresponding to the preliminary vignetting correction image are determined. This can be achieved by calculating the mean brightness, standard deviation brightness, corrected range of the ratio processing results of the first and second channels, corrected range of color a channel, corrected range of color b channel, saturation, and other attributes of each third backup connected set. If all of the above attributes of the third backup connected set are less than the threshold corresponding to each predetermined attribute, the third backup connected set is retained and determined as the target connected set corresponding to the preliminary vignetting correction image. If at least one of the above attributes of the third backup connected set is not less than the threshold corresponding to that attribute, the third backup connected set is deleted.
[0166] It should be noted that each of the aforementioned third alternative connected sets includes all pixels in its corresponding second sequence that traverse from the pixel of the target minimum value to the pixel of the target maximum value. Optionally, the thresholding process can be either binarization thresholding or debinarization thresholding. Further optionally, the pixel values of the first type of pixels included in the thresholding result can be zero, and the pixel values of the second type of pixels can be one. As another optional step, the aforementioned pre-determined sorting method can be either ascending or descending sorting; this embodiment of the invention does not impose any limitations.
[0167] As can be seen, this optional implementation can accurately determine multiple initial connected sets based on the threshold processing results, and determine multiple target connected sets based on all initial connected sets, thereby improving the reliability and accuracy of the determined target connected sets.
[0168] In this optional embodiment, as an optional implementation method, determining the target maximum value of the second sequence based on the value corresponding to the current maximum value in the second sequence and the first preset position of the second sequence may include:
[0169] If the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, delete the current maximum value in the second sequence, and repeat the above operation of deleting the current maximum value in the second sequence when the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, until the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is less than or equal to the first preset difference. Then, the current maximum value in the second sequence obtained after stopping the repetition of this operation is determined as the target maximum value of the second sequence.
[0170] Furthermore, determining the target minimum value of the second sequence based on the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence may include:
[0171] If the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, delete the current minimum value in the second sequence. Repeat the above operation of deleting the current minimum value in the second sequence when the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, until the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is less than or equal to the second preset difference. Then, stop repeating this operation and determine the current minimum value in the second sequence as the target minimum value of the second sequence.
[0172] It should be noted that, in this optional implementation, the current maximum value can be deleted first and then the current minimum value can be deleted, or the current minimum value can be deleted first and then the current maximum value can be deleted, or both the current maximum and the current minimum value can be deleted simultaneously. This embodiment of the invention does not limit the implementation.
[0173] As can be seen, this optional implementation can repeatedly delete the current maximum and minimum values in the second sequence until the target maximum and minimum values are determined, thereby improving the accuracy of the determined target maximum and minimum values, and thus improving the accuracy of the determined third alternative connected set.
[0174] In an optional embodiment, step 205 above, determining the target vignetting correction image corresponding to the reduced target image based on the preliminary correction gain table and the secondary correction gain table, may include:
[0175] Based on the secondary correction gain table, the gain values in the channels that match the channels in the secondary correction gain table in the preliminary correction gain table are updated to obtain the updated preliminary correction gain table.
[0176] Based on the updated preliminary correction gain table, determine the target vignetting correction image corresponding to the target image.
[0177] Optionally, the channel that matches the channel in the preliminary correction gain table and the channel in the secondary correction gain table (the channel in the secondary correction gain table is the first channel) can be the first channel or any other channel; this embodiment of the invention does not limit the choice.
[0178] As can be seen, this optional embodiment can update the preliminary correction gain table based on the secondary correction gain table, thereby improving the similarity between the updated preliminary correction gain table and the correction gain table calibrated under the scene light source of the scene corresponding to the target image. This improves the accuracy of the updated preliminary correction gain table, and the target image is corrected based on the accurate preliminary correction gain table to obtain the target vignetting correction image. This improves the accuracy of the determined target vignetting correction image, thereby improving the matching degree between the image content of the target vignetting correction image and the target environment.
[0179] In an optional embodiment, prior to step 201 above, the method may further include:
[0180] The target image is scaled according to a preset scaling ratio to obtain a scaled target image, and the operation of step 201 is triggered to perform preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image.
[0181] Furthermore, the preliminary correction of the target image based on the predetermined preliminary correction gain table in step 201 above, to obtain a preliminary vignetting correction image, may include:
[0182] The predetermined preliminary correction gain table is scaled according to a preset scaling ratio to obtain a scaled preliminary correction gain table. The scaled target image is then preliminarily corrected based on the scaled preliminary correction gain table to obtain a scaled preliminary vignetting correction image.
[0183] As can be seen, this optional embodiment can scale the target image by a preset scaling ratio and perform a series of processes based on the scaled target image to correct the vignetting of the target image, thus balancing accuracy and speed when correcting the vignetting of the target image.
[0184] Example 3
[0185] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of an adaptive vignetting correction method disclosed in an embodiment of the present invention. Figure 3 The described adaptive vignetting correction apparatus may include a correction device or a correction server, wherein the correction server may include a cloud server or a local server, and the embodiments of the present invention are not limited thereto. Figure 3 As shown, the adaptive vignetting correction device may include the following operations:
[0186] The preliminary correction module 301 is used to perform preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image.
[0187] The preliminary correction gain table includes the gain values obtained after calibrating the pixel values of each channel of each pixel in the calibration image according to the first preset light source.
[0188] The determination module 302 is used to determine multiple candidate correction gain tables for the target image.
[0189] The filtering module 303 is used to filter the secondary correction gain table of the target image from all candidate correction gain tables based on the preliminary vignetting correction image.
[0190] The secondary correction module 304 is used to determine the target vignetting correction image corresponding to the target image based on the preliminary correction gain table and the secondary correction gain table.
[0191] As can be seen, the apparatus described in the embodiments of the present invention can determine a preliminary vignetting correction image of a target image based on a predetermined preliminary correction gain table, and intelligently analyze multiple candidate correction gain tables based on the preliminary vignetting correction image. It then selects a secondary correction gain table from all candidate correction gain tables based on the analysis results, improving the accuracy of the selected secondary correction gain table. Furthermore, it updates the preliminary correction gain table using the accurate secondary correction gain table and determines the target vignetting correction image of the target image based on the updated preliminary correction gain table, further improving the accuracy of the determined target vignetting correction image. This improves the matching degree between the image content of the target vignetting correction image and the target environment. Additionally, it is applicable to situations with anisotropic camera modules and can be used in various scenarios, as well as address color shift issues.
[0192] In an optional embodiment, the method by which the determining module 302 determines multiple candidate correction gain tables for the target image may specifically include:
[0193] Multiple first-channel correction gain tables are obtained; each first-channel correction gain table has a corresponding calibration light source; each first-channel correction gain table includes multiple gain values obtained after calibrating the pixel value of the first channel of each pixel in all pixels of the calibration image according to the calibration light source corresponding to the first-channel correction gain table.
[0194] Based on all the first-channel correction gain tables, determine multiple candidate correction gain tables for the scaled-down target image.
[0195] As can be seen, this optional embodiment can determine multiple candidate correction gain tables based on the determined multiple first channel correction gain tables (each first channel correction gain table has a corresponding calibration light source), thereby improving the diversity and accuracy of determining multiple candidate correction gain tables.
[0196] In this optional embodiment, as an optional implementation, the filtering module 303 determines multiple candidate correction gain tables for the scaled-down target image based on all first channel correction gain tables in a specific manner, including:
[0197] A mixing operation is performed on all first channel correction gain tables according to a first preset ratio to obtain a mixed correction gain table;
[0198] Based on each first channel correction gain table and the hybrid correction gain table, calculate the initial correction gain table corresponding to the first channel correction gain table;
[0199] All initial correction gain tables are mixed according to multiple second preset ratios to obtain multiple candidate correction gain tables for the scaled-down target image. Each second preset ratio has a unique corresponding candidate correction gain table.
[0200] As can be seen, this optional embodiment can perform a mixing operation on all first channel correction gain tables based on a first preset ratio to obtain a mixed correction gain table, which improves the matching degree between the determined mixed correction gain table and the preliminary correction gain table. Based on the mixed correction gain table, an initial correction gain table corresponding to each first channel correction gain table is calculated, and a mixing operation is performed on all initial correction gain tables based on multiple second preset ratios to obtain multiple candidate correction gain tables, which improves the matching degree between each determined candidate correction gain table and the preliminary correction gain table, thereby helping to improve the reliability and accuracy of the determined multiple candidate correction gain tables.
[0201] In an optional embodiment, the filtering module 303 may specifically select the secondary correction gain table of the scaled target image from all candidate correction gain tables based on the preliminary vignetting correction image in the following ways:
[0202] Based on the preliminary vignetting correction image, calculate the total standard deviation of each candidate correction gain table;
[0203] From all candidate correction gain tables, select the candidate correction gain table with the smallest total standard deviation as the secondary correction gain table for the scaled-down target image.
[0204] As can be seen, this optional embodiment can calculate the total standard deviation of each candidate correction gain table based on the initial vignetting correction image, and select the candidate correction gain table with the smallest total standard deviation from all candidate correction gain tables as the secondary correction gain table, thereby improving the reliability and accuracy of the selected secondary correction gain table.
[0205] In this optional embodiment, as an optional implementation, the method by which the screening module 303 calculates the total standard deviation corresponding to each candidate correction gain table based on the preliminary vignetting correction image may specifically include:
[0206] Determine the ratio image between the first and second channels of the preliminary vignetting correction image;
[0207] Calculate the gradient image corresponding to the ratio image based on the ratio image, and determine all target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image.
[0208] Calculate the total standard deviation of all candidate correction gain tables based on the ratio image and all target connected sets.
[0209] As can be seen, this optional implementation can determine the ratio image corresponding to the first channel and the second channel based on the preliminary vignetting correction image, and determine all target connected sets based on the ratio image. By using the ratio image and all target connected sets, the total standard deviation corresponding to all candidate correction gain tables is calculated, which improves the accuracy of the total standard deviation of each candidate correction gain table, and thus improves the accuracy of the determined secondary correction gain table.
[0210] In this optional embodiment, as an optional implementation, the method by which the filtering module 303 determines the ratio image corresponding to the first channel and the second channel of the preliminary vignetting correction image may specifically include:
[0211] Obtain the grayscale value of the first channel and the grayscale value of the second channel of each pixel in the initial vignetting correction image.
[0212] The grayscale value of the first channel of each pixel is compared with the grayscale value of the second channel of the same pixel to obtain the ratio processing result of the pixel.
[0213] Based on the ratio processing results of all pixels, the ratio images corresponding to the first and second channels of the preliminary vignetting correction image are determined.
[0214] As can be seen, this optional implementation can smoothly and accurately determine the ratio image of the first channel and the second channel of the preliminary vignetting correction image by processing the gray value of the first channel and the gray value of the second channel of each pixel in all pixels.
[0215] In this optional embodiment, as an optional implementation, the filtering module 303 determines the multiple target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image, specifically including:
[0216] The gradient image is thresholded to obtain the thresholding result; the thresholding result includes first-class pixels and second-class pixels, and the gray values of the first-class pixels are different from those of the second-class pixels.
[0217] All pixels in the second category of pixels included in the threshold processing result are grouped to obtain multiple initial connected sets;
[0218] Select all first alternative connected sets from all initial connected sets, where the number of pixels is greater than or equal to the first preset number of pixels;
[0219] For any first backup connected set, each pixel in the first backup connected set is sorted according to the ratio of the pixel based on a predetermined sorting method to obtain all sorted pixels. Smoothing difference processing is then performed on all sorted pixels to obtain the first sequence corresponding to the first backup connected set.
[0220] When the ratio of any pixel in the first sequence is greater than the preset ratio value, the pixel and other pixels within the preset range of the pixel are deleted to obtain the second backup connected set corresponding to the first backup connected set.
[0221] For any second backup connected set, each pixel in all pixels included in the second backup connected set is sorted according to the ratio of the pixel based on a predetermined sorting method, to obtain the second sequence corresponding to the second backup connected set;
[0222] Based on the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence, determine the target maximum value of the second sequence; based on the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence, determine the target minimum value of the second sequence; based on the target maximum value and the target minimum value of the second sequence, determine the third backup connected set corresponding to the second backup connected set.
[0223] Based on all third-backup connected sets and preset retention conditions, determine multiple target connected sets corresponding to the initial vignetting correction image.
[0224] As can be seen, this optional implementation can accurately determine multiple initial connected sets based on the threshold processing results, and determine multiple target connected sets based on all initial connected sets, thereby improving the reliability and accuracy of the determined target connected sets.
[0225] In this optional embodiment, as an optional implementation method, the filtering module 303 determines the target maximum value of the second sequence based on the value corresponding to the current maximum value in the second sequence and the first preset position of the second sequence, specifically including:
[0226] If the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, delete the current maximum value in the second sequence, and repeat the above operation of deleting the current maximum value in the second sequence when the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, until the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is less than or equal to the first preset difference. Then, the current maximum value in the second sequence obtained after stopping the repetition of this operation is determined as the target maximum value of the second sequence.
[0227] Furthermore, the filtering module 303 determines the target minimum value of the second sequence based on the value corresponding to the current minimum value in the second sequence and the second preset position in the second sequence, specifically including:
[0228] If the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, delete the current minimum value in the second sequence. Repeat the above operation of deleting the current minimum value in the second sequence when the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, until the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is less than or equal to the second preset difference. Then, stop repeating this operation and determine the current minimum value in the second sequence as the target minimum value of the second sequence.
[0229] As can be seen, this optional implementation can repeatedly delete the current maximum and minimum values in the second sequence until the target maximum and minimum values are determined, thereby improving the accuracy of the determined target maximum and minimum values, and thus improving the accuracy of the determined third alternative connected set.
[0230] In an optional embodiment, the secondary correction module 304 determines the target vignetting correction image corresponding to the reduced target image based on the preliminary correction gain table and the secondary correction gain table, specifically including:
[0231] Based on the secondary correction gain table, the gain values in the channels that match the channels in the secondary correction gain table in the preliminary correction gain table are updated to obtain the updated preliminary correction gain table.
[0232] Based on the updated preliminary correction gain table, determine the target vignetting correction image corresponding to the target image.
[0233] As can be seen, this optional embodiment can update the preliminary correction gain table based on the secondary correction gain table, thereby improving the accuracy of the updated preliminary correction gain table. The target image is then corrected based on the accurate preliminary correction gain table to obtain the target vignetting correction image, which improves the accuracy of the determined target vignetting correction image and thus improves the matching degree between the image content of the target vignetting correction image and the target environment.
[0234] In an optional embodiment, such as Figure 4 As shown, the device may further include:
[0235] The scaling module 305 is used to scale the target image according to a preset scaling ratio before the preliminary correction module 301 performs preliminary correction on the target image according to the predetermined preliminary correction gain table to obtain a preliminary vignetting correction image, and to trigger the operation of the preliminary correction module 301 to perform preliminary correction on the target image according to the predetermined preliminary correction gain table to obtain a preliminary vignetting correction image.
[0236] Furthermore, the preliminary correction module 301 performs preliminary correction on the target image according to a pre-determined preliminary correction gain table to obtain a preliminary vignetting correction image. Specifically, this process may include:
[0237] The predetermined preliminary correction gain table is scaled according to a preset scaling ratio to obtain a scaled preliminary correction gain table. The scaled target image is then preliminarily corrected based on the scaled preliminary correction gain table to obtain a scaled preliminary vignetting correction image.
[0238] As can be seen, this optional embodiment can scale the target image by a preset scaling ratio and perform a series of processes based on the scaled target image to correct the vignetting of the target image, thus balancing accuracy and speed when correcting the vignetting of the target image.
[0239] Example 4
[0240] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of another adaptive vignetting correction device disclosed in an embodiment of the present invention. Figure 5 As shown, the adaptive vignetting correction device may include:
[0241] Memory 401 storing executable program code;
[0242] Processor 402 coupled to memory 401;
[0243] The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the adaptive vignetting correction method described in Embodiment 1 or Embodiment 2 of the present invention.
[0244] Example 5
[0245] This invention discloses a computer storage medium storing computer instructions, which, when invoked, are used to execute the steps in the adaptive vignetting correction method described in Embodiment 1 or Embodiment 2 of this invention.
[0246] Example 6
[0247] This invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform the steps of the adaptive vignetting correction method described in Embodiment 1 or Embodiment 2.
[0248] The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0249] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0250] Finally, it should be noted that the adaptive vignetting correction method and apparatus disclosed in the embodiments of the present invention are merely preferred embodiments of the present invention and are only used to illustrate the technical solutions of the present invention, not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for adaptive vignetting correction, characterized in that, The method includes: The target image is preliminarily corrected according to the preliminarily determined preliminary correction gain table to obtain a preliminary vignetting correction image; the preliminary correction gain table includes the gain value obtained after calibrating the pixel value of each channel of each pixel in all pixels of the calibration image according to the first preset light source; Multiple candidate correction gain tables for the target image are determined, and a secondary correction gain table for the target image is selected from all the candidate correction gain tables based on the initial vignetting correction image. Based on the preliminary correction gain table and the secondary correction gain table, determine the target vignetting correction image corresponding to the target image; The step of determining the multiple candidate correction gain tables for the target image includes: Multiple first-channel correction gain tables are obtained; each first-channel correction gain table has a corresponding calibration light source; each first-channel correction gain table includes multiple gain values obtained after calibrating the pixel values of the first channel of each pixel in the calibration image according to the calibration light source corresponding to the first-channel correction gain table; Based on all the first channel correction gain tables, a plurality of candidate correction gain tables for the target image are determined; The step of determining multiple candidate correction gain tables for the target image based on all the first channel correction gain tables includes: A mixing operation is performed on all the first channel correction gain tables according to a first preset ratio to obtain a mixed correction gain table; Based on each first channel correction gain table and the hybrid correction gain table, calculate the initial correction gain table corresponding to the first channel correction gain table; All the initial correction gain tables are mixed according to multiple second preset ratios to obtain multiple candidate correction gain tables for the target image, and each second preset ratio has a unique corresponding candidate correction gain table.
2. The adaptive vignetting correction method according to claim 1, characterized in that, The step of selecting the secondary correction gain table of the target image from all candidate correction gain tables based on the preliminary vignetting correction image includes: Based on the preliminary vignetting correction image, calculate the total standard deviation of each of the candidate correction gain tables; From all the candidate correction gain tables, the candidate correction gain table with the smallest total standard deviation is selected as the secondary correction gain table of the target image; The step of calculating the total standard deviation corresponding to each candidate correction gain table based on the preliminary vignetting correction image includes: Determine the ratio image between the first channel and the second channel of the preliminary vignetting correction image; Calculate the gradient image corresponding to the ratio image based on the ratio image, and determine all target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image; Based on the ratio image and all target connected sets, calculate the total standard deviation corresponding to all candidate correction gain tables.
3. The adaptive vignetting correction method according to claim 2, characterized in that, The step of determining the ratio image between the first channel and the second channel of the preliminary vignetting correction image includes: Obtain the grayscale value of the first channel and the grayscale value of the second channel of each pixel in the preliminary vignetting correction image. The grayscale value of the first channel of each pixel is compared with the grayscale value of the second channel to obtain the ratio processing result of the pixel. Based on the ratio processing results of all the pixels, the ratio image corresponding to the first channel and the second channel of the preliminary vignetting correction image is determined.
4. The adaptive vignetting correction method according to claim 2 or 3, characterized in that, The step of determining multiple target connected sets corresponding to the preliminary vignetting correction image based on the gradient image corresponding to the ratio image includes: The gradient image is subjected to thresholding to obtain a thresholding result; the thresholding result includes a first type of pixel and a second type of pixel, and the gray values of the first type of pixel and the second type of pixel are different. All the pixels in the second type of pixels included in the threshold processing result are grouped to obtain multiple initial connected sets; From all the initial connected sets, select all first alternative connected sets whose number of pixels is greater than or equal to the first preset number of pixels; For any first backup connected set, each pixel in all the pixels included in the first backup connected set is sorted according to the ratio processing result of the pixel based on a predetermined sorting method to obtain all sorted pixels. Smoothing difference processing is then performed on all sorted pixels to obtain the first sequence corresponding to the first backup connected set. When the ratio of any pixel in the first sequence is greater than the preset ratio value, the pixel and other pixels within the preset range of the pixel are deleted to obtain the second backup connected set corresponding to the first backup connected set. For any second backup connected set, each pixel in all the pixels included in the second backup connected set is sorted according to the ratio of the pixel based on a predetermined sorting method to obtain the second sequence corresponding to the second backup connected set; Based on the current maximum value in the second sequence and the value corresponding to the first preset position of the second sequence, determine the target maximum value of the second sequence; based on the current minimum value in the second sequence and the value corresponding to the second preset position of the second sequence, determine the target minimum value of the second sequence; based on the target maximum value and the target minimum value of the second sequence, determine the third backup connected set corresponding to the second backup connected set. Based on all the third backup connected sets and the preset retention conditions, multiple target connected sets corresponding to the preliminary vignetting correction image are determined.
5. The adaptive vignetting correction method according to claim 4, characterized in that, The step of determining the target maximum value of the second sequence based on the value corresponding to the current maximum value in the second sequence and the first preset position of the second sequence includes: If the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, delete the current maximum value in the second sequence, and repeat the operation of deleting the current maximum value in the second sequence when the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is greater than the first preset difference, until the difference between the current maximum value in the second sequence and the value corresponding to the first preset position in the second sequence is less than or equal to the first preset difference. Then, the current maximum value in the second sequence obtained after stopping the repetition of this operation is determined as the target maximum value of the second sequence. And, determining the target minimum value of the second sequence based on the value corresponding to the current minimum value in the second sequence and the second preset position of the second sequence includes: If the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, delete the current minimum value in the second sequence, and repeat the operation of deleting the current minimum value in the second sequence when the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is greater than the second preset difference, until the difference between the current minimum value in the second sequence and the value corresponding to the second preset position in the second sequence is less than or equal to the second preset difference. The current minimum value in the second sequence obtained after stopping the repetition of this operation is determined as the target minimum value of the second sequence.
6. The adaptive vignetting correction method according to claim 1, characterized in that, The step of determining the target vignetting correction image corresponding to the target image based on the preliminary correction gain table and the secondary correction gain table includes: Based on the secondary correction gain table, the gain values in the channels in the preliminary correction gain table that match the channels in the secondary correction gain table are updated to obtain the updated preliminary correction gain table. Based on the updated preliminary correction gain table, the target vignetting correction image corresponding to the target image is determined.
7. The adaptive vignetting correction method according to claim 1, characterized in that, Before performing preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting corrected image, the method further includes: The target image is scaled according to a preset scaling ratio to obtain a scaled target image, and the operation of performing preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image is triggered. And, the step of performing preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image includes: The predetermined preliminary correction gain table is scaled according to the preset scaling ratio to obtain a scaled preliminary correction gain table. The scaled target image is then preliminarily corrected based on the scaled preliminary correction gain table to obtain a scaled preliminary vignetting correction image.
8. An adaptive vignetting correction device, characterized in that, The apparatus is used to perform the adaptive vignetting correction method as described in any one of claims 1-7; and the apparatus comprises: The preliminary correction module is used to perform preliminary correction on the target image according to a predetermined preliminary correction gain table to obtain a preliminary vignetting correction image; the preliminary correction gain table includes the gain value obtained after calibrating the pixel value of each channel of each pixel in all pixels of the calibration image according to a first preset light source; A determination module is used to determine multiple candidate correction gain tables for the target image; The filtering module is used to filter the secondary correction gain table of the target image from all the candidate correction gain tables based on the preliminary vignetting correction image; The secondary correction module is used to determine the target vignetting correction image corresponding to the target image based on the preliminary correction gain table and the secondary correction gain table.
9. A device for adaptive vignetting correction, characterized in that, The device includes: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the adaptive vignetting correction method as described in any one of claims 1-7.
Citation Information
Patent Citations
Signal processing method and device
CN112800981A