Image processing method, device, electronic device and computer readable storage medium

By dividing the image into blocks and calculating correlation, the mean value of the target color channel is selected to calculate the gain value, which solves the problem of poor correction effect of large-area single-color images under different color temperature illumination, and achieves more accurate image correction.

CN114022375BActive Publication Date: 2024-10-18SHENZHEN LUMIUNITED TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111292994.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-03
Publication Date
2024-10-18
Estimated Expiration
2041-11-03

AI Technical Summary

Technical Problem

In the existing technology, the image correction effect is poor when images taken under illumination with different color temperatures have a single color over a large area.

Method used

By dividing the image to be processed into blocks, calculate the color channel mean and feature parameters of each image block, select the target color channel mean based on the image blocks whose correlation meets the threshold, calculate a more accurate gain value, and calculate each pixel in the image Click to perform image correction processing.

Benefits of technology

When a large area of ​​a single color appears in the image, the accuracy and effect of image correction are improved, making the image color closer to the color of the real object.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114022375B_ABST
    Figure CN114022375B_ABST
Patent Text Reader

Abstract

The embodiment of the present application proposes an image processing method, device, electronic device and computer-readable storage medium, which relate to the field of image processing. For multiple image blocks obtained by dividing the image to be processed, the color channel mean and image feature parameters corresponding to each image block are determined, the correlation corresponding to each image block is calculated by the image feature parameters, and the color channel mean corresponding to the image block whose correlation meets the threshold is selected to participate in the calculation of the gain value. Since the image feature parameters represent the information richness of the image block, when a large area of ​​single color appears in the image, the color channel mean corresponding to the image block whose information richness meets the conditions can be selected to participate in the calculation of the gain value. In this way, image correction processing is performed on each pixel point in the image to be processed based on the calculated gain value, so that the image color after image correction processing is closer to the real object color, thereby ensuring that when a large area of ​​single color appears in the image, there is a better image correction effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular, to an image processing method, device, electronic device and computer-readable storage medium. Background Art

[0002] Due to the different spectral characteristics of different lighting, objects have different tones under lighting of different color temperatures. The higher the color temperature of the light source, the bluer the object is, and the lower the color temperature of the light source, the yellower the object is. Therefore, it is necessary to correct the images taken under light sources of different color temperatures.

[0003] In the prior art, the grayscale world method can be used for image correction processing. This method mainly calculates the gain based on the mean of the three color channels (Red, Green, Blue) of the entire image, and corrects the image based on the gain. However, when a large area of ​​a single color appears in the image, the effect of image correction using the grayscale world method is poor. Summary of the invention

[0004] In view of this, the purpose of the present application is to provide an image processing method, device, electronic device and computer-readable storage medium to solve the problem in the prior art that the image correction effect is poor when a large area of ​​a single color appears in the picture.

[0005] In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0006] In a first aspect, the present application provides an image processing method, the method comprising:

[0007] For multiple image blocks obtained by dividing the image to be processed, determining the color channel mean and image feature parameters corresponding to each image block; the image feature parameters represent the information richness of the image block;

[0008] Calculating the correlation corresponding to each of the image blocks according to the image feature parameters;

[0009] Determine the target color channel mean corresponding to the image to be processed according to the color channel mean corresponding to the image block whose correlation meets the threshold, and determine the gain value corresponding to the image to be processed according to the target color channel mean;

[0010] Image correction processing is performed on each pixel in the image to be processed based on the gain value.

[0011] In a second aspect, the present application provides an image processing device, the device comprising:

[0012] A feature parameter calculation module is used to determine the color channel mean and image feature parameters corresponding to each image block for a plurality of image blocks obtained by dividing the image to be processed; the image feature parameters represent the information richness of the image block;

[0013] A correlation calculation module, used for calculating the correlation corresponding to each of the image blocks according to the image feature parameters;

[0014] A gain calculation module, used to determine a target color channel mean corresponding to the image to be processed according to a color channel mean corresponding to the image block whose correlation meets a threshold, and determine a gain value corresponding to the image to be processed according to the target color channel mean;

[0015] The image correction module is used to perform image correction processing on each pixel point in the image to be processed based on the gain value.

[0016] In an optional embodiment, the correlation calculation module is used to determine the correlation between each image block and an adjacent image block in a preset direction based on image feature parameters of each image block, so as to obtain the correlation corresponding to each image block; and for a terminal image block in the preset direction, the correlation of an image block adjacent to the terminal image block in a direction opposite to the preset direction is determined as the correlation corresponding to the terminal image block.

[0017] In an optional embodiment, the gain calculation module is used to add a first identifier to the image block if the correlation of the image block meets the threshold; if the correlation of the image block does not meet the threshold, add a second identifier to the image block; determine the target color channel mean corresponding to the image to be processed based on the color channel mean corresponding to the image block with the first identifier added; wherein the image block with the first identifier added represents an image block with rich image colors.

[0018] In an optional embodiment, the gain calculation module is used to determine the target red channel mean corresponding to the image to be processed based on the red channel mean corresponding to the image block to which the first identifier is added; determine the target green channel mean corresponding to the image to be processed based on the green channel mean corresponding to the image block to which the first identifier is added; and determine the target blue channel mean corresponding to the image to be processed based on the blue channel mean corresponding to the image block to which the first identifier is added.

[0019] In an optional embodiment, the target color channel mean includes a target red channel mean, a target green channel mean and a target blue channel mean, and the gain calculation module is used to calculate the sum of the target red channel mean, the target green channel mean and the target blue channel mean; calculate the red channel gain value corresponding to the image to be processed based on the sum and the target red channel mean; calculate the green channel gain value corresponding to the image to be processed based on the sum and the target green channel mean; calculate the blue channel gain value corresponding to the image to be processed based on the sum and the target blue channel mean.

[0020] In an optional embodiment, the image correction module is used to perform gain correction on each pixel in the red channel according to the red channel gain value; to perform gain correction on each pixel in the green channel according to the green channel gain value; and to perform gain correction on each pixel in the blue channel according to the blue channel gain value.

[0021] In an optional embodiment, the image feature parameters include a color channel standard deviation, and the feature parameter calculation module is used to perform mean calculation on the color channel values ​​corresponding to all pixels in each of the image blocks to obtain the color channel mean corresponding to each of the image blocks; and calculate the color channel standard deviation corresponding to each of the image blocks based on the color channel mean corresponding to each of the image blocks and the color channel values ​​corresponding to all pixels in each of the image blocks.

[0022] In a third aspect, the present application provides an electronic device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of an image processing method as described in any one of the aforementioned embodiments.

[0023] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the image processing method as described in any one of the aforementioned embodiments are implemented.

