Black level correction method and device, computer device, and storage medium
Patent Information
- Application Number
- CN202311062163.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-22
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2043-08-22
AI Technical Summary
[0003]有鉴于此,本发明提供了一种黑电平校正方法、装置、计算机设备及存储介质,以解决黑电平校正不能很好的恢复真实图像,导致图像存在较大偏色的问题
[0003] In view of this, the present invention provides a black level correction method, apparatus, computer equipment and storage medium to solve the problem that black level correction cannot well restore the true image, resulting in a large color cast in the image.
Smart Images

Figure CN117221459B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and more specifically to black level correction methods, apparatus, computer equipment, and storage media. Background Technology
[0002] CMOS (Complementary Metal Oxide Semiconductor) sensors are widely used in digital cameras, mobile phones, medical instruments, and other devices. They use a single sensor combined with a color filter array (CFA) to capture the color components of the red, green, and blue channels, resulting in an incomplete color image, called a CFA image or mosaic image. Only one channel is sampled at each pixel location. During imaging, each pixel location is controlled by a photodiode to convert an electrical signal into a digital signal. Each photodiode has a certain voltage when operating, causing the sensor to generate an electrical signal even in the absence of external light, thus forming a dark image. When there is light, the electrical signal corresponding to the dark image is superimposed on the image signal, causing color cast. Therefore, black level correction is needed during image processing to remove the superimposed dark image electrical signal. Common black level correction methods, such as the median method and the mean method, are not very effective for image processing, often resulting in overcorrection or undercorrection, failing to accurately restore the true image and leading to significant color cast. Summary of the Invention
[0003] In view of this, the present invention provides a black level correction method, apparatus, computer equipment and storage medium to solve the problem that black level correction cannot well restore the true image, resulting in a large color cast in the image.
[0004] In a first aspect, the present invention provides a black level correction method, comprising:
[0005] Obtain the target dark image;
[0006] Based on the color type of the pixel, data of the color channels of the target dark image is extracted to obtain data of multiple color channels;
[0007] The data from multiple color channels are filtered separately to obtain the first correction data that corresponds one-to-one with each of the multiple color channels;
[0008] The data from multiple color channels are averaged separately to obtain second correction data that corresponds one-to-one with each of the multiple color channels;
[0009] For each color channel, the minimum value between the first correction data and the second correction data corresponding to that color channel is determined as the correction data corresponding to that color channel;
[0010] The image to be corrected is obtained by correcting the image based on the correction data corresponding to multiple color channels.
[0011] In this way, the impact of noise interference can be reduced, image color cast can be decreased, and the true image can be restored well, thus improving the color fidelity of the output target image.
[0012] As an optional implementation, acquiring the target dark image includes:
[0013] Obtain the dark image at a preset number of frames;
[0014] The pixel values of pixels at the same position in the dark image of a preset number of frames are averaged, and the image formed by the pixels corresponding to each pixel value obtained after averaging is used as the target dark image.
[0015] In this way, the randomness of black level distribution can be reduced and the universality of the correction matrix can be improved.
[0016] As an optional implementation, color channel data is extracted from the target dark image based on the color type of each pixel, resulting in data for multiple color channels, including:
[0017] Pixels in the target dark image are classified based on their color type to obtain channel pixels corresponding to multiple color channels.
[0018] The pixel values of the channel pixels corresponding to multiple color channels are arranged into a matrix to obtain the data of multiple color channels. The position of each channel pixel in the multiple matrices is the same as the position of the channel pixel in the target dark image.
[0019] As an optional implementation, the image to be corrected is corrected based on correction data corresponding to multiple color channels to obtain the target image, including:
[0020] According to color type, the pixels in the image to be corrected are classified to obtain the data to be corrected corresponding to multiple color channels;
[0021] The data to be corrected corresponding to multiple color channels is corrected based on the correction data corresponding to multiple color channels to obtain the pixel value of the target pixel, where the target pixel is any pixel in multiple color channels;
[0022] The target image is obtained by arranging the pixel values of all target pixels corresponding to multiple color channels according to the position of each target pixel in the image to be corrected.
[0023] In this way, the image to be corrected can be corrected using a correction matrix, thereby improving the color fidelity of the output target image.
[0024] As an optional implementation, the data to be corrected corresponding to multiple color channels is corrected based on the correction data corresponding to multiple color channels to obtain the pixel value of the target pixel, including:
[0025] The correction data corresponding to the target color channel is determined as the target correction data of the data to be corrected corresponding to the target color channel, wherein the target color channel is the color channel with the same color type as the target dark image and the image to be corrected.
[0026] The target correction data is used to correct the data to be corrected in order to obtain the pixel values of the target pixels in multiple color channels.
[0027] As an optional implementation, the target correction data is used to correct the corresponding data to be corrected to obtain the pixel values of the target pixels in multiple color channels, including:
[0028] Subtract the target correction data from the data to be corrected to obtain the target value of the target pixel corresponding to the data to be corrected;
[0029] When the target value is greater than the preset value, the target value is determined as the pixel value of the target pixel.
[0030] As an optional implementation, after subtracting the target correction data corresponding to the data to be corrected from the target correction data to obtain the target value of the target pixel corresponding to the data to be corrected, the method further includes:
[0031] When the target value is less than or equal to the preset value, the preset value is determined as the pixel value of the target pixel.
[0032] Secondly, the present invention provides a black level correction device, comprising:
[0033] The target dark image acquisition module is used to acquire the target dark image;
[0034] The data extraction module is used to extract color channel data from the target dark image based on the color type of the pixel, and obtain data for multiple color channels;
[0035] The first correction data determination module is used to filter the data of multiple color channels respectively to obtain the first correction data corresponding to each of the multiple color channels.
[0036] The second correction data determination module is used to perform mean processing on the data of multiple color channels to obtain second correction data that corresponds one-to-one with the multiple color channels.
[0037] The calibration data determination module is used to determine the minimum value between the first calibration data and the second calibration data corresponding to each color channel as the calibration data corresponding to that color channel.
[0038] The image correction module is used to correct the image to be corrected based on the correction data corresponding to multiple color channels, so as to obtain the target image.
[0039] Thirdly, the present invention provides a computer device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the black level correction method of the first aspect or any corresponding embodiment described above.
[0040] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the black level correction method of the first aspect or any corresponding embodiment described above. Attached Figure Description
[0041] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0042] Figure 1 This is a flowchart illustrating the black level correction method according to an embodiment of the present invention;
[0043] Figure 2 A mosaic image schematic diagram of the black level correction method according to an embodiment of the present invention;
[0044] Figure 3 This is a flowchart illustrating another black level correction method according to an embodiment of the present invention;
[0045] Figure 4 This is a flowchart illustrating another black level correction method according to an embodiment of the present invention;
[0046] Figure 5 This is a flowchart illustrating another black level correction method according to an embodiment of the present invention;
[0047] Figure 6This is a structural block diagram of a black level correction device according to an embodiment of the present invention;
[0048] Figure 7 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, 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.
[0050] In related technologies, black level correction typically employs a method of subtracting a fixed value. Common methods for subtracting a fixed value include the mean method and the median method, which divide the dark image into four channels. Specifically, the dark image is divided into four channels according to the color type of the sampled pixels. Red and blue color types each correspond to one channel (red channel R and blue channel B), while the green color type, corresponding to the green channel G, is split into two channels: Gr and Gb. The average or median of the four channels is calculated and used as the correction value for the corresponding channel to correct subsequent images. For the two green color type channels, a further linear stretching operation is performed to normalize them to between 0 and 255 to prevent unsaturation of the green channel G after correction.
[0051] However, the above method does not take into account the impact of noise distribution on dark image acquisition, and using a fixed value as the correction value for all pixels in one channel will result in some pixel locations being over-corrected or under-corrected, leading to color cast in the final corrected image, especially in areas close to overexposure, where a purplish tint will appear, affecting the color fidelity of the image.
[0052] Based on this, the present invention provides a black level correction method that, while considering the influence of noise distribution, determines the corresponding correction value for each pixel in each channel to avoid over-correction or under-correction at certain pixel locations, thereby ensuring the color authenticity of the final corrected image.
[0053] Specifically, the process involves: acquiring the target dark image; extracting color channel data from the target dark image based on the color type of each pixel to obtain data for multiple color channels; filtering the data for each color channel to obtain first correction data corresponding to each color channel; averaging the data for each color channel to obtain second correction data corresponding to each color channel; for each color channel, determining the minimum value between the first and second correction data as the correction data for that color channel; and correcting the image to be corrected based on the correction data for each color channel to obtain the target image.
[0054] In this embodiment of the invention, the black level correction method can be applied to all devices or equipment that include image sensors, such as CCD sensors and CMOS sensors, for example, cameras in mobile terminals such as mobile phones, tablets, and computers, and vehicle cameras.
[0055] According to an embodiment of the present invention, a black level correction method embodiment is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0056] This embodiment provides a black level correction method, which can be used in cameras in mobile terminals such as mobile phones, tablets, and computers, as well as in-vehicle cameras. Figure 1 This is a flowchart of a black level correction method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps:
[0057] Step S101: Obtain the target dark image.
[0058] In this embodiment of the invention, the target dark image is obtained based on the dark image and is used to determine the target correction data. Since a color filter array (CFA) is used to capture the color components of the red, green, and blue channels respectively, only one channel's color component is sampled at each pixel. (Reference) Figure 2 R corresponds to the red channel, G corresponds to the green channel, and B corresponds to the blue channel. At the pixel position (i,j), only the G channel, which is the green channel, is used, and only the green channel has a pixel value.
[0059] Step S102: Extract color channel data from the target dark image based on the color type of the pixel to obtain data for multiple color channels.
[0060] In this embodiment of the invention, considering that the pixel values of pixels in different channels belong to different color components, the pixels in the target dark image are classified according to the corresponding color type, that is, the sampling channel type, and their corresponding pixel values are extracted to obtain data for multiple color channels. Specifically, data corresponding to the red channel, green channel and blue channel are obtained respectively, and the correction data for different channels are calculated respectively.
[0061] Step S103: Filter the data of multiple color channels respectively to obtain the first correction data corresponding to each of the multiple color channels.
[0062] In this embodiment of the invention, considering that noise can interfere with the pixel values of pixels in an image, the data of multiple color channels are filtered separately to remove the influence of noise on the data of each color channel, that is, the pixel values of pixels in the target dark image, to obtain the first correction data for each color channel. The first correction data is the pixel value of the pixel in the target image after removing noise interference, which can relatively realistically represent the pixel value of each pixel in the dark image without noise interference.
[0063] As an optional implementation, Gaussian filtering can be used to filter the data of multiple color channels separately. Gaussian filtering is a linear smoothing filter, suitable for eliminating Gaussian noise. It can be used as a low-pass filter and is very effective in suppressing noise that follows a normal distribution. Gaussian filtering can suppress noise and smooth the image. Using Gaussian filtering can remove noise interference from the data of each color channel and smooth the values of the data in each color channel.
[0064] As an optional implementation, the following Gaussian filtering operator can be used to perform Gaussian filtering on the data of each color channel:
[0065]
[0066] Step S104: The data of multiple color channels are averaged to obtain second correction data corresponding to each of the multiple color channels.
[0067] In this embodiment of the invention, the data of multiple color channels are subjected to mean processing, and the average value of each color channel is calculated by adding the data of each color channel. The average value is then used as the second correction data for the corresponding color channel.
[0068] As an alternative implementation, the second correction data can be determined using a global mean. Accordingly, within the same color channel, the second correction data for each data point is identical, equal to the average value of that color channel.
[0069] Step S105: For each color channel, the minimum value between the first correction data and the second correction data corresponding to that color channel is determined as the correction data corresponding to that color channel.
[0070] In this embodiment of the invention, to reduce the impact of noise distribution on the calculation of correction values and to avoid overcorrection at some pixel locations, for each color channel, the minimum value between the first correction data and the second correction data corresponding to that color channel is used as the correction value for each pixel value in that color channel. The correction values for each pixel value are then arranged according to the position of the corresponding pixel in the target dark image to obtain the correction data for each color channel. When the first correction data is less than the second correction data, it indicates that correcting the pixel corresponding to that pixel value using the second correction data obtained by averaging would result in overcorrection. In this case, the first correction data is used as the correction value for that pixel value.
[0071] Step S106: Correct the image to be corrected based on the correction data corresponding to multiple color channels to obtain the target image.
[0072] In this embodiment of the invention, the pixels of the corresponding color channel in the image to be corrected are corrected using target correction data to obtain the corrected target image.
[0073] The black level correction method provided in this embodiment obtains first correction data by filtering the data of multiple color channels respectively, and obtains second correction data by averaging the data of multiple color channels respectively. The smaller value between the first correction data and the second correction data is used as the correction value to construct the target correction data. This can reduce the influence of noise interference, reduce image color cast, and thus better restore the real image and improve the color authenticity of the output target image.
[0074] This embodiment provides a black level correction method, which can be used in cameras in mobile terminals such as mobile phones, tablets, and computers, as well as in-vehicle cameras. Figure 3 This is a flowchart of another black level correction method according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps:
[0075] Step S301: Obtain the target dark image.
[0076] Specifically, step S301 above includes:
[0077] Step S3011: Obtain a dark image at a preset number of frames.
[0078] In this embodiment of the invention, to avoid the randomness of the black level distribution in a single frame of dark image, a preset number of dark images are obtained.
[0079] As an optional implementation, the preset number of frames can be any number greater than 3.
[0080] Step S3012: The pixel values of pixels at the same position in the dark image of a preset number of frames are averaged, and the image formed by the pixels corresponding to each pixel value obtained after averaging is used as the target dark image.
[0081] In this embodiment of the invention, since the dark images are acquired from the same image sensor for a preset number of frames, the arrangement of pixels in each frame of the dark image is completely consistent with the channel type arrangement. Therefore, pixels at the same position in different dark images correspond one-to-one. During averaging, only the pixel values of pixels at the same position in each frame of the dark image need to be averaged to obtain the pixel value of the pixel at that position in the target dark image, thereby determining the target dark image.
[0082] Therefore, by averaging the pixel values of pixels in multiple dark images to determine the target dark image, the randomness of the black level distribution when using a single dark image as the target dark image is avoided, which would lead to the target correction data not having universality. This improves the universality and reliability of the target correction data.
[0083] Step S302: Extract color channel data from the target dark image based on the color type of each pixel, obtaining data for multiple color channels. For details, please refer to [link to relevant documentation]. Figure 1 Step S102 of the illustrated embodiment will not be described again here.
[0084] Step S303 involves filtering the data from multiple color channels to obtain first correction data corresponding to each color channel. For details, please refer to [link to relevant documentation]. Figure 1 Step S103 of the illustrated embodiment will not be described again here.
[0085] Step S304: Average the data from multiple color channels to obtain second correction data corresponding to each color channel. For details, please refer to [link to relevant documentation]. Figure 1 Step S104 of the illustrated embodiment will not be described again here.
[0086] Step S305: For each color channel, the minimum value between the first correction data and the second correction data corresponding to that color channel is determined as the correction data corresponding to that color channel. See details below. Figure 1 Step S105 of the illustrated embodiment will not be described again here.
[0087] Step S306: Based on the correction data corresponding to multiple color channels, the image to be corrected is corrected to obtain the target image. For details, please refer to [link to relevant documentation]. Figure 1Step S106 of the illustrated embodiment will not be described again here.
[0088] The black level correction method provided in this embodiment determines the target dark image by averaging the pixel values of pixels in multiple frames of dark images. This avoids the randomness of black level distribution when using a single frame of dark image as the target dark image, which would lead to the final target correction data not having universality. This improves the universality and reliability of the target correction data and enhances the reliability of the corrected target image.
[0089] This embodiment provides a black level correction method, which can be used in cameras in mobile terminals such as mobile phones, tablets, and computers, as well as in-vehicle cameras. Figure 4 This is a flowchart of another black level correction method according to an embodiment of the present invention, such as... Figure 4 As shown, the process includes the following steps:
[0090] Step S401: Obtain the target dark image. For details, please refer to [link to relevant documentation]. Figure 1 Step S106 of the illustrated embodiment will not be described again here.
[0091] Step S402: Extract color channel data from the target dark image based on the color type of the pixel to obtain data for multiple color channels.
[0092] Specifically, step S402 above includes:
[0093] Step S4021: Classify the pixels in the target dark image based on the color type of the pixels to obtain the channel pixels corresponding to multiple color channels.
[0094] In this embodiment of the invention, the pixels are classified according to the color type of the pixels sampled in the target dark image, namely the red channel R, the green channel G, and the blue channel B. The classified pixels are used as channel pixels of the corresponding color channels. Then, based on the pixel values of these channel pixels, a channel matrix is constructed, which is the data of the corresponding color channels.
[0095] Step S4012: Arrange the pixel values of the channel pixels corresponding to the multiple color channels into a matrix to obtain the data of the multiple color channels.
[0096] In this embodiment of the invention, the position of each channel pixel in the multiple matrices is the same as the position of that channel pixel in the target dark image. Considering that subsequent filtering processing of the data for each color channel is required, the arrangement order of the data for each color channel, that is, the pixel values of the pixels, needs to be consistent with the arrangement order of the corresponding pixels in the target dark image. This ensures that filtering is performed according to the correct noise distribution in the target dark image. Since Gaussian filtering actually uses the weighted average of the neighborhood of a pixel to replace the pixel value, the pixel value of each pixel obtained by filtering incorporates information from surrounding pixels. If the color channel data is not arranged according to the arrangement order of the corresponding pixels in the target dark image, the filtered data, that is, the first correction data, will incorporate information from incorrect pixels, causing the first correction data to be distorted and unable to represent the actual black level in the target dark image. Based on this, the pixel values of the channel pixels corresponding to multiple color channels are arranged into matrices to obtain the data for multiple color channels.
[0097] For example, with Figure 2 Taking the pixel arrangement shown as an example, to construct the matrix of the green channel G, as shown... Figure 2 As shown, in the first row, i.e., the (i-4)th row of pixels, the pixel at position (i-4, j-4) is the first pixel sampled in the green channel G. Therefore, the pixel value of this pixel is used as the first element of the matrix corresponding to the green channel G. Similarly, the pixel at position (i-4, j-2) in the first row is the second pixel sampled in the green channel G. Therefore, the pixel value of this pixel is used as the second element of the first row of the matrix corresponding to the green channel G. This process continues, resulting in the first row of the channel matrix corresponding to the green channel G containing the pixel at positions (i-4, j-4), (i-4, j-2), (i-4, j), (i-4, j+2), and (i-4, j+4) in the target dark image. By sequentially obtaining the pixel values of the pixel corresponding to the matrix elements in each row and column of the matrix in the above manner, a matrix is constructed, yielding the color channel data.
[0098] Step S403 involves filtering the data from multiple color channels to obtain first correction data corresponding to each color channel. For details, please refer to [link to relevant documentation]. Figure 1 Step S103 of the illustrated embodiment will not be described again here.
[0099] Step S404: Average the data from multiple color channels to obtain second correction data corresponding to each color channel. For details, please refer to [link to relevant documentation]. Figure 1 Step S104 of the illustrated embodiment will not be described again here.
[0100] Step S405: For each color channel, the minimum value between the first correction data and the second correction data corresponding to that color channel is determined as the correction data corresponding to that color channel. See details below. Figure 1 Step S105 of the illustrated embodiment will not be described again here.
[0101] Step S406: Based on the correction data corresponding to multiple color channels, the image to be corrected is corrected to obtain the target image. For details, please refer to [link to relevant documentation]. Figure 1 Step S106 of the illustrated embodiment will not be described again here.
[0102] This embodiment provides a black level correction method, which can be used in cameras in mobile terminals such as mobile phones, tablets, and computers, as well as in-vehicle cameras. Figure 5 This is a flowchart of another black level correction method according to an embodiment of the present invention, such as... Figure 5 As shown, the process includes the following steps:
[0103] Step S501: Obtain the target dark image. For details, please refer to [link to relevant documentation]. Figure 1 Step S101 of the illustrated embodiment will not be described again here.
[0104] Step S502: Extract color channel data from the target dark image based on the color type of each pixel, obtaining data for multiple color channels. For details, please refer to [link to relevant documentation]. Figure 1 Step S102 of the illustrated embodiment will not be described again here.
[0105] Step S503 involves filtering the data from multiple color channels to obtain first correction data corresponding to each color channel. For details, please refer to [link to relevant documentation]. Figure 1 Step S103 of the illustrated embodiment will not be described again here.
[0106] Step S504: Average the data from multiple color channels to obtain second correction data corresponding to each color channel. For details, please refer to [link to relevant documentation]. Figure 1 Step S104 of the illustrated embodiment will not be described again here.
[0107] Step S505: For each color channel, the minimum value between the first correction data and the second correction data corresponding to that color channel is determined as the correction data corresponding to that color channel. See details below. Figure 1 Step S105 of the illustrated embodiment will not be described again here.
[0108] Step S506: Correct the image to be corrected based on the correction data corresponding to multiple color channels to obtain the target image.
[0109] Specifically, step S506 above includes:
[0110] Step S5061: According to color type, classify the pixels in the image to be corrected to obtain the data to be corrected corresponding to multiple color channels.
[0111] In this embodiment of the invention, pixels are categorized according to their color channels (red channel R, green channel G, and blue channel B) in the image to be corrected. These categorized pixels are then used as the pixels to be corrected for their respective color channels. A matrix is constructed based on the pixel values of these pixels to be corrected to obtain the data to be corrected. For details, please refer to... Figure 4 In step S402 of the illustrated embodiment, the data to be corrected for each color channel is constructed using the same method as in step S402.
[0112] Step S5062: Correct the data to be corrected for multiple color channels based on the correction data corresponding to multiple color channels to obtain the pixel value of the target pixel.
[0113] In this embodiment of the invention, the target pixel is any pixel in multiple color channels, that is, each pixel in each color channel is corrected to obtain the pixel value of each pixel.
[0114] As an optional implementation, step S5062 above includes:
[0115] Step b1: Determine the correction data corresponding to the target color channel as the target correction data of the data to be corrected corresponding to the target color channel, wherein the target color channel is the color channel with the same color type as the target dark image and the image to be corrected.
[0116] Step b2: Correct the data to be corrected using the target correction data to obtain the pixel values of the target pixels in multiple color channels.
[0117] As an optional implementation, step b2 above includes:
[0118] Step b21: Subtract the target correction data from the data to be corrected to obtain the target value of the target pixel corresponding to the data to be corrected.
[0119] In this embodiment of the invention, the target correction data represents the distribution of black level values at each pixel location in the dark image. Therefore, it needs to be subtracted from the image to be corrected to remove the influence of black level on the color of the image to be corrected. Since the target correction data and the data to be corrected are matrices constructed from the corresponding images in the same way, the data at the same position, that is, the corresponding matrix elements, correspond to the pixels at the same position in the image. In other words, the matrix elements in the target correction data and the data to be corrected are in one-to-one correspondence. Therefore, during correction, subtracting the matrix element in the data to be corrected from the corresponding matrix element in the target correction data yields the target value for each target pixel in the target image.
[0120] Step b22: When the target value is greater than the preset value, the target value is determined as the pixel value of the target pixel.
[0121] In this embodiment of the invention, since the pixel value of a pixel in an image should be a value between 0 and 255, and the value of a matrix element in the target matrix should be greater than 0, the preset value is set to 0. After obtaining the target value of the target pixel in step b21, it is determined whether the target value is greater than 0. When the target value is greater than 0, the target value is determined as the pixel value of the target pixel.
[0122] Step b23: When the target value is less than or equal to the preset value, the preset value is determined as the pixel value of the target pixel.
[0123] In this embodiment of the invention, when the target value is less than the preset value 0, it indicates that the corrected value does not meet the range requirement of the pixel value of the pixel point. At this time, the preset value 0 is determined as the pixel value of the target pixel point.
[0124] Step S5063: Arrange the pixel values of all target pixels corresponding to multiple color channels according to the position of each target pixel in the image to be corrected to obtain the target image.
[0125] In this embodiment of the invention, the target pixel values are still arranged according to the data arrangement in the data to be corrected, and the target pixel values are still independent of each other and are not merged into the pixel value matrix corresponding to an image. Therefore, after obtaining the pixel values of the target pixels, these pixel values are arranged according to the position of the corresponding pixel in the image to be corrected, and then merged to obtain the target image.
[0126] The black level correction method provided in this embodiment corrects the data to be corrected for each color channel by using target correction data, thereby correcting each pixel in the image to be corrected and improving the color fidelity of the output target image.
[0127] This embodiment also provides a black level correction device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the terms "module" and "unit" can refer to a combination of software and / or hardware that performs a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.
[0128] This embodiment provides a black level correction device, such as Figure 6 As shown, it includes:
[0129] The target dark image acquisition module 601 is used to acquire the target dark image;
[0130] Data extraction module 602 is used to extract color channel data from a target dark image based on the color type of a pixel, and obtain data for multiple color channels;
[0131] The first correction data determination module 603 is used to filter the data of multiple color channels respectively to obtain first correction data corresponding to each of the multiple color channels.
[0132] The second correction data determination module 604 is used to perform averaging on the data of multiple color channels to obtain second correction data that corresponds one-to-one with the multiple color channels.
[0133] The calibration data determination module 605 is used to determine the minimum value between the first calibration data and the second calibration data corresponding to each color channel as the calibration data corresponding to that color channel for each color channel.
[0134] The image correction module 606 is used to correct the image to be corrected based on the correction data corresponding to multiple color channels to obtain the target image.
[0135] As an optional implementation, the target dark image acquisition module 601 includes:
[0136] Dark image acquisition unit, used to acquire dark images for a preset number of frames;
[0137] The pixel value determination unit is used to perform mean processing on the pixel values of pixels located at the same position in the dark image of a preset number of frames, and to use the image formed by the pixels corresponding to each pixel value obtained after mean processing as the target dark image.
[0138] As an optional implementation, the data extraction module 602 includes:
[0139] The channel pixel determination unit is used to classify pixels in the target dark image based on the color type of the pixels, and obtain the channel pixels corresponding to multiple color channels respectively;
[0140] The pixel value arrangement unit is used to arrange the pixel values of the channel pixels corresponding to multiple color channels into a matrix to obtain data for multiple color channels. The position of each channel pixel in the multiple matrices is the same as the position of the channel pixel in the target dark image.
[0141] As an optional implementation, the image correction module 606 includes:
[0142] The data to be corrected determination unit is used to classify the pixels in the image to be corrected according to the color type, and obtain data to be corrected for multiple color channels.
[0143] The pixel value determination unit is used to correct the data to be corrected corresponding to multiple color channels based on the correction data corresponding to multiple color channels, so as to obtain the pixel value of the target pixel, wherein the target pixel is any pixel in the multiple color channels;
[0144] The target image determination unit is used to arrange the pixel values of all target pixels corresponding to multiple color channels according to the position of each target pixel in the image to be corrected, so as to obtain the target image.
[0145] As an optional implementation, the pixel value determination unit includes:
[0146] The target correction data determination subunit is used to determine the correction data corresponding to the target color channel as the target correction data of the data to be corrected corresponding to the target color channel, wherein the target color channel is a color channel with the same color type as the target dark image and the image to be corrected.
[0147] The pixel value determination subunit is used to correct the data to be corrected using the target correction data to obtain the pixel values of the target pixels in multiple color channels.
[0148] As an optional implementation, the pixel value determination subunit includes:
[0149] The target value determination submodule is used to subtract the target correction data of the data to be corrected from the target correction data of the data to be corrected to obtain the target value of the target pixel corresponding to the data to be corrected.
[0150] The pixel value determination submodule is used to determine the target value as the pixel value of the target pixel when the target value is greater than the preset value.
[0151] As an optional implementation, the pixel value determination submodule is also used for:
[0152] When the target value is less than or equal to the preset value, the preset value is determined as the pixel value of the target pixel.
[0153] In this embodiment, the black level correction device is presented in the form of a functional unit. Here, a unit refers to an ASIC circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0154] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0155] This invention also provides a computer device having the above-described features. Figure 6 The black level correction device shown.
[0156] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 7 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 7 Take a processor 10 as an example.
[0157] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0158] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0159] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device as shown by a landing page for an app. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, which can be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0160] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0161] The computer device also includes an input device 30 and an output device 40. The processor 10, memory 20, input device 30, and output device 40 can be connected via a bus or other means. Figure 7 Taking the example of a connection between China and Israel via a bus.
[0162] Input device 30 can receive input numerical or character information, and generate key signal inputs related to user settings and function control of the computer device, such as a touchscreen, keypad, mouse, trackpad, touchpad, joystick, one or more mouse buttons, trackball, joystick, etc. Output device 40 may include display devices, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibration motors). The aforementioned display devices include, but are not limited to, liquid crystal displays, light-emitting diodes, displays, and plasma displays. In some alternative embodiments, the display device may be a touchscreen.
[0163] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0164] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A black level correction method, characterized in that, The method includes: Obtain the target dark image; Based on the color type of the pixel, data of the target dark image is extracted from the color channels to obtain data of multiple color channels; The data of the multiple color channels are filtered respectively to obtain first correction data corresponding to each of the multiple color channels, wherein the first correction data represents the pixel value of each pixel after filtering. The data of the multiple color channels are respectively subjected to mean processing to obtain second correction data that corresponds one-to-one with the multiple color channels; For each color channel, the minimum value between the first correction data and the second correction data corresponding to that color channel is determined as the correction data corresponding to that color channel; The image to be corrected is obtained by correcting the image based on the correction data corresponding to the multiple color channels.
2. The method according to claim 1, characterized in that, The acquisition of the target dark image includes: Obtain the dark image at a preset number of frames; The pixel values of pixels at the same position in the dark image of the preset number of frames are averaged, and the image formed by the pixels corresponding to each pixel value obtained after averaging is used as the target dark image.
3. The method according to claim 1, characterized in that, The target dark image is subjected to color channel data extraction based on the color type of each pixel, resulting in data for multiple color channels, including: The pixels in the target dark image are classified based on their color type to obtain channel pixels corresponding to multiple color channels. The pixel values of the channel pixels corresponding to the multiple color channels are arranged into a matrix to obtain the data of the multiple color channels, wherein the position of each channel pixel in the multiple matrices is the same as the position of the channel pixel in the target dark image.
4. The method according to claim 1, characterized in that, The step of correcting the image to be corrected based on the correction data corresponding to multiple color channels to obtain the target image includes: According to the color type, the pixels in the image to be corrected are classified to obtain the data to be corrected corresponding to multiple color channels; The data to be corrected corresponding to the multiple color channels is corrected based on the correction data corresponding to the multiple color channels to obtain the pixel value of the target pixel, wherein the target pixel is any pixel in the multiple color channels; The pixel values of all target pixels corresponding to the multiple color channels are arranged according to the position of each target pixel in the image to be corrected to obtain the target image.
5. The method according to claim 4, characterized in that, The step of correcting the data to be corrected corresponding to the multiple color channels based on the correction data corresponding to the multiple color channels to obtain the pixel value of the target pixel includes: The correction data corresponding to the target color channel is determined as the target correction data of the data to be corrected corresponding to the target color channel, wherein the target color channel is a color channel with the same color type as the target dark image and the image to be corrected; The data to be corrected is corrected using the target correction data to obtain the pixel values of the target pixels in multiple color channels.
6. The method according to claim 5, characterized in that, The step of correcting the data to be corrected using the target correction data to obtain the pixel values of target pixels in multiple color channels includes: Subtract the target correction data from the data to be corrected to obtain the target value of the target pixel corresponding to the data to be corrected; When the target value is greater than the preset value, the target value is determined as the pixel value of the target pixel.
7. The method according to claim 6, characterized in that, After subtracting the target correction data corresponding to the data to be corrected from the target correction data to obtain the target value of the target pixel in the data to be corrected, the method further includes: When the target value is less than or equal to the preset value, the preset value is determined as the pixel value of the target pixel.
8. A black level correction device, characterized in that, The device includes: The target dark image acquisition module is used to acquire the target dark image; The data extraction module is used to extract color channel data from the target dark image based on the color type of the pixels, and obtain data for multiple color channels; The first correction data determination module is used to filter the data of the multiple color channels respectively to obtain first correction data corresponding to the multiple color channels one by one, wherein the first correction data represents the pixel value of each pixel after filtering. The second correction data determination module is used to perform mean processing on the data of the multiple color channels respectively to obtain second correction data that corresponds one-to-one with the multiple color channels. The calibration data determination module is used to determine the minimum value between the first calibration data and the second calibration data corresponding to each color channel as the calibration data corresponding to that color channel. The image to be corrected module is used to correct the image to be corrected based on the correction data corresponding to the multiple color channels to obtain the target image.
9. A computer device, characterized in that, include: A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the black level correction method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the black level correction method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Algorithm used for black level correction of CMOS (Complementary Metal Oxide Semiconductor) image sensor and system thereof
CN104333717A
Local black level calibration method for CMOS image sensor
CN109348147A