Image processing method, device, storage medium and electronic device
By inverting the image and using transmittance weight and atmospheric light value processing, the problem of low image quality under non-uniform illumination is solved, the illumination balance and noise removal of the image are achieved, and the image quality is improved.
Patent Information
- Application Number
- CN202111586255.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-21
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2041-12-21
AI Technical Summary
The image quality captured under non-uniform lighting conditions is too low, resulting in errors in the judgment of the intelligent system or issues incorrect commands.
The image to be processed is inverted, the global atmospheric light value and dark channel map are determined, and the transmission weight and image scattering model are processed, the illumination balance of the image is adjusted and noise is removed.
Improve the quality of the image, realize lighting balance and noise removal, and ensure accurate judgment of the intelligent system.
Smart Images

Figure CN114387179B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular, to an image processing method, device, storage medium, and electronic device. Background Art
[0002] High-quality images are a prerequisite for the reliable operation of intelligent systems such as autonomous driving, intelligent transportation, and smart cities. However, in many real-world scenarios, the quality of the captured images is often too low due to the non-uniform lighting conditions of the shooting scene. This makes the image unable to accurately reflect the scene information, which in turn causes the intelligent system to make incorrect judgments or issue erroneous instructions. For example, when capturing traffic violations on the road, due to the distance requirements for image acquisition, fill light is usually required during shooting. The image obtained after fill light contains a lot of noise and has the problem of lighting imbalance, that is, the brightness of the main driver and co-driver seats is high, and the brightness of the rear seats is low. For another example, when a vehicle is driving in low light with the headlights on, the image obtained also has the problem of lighting imbalance, that is, the brightness of the vehicle in front is high, and the brightness of other areas is low. Summary of the Invention
[0003] The present disclosure aims to provide an image processing method, apparatus, storage medium and electronic device, which are used to solve the problem of low image quality caused by non-uniform lighting conditions in the prior art.
[0004] To achieve the above objective, according to a first aspect of an embodiment of the present disclosure, a method for processing an image is provided, the method comprising:
[0005] Invert the image to be processed to obtain an inverted image;
[0006] Determining a global atmospheric light value and a dark channel image corresponding to the negated image according to a minimum value of each pixel in the negated image in multiple color channels;
[0007] If the average pixel intensity of the image to be processed belongs to the first intensity range, determining the transmittance weight corresponding to each pixel in the inverted image according to the pixel intensity corresponding to the multiple color channels;
[0008] Determining the transmittance corresponding to each pixel in the negated image according to the dark channel image and the transmittance weight corresponding to each pixel in the negated image;
[0009] The negated image is processed according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image.
[0010] According to a second aspect of an embodiment of the present disclosure, there is provided an image processing apparatus, the apparatus comprising:
[0011] A negation module, used to negate the image to be processed to obtain a negated image;
[0012] a preprocessing module, configured to determine a global atmospheric light value and a dark channel image corresponding to the negated image according to a minimum value of each pixel in the negated image in a plurality of color channels;
[0013] a weight determination module, configured to determine a transmittance weight corresponding to each pixel in the inverted image based on the pixel intensities corresponding to the pixel in multiple color channels if the average pixel intensity of the image to be processed falls within a first intensity range;
[0014] a transmittance determination module, configured to determine the transmittance corresponding to each pixel in the negated image based on the dark channel image and the transmittance weight corresponding to each pixel in the negated image;
[0015] A processing module is used to process the negated image according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image.
[0016] According to a third aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the steps of the method described in the first aspect of the embodiment of the present disclosure are implemented.
[0017] According to a fourth aspect of the embodiments of the present disclosure, there is provided an electronic device, including:
[0018] a memory having a computer program stored thereon;
[0019] A processor is used to execute the computer program in the memory to implement the steps of the method described in the first aspect of the embodiment of the present disclosure.
[0020] Through the above technical solution, the present invention inverts the image to be processed to obtain a negated image, and then determines the global atmospheric light value and the dark channel map corresponding to the negated image according to the minimum value of each pixel in the negated image in multiple color channels. When the average pixel intensity of the image to be processed belongs to the first intensity range, the transmittance weight corresponding to the pixel is determined according to the pixel intensity corresponding to each pixel in the negated image in multiple color channels, and then the transmittance corresponding to each pixel in the negated image is determined according to the dark channel map and the transmittance weight corresponding to each pixel in the negated image. Finally, according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image, the negated image is processed to obtain a processed target image. The present invention determines the transmittance weight by the pixel intensity corresponding to each pixel in multiple color channels, and then uses the transmittance weight to determine the corresponding transmittance, thereby obtaining a processed target image, which can adjust the lighting balance of the image and remove noise to improve the quality of the image.
[0021] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following detailed description, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0023] Figure 1 is a flowchart of a method for processing an image according to an exemplary embodiment;
[0024] Figure 2 is a flowchart of another image processing method according to an exemplary embodiment;
[0025] Figure 3 is a flowchart of another image processing method according to an exemplary embodiment;
[0026] Figure 4 is a flowchart of another image processing method according to an exemplary embodiment;
[0027] Figure 5 is a flowchart of another image processing method according to an exemplary embodiment;
[0028] Figure 6 is a flowchart of another image processing method according to an exemplary embodiment;
[0029] Figure 7 is a flowchart of another image processing method according to an exemplary embodiment;
[0030] Figure 8 is a flowchart of another image processing method according to an exemplary embodiment;
[0031] Figure 9 is a block diagram of an image processing device according to an exemplary embodiment;
[0032] Figure 10 is a block diagram of another image processing device according to an exemplary embodiment;
[0033] Figure 11 is a block diagram of another image processing device according to an exemplary embodiment;
[0034] Figure 12 is a block diagram of another image processing device according to an exemplary embodiment;
[0035] Figure 13 is a block diagram of another image processing device according to an exemplary embodiment;
[0036] Figure 14 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0037] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible embodiments consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
[0038] Figure 1 is a flowchart of a method for processing an image according to an exemplary embodiment. Figure 1 As shown, the method includes the following steps:
[0039] Step 101: invert the image to be processed to obtain an inverted image.
[0040] For example, first obtain the image to be processed. The image to be processed can be any image, for example, it can be an image collected by an image acquisition device, it can be any frame image in a video, or it can be an image obtained from the Internet. The present disclosure does not make specific limitations on this. The image to be processed can then be inverted to obtain a inverted image. When the shooting scene of the image to be processed belongs to a non-uniform lighting situation, the inverted image is very close to the foggy image, so the inverted image can be used as a foggy image for defogging to obtain a high-quality image. Specifically, the inversion process can be understood as inverting each pixel in the image to be processed, and the pixels in the inverted image correspond one-to-one to the pixels in the image to be processed, and the sum of the pixel intensity of each pixel in the inverted image and the pixel intensity of the corresponding pixel in the image to be processed is 255. Taking the RGB (English: Red Green Blue) color space as an example, c represents any color channel (that is, c can be the R channel, the G channel, or the B channel), I c (x) represents the pixel intensity at position x in the image to be processed in channel c, and x represents any pixel in the image to be processed. Then the inverted image can be expressed as represents the pixel intensity in channel c at position x in the negated image. The negated image satisfies the image scattering model: Where t(x) represents the transmittance at position x (which can be understood as the transmission rate of the reflected light on the surface of the actual object corresponding to position x after the light is affected by the suspended particles in the atmosphere). represents the pixel intensity at position x in the c channel of the image after defogging the inverted image (i.e., the inverted target image mentioned later), and A represents the global atmospheric light value. According to the image scattering model, we can determine Then A and t(x) need to be determined.
[0041] Step 102 : determining the global atmospheric light value and the dark channel image corresponding to the inverted image according to the minimum value of each pixel in the inverted image in multiple color channels.
[0042] For example, since the negated image can be regarded as a foggy image, the negated image should satisfy the Dark Channel Prior (DCP) principle. This means that after defogging the negated image, at least one color channel has very low brightness at some pixels. This can be expressed as: Where y represents any pixel point in the patch near the x position, and the size of the patch can be, for example, 15*15. Then the image scattering model can be transformed to obtain: After obtaining the inverted image, we can first determine the minimum value of each pixel in the inverted image in multiple color channels, that is, Afterwards, the global atmospheric light value and the dark channel map (English: Dark Channel Map) corresponding to the negated image can be determined based on the minimum value of each pixel in the negated image in multiple color channels. The global atmospheric light value can be determined first. Since there is often noise or white objects (for example, a white car or a white building) in the image to be processed, the atmospheric light may be confused. It can be assumed that the pixels corresponding to the atmospheric light are located in a large smooth area, and the global atmospheric light value remains unchanged over a period of time. Therefore, the minimum value of each pixel in the negated image in multiple color channels can be median filtered, and the maximum value in the filtering result can be used as the global atmospheric light value. The dark channel map can be determined by taking the ratio of the minimum value of each pixel in the negated image in multiple color channels to the global atmospheric light value as the dark channel map. It can also be filtering the ratio of the minimum value of each pixel in the negated image in multiple color channels to the global atmospheric light value to remove the details therein and obtain a dark channel map. The dark channel map can be expressed as I dark (x), the pixels in the dark channel image correspond one-to-one to the pixels in the negated image, and the pixel intensity of each pixel in the dark channel image is determined according to the minimum value of the corresponding pixel in the negated image in multiple color channels.
[0043] Step 103 : If the average pixel intensity of the image to be processed belongs to the first intensity range, the transmittance weight corresponding to each pixel in the inverted image is determined according to the pixel intensity corresponding to the multiple color channels.
[0044] For example, under normal circumstances, according to the image scattering model and the dark channel map, the transmittance corresponding to each pixel can be obtained, that is, t(x) = 1-ωI dark(x), where ω is the preset transmittance weight, typically set to 0.98. However, images captured under non-uniform lighting conditions often contain a lot of noise and suffer from uneven lighting. For example, images captured after fill-lighting of traffic violations on the road, or images of the front of a vehicle captured in low light with the headlights on, can cause the inverted image to not conform to the DCP principle. Directly using the DCP principle to calculate t(x) and then defogging the inverted image may result in excessive noise points in the resulting image. Furthermore, uneven lighting can cause the pixel intensity in the dark channel of the image to approach the intermediate pixel intensity in the RGB channels (the intermediate pixel intensity can be understood as the pixel intensity in the middle of the pixel intensities corresponding to multiple color channels). Directly using the DCP principle to calculate t(x) and then defogging the inverted image will cause the intermediate pixel intensity to also approach zero. Therefore, for images captured under non-uniform lighting, ω can be adjusted to ω(x). This means that the transmittance weight of the image is no longer a fixed value, but rather each pixel has a corresponding transmittance weight.
[0045] Specifically, the pixel intensity can be divided into a first intensity range and a second intensity range, wherein the first intensity range can be, for example, [5, 30], and the second intensity range can be [0, 5) and (30, 255). The first intensity range can also be [5, 35], and the second intensity range can also be [0, 5] and (35, 255]. The present disclosure does not make specific limitations on this. The average pixel intensity of the image to be processed can be determined first. The average pixel intensity can be understood as the average pixel intensity of each pixel in the image to be processed. If the average pixel intensity of the image to be processed belongs to the image to be processed in the second intensity range, then it can be determined that there is no lighting imbalance problem in the image to be processed, and t(x)=1-ωI can be directly used. dark (x) is used to determine the transmittance. If the average pixel intensity of the image to be processed falls within the first intensity range, it can be determined that the image to be processed was captured under non-uniform lighting conditions. The transmittance weight corresponding to each pixel in the inverted image can then be determined based on the pixel intensities corresponding to each pixel in multiple color channels.
[0046] The pixel intensity of each pixel in the negated image corresponding to multiple color channels can be determined first to determine the minimum color channel (i.e., dark channel) with the minimum pixel intensity, the maximum color channel with the maximum pixel intensity, and the intermediate color channel with pixel intensity between the minimum and maximum. Afterwards, the transmittance weight corresponding to the pixel can be determined based on the pixel intensity of the pixel in the corresponding minimum color channel, the pixel intensity of the pixel in the corresponding intermediate color channel, and the global atmospheric light value. The transmittance weight corresponding to the pixel can also be determined based on the ratio of the pixel intensity of the pixel in the corresponding minimum color channel to the pixel intensity of the pixel in the corresponding intermediate color channel, the ratio of the pixel intensity of the pixel in the corresponding minimum color channel to the global atmospheric light value, and a preset adjustment parameter. The transmittance weight corresponding to each pixel is related to the pixel intensity of the pixel in the corresponding minimum color channel and the pixel intensity of the pixel in the corresponding intermediate color channel. This can avoid the problem that the intermediate pixel intensity of the processed image is close to zero due to the pixel intensity of the negated image in the dark channel being close to the intermediate pixel intensity.
[0047] Step 104 : Determine the transmittance corresponding to each pixel in the negated image according to the dark channel image and the transmittance weight corresponding to each pixel in the negated image.
[0048] Step 105 : Processing the negated image according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image.
[0049] For example, the transmittance weight corresponding to each pixel in the inverted image can be multiplied by the pixel intensity corresponding to the pixel in the dark channel image, and then the difference between 1 and the multiplication result is used as the transmittance corresponding to the pixel. For example, the transmittance corresponding to each pixel can be determined by formula 1:
[0050] t(x)=1-ω(x)I dark (x) Formula 1
[0051] Where t(x) represents the transmittance at position x, ω(x) represents the transmittance weight at position x, and I dark (x) represents the pixel intensity at position x in the dark channel image.
[0052] Afterwards, the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image can be brought into the image scattering model to obtain the image after the negated image is defogged, and then the image is negated to obtain the processed target image. After obtaining the target image, operations such as violation identification, obstacle identification, positioning, path planning, and automatic driving can be performed based on the target image, and the present disclosure does not make specific restrictions on this. In this way, the transmittance is determined by the transmittance weight corresponding to each pixel, and the negated image is adjusted for illumination balance and denoised through the image scattering model to obtain the target image. This can avoid the problem that the pixel intensity of the negated image in the dark channel is close to the intermediate pixel intensity, resulting in the intermediate pixel intensity being close to zero, thereby achieving the effects of illumination balance, denoising, and improving the quality of the target image.
[0053] In summary, the present invention inverts the image to be processed to obtain a negated image, and then determines the global atmospheric light value and the dark channel map corresponding to the negated image based on the minimum value of each pixel in the negated image in multiple color channels. When the average pixel intensity of the image to be processed belongs to the first intensity range, the transmittance weight corresponding to the pixel is determined based on the pixel intensity corresponding to each pixel in the negated image in multiple color channels, and then the transmittance corresponding to each pixel in the negated image is determined based on the dark channel map and the transmittance weight corresponding to each pixel in the negated image. Finally, the negated image is processed according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image. The present invention determines the transmittance weight by the pixel intensity corresponding to each pixel in multiple color channels, and then uses the transmittance weight to determine the corresponding transmittance, thereby obtaining a processed target image, which can adjust the lighting balance of the image and remove noise to improve the quality of the image.
[0054] Figure 2 is a flowchart of another image processing method according to an exemplary embodiment. Figure 2 As shown, the method may further include:
[0055] Step 106 : If the average pixel intensity of the image to be processed belongs to the second intensity range, the transmittance corresponding to each pixel in the inverted image is determined according to the dark channel map and the preset transmittance weight.
[0056] Step 107 : Process the negated image according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a target image.
[0057] For example, if the average pixel intensity of the image to be processed belongs to the second intensity range of the image to be processed, it can be determined that there is no lighting imbalance problem in the image to be processed, and the transmittance corresponding to each pixel in the inverted image can be determined based on the dark channel image and the preset transmittance weight. For example, the transmittance corresponding to each pixel can be determined by Formula 2:
[0058] t(x)=1-ωI dark (x) Formula 2
[0059] Where t(x) represents the transmittance at position x, ω represents the preset transmittance weight, and I dark (x) represents the intensity of the pixel at position x in the dark channel image. ω can usually be set to 0.98.
[0060] Afterwards, the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image can be brought into the image scattering model to obtain the image after defogging the negated image, which is then negated to obtain the processed target image.
[0061] Figure 3 is a flowchart of another image processing method according to an exemplary embodiment. Figure 3 As shown, step 103 can be implemented by the following steps:
[0062] Step 1031: For each pixel point in the inverted image, sort the multiple color channels according to the pixel intensity corresponding to the pixel point in the multiple color channels, and determine the minimum color channel and the middle color channel corresponding to the pixel point. The pixel intensity of the pixel point in the corresponding minimum color channel is the smallest, and the pixel intensity of the pixel point in the corresponding middle color channel is in the middle.
[0063] For example, for each pixel in the negated image, the multiple color channels can be sorted according to the pixel intensities corresponding to the pixel in the multiple color channels, and the color channel with the smallest pixel intensity is determined as the minimum color channel, the color channel with the middle pixel intensity is determined as the middle color channel, and the color channel with the largest pixel intensity is determined as the maximum color channel. Assume that the pixel intensities of a certain pixel in the negated image in the R channel, G channel, and B channel meet the following relationship:
[0064]
[0065] in, Indicates the pixel intensity in the R channel at the x position in the inverted image. Indicates the pixel intensity in the G channel at the x position in the inverted image, Indicates the pixel intensity in the B channel at position x in the inverted image, so it can be determined that the R channel is the minimum color channel and the G channel is the middle color channel.
[0066] Step 1032 : Determine the transmittance weight corresponding to the pixel point based on the pixel intensity of the pixel point in the corresponding minimum color channel, the pixel intensity of the pixel point in the corresponding intermediate color channel, and the global atmospheric light value.
[0067] For example, the inverted image can be substituted into the image scattering model to obtain:
[0068]
[0069]
[0070]
[0071] According to the DCP principle, we know should approach 0, then we can get Substituting into formulas 4 and 5, we can get:
[0072]
[0073] From the above, we can see that if and Close, then will become 0, or if and Close, then will become 0. That is, if the pixel corresponds to the pixel intensity in the minimum color channel (expressed as ), and the pixel intensity corresponding to the pixel in the middle color channel (expressed as ) is close, which will result in the pixel intensity in the middle color channel of the obtained image being 0, so the transmittance weight can be adjusted to limit and As shown in Formula 6:
[0074]
[0075] Among them, α is a preset adjustment parameter, and its value range is between 0 and 1. Accordingly, ω(x) should be minimized, so the corresponding transmittance weight can be obtained by formula 7:
[0076]
[0077] Here, α can be 0.85.
[0078] Figure 4 is a flowchart of another image processing method according to an exemplary embodiment. Figure 4 As shown, after step 103, the method may further include:
[0079] Step 108 : Correcting the transmittance weight corresponding to each pixel in the negated image to obtain a corrected transmittance weight corresponding to each pixel in the negated image.
[0080] Accordingly, step 104 may be implemented as follows:
[0081] The transmittance corresponding to each pixel in the negated image is determined according to the dark channel image and the corrected transmittance weight corresponding to each pixel in the negated image.
[0082] For example, after obtaining the transmittance weight corresponding to each pixel in the inverted image, the transmittance weight can be further corrected to obtain the corrected transmittance weight corresponding to each pixel in the inverted image, expressed as ω para (x), the transmittance determined based on the corrected transmittance weight can improve the accuracy of the transmittance, thereby further improving the illumination balance level, noise level, and image quality of the target image. Accordingly, when determining the corresponding transmittance, the corrected transmittance weight corresponding to each pixel in the inverted image can be multiplied by the pixel intensity corresponding to the pixel in the dark channel image, and then the difference between 1 and the multiplication result is used as the transmittance corresponding to the pixel. For example, the transmittance corresponding to each pixel can be determined by Formula 8:
[0083] t(x)=1-ω para (x)I dark (x) Formula 8
[0084] Figure 5 is a flowchart of another image processing method according to an exemplary embodiment. Figure 5 As shown, step 108 may include:
[0085] Step 1081: Perform Gaussian filtering on the transmittance weight corresponding to each pixel in the negated image to obtain a corrected transmittance weight corresponding to each pixel in the negated image. Or,
[0086] Step 1082: For each pixel in the inverted image, if the transmittance weight corresponding to the pixel is greater than a preset weight threshold, the corrected transmittance weight corresponding to the pixel is determined to be the weight threshold. If the transmittance weight corresponding to the pixel is less than or equal to the weight threshold, the transmittance weight corresponding to the pixel is used as the corrected transmittance weight corresponding to the pixel.
[0087] For example, the transmittance weight can be corrected by performing Gaussian filtering on the transmittance weight corresponding to each pixel in the inverted image to obtain the corrected transmittance weight corresponding to each pixel in the inverted image. That is, the corresponding corrected transmittance weight can be determined by Formula 9:
[0088] ω para (x) = G[ω(x)] Formula 9
[0089] Among them, ω para (x) represents the corrected transmittance weight at the position x, and G represents Gaussian filtering.
[0090] Alternatively, a preset weight threshold can also be used to determine the corrected transmittance weight. For each pixel in the inverted image, if the transmittance weight corresponding to the pixel is greater than the preset weight threshold, the corrected transmittance weight corresponding to the pixel is determined to be the weight threshold. If the transmittance weight corresponding to the pixel is less than or equal to the weight threshold, the transmittance weight corresponding to the pixel is used as the corrected transmittance weight corresponding to the pixel. That is, the corresponding corrected transmittance weight can be determined by formula 10:
[0091]
[0092] Among them, ω initial Indicates the weight threshold, which can be set to 0.98, for example.
[0093] Figure 6 is a flowchart of another image processing method according to an exemplary embodiment. Figure 6 As shown, step 108 may include:
[0094] Step 1083 , performing Gaussian filtering on the transmittance weight corresponding to each pixel in the negated image to obtain a filtered transmittance weight corresponding to each pixel in the negated image.
[0095] Step 1084: For each pixel in the negated image, if the filtered transmittance weight corresponding to the pixel is greater than a preset weight threshold, the corrected transmittance weight corresponding to the pixel is determined to be the weight threshold. If the filtered transmittance weight corresponding to the pixel is less than or equal to the weight threshold, the filtered transmittance weight corresponding to the pixel is used as the corrected transmittance weight corresponding to the pixel.
[0096] In another implementation, the transmittance weight corresponding to each pixel in the inverted image can be Gaussian filtered to obtain the corresponding filtered transmittance weight. Then, a preset weight threshold is used to determine the corrected transmittance weight. That is, the corrected transmittance weight can be determined using Formula 11:
[0097] ω dynamicblur (x) = G[ω(x)]
[0098]
[0099] Among them, ω para (x) represents the corrected transmittance weight at position x, ω dynamicblur (x) represents the filtered transmittance weight at position x, and G represents Gaussian filtering. initial Indicates the weight threshold, which can be set to 0.98, for example.
[0100] Figure 7 is a flowchart of another image processing method according to an exemplary embodiment. Figure 7 As shown, step 105 may include:
[0101] Step 1051 : Determine a negated target image corresponding to the negated image according to the negated image, the global atmospheric light value, the transmittance corresponding to each pixel in the negated image, and the image scattering model.
[0102] Step 1052: invert the inverted target image to obtain the target image.
[0103] As an example, the following specifically describes how to process the inverted image. The inverted image, the global atmospheric light value, and the transmittance corresponding to each pixel in the inverted image can be brought into the image scattering model to obtain the inverted target image. For example, the inverted target image can be determined using Formula 12:
[0104]
[0105] in, Indicates the inverse of the pixel intensity at position x in the c channel of the target image.
[0106] Then, the inverted target image is inverted to obtain the processed target image. For example, the target image can be determined by formula 13:
[0107]
[0108] Among them, J c (x) represents the pixel intensity in channel c at position x in the target image.
[0109] Figure 8 is a flowchart of another image processing method according to an exemplary embodiment. Figure 8 As shown, step 102 can be implemented by the following steps:
[0110] Step 1021 , performing median filtering on the minimum value of each pixel in the inverted image in multiple color channels, and taking the maximum value of the filtering results as the global atmospheric light value.
[0111] For example, the minimum value of each pixel in the inverted image in multiple color channels can be median filtered, that is, Among them, I blur (x) represents the median filtering result, and Med represents the median filtering process. Then I blur The maximum value in (x) is taken as the global atmospheric light value A.
[0112] Step 1022: Determine a rough dark channel map based on the minimum value of each pixel in the negated image in multiple color channels, and perform median filtering on the rough dark channel map to obtain a median dark channel map. The value of each pixel in the rough dark channel map is the ratio of the minimum value of the corresponding pixel in the negated image in multiple color channels to the global atmospheric light value.
[0113] Step 1023 , performing median filtering on the absolute value of the difference between the coarse dark channel image and the median dark channel image to obtain a detail dark channel image.
[0114] Step 1024: The difference between the median dark channel image and the detail dark channel image is used as a smoothed dark channel image.
[0115] Step 1025 : Determine a dark channel map according to the smooth dark channel map and the rough dark channel map.
[0116] For example, after determining the global atmospheric light value, a rough dark channel map can be determined based on the minimum value of each pixel in the inverted image in multiple color channels. The rough dark channel map can be determined using Formula 14:
[0117]
[0118] in, Represents the pixel intensity at position x in the rough dark channel image.
[0119] The rough dark channel image can then be median filtered to obtain a median dark channel image. The median dark channel image can be determined by formula 15:
[0120]
[0121] Among them, I med (x) represents the pixel intensity at position x in the median dark channel image.
[0122] Furthermore, in order to make the transmittance t(x) locally smooth while maintaining the edge, it is necessary to med(x) to erase details. First, the local standard deviation can be used to approximate the local details. In addition, the median filter can enhance the robustness of the local detail approximation. Therefore, the absolute value of the difference between the rough dark channel image and the median dark channel image can be median filtered to obtain the detail dark channel image. The detail dark channel image can be determined by formula 16:
[0123]
[0124] Among them, I detail (x) represents the pixel intensity at position x in the detail dark channel image.
[0125] Finally, the difference between the median dark channel image and the detail dark channel image can be used as the smoothed dark channel image, and then the dark channel image can be determined based on the smoothed dark channel image, the rough dark channel image and the preset coefficient. Specifically, the smoothed dark channel image can be determined using Formula 17:
[0126] I smooth (x)=I med (x)-I detail (x) Formula 17
[0127] Among them, I smooth (x) represents the pixel intensity at position x in the smoothed dark channel image.
[0128] Specifically, for each pixel, if the pixel intensity of the pixel in the rough dark channel image is less than the pixel intensity of the pixel in the smooth dark channel image, then the pixel intensity of the pixel in the dark channel image can be determined as the product of a preset coefficient and the pixel intensity of the pixel in the rough dark channel image. If the pixel intensity of the pixel in the rough dark channel image is greater than or equal to the pixel intensity of the pixel in the smooth dark channel image, then the pixel intensity of the pixel in the dark channel image can be determined as the pixel intensity of the pixel in the smooth dark channel image. The dark channel image can be determined using Formula 18:
[0129]
[0130] Among them, μ is a preset coefficient, which can be set to 0.95.
[0131] In summary, the present invention inverts the image to be processed to obtain a negated image, and then determines the global atmospheric light value and the dark channel map corresponding to the negated image based on the minimum value of each pixel in the negated image in multiple color channels. When the average pixel intensity of the image to be processed belongs to the first intensity range, the transmittance weight corresponding to the pixel is determined based on the pixel intensity corresponding to each pixel in the negated image in multiple color channels, and then the transmittance corresponding to each pixel in the negated image is determined based on the dark channel map and the transmittance weight corresponding to each pixel in the negated image. Finally, the negated image is processed according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image. The present invention determines the transmittance weight by the pixel intensity corresponding to each pixel in multiple color channels, and then uses the transmittance weight to determine the corresponding transmittance, thereby obtaining a processed target image, which can adjust the lighting balance of the image and remove noise to improve the quality of the image.
[0132] Figure 9 is a block diagram of an image processing device according to an exemplary embodiment. Figure 9 As shown, the device 200 includes:
[0133] The inversion module 201 is used to invert the image to be processed to obtain a inverted image.
[0134] The pre-processing module 202 is configured to determine the global atmospheric light value and the dark channel image corresponding to the inverted image according to the minimum value of each pixel in the inverted image in multiple color channels.
[0135] The weight determination module 203 is configured to determine the transmittance weight corresponding to each pixel in the inverted image according to the pixel intensities corresponding to the multiple color channels of each pixel if the average pixel intensity of the image to be processed belongs to the first intensity range.
[0136] The transmittance determination module 204 is configured to determine the transmittance corresponding to each pixel in the negated image according to the dark channel image and the transmittance weight corresponding to each pixel in the negated image.
[0137] The processing module 205 is used to process the negated image according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image.
[0138] In one implementation, the transmittance determination module 204 is further configured to:
[0139] If the average pixel intensity of the image to be processed belongs to the second intensity range, the transmittance corresponding to each pixel in the inverted image is determined according to the dark channel map and the preset transmittance weight.
[0140] Figure 10is a block diagram of another image processing device according to an exemplary embodiment. Figure 10 As shown, the weight determination module 203 may include:
[0141] The sorting submodule 2031 is used to sort the multiple color channels for each pixel in the inverted image according to the pixel intensity corresponding to the pixel in the multiple color channels, and determine the minimum color channel and the middle color channel corresponding to the pixel. The pixel intensity of the pixel in the corresponding minimum color channel is the smallest, and the pixel intensity of the pixel in the corresponding middle color channel is in the middle.
[0142] The weight determination submodule 2032 is used to determine the transmittance weight corresponding to the pixel point according to the pixel intensity of the pixel point in the corresponding minimum color channel, the pixel intensity of the pixel point in the corresponding intermediate color channel and the global atmospheric light value.
[0143] Figure 11 is a block diagram of another image processing device according to an exemplary embodiment. Figure 11 As shown, the device 200 further includes:
[0144] The correction module 206 is used to correct the transmittance weight corresponding to each pixel in the negated image after determining the transmittance weight corresponding to the pixel intensities corresponding to the pixel in multiple color channels in the negated image, so as to obtain the corrected transmittance weight corresponding to each pixel in the negated image.
[0145] Accordingly, the transmittance determination module 204 may be used to:
[0146] The transmittance corresponding to each pixel in the negated image is determined according to the dark channel image and the corrected transmittance weight corresponding to each pixel in the negated image.
[0147] In another implementation, the correction module 206 is configured to:
[0148] Perform Gaussian filtering on the transmittance weight corresponding to each pixel in the negated image to obtain the corrected transmittance weight corresponding to each pixel in the negated image. Or,
[0149] For each pixel in the inverted image, if the transmittance weight corresponding to the pixel is greater than a preset weight threshold, the corrected transmittance weight corresponding to the pixel is determined to be the weight threshold. If the transmittance weight corresponding to the pixel is less than or equal to the weight threshold, the transmittance weight corresponding to the pixel is used as the corrected transmittance weight corresponding to the pixel.
[0150] In yet another implementation, the correction module 206 is configured to:
[0151] Gaussian filtering is performed on the transmittance weight corresponding to each pixel in the negated image to obtain a filtered transmittance weight corresponding to each pixel in the negated image.
[0152] For each pixel in the inverted image, if the filtered transmittance weight corresponding to the pixel is greater than a preset weight threshold, the corrected transmittance weight corresponding to the pixel is determined to be the weight threshold. If the filtered transmittance weight corresponding to the pixel is less than or equal to the weight threshold, the filtered transmittance weight corresponding to the pixel is used as the corrected transmittance weight corresponding to the pixel.
[0153] Figure 12 is a block diagram of another image processing device according to an exemplary embodiment. Figure 12 As shown, the processing module 205 includes:
[0154] The processing submodule 2051 is used to determine a negated target image corresponding to the negated image according to the negated image, the global atmospheric light value, the transmittance corresponding to each pixel in the negated image, and the image scattering model.
[0155] The negation submodule 2052 is used to negate the negation target image to obtain the target image.
[0156] Figure 13 is a block diagram of another image processing device according to an exemplary embodiment. Figure 13 As shown, the pre-processing module 202 may include:
[0157] The first filtering submodule 2021 is used to perform median filtering on the minimum value of each pixel in the inverted image in multiple color channels, and use the maximum value in the filtering results as the global atmospheric light value.
[0158] The second filtering submodule 2022 is used to determine a rough dark channel map according to the minimum value of each pixel point in the negated image in multiple color channels, and perform median filtering on the rough dark channel map to obtain a median dark channel map, where the value of each pixel point in the rough dark channel map is the ratio of the minimum value of the corresponding pixel point in the negated image in multiple color channels to the global atmospheric light value.
[0159] The third filtering submodule 2023 is configured to perform median filtering on the absolute value of the difference between the coarse dark channel image and the median dark channel image to obtain a detail dark channel image.
[0160] The first processing submodule 2024 is configured to use the difference between the median dark channel image and the detail dark channel image as a smoothed dark channel image.
[0161] The second processing submodule 2025 is configured to determine a dark channel map according to the smooth dark channel map and the rough dark channel map.
[0162] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0163] In summary, the present invention inverts the image to be processed to obtain a negated image, and then determines the global atmospheric light value and the dark channel map corresponding to the negated image based on the minimum value of each pixel in the negated image in multiple color channels. When the average pixel intensity of the image to be processed belongs to the first intensity range, the transmittance weight corresponding to the pixel is determined based on the pixel intensity corresponding to each pixel in the negated image in multiple color channels, and then the transmittance corresponding to each pixel in the negated image is determined based on the dark channel map and the transmittance weight corresponding to each pixel in the negated image. Finally, the negated image is processed according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image. The present invention determines the transmittance weight by the pixel intensity corresponding to each pixel in multiple color channels, and then uses the transmittance weight to determine the corresponding transmittance, thereby obtaining a processed target image, which can adjust the lighting balance of the image and remove noise to improve the quality of the image.
[0164] Figure 14 FIG. 1 is a block diagram of an electronic device 300 according to an exemplary embodiment. Figure 14 As shown, the electronic device 300 may include: a processor 301 , a memory 302 , and may further include one or more of a multimedia component 303 , an input / output (I / O) interface 304 , and a communication component 305 .
[0165] The processor 301 is used to control the overall operation of the electronic device 300 to complete all or part of the steps in the above-mentioned image processing method. The memory 302 is used to store various types of data to support the operation of the electronic device 300. Such data may include, for example, instructions for any application or method operating on the electronic device 300, as well as application-related data, such as contact information, sent and received messages, pictures, audio, video, etc. The memory 302 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The multimedia component 303 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in the memory 302 or transmitted via the communication component 305. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 304 provides an interface between the processor 301 and other interface modules. The aforementioned other interface modules may be a keyboard, a mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 305 is used for wired or wireless communication between the electronic device 300 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more thereof, is not limited here. Therefore, the corresponding communication component 305 may include: a Wi-Fi module, a Bluetooth module, an NFC module, etc.
[0166] In an exemplary embodiment, the electronic device 300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above-mentioned image processing method.
[0167] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided. When executed by a processor, the program instructions implement the steps of the above-described image processing method. For example, the computer-readable storage medium may be the aforementioned memory 302 including the program instructions. The program instructions may be executed by the processor 301 of the electronic device 300 to implement the above-described image processing method.
[0168] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program executable by a programmable device, and has a code portion for executing the above-mentioned image processing method when executed by the programmable device.
[0169] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings. However, the present disclosure is not limited to the specific details of the above embodiments. Within the technical concept of the present disclosure, various simple modifications can be made to the technical solutions of the present disclosure, and these simple modifications all fall within the scope of protection of the present disclosure.
[0170] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any appropriate manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0171] In addition, the various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A method for processing an image, characterized in that: The method comprises: Invert the image to be processed to obtain an inverted image; Determining a global atmospheric light value and a dark channel image corresponding to the negated image according to a minimum value of each pixel in the negated image in multiple color channels; If the average pixel intensity of the image to be processed falls within the first intensity range, determining a transmittance weight corresponding to each pixel in the inverted image based on the pixel intensities corresponding to the plurality of color channels; the transmittance weight corresponding to each pixel is related to the pixel intensity of the pixel in the corresponding minimum color channel and the pixel intensity of the pixel in the corresponding intermediate color channel, where the pixel intensity of the pixel in the corresponding minimum color channel is the smallest and the pixel intensity of the pixel in the corresponding intermediate color channel is in the middle; Determining the transmittance corresponding to each pixel in the negated image according to the dark channel image and the transmittance weight corresponding to each pixel in the negated image; The negated image is processed according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image.
2. The method according to claim 1, characterized in that The method further comprises: If the average pixel intensity of the image to be processed belongs to the second intensity range, the transmittance corresponding to each pixel in the negated image is determined according to the dark channel map and the preset transmittance weight; the negated image is processed according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain the target image.
3. The method according to claim 1, characterized in that Determining the transmittance weight corresponding to each pixel point in the inverted image according to the pixel intensities corresponding to the plurality of color channels includes: For each pixel in the negated image, sort the multiple color channels according to the pixel intensities corresponding to the pixel in the multiple color channels, and determine the minimum color channel and the middle color channel corresponding to the pixel; The transmittance weight corresponding to the pixel point is determined according to the pixel intensity of the pixel point in the corresponding minimum color channel, the pixel intensity of the pixel point in the corresponding intermediate color channel and the global atmospheric light value.
4. The method according to claim 1, wherein After determining the transmittance weight corresponding to each pixel point in the inverted image based on the pixel intensities corresponding to the multiple color channels, the method further includes: Correcting the transmittance weight corresponding to each pixel in the negated image to obtain a corrected transmittance weight corresponding to each pixel in the negated image; The determining, according to the dark channel image and the transmittance weight corresponding to each pixel in the negated image, the transmittance corresponding to each pixel in the negated image includes: The transmittance corresponding to each pixel in the negated image is determined according to the dark channel image and the corrected transmittance weight corresponding to each pixel in the negated image.
5. The method according to claim 4, characterized in that The correcting the transmittance weight corresponding to each pixel in the negated image to obtain a corrected transmittance weight corresponding to each pixel in the negated image includes: Performing Gaussian filtering on the transmittance weight corresponding to each pixel in the negated image to obtain a corrected transmittance weight corresponding to each pixel in the negated image; or For each pixel point in the inverted image, if the transmittance weight corresponding to the pixel point is greater than the preset weight threshold, the corrected transmittance weight corresponding to the pixel point is determined to be the weight threshold; if the transmittance weight corresponding to the pixel point is less than or equal to the weight threshold, the transmittance weight corresponding to the pixel point is used as the corrected transmittance weight corresponding to the pixel point.
6. The method according to claim 4, characterized in that The correcting the transmittance weight corresponding to each pixel in the negated image to obtain a corrected transmittance weight corresponding to each pixel in the negated image includes: Performing Gaussian filtering on the transmittance weight corresponding to each pixel in the negated image to obtain a filtered transmittance weight corresponding to each pixel in the negated image; For each pixel point in the inverted image, if the filtered transmittance weight corresponding to the pixel point is greater than the preset weight threshold, the corrected transmittance weight corresponding to the pixel point is determined to be the weight threshold; if the filtered transmittance weight corresponding to the pixel point is less than or equal to the weight threshold, the filtered transmittance weight corresponding to the pixel point is used as the corrected transmittance weight corresponding to the pixel point.
7. The method according to any one of claims 1 to 6, characterized in that The processing of the negated image according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image includes: Determining a negated target image corresponding to the negated image according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image and an image scattering model; The inverted target image is inverted to obtain the target image.
8. The method according to any one of claims 1 to 6, characterized in that The determining, according to the minimum value of each pixel point in the negated image in multiple color channels, a global atmospheric light value and a dark channel image corresponding to the negated image, comprises: Performing median filtering on the minimum value of each pixel in the inverted image in multiple color channels, and taking the maximum value of the filtering results as the global atmospheric light value; Determining a rough dark channel map according to the minimum value of each pixel in the negated image in multiple color channels, and performing median filtering on the rough dark channel map to obtain a median dark channel map, wherein the value of each pixel in the rough dark channel map is the ratio of the minimum value of the corresponding pixel in the negated image in multiple color channels to the global atmospheric light value; Performing median filtering on the absolute value of the difference between the rough dark channel image and the median dark channel image to obtain a detail dark channel image; The difference between the median dark channel image and the detail dark channel image is used as a smoothed dark channel image; The dark channel map is determined according to the smooth dark channel map and the rough dark channel map.
9. An image processing device, characterized in that: The device comprises: A negation module, used to negate the image to be processed to obtain a negated image; a preprocessing module, configured to determine a global atmospheric light value and a dark channel image corresponding to the negated image according to a minimum value of each pixel in the negated image in a plurality of color channels; a weight determination module configured to determine, if the average pixel intensity of the image to be processed falls within a first intensity range, a transmittance weight corresponding to each pixel in the inverted image based on the pixel intensities corresponding to the pixel in multiple color channels; the transmittance weight corresponding to each pixel being related to the pixel intensity of the pixel in the corresponding minimum color channel and the pixel intensity of the pixel in the corresponding intermediate color channel, the pixel intensity of the pixel in the corresponding minimum color channel being the smallest and the pixel intensity of the pixel in the corresponding intermediate color channel being intermediate; a transmittance determination module, configured to determine the transmittance corresponding to each pixel in the negated image based on the dark channel image and the transmittance weight corresponding to each pixel in the negated image; A processing module is used to process the negated image according to the negated image, the global atmospheric light value, and the transmittance corresponding to each pixel in the negated image to obtain a processed target image.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
11. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Image defogging method and device, electronic equipment and readable storage medium
CN112419162A