[0024] The image processing method, device, electronic device and computer-readable storage medium provided by the embodiments of the present application determine the color channel mean and image feature parameters corresponding to each image block for multiple image blocks obtained by dividing the image to be processed, calculate the correlation corresponding to each image block through the image feature parameters, and select the color channel mean corresponding to the image block whose correlation meets the threshold to participate in the calculation of the gain value. Since the image feature parameters can characterize the information richness of the image block, when a large area of ​​single color appears in the image, the color channel mean corresponding to the image block whose information richness meets the conditions can be selected to participate in the calculation of the gain value, thereby obtaining a more accurate gain value. In this way, image correction processing is performed on each pixel point in the image to be processed based on the calculated gain value, so that the color of the image after the image correction processing is closer to the color of the real object, thereby ensuring a better image correction effect when a large area of ​​single color appears in the image.

[0025] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0027] Figure 1 A schematic diagram of an application environment of the image processing method provided by an embodiment of the present application is shown;

[0028] Figure 2 Another schematic diagram of an application environment of the image processing method provided in an embodiment of the present application is shown;

[0029] Figure 3 A schematic diagram of a process of an image processing method provided by an embodiment of the present application is shown;

[0030] Figure 4 Another schematic diagram of the process of the image processing method provided in the embodiment of the present application is shown;

[0031] Figure 5 A schematic diagram showing the comparison between the original image and the image after white balance correction is shown;

[0032] Figure 6 A functional module diagram of an image processing device provided by an embodiment of the present application is shown;

[0033] Figure 7A hardware structure block diagram of an electronic device provided in an embodiment of the present application is shown.

[0034] Icons: 10-smart home system; 100-sub-device; 200-gateway device; 300-server; 400-terminal device; 500-router; 600-image processing device; 610-feature parameter calculation module; 620-correlation calculation module; 630-gain calculation module; 640-image correction module; 111-processor; 112-storage medium; 113-memory; 114-input and output interface; 115-wired or wireless network interface; 116-power supply; 1121-operating system; 1122-data; 1123-application. DETAILED DESCRIPTION

[0035] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0036] Please refer to Figure 1 , is a schematic diagram of an application environment applicable to the embodiment of the present application. Among them, Figure 1 A smart home system 10 is provided, which includes a sub-device 100, a gateway device 200 connected to the sub-device 100, and a server 300 connected to the gateway device 200. The number of the sub-device 100 may be at least one, and the number of the gateway device 200 may be at least one. In addition, when the number of the gateway devices 200 is multiple, different gateway devices 200 may also be connected to each other in communication.

[0037] In this embodiment, the gateway device 200 can be an intelligent gateway for smart home control, which can realize functions such as system information collection, information input, information output, centralized control, remote control, and linkage control. The gateway device 200 can be responsible for specific security alarms, home appliance control, and electricity consumption information collection. The gateway device 200 can also exchange information with products such as intelligent interactive terminals wirelessly. The gateway device 200 also has a wireless routing function, as well as excellent wireless performance, network security, and coverage area. The sub-device 100 connected to the gateway device 200 can exchange information and instructions with the gateway device 200. The gateway device 200 and the sub-device 100 can be connected through communication methods such as Bluetooth, WiFi (Wireless-Fidelity), and ZigBee. Of course, the connection method between the gateway device 200 and the sub-device 100 in the embodiment of this application may not be limited.

[0038] In this embodiment, the sub-device 100 may include a variety of smart devices, sensing devices, and detection devices arranged in the indoor space, such as smart TVs, smart refrigerators, smart air conditioners, smart door locks, temperature and humidity sensors, pressure sensors, smoke sensors, human body sensors, door and window sensors, smart switches, sockets, electric lights, infrared transmitting devices, camera devices, etc.

[0039] In this embodiment, the server 300 may be a local server, a cloud server, or other servers, and the specific server type may not be limited in the embodiment of the present application. The server 300 connected to the gateway device 200 may exchange information with the gateway device 200 wirelessly. The gateway devices 200 arranged in different indoor spaces may communicate with the same server 300 through the network to exchange information between the server 300 and the gateway device 200.

[0040] Optionally, the smart home system 10 may further include a terminal device 400. The terminal device 400 may include a personal computer (PC), a tablet computer, a smart phone, a personal digital assistant (PDA), etc., which are not limited here. The terminal device 400 may exchange information with the server 300 through wireless methods such as 2G / 3G / 4G / 5G / WiFi. Of course, the connection method between the terminal device 400 and the server 300 may not be limited in the embodiment of the present application. In some embodiments, the terminal device 400 may also be used to interact with users, so that users can wirelessly communicate with the gateway device 200 based on the router 500 through the terminal device 400. In addition, the user can add an account information to the gateway device 200 and the terminal device 400 at the same time, and realize the information synchronization of the gateway device 200 and the terminal device 400 through the account information.

[0041] The corresponding App is installed on the terminal device 400. When configuring the system, you must first add at least one gateway device 200 on the App. When adding other sub-devices 100, click the Add Sub-Device button in the App interface, and select the gateway device 200 that the sub-device 100 needs to access in the adding interface, so that the sub-device 100 is added to the ZigBee network corresponding to the gateway device 200, and together with other added sub-devices 100 and gateway devices 200, it forms a ZigBee local area network.

[0042] When the App, the router 500 and the gateway device 200 are in the same local area network, the App can interact with the gateway device 200 and the sub-device 100 connected to the gateway device 200 through the local area network path, and can also interact with the gateway device 200 and the sub-device 100 connected to the gateway device 200 through the wide area network path.

[0043] When the App, the router 500 and the gateway device 200 are not in the same local area network, the App interacts with the gateway device 200 and the sub-device 100 connected to the gateway device 200 through a wide area network path.

[0044] In some embodiments, the user can set different trigger scenarios or automation linkages through the App of the terminal device 400. As one way, the terminal device 400 can upload the scenario configuration information or automation scheme to the server 300, so that when the triggering condition of the triggering scenario or automation is reached, the server 300 can find the device corresponding to the execution action in the scenario configuration information or automation scheme according to the stored scenario configuration information or automation scheme, so as to notify the device to perform the execution action to meet the execution result of the triggering scenario or automation. As another way, the server 300 can also send the scenario configuration information or automation scheme to the gateway device 200, and the gateway device 200 can find the device corresponding to the execution action in the scenario configuration information or automation scheme according to the stored scenario configuration information or automation scheme. At the same time, the gateway device 200 can feedback the execution status of the device to the server 300.

[0045] Automation (or automation linkage) is a linkage application built between a gateway device 200 or a sub-device 100 connected to the gateway device 200; automation includes trigger conditions and execution actions. The devices in automation include trigger devices and controlled devices (or execution devices), which are communicatively connected through the gateway device 200. When the trigger device meets the trigger conditions, the gateway device 200 controls the controlled device to perform the corresponding execution action.

[0046] The trigger device may be various sensors such as a pressure sensor, a temperature sensor, a humidity sensor, a door / window sensor, or a smoke sensor.

[0047] The controlled device may be various switches, sockets, electric lights, infrared emitting devices or camera devices, etc. The triggering device and the controlled device may be the same device.

[0048] Below, we will use an example to illustrate automation. Figure 2As shown in the figure, suppose the user sets an automation linkage to automatically turn on the light when the doors and windows are opened. The condition of this scenario is that the doors and windows are opened, and the execution action is that the smart switch controls the light bulb to turn on the light. Based on this application scenario, the door and window sensor is set as the trigger device, and the smart switch connected to the light bulb is set as the controlled device. The specific execution principle is:

[0049] If the automation is performed locally on the gateway device 200 through the LAN path, the door and window sensors sense that the doors and windows are opened and report the event to the gateway device 200. After receiving the event that the doors and windows are opened, the gateway device 200 finds the corresponding device for executing the action based on the stored scene configuration information, which is the smart switch in this embodiment, and notifies the smart switch to turn on the lights, thereby realizing an automated linkage in which the lights are automatically turned on when the doors and windows are opened.

[0050] If the automatic execution is performed on the server 300 through the wide area network path, the door and window sensors sense that the doors and windows are opened, and report this time to the gateway device 200. After the gateway device 200 receives the event of the doors and windows being opened, the event is reported to the server 300 (cloud). The server 300 finds the corresponding device for executing the action based on the stored scene configuration information, which is a smart switch in this embodiment, and notifies the smart switch to turn on the light through the gateway device 200.

[0051] When the light is turned on, a message indicating that the light has been turned on successfully is fed back to the gateway device 200. After the gateway device 200 learns that the light has been turned on successfully, it reports the current time, the corresponding scene ID, and a message of success or failure to the server 300, which is responsible for storing the information.

[0052] The various embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0053] Please refer to Figure 3 , is a flow chart of an image processing method provided in an embodiment of the present application. It should be noted that the image processing method in the embodiment of the present application is not based on Figure 3 The specific order below is not limited. It should be understood that in other embodiments, the order of some steps in the image processing method of the present application can be interchanged according to actual needs, or some steps can be omitted or deleted. The image processing method can be applied to electronic devices, which can be various smart devices with image acquisition functions, for example, cameras, smart door locks with camera functions, etc. Figure 3 The specific process shown is described in detail.

[0054] Step S301, for a plurality of image blocks obtained by dividing the image to be processed, determine the color channel mean and image feature parameters corresponding to each image block; the image feature parameters represent the information richness of the image block.

[0055] In this embodiment, the image block refers to a block image of a preset size obtained by segmenting the image to be processed. When the electronic device segments the image to be processed, it is best to use an integer multiple of the image width and height, and a suitable size needs to be selected. If the block is too large, it is easy to fail to select a single color block, and if the block is too small, it is easy to be judged as a single color block.

[0056] For example, the preset size corresponding to the block image may be set to 16*16 (unit pixel), and then after the image to be processed is processed into blocks, a plurality of image blocks of 16*16 pixel size may be obtained.

[0057] Images generally have one or more color channels. For example, when the image to be processed is an RGB image, there will be three color channels, R for the red channel, G for the green channel, and B for the blue channel. Each color channel stores the information of the color elements in the image, and the colors in all color channels are superimposed and mixed to produce the color of the pixels in the image.

[0058] In this embodiment, the color channel mean corresponding to the image block can be obtained by calculating the mean of pixels of different color channels in the image block; the image feature parameter can be a parameter reflecting the characteristics of the image block, and the information richness of the image block can be characterized by the size of the image feature parameter. For example, when the image information of the image block is rich, the value of the image feature parameter corresponding to the image block is large, and when the image information of the image block is relatively simple, the value of the image feature parameter corresponding to the image block is small.

[0059] The image feature parameters may specifically be basic parameter information of the image, such as standard deviation, image information entropy, variance, etc., which may reflect the information richness of the image block.

[0060] Step S302: Calculate the correlation corresponding to each image block according to the image feature parameters.

[0061] In this embodiment, after determining the image feature parameters corresponding to each image block, the electronic device can calculate the correlation corresponding to each image block based on the image feature parameters. By calculating the correlation corresponding to each image block, it is convenient to subsequently select the color channel mean corresponding to the image block whose correlation meets the conditions to participate in the calculation of the gain value.

[0062] Step S303, determining the target color channel mean corresponding to the image to be processed according to the color channel mean corresponding to the image block whose correlation meets the threshold, and determining the gain value corresponding to the image to be processed according to the target color channel mean.

[0063] In this embodiment, after calculating the correlation corresponding to each image block, the electronic device compares the correlation corresponding to each image block with a set threshold, and can determine the image block whose correlation meets the threshold, and then perform weighted average calculation based on the color channel means corresponding to the image blocks whose correlation meets the threshold, to obtain the target color channel mean corresponding to the image to be processed, and calculate the gain value corresponding to the image to be processed based on the target color channel mean.

[0064] Since the correlation is calculated based on the image feature parameters of the image block, and the image feature parameters can reflect the information richness of the image block, the color channel mean corresponding to the image block whose correlation meets the threshold is selected to participate in the calculation of the gain value. In fact, the color channel mean corresponding to the image block whose information richness meets the conditions is selected to participate in the calculation of the gain value. Therefore, a more accurate gain value can be obtained. In this way, when a large area of ​​single color appears in the image, the influence of the large area of ​​single color on the gain calculation can be effectively eliminated, thereby effectively improving the accuracy of the gain calculation.

[0065] Step S304: performing image correction processing on each pixel in the image to be processed based on the gain value.

[0066] In this embodiment, the electronic device selects the color channel means corresponding to the image blocks whose correlation meets the threshold value to participate in the calculation of the gain value, thereby realizing the selection of the color channel means corresponding to the image blocks whose information richness meets the conditions to participate in the calculation of the gain value. In this way, image correction processing is performed on each pixel point in the processed image based on the calculated gain value, so that the color of the image after the image correction processing is closer to the color of the real object, thereby ensuring a better image correction effect when a large area of ​​a single color appears in the image.

[0067] The image correction processing in this embodiment may be performing white balance correction processing on the image to be processed, so that the image after the image correction processing has a better white balance effect.

[0068] The image processing method provided by the embodiment of the present application determines the color channel mean and image feature parameters corresponding to each image block for multiple image blocks obtained by dividing the image to be processed, calculates the correlation corresponding to each image block through the image feature parameters, selects the color channel mean corresponding to the image block whose correlation meets the threshold to participate in the calculation of the gain value, and because the image feature parameters can characterize the information richness of the image block, when a large area of ​​single color appears in the image, the color channel mean corresponding to the image block whose information richness meets the conditions can be selected to participate in the calculation of the gain value, thereby obtaining a more accurate gain value, and thus performing image correction processing on each pixel point in the image to be processed based on the calculated gain value, so that the image color after image correction processing is closer to the color of the real object, thereby ensuring that when a large area of ​​single color appears in the image, there is a better image correction effect. In addition, the algorithm used in the image processing method has a small amount of calculation and a fast execution speed, which maintains the advantage of the very fast execution speed of the gray world algorithm.

[0069] In one embodiment, the above-mentioned image feature parameters may include color channel standard deviation, wherein the color channel standard deviation can be understood as the standard deviation corresponding to each image block in different color channels; when the image information of the image block is rich, the standard deviation corresponding to the image block is larger, and when the image information of the image block is relatively simple, the standard deviation corresponding to the image block is smaller. Please refer to Figure 4 In the case where the image characteristic parameter is the color channel standard deviation, the above step S301 may include the following sub-steps:

[0070] Sub-step S3011, for multiple image blocks obtained by dividing the image to be processed, the color channel values ​​corresponding to all pixels in each image block are averaged to obtain the color channel mean corresponding to each image block.

[0071] In this embodiment, taking the case where the image to be processed has three color channels (R, G, B) as an example, the color channel values ​​corresponding to each pixel point include a red channel value, a green channel value, and a blue channel value, and the color channel means corresponding to each pixel block include a red channel mean, a green channel mean, and a blue channel mean.

[0072] For example, assuming that each image block includes 16*16 pixels, the electronic device can obtain the red channel mean value R corresponding to each image block by calculating the mean of the red channel value, green channel value, and blue channel value corresponding to each pixel in each image block. i,j , green channel mean G i,j , blue channel mean B i,j .

[0073] Sub-step S3012, calculating the color channel standard deviation corresponding to each image block according to the color channel mean corresponding to each image block and the color channel values ​​corresponding to all the pixels in each image block.

[0074] In this embodiment, since the color channel standard deviation refers to the standard deviation corresponding to each image block in different color channels, the color channel standard deviation corresponding to each image block may include a red channel standard deviation, a green channel standard deviation, and a blue channel standard deviation. When the electronic device calculates the red channel standard deviation corresponding to each image block, it can subtract the red channel mean from the red channel value corresponding to each pixel in the image block, calculate the sum of the squares of the differences, then calculate the mean, and perform square root calculation on the calculated mean to obtain the red channel standard deviation corresponding to the image block.

[0075] The following example illustrates the calculation process of the standard deviation. Assume that there are 4 pixels in an image block, and the red channel values ​​of the 4 pixels are 1, 2, 2, and 3 respectively. The mean value of the red channel of the image block is (1+2+2+3) / 4=2. Calculate the sum of the squares of the differences between the red channel values ​​corresponding to each pixel and the red channel mean value (1-2). 2 +(2-2) 2 +(2-2) 2 +(3-2) 2 =2, the mean is 2 / 4=0.5, and then the square root of 0.5 is taken to get the standard deviation of the red channel corresponding to the image block.

[0076] Similarly, when calculating the green channel standard deviation, the green channel value corresponding to each pixel in the image block can be subtracted from the green channel mean, the sum of the squares of the differences can be calculated, the mean can be obtained, and the square root calculation can be performed on the mean to obtain the green channel standard deviation corresponding to the image block; when calculating the blue channel standard deviation, the blue channel value corresponding to each pixel in the image block can be subtracted from the blue channel mean, the sum of the squares of the differences can be calculated, the mean can be obtained, and the square root calculation can be performed on the mean to obtain the blue channel standard deviation corresponding to the image block.

[0077] It can be seen that the image processing method provided in the embodiment of the present application calculates the color channel mean and color channel standard deviation corresponding to each image block, and the standard deviation can more accurately reflect the information richness of the image block. Therefore, according to the color channel standard deviation, the color channel mean corresponding to the image block whose information richness meets the conditions can be selected to participate in the calculation of the gain value, thereby effectively improving the accuracy of the gain calculation and avoiding the problem of gain deviation caused by the presence of a large area of ​​single color in the image.

[0078] In one embodiment, when calculating the correlation corresponding to each image block, the correlation between two adjacent image blocks in a preset direction may be used as the correlation corresponding to each image block. Based on this, the above-mentioned step S302 may include the following sub-steps: determining the correlation between each image block and the image blocks adjacent to the preset direction according to the image feature parameters of each image block, and obtaining the correlation corresponding to each image block; for the terminal image block in the preset direction, determining the correlation of the image block adjacent to the terminal image block in the opposite direction of the preset direction as the correlation corresponding to the terminal image block.

[0079] In this embodiment, the preset direction can be set according to actual needs. For example, for any image to be processed, the horizontal direction from left to right can be set as the preset direction, and the adjacent image blocks in the preset direction can be understood as the image blocks adjacent to the right side of the current image block. When calculating the correlation of the current image block, the image feature parameters of the current image block and the image feature parameters of the image blocks adjacent to the right side of the current image block are used as the basis, and the correlation between the current image block and the image block adjacent to the right side of the current image block is calculated and used as the correlation of the current image block.

[0080] The end image block in the preset direction is the image block located on the far right in the horizontal direction. Since there is no adjacent image block on its right side, the correlation cannot be calculated based on the correlation between the image blocks adjacent to the preset direction. Therefore, in this embodiment, the correlation of the image blocks adjacent to the left side of the end image block in the horizontal direction (that is, the image blocks adjacent in the direction opposite to the preset direction) is determined as the correlation corresponding to the end image block.

[0081] The following is an example of an implementation method for calculating correlation, taking the image feature parameters including the standard deviation of the three color channels R, G, and B as an example. Assume that the standard deviation of the image block in the three color channels R, G, and B is SR i,j SG i,j , SB i,j , i and j represent the coordinate values ​​of the image block, then we can use the formula Calculate the correlation of each image block; D i,j Represents the correlation of image patches with coordinates i and j.

[0082] Taking i as the vertical coordinate and j as the horizontal coordinate as an example, according to the above correlation calculation formula, when calculating the correlation of each image block, it is actually based on the image feature parameters of the two adjacent image blocks in the horizontal direction from left to right. Assuming that the image to be processed becomes 4*4 after block division, the value range of i is 1~4, and the value range of j is 1~3. The value of the correlation of the last image block (the end image block) in the horizontal direction is the same as the image block adjacent to the left side of the end image block in the horizontal direction, that is, D 1,4 =D 1,3 , D 2,4 =D 2,3 , D 3,4 =D 3,3 , D 4,4 =D 4,3 .

[0083] It can be seen that in this embodiment, the correlation between each image block and the image block adjacent to it in the preset direction is determined through the image feature parameters of each image block, and the correlation corresponding to each image block is obtained. For the terminal image block in the preset direction, the correlation of the image block adjacent to the terminal image block in the opposite direction of the preset direction is determined as the correlation corresponding to the terminal image block. In this way, the degree of correlation between the image block and its adjacent image blocks can be determined based on the size of the correlation corresponding to the image block, thereby facilitating the determination of whether the image block is a single color block.

[0084] In one embodiment, the electronic device obtains the target color channel mean corresponding to the image to be processed based on the color channel mean corresponding to the image block whose correlation meets the threshold, which may specifically include the following sub-steps:

[0085] If the correlation of the image block meets the threshold, a first identifier is added to the image block; if the correlation of the image block does not meet the threshold, a second identifier is added to the image block; according to the color channel mean corresponding to the image block with the first identifier, the target color channel mean corresponding to the image to be processed is determined; wherein the image block with the first identifier represents an image block with rich image colors.

[0086] That is to say, after calculating the correlation of each image block, the electronic device can compare the correlation with a threshold value and add a mark to each image block according to the comparison result. If the correlation of the image block meets the threshold value, a first mark is added to the image block; if the correlation of the image block does not meet the threshold value, a second mark is added to the image block. By adding different marks to the image block, it is used to indicate whether the image block is a single color block.

[0087] The threshold is set according to actual needs, for example, it is set to 0.12. When the correlation of the image block is greater than or equal to the threshold, it is considered that the correlation of the image block meets the threshold; when the correlation of the image block is less than the threshold, it is considered that the correlation of the image block does not meet the threshold. The first identifier indicates that the image block is not a single color block. Therefore, the image block with the first identifier added indicates that the image of the image block is rich in color; the second identifier indicates that the image block is a single color block. For example, the first identifier can be set to 1 and the second identifier can be set to 0.

[0088] Assuming the threshold is T, the first identifier is 1, and the second identifier is 0, the identifier corresponding to each image block can be expressed as: That is, according to the correlation D of each image block i,j Then you can set the corresponding flag S i,j Since the value of the correlation of the end image block in the preset direction is the same as that of the adjacent image block in the opposite direction of the preset direction, the identifier of the end image block in the preset direction is also the same as that of the adjacent image block in the opposite direction of the preset direction. 1,3 =1, then S 1,4 The value of is also 1.

[0089] After adding the corresponding identifier to the image block, the target color channel mean corresponding to the image to be processed is calculated according to the color channel mean corresponding to the image block with the first identifier, and the gain value corresponding to the image to be processed is calculated according to the target color channel mean. Since the image block with the first identifier represents the image block with rich colors, the image block with rich colors in the image to be processed is selected to participate in the calculation of the gain value to obtain a more accurate gain value, thereby effectively avoiding the problem of gain deviation caused by the presence of a large area of ​​single color in the image, and improving the accuracy of gain value calculation.

[0090] In one embodiment, since the color channel means include the red channel means, the green channel means and the blue channel means, the target color channel means corresponding to the image to be processed include the target red channel means, the target green channel means and the target blue channel means. Based on this, the electronic device determines the target color channel means corresponding to the image to be processed according to the color channel means corresponding to the image block to which the first identifier is added, which may specifically include the following sub-steps:

[0091] According to the red channel mean corresponding to the image block with the first identifier added, the target red channel mean corresponding to the image to be processed is determined; according to the green channel mean corresponding to the image block with the first identifier added, the target green channel mean corresponding to the image to be processed is determined; according to the blue channel mean corresponding to the image block with the first identifier added, the target blue channel mean corresponding to the image to be processed is determined.

[0092] As an implementation method, a weighted average calculation may be performed based on the identifiers corresponding to each image block and the color channel mean, thereby obtaining the target color channel mean corresponding to the image to be processed. i,j Add the corresponding identifier S to the image block i,j After that, the marker S i,j As the weight value, the red channel mean R corresponding to each image block i,j Perform weighted average calculation to obtain the weighted average value of the red channel corresponding to the image to be processed (i.e., the target red channel mean); mark S i,j As the weight value, the mean value of the green channel corresponding to each image block is G i,j Perform weighted average calculation to obtain the weighted average value of the green channel corresponding to the image to be processed (i.e., the target green channel mean); mark S i,j As the weight value, the blue channel mean B corresponding to each image block i,j Perform weighted average calculation to obtain the weighted average value of the blue channel corresponding to the image to be processed (i.e., the target blue channel mean).

[0093] For example, according to the formula Calculate the weighted average value of the red channel corresponding to the image to be processed; according to the formula Calculate the weighted average value of the green channel corresponding to the image to be processed; according to the formula Calculate the weighted average of the blue channel corresponding to the image to be processed; where i and j represent the coordinate values ​​of the image block, S i,j Indicates the label corresponding to the image block, R i,j represents the mean value of the red channel corresponding to the image block, G i,j represents the mean value of the green channel corresponding to the image block, B i,j Represents the mean of the blue channel corresponding to the image block; WR represents the target red channel mean corresponding to the image to be processed (i.e., the weighted average of the red channel); WG represents the target green channel mean corresponding to the image to be processed (i.e., the weighted average of the green channel); WB represents the target blue channel mean corresponding to the image to be processed (i.e., the weighted average of the blue channel).

[0094] According to the calculation formulas of WR, WG, and WB, when the first identifier is 1 and the second identifier is 0, when weighted average calculation is performed according to the identifiers corresponding to each image block and the color channel mean, in fact, only the image block with the first identifier added effectively participates in the calculation of the gain value, and the image block with the first identifier added represents the image block with rich image colors. Therefore, it is achieved that the image block with rich colors in the image to be processed (the image block with the first identifier added) is selected to participate in the calculation of the gain value, thereby effectively avoiding the problem of gain deviation caused by the presence of a large area of ​​single color in the image, and improving the accuracy of the gain value calculation.

[0095] In one embodiment, after the target red channel mean, target green channel mean, and target blue channel mean corresponding to the image to be processed are calculated, the gain values ​​corresponding to the three channels of R, G, and B of the image to be processed can be calculated according to the following sub-steps:

[0096] Calculate the sum of the target red channel mean, the target green channel mean and the target blue channel mean; calculate the red channel gain value corresponding to the image to be processed based on the sum and the target red channel mean; calculate the green channel gain value corresponding to the image to be processed based on the sum and the target green channel mean; calculate the blue channel gain value corresponding to the image to be processed based on the sum and the target blue channel mean.

[0097] For example, after calculating the sum of the target red channel mean WR, the target green channel mean WG, and the target blue channel mean WB (ie, WR+WG+WB), the formula Calculate the red channel gain value corresponding to the image to be processed; according to the formula Calculate the green channel gain value corresponding to the image to be processed; according to the formula Calculate the blue channel gain value corresponding to the image to be processed. gain Indicates the red channel gain value, G gain Indicates the green channel gain value, B gain Indicates the blue channel gain value.

[0098] In one embodiment, after the red channel gain value, the green channel gain value, and the blue channel gain value corresponding to the image to be processed are calculated, gain correction can be performed on each pixel in the image to be processed based on the red channel gain value, the green channel gain value, and the blue channel gain value, that is, the above-mentioned step S304 includes the following sub-steps:

[0099] Perform gain correction on each pixel in the red channel according to the red channel gain value; perform gain correction on each pixel in the green channel according to the green channel gain value; perform gain correction on each pixel in the blue channel according to the blue channel gain value.

[0100] For example, the color channel value of each pixel in the original image to be processed is represented as R in (red channel value), G in (green channel value), B in (blue channel value), the color channel value of each pixel in the gain-corrected image is represented as R out , G out , B out , then the red channel gain value R corresponding to the image to be processed is calculated gain, Green channel gain value G gain And the blue channel gain value B gain After that, the gain correction can be performed on each pixel in the three channels of R, G, and B as follows:

[0101] After the gain correction is completed, the red channel value, green channel value, and blue channel value of each pixel are adjusted to the range of [0, 255] to obtain the image after white balance correction. Figure 5 As shown in the figure, (a) represents the original image captured, and (b) represents the image obtained after white balance correction of the original image. By comparing (a) and (b), it can be seen that the image after white balance correction is closer to the color of the real object, and a better white balance effect can be achieved when a large area of ​​single color appears in the image.

[0102] It should be noted that, taking the electronic device as a camera as an example, the color of the image collected by the camera will be different at different color temperatures throughout the day. In the case of white light, the values ​​of the three color channels (R, G, B) of the image are the same, and the ratios of R / G and B / G are also the same. When the ratios of R / G and B / G are different, it indicates that the color temperature has changed. At this time, the camera needs to call the white balance interface to perform white balance correction on the image.

[0103] It should be understood that for automatic white balance, regardless of whether the color temperature changes or to what extent, as long as the camera captures an image, the white balance interface can be called to achieve real-time white balance correction of the image. For example, cameras on smart door locks, smart cameras for home use, and other network cameras can achieve automatic white balance. For non-automatic white balance, manual judgment and setting are required. When the white balance interface needs to be called, it is called manually. For example, for SLR cameras, the correction gear can be manually selected. When the user flips the gear switch, the white balance interface is enabled for correction. When the user flips the gear switch back, the white balance interface is closed.

[0104] It should also be noted that, in actual applications, the white balance corrected image can be output by the electronic device in real time to the APP of the terminal device 400 for display. For electronic devices with display screens, such as smart door locks, cameras and other screen devices with display screens, the white balance corrected image can also be displayed directly on its own screen.

[0105] Below, taking the door lock scene as an example, the application of the above-mentioned image processing method in the door lock scene is explained. The user uses the App installed on the terminal device 400 to add the gateway device 200, and adds the smart door lock, door and window sensor, smart switch, etc. as sub-devices into the ZigBee network corresponding to the gateway device 200, and together with the gateway device 200, forms a ZigBee local area network. The user sets an automation scheme for automatically turning on the lights when the doors and windows are opened. When the door and window sensor detects that the smart door lock is opened, the smart switch will control the light bulb connected to it to turn on the light. The smart door lock is provided with a camera, which can shoot the real-time scene within the camera area. The captured image information can be displayed on the smart door lock, or the smart door lock can send the captured image information to the APP of the terminal device 400 through the local area network path or the wide area network path for display, so that the user can view the real-time scene within the camera area in real time. The smart door lock can also use the image information captured by the camera to identify the target object (for example, face recognition). When the target object is recognized to appear within the camera area, the smart door lock can be automatically opened.

[0106] In order to make the images captured by the camera accurately reflect the real color of the object being photographed and improve the color cast that may occur in the captured image, the camera will call the white balance interface when collecting images to achieve real-time white balance correction of the image. The process of the camera performing white balance correction on the collected image is as follows: (1) Divide the image to be processed into small blocks of 16×16 (unit pixels);

[0107] (2) Calculate the pixel average value (R) of the three channels of R, G, and B for each small block. i,j , G i,j , B i,j ) and standard deviation (SR i,j SG i,j , SB i,j );

[0108] (3) Calculate the correlation D of each small block based on the standard deviation of the three color channels R, G, and B corresponding to each small block i,j ,

[0109] (4) According to the correlation D i,j Set a flag S for each small block i,j , That is, the correlation D i,j The block with the set threshold T is compared to determine whether the mark is 0 or 1. The block with the mark 1 indicates that it is not a single color block, and the block with the mark 0 indicates a single color block. The mark of the block at the end of the horizontal direction is the same as the mark of the block adjacent to it in the horizontal direction, for example, S 1,3The value of is 1, then S 1,4 The value of is also 1;

[0110] (5) According to the label corresponding to each small block and the pixel average value of the three channels of R, G, and B (R i,j , G i,j , B i,j ), realize the calculation of the weighted average value WR of the red channel, the weighted average value WG of the green channel and the weighted average value WB of the blue channel based on the weighted standard deviation,

[0111] (6) Calculate the gain values ​​of the three channels R, G, and B of the image to be processed, and the gain value of the red channel Green channel gain value Blue channel gain value

[0112] (7) According to the gain values ​​of the three channels R, G, and B, gain correction is performed on each pixel point (720*1280) in the three channels R, G, and B, that is, Thus, the color channel value R of each pixel in the gain-corrected image is obtained. out , G out , B out Finally, R out , G out , B out By adjusting it to the range of [0, 255], you can get the image after white balance correction.

[0113] After the camera performs white balance correction on the captured image, the white balance corrected image can be sent by the smart door lock to the APP of the terminal device 400 through the LAN path or the WAN path for display. If the smart door lock has a display screen, the white balance corrected image can also be displayed on the smart door lock. The smart door lock can also perform face recognition based on the white balance corrected image or send the white balance corrected image to the server 300 through the WAN path for face recognition. When the target face is recognized, the door lock is automatically opened. At this time, the door and window sensors sense that the door lock is opened and report the event to the gateway device 200. The gateway device 200 notifies the smart switch to turn on the light, thereby realizing an automated solution for automatically turning on the light when the door and window are opened.

[0114] It can be seen that the image processing method provided in this embodiment proposes an automatic white balance algorithm based on standard deviation weighting. When the image information is rich, the image standard deviation is larger, and when the image is relatively simple, the standard deviation is smaller. According to this principle, the image blocks with rich colors in the image are selected to calculate the gain values ​​of the three channels of R, G, and B. This effectively addresses the problem in the prior art that the grayscale world algorithm has poor effect when a large area of ​​a single color appears in the image. The entire white balance correction process has a small amount of calculation and a fast execution speed. It not only maintains the advantage of the fast execution speed of the grayscale world algorithm, but also eliminates the influence of a large area of ​​a single color in the image on the white balance effect.

[0115] In order to execute the corresponding steps in the above embodiments and various possible methods, an implementation method of an image processing device is given below. Figure 6 , which is a functional module diagram of an image processing device 600 provided in an embodiment of the present invention. It should be noted that the basic principle and technical effects of the image processing device 600 provided in this embodiment are the same as those of the above-mentioned embodiment. For the sake of brief description, for parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above-mentioned embodiment. The image processing device 600 includes a feature parameter calculation module 610, a correlation calculation module 620, a gain calculation module 630 and an image correction module 640.

[0116] The feature parameter calculation module 610 is used to determine the color channel mean and image feature parameters corresponding to each image block for multiple image blocks obtained by dividing the image to be processed; the image feature parameters represent the information richness of the image block.

[0117] It can be understood that the characteristic parameter calculation module 610 can execute the above step S301.

[0118] The correlation calculation module 620 is used to calculate the correlation corresponding to each image block according to the image feature parameters.

[0119] It can be understood that the correlation calculation module 620 can execute the above step S302.

[0120] The gain calculation module 630 is used to determine the target color channel mean corresponding to the image to be processed according to the color channel mean corresponding to the image block whose correlation meets the threshold, and determine the gain value corresponding to the image to be processed according to the target color channel mean.

[0121] It can be understood that the gain calculation module 630 can execute the above step S303.

[0122] The image correction module 640 is used to perform image correction processing on each pixel in the image to be processed based on the gain value.

[0123] It can be understood that the image correction module 640 can execute the above step S304.

[0124] Optionally, the image feature parameters include a color channel standard deviation. The feature parameter calculation module 610 can be used to calculate the mean of the color channel values ​​corresponding to all pixels in each image block for multiple image blocks obtained by dividing the image to be processed, so as to obtain the color channel mean corresponding to each image block; and calculate the color channel standard deviation corresponding to each image block based on the color channel mean corresponding to each image block and the color channel values ​​corresponding to all pixels in each image block.

[0125] It can be understood that the characteristic parameter calculation module 610 can execute the above sub-steps S3011 and S3012.

[0126] Optionally, the correlation calculation module 620 can be specifically used to determine the correlation between each image block and the image blocks adjacent to it in a preset direction based on the image feature parameters of each image block, so as to obtain the correlation corresponding to each image block; for the terminal image block in the preset direction, the correlation of the image blocks adjacent to the terminal image block in the direction opposite to the preset direction is determined as the correlation corresponding to the terminal image block.

[0127] Optionally, the gain calculation module 630 can be used to add a first identifier to the image block if the correlation of the image block meets the threshold; if the correlation of the image block does not meet the threshold, add a second identifier to the image block; determine the target color channel mean corresponding to the image to be processed based on the color channel mean corresponding to the image block with the first identifier added; wherein the image block with the first identifier added represents an image block with rich image colors.

[0128] Among them, the gain calculation module 630 is specifically used to determine the target red channel mean corresponding to the image to be processed according to the red channel mean corresponding to the image block with the first identifier added; determine the target green channel mean corresponding to the image to be processed according to the green channel mean corresponding to the image block with the first identifier added; determine the target blue channel mean corresponding to the image to be processed according to the blue channel mean corresponding to the image block with the first identifier added.

[0129] Optionally, the target color channel mean includes a target red channel mean, a target green channel mean and a target blue channel mean, and the gain calculation module 630 is further specifically used to calculate the sum of the target red channel mean, the target green channel mean and the target blue channel mean; calculate the red channel gain value corresponding to the image to be processed based on the sum and the target red channel mean; calculate the green channel gain value corresponding to the image to be processed based on the sum and the target green channel mean; calculate the blue channel gain value corresponding to the image to be processed based on the sum and the target blue channel mean.

[0130] Optionally, the image correction module 640 can be used to perform gain correction on each pixel in the red channel according to the red channel gain value; perform gain correction on each pixel in the green channel according to the green channel gain value; and perform gain correction on each pixel in the blue channel according to the blue channel gain value.

[0131] It can be seen that in the image processing device 600 provided by the embodiment of the present application, the feature parameter calculation module 610 determines the color channel mean and image feature parameters corresponding to each image block for multiple image blocks obtained by dividing the image to be processed, the correlation calculation module 620 calculates the correlation corresponding to each image block through the image feature parameters, and the gain calculation module 630 selects the color channel mean corresponding to the image block whose correlation meets the threshold to participate in the calculation of the gain value. Since the image feature parameter can characterize the information richness of the image block, when a large area of ​​single color appears in the image, the color channel mean corresponding to the image block whose information richness meets the conditions can be selected to participate in the calculation of the gain value, thereby obtaining a more accurate gain value. In this way, the image correction module 640 performs image correction processing on each pixel in the image to be processed based on the calculated gain value, so that the image color after the image correction processing is closer to the real object color, thereby ensuring a better image correction effect when a large area of ​​single color appears in the image.

[0132] The electronic device provided in an embodiment of the present application may include a processor and a memory, in which at least one instruction, at least one program, a code set or an instruction set is stored. The at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the image processing method provided in the above method embodiment.

[0133] The memory can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required for functions, etc.; the data storage area can store data created according to the use of the device, etc. In addition, the memory can include a high-speed random access memory and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory can also include a memory controller to provide the processor with access to the memory.

[0134] Figure 7 is a hardware structure block diagram of an electronic device provided in an embodiment of the present application. Figure 7As shown, the electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors (Processing Units, CPU) 111 (the processor 111 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 113 for storing data, and one or more storage media 112 (such as one or more mass storage devices) for storing application programs 1123 or data 1122. Among them, the memory 113 and the storage medium 112 can be short-term storage or permanent storage. The program stored in the storage medium 112 may include one or more modules, each of which may include a series of instruction operations in the electronic device. Furthermore, the processor 111 can be configured to communicate with the storage medium 112 to execute a series of instruction operations in the storage medium 112 on the electronic device. The electronic device may also include one or more power supplies 116, one or more wired or wireless network interfaces 115, one or more input and output interfaces 114, and / or one or more operating systems 1121, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, FreeBSD TM, etc.

[0135] The input / output interface 114 may be used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of the electronic device. In one example, the input / output interface 114 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the input / output interface 114 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0136] It can be understood by those skilled in the art that Figure 7 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 7 More or fewer components as shown, or with Figure 7 Different configurations are shown.

[0137] The electronic device provided in the embodiment of the present application determines the color channel mean and image feature parameters corresponding to each image block for multiple image blocks obtained by dividing the image to be processed, calculates the correlation corresponding to each image block through the image feature parameters, and selects the color channel mean corresponding to the image block whose correlation meets the threshold to participate in the calculation of the gain value. Since the image feature parameters can characterize the information richness of the image block, when a large area of ​​single color appears in the image, the color channel mean corresponding to the image block whose information richness meets the conditions can be selected to participate in the calculation of the gain value, thereby obtaining a more accurate gain value. In this way, image correction processing is performed on each pixel point in the image to be processed based on the calculated gain value, so that the color of the image after the image correction processing is closer to the color of the real object, thereby ensuring a better image correction effect when a large area of ​​single color appears in the image.

[0138] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned image processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0139] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0140] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a gateway, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0141] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. An image processing method, characterized in that: The method comprises: For multiple image blocks obtained by dividing the image to be processed, determining the color channel mean and image feature parameters corresponding to each image block; the image feature parameters represent the information richness of the image block; According to the image feature parameters, the correlation corresponding to each of the image blocks is calculated; the image feature parameters include standard deviations on three color channels of R, G, and B, and the correlation corresponding to the image block is calculated according to the ratio of the sum of the absolute values ​​of the differences between the image block and the adjacent image blocks in a preset direction on each color channel to the sum of the absolute values ​​of the sum of the standard deviations on each color channel; Determine the target color channel mean corresponding to the image to be processed according to the color channel mean corresponding to the image block whose correlation meets the threshold, and determine the gain value corresponding to the image to be processed according to the target color channel mean; Image correction processing is performed on each pixel in the image to be processed based on the gain value.

2. The method according to claim 1, characterized in that The calculating, according to the image feature parameters, the correlation corresponding to each of the image blocks comprises: Determine, according to the image feature parameters of each image block, the correlation between each image block and an adjacent image block in a preset direction, and obtain the correlation corresponding to each image block; For the terminal image block in the preset direction, the correlation of the image blocks adjacent to the terminal image block in the direction opposite to the preset direction is determined as the correlation corresponding to the terminal image block.

3. The method according to claim 1, characterized in that Determining the target color channel mean corresponding to the image to be processed according to the color channel mean corresponding to the image block whose correlation meets the threshold comprises: If the correlation of the image block meets the threshold, adding a first identifier to the image block; If the correlation of the image block does not meet the threshold, adding a second identifier to the image block; The target color channel mean corresponding to the image to be processed is determined according to the color channel mean corresponding to the image block with the first identifier added thereto; wherein the image block with the first identifier added thereto represents an image block with rich image colors.

4. The method according to claim 3, characterized in that The step of determining the target color channel mean corresponding to the image to be processed according to the color channel mean corresponding to the image block to which the first identifier is added comprises: Determining a target red channel mean corresponding to the image to be processed according to a red channel mean corresponding to the image block to which the first identifier is added; Determining a target green channel mean value corresponding to the image to be processed according to a green channel mean value corresponding to the image block to which the first identifier is added; A target blue channel mean value corresponding to the image to be processed is determined according to the blue channel mean value corresponding to the image block to which the first identifier is added.

5. The method according to claim 1, characterized in that The target color channel means include a target red channel mean, a target green channel mean, and a target blue channel mean, and determining the gain value corresponding to the image to be processed according to the target color channel means includes: Calculate the sum of the target red channel mean, the target green channel mean and the target blue channel mean; Calculate the red channel gain value corresponding to the image to be processed according to the sum value and the target red channel mean; Calculating a green channel gain value corresponding to the image to be processed according to the sum value and the target green channel mean value; A blue channel gain value corresponding to the image to be processed is calculated according to the sum value and the target blue channel mean value.

6. The method according to claim 5, characterized in that The performing image correction processing on each pixel in the image to be processed based on the gain value includes: Performing gain correction on each pixel in the red channel according to the red channel gain value; Performing gain correction on each pixel in the green channel according to the green channel gain value; Gain correction is performed on each pixel in the blue channel according to the blue channel gain value.

7. The method according to any one of claims 1 to 6, characterized in that: The image characteristic parameters include a color channel standard deviation, and the color channel mean and image characteristic parameters corresponding to each image block are determined for the plurality of image blocks obtained by dividing the image to be processed into blocks, including: Calculate the mean of the color channel values ​​corresponding to all the pixels in each of the image blocks to obtain the color channel mean corresponding to each of the image blocks; The color channel standard deviation corresponding to each image block is calculated according to the color channel mean corresponding to each image block and the color channel values ​​corresponding to all the pixels in each image block.

8. An image processing device, characterized in that: The device comprises: A feature parameter calculation module is used to determine the color channel mean and image feature parameters corresponding to each image block for a plurality of image blocks obtained by dividing the image to be processed; the image feature parameters represent the information richness of the image block; A correlation calculation module, used to calculate the correlation corresponding to each of the image blocks according to the image feature parameters; the image feature parameters include standard deviations on three color channels of R, G, and B, and the correlation corresponding to the image block is calculated according to the ratio of the sum of the absolute values ​​of the difference between the standard deviations of the image block and the adjacent image blocks in a preset direction on each color channel to the sum of the absolute values ​​of the sum of the standard deviations on each color channel; A gain calculation module, used to determine a target color channel mean corresponding to the image to be processed according to a color channel mean corresponding to the image block whose correlation meets a threshold, and determine a gain value corresponding to the image to be processed according to the target color channel mean; The image correction module is used to perform image correction processing on each pixel point in the image to be processed based on the gain value.

9. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the image processing method according to any one of claims 1 to 7 when executed by the processor.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image processing method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Original data white balance system and method based on digital camera

    CN103686113A

  • SP-FCN-based MRI brain tumor image segmentation system and method

    CN111932549A