Image processing method and electronic device
By identifying and correcting the local color cast area of the image in a mixed light source scene, and using bilateral grid information to perform matrix adjustment, the problem of local color cast in the image caused by automatic white balance processing is solved, and the authenticity and quality of the image are improved.
Patent Information
- Application Number
- CN202311119808.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2043-08-31
AI Technical Summary
In mixed light source scenarios, automatic white balance processing can easily lead to local color casts in the image. Existing technologies are difficult to effectively solve this problem, affecting the authenticity and quality of the image.
By obtaining the initial image and the image after automatic white balance processing, the color cast area is determined, and the bilateral grid information generated by the preset network model is used to calculate the adjustment matrix corresponding to the color cast area, and the local color cast correction is performed on the image to generate Correct the image.
Effectively identify and correct local color cast areas in images, improve image authenticity and quality, and reduce color errors caused by automatic white balance processing.
Smart Images

Figure CN117692788B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method and electronic equipment. Background Art
[0002] The color of an object is determined by its reflectivity characteristics. Under the influence of factors such as different lighting conditions, the color presented by the object may be different. During the image acquisition process, due to changes in external color temperature, shooting scene switching or white balance (white balance) adjustment deviation, electronic equipment will be affected by factors such as the external light environment and the characteristics of the imaging photosensitive components themselves, resulting in a certain degree of error between the imaging color and the true color of the object, that is, color cast. Color cast may cause the image to lack a sense of reality, thereby reducing image quality. Usually, electronic devices use automatic white balance (AWB) to adjust the color cast of the image. However, AWB is a global adjustment method, which is prone to cause local color cast of the image in mixed light source scenes. In mixed light source scenes, how to solve the problem of local color cast of the image caused by AWB processing is an urgent problem to be solved. Summary of the invention
[0003] The embodiments of the present application provide an image processing method and an electronic device, which can reduce the local color cast problem of an image caused by automatic white balance processing.
[0004] In a first aspect, the method may be executed by an electronic device, or by a device matched with the electronic device, such as a processor, a chip, or a chip system. The method may include: in response to a click operation on a shooting control, acquiring an initial image, and performing automatic white balance processing on the initial image to obtain a first image; determining a second image based on the initial image and the first image; the second image includes a color cast area of the first image; inputting the first image and the second image into a preset network model to obtain bilateral grid information output by the preset network model; the bilateral grid information includes an adjustment matrix corresponding to the color cast area; performing color cast correction processing on the first image based on the adjustment matrix corresponding to the color cast area to obtain a corrected image; and displaying the corrected image on a preview interface.
[0005] It can be seen that the present application can determine the color cast area based on the initial image and the first image, and obtain bilateral grid information based on a preset network model; based on the bilateral grid information, the color cast area can be corrected to obtain a corrected image, thereby eliminating the local color cast problem of the image caused by automatic white balance processing and improving the authenticity and image quality of the image.
[0006] In a possible implementation, the method for determining the second image based on the initial image and the first image may include: determining whether pixel i is a color-cast pixel or a non-color-cast pixel based on the RGB value of pixel i in the first image and the RGB value of pixel j in the initial image; the pixel i corresponds to pixel j; determining the color-cast area and the non-color-cast area of the first image based on whether pixel i is a color-cast pixel or a non-color-cast pixel; and marking the color-cast area and the non-color-cast area in the first image respectively to obtain the second image.
[0007] It can be seen that based on the RGB value of pixel i in the first image and the RGB value of pixel j corresponding to pixel i in the initial image, it can be determined whether pixel i is color cast, thereby determining the color cast area and non-color cast area of the first image, which is conducive to improving the accuracy of determining the local color cast of the image.
[0008] In one possible implementation, determining whether pixel i is a color-cast pixel or a non-color-cast pixel based on the RGB value of pixel i in the first image and the RGB value of pixel j in the initial image may include: determining that pixel i is a color-cast pixel in response to the channel size relationship of the RGB value of pixel i in the first image being different from the channel size relationship of the RGB value of pixel j in the initial image; determining that pixel i is a non-color-cast pixel in response to the channel size relationship of the RGB value of pixel i in the first image being different from the channel size relationship of the RGB value of pixel j in the initial image; wherein the channel size relationship is used to indicate the size relationship between channels in the RGB value.
[0009] It can be seen that whether a pixel is a color cast pixel can be determined based on the channel size relationship, which is conducive to improving the accuracy of determining the color cast area.
[0010] In a possible implementation, the bilateral grid information also includes multiple brightness intervals, multiple grid areas and multiple adjustment matrices; based on this, the above method may also include: based on the brightness of pixel i, determining the brightness interval corresponding to pixel i from multiple brightness intervals; the brightness of pixel i is determined based on the RGB value of pixel i; based on the position of pixel i in the first image, determining the grid area corresponding to pixel i from multiple grid areas; based on the grid area corresponding to pixel i and the brightness interval corresponding to pixel i, determining the adjustment matrix corresponding to pixel i from multiple adjustment matrices; based on the adjustment matrix corresponding to pixel i, determining the adjustment matrix corresponding to the color cast area and the adjustment matrix corresponding to the non-color cast area of the first image.
[0011] It can be seen that the corresponding adjustment matrix can be found from the bilateral grid information through the RGB value of each pixel in the first image.
[0012] In a possible implementation, based on an adjustment matrix corresponding to the color cast area, performing color cast correction processing on the first image to obtain a corrected image may include: based on an adjustment matrix corresponding to the color cast area and an adjustment matrix corresponding to the non-color cast area, performing color cast correction on the first image to obtain a corrected image; wherein the adjustment matrix corresponding to the color cast area is a non-unit matrix, and the adjustment matrix corresponding to the non-color cast area is a unit matrix.
[0013] It can be seen that the adjustment matrix corresponding to the color cast area and the adjustment matrix corresponding to the non-color cast area can be found from the bilateral grid information, and the color cast correction can be performed on the color cast area while ensuring that the non-color cast area remains unchanged, thereby realizing local color cast correction for the first image and increasing the accuracy and effectiveness of the color cast correction.
[0014] In a possible implementation, color cast correction is performed on the first image based on the adjustment matrix corresponding to the color cast area and the adjustment matrix corresponding to the non-color cast area to obtain a corrected image, which may include: obtaining a target RGB matrix corresponding to pixel i based on the RGB matrix corresponding to the RGB value of pixel i and the adjustment matrix corresponding to pixel i; determining a target RGB value of pixel i based on the target RGB matrix corresponding to pixel i; determining a target RGB value corresponding to the color cast area and a target RGB value corresponding to the non-color cast area based on the target RGB value of pixel i; and determining a corrected image based on the target RGB value corresponding to the color cast area and the target RGB value corresponding to the non-color cast area.
[0015] It can be seen that based on the adjustment matrix, the RGB value of each pixel can be adjusted to achieve color cast correction for the color cast area.
[0016] In a possible implementation, the method may further include: downsampling the first image to obtain a first image of a preset size; based on this, the first image and the second image are input into a preset network model to obtain bilateral grid information output by the preset network model, which may include: inputting the first image and the second image of a preset size into a preset network model to obtain bilateral grid information output by the preset network model; wherein the image size of the second image is a preset size.
[0017] It can be seen that by downsampling the first image based on the preset size, the thumbnail of the first image (i.e., the first image of the preset size) can be obtained without changing the color-cast area and the non-color-cast area in the first image; inputting the first image and the second image of the preset size into the preset network model is conducive to the preset network model generating bilateral grid information.
[0018] In a second aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method described in the first aspect or any one of the implementation methods of the first aspect.
[0019] In a third aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to execute the method described in the first aspect or any one of the implementations of the first aspect.
[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on an electronic device, enable the electronic device to execute the method described in the first aspect or any one of the implementations of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1A-1B It is a schematic diagram of an image processing effect provided by an embodiment of the present application;
[0022] Figure 2 is a schematic diagram of a user interface provided in an embodiment of the present application;
[0023] Figure 3 It is a flowchart of an image processing method provided in an embodiment of the present application;
[0024] Figure 4A is a schematic diagram of a grid area division provided in an embodiment of the present application;
[0025] Figure 4B It is a schematic diagram of a coordinate system provided in an embodiment of the present application;
[0026] Figure 4C is a schematic diagram of a first image provided in an embodiment of the present application;
[0027] Figure 4D is a schematic diagram of a second image provided in an embodiment of the present application;
[0028] Figure 5 This is a schematic diagram of the interaction between various modules of an electronic device provided in an embodiment of the present application;
[0029] Figure 6 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0030] Figure 7 It is a schematic diagram of a software framework of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] The embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0032] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0033] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0034] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0035] The terms "component", "module", "system", etc. used in this specification are used to represent computer-related entities, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program and / or a computer. By way of illustration, both applications running on a computing device and a computing device can be components. One or more components may reside in a process and / or an execution thread, and a component may be located on a computer and / or distributed between two or more computers. In addition, these components may be executed from various computer-readable media having various data structures stored thereon. Components may, for example, communicate through local and / or remote processes according to signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system and / or a network, such as the Internet interacting with other systems through signals).
[0036] Color temperature is used to define the color of a light source. Color temperature refers to the color of an absolute black body after being heated from absolute zero (-273℃). When heated to a certain temperature, the spectral components of the light emitted by an absolute black body are called the color temperature at this temperature, and the unit of measurement is Kelvin (K). For example, after being heated, the color of an absolute black body gradually changes from black to red, then gradually to yellow, white, and finally to blue. If the light emitted by a certain light source has the same spectral components as the light emitted by a black body at a certain temperature, it is called a certain K color temperature. For example, the color of the light emitted by a 100W bulb is the same as the color of an absolute black body at 2527℃, then the color temperature of the light emitted by this bulb is: (2527+273)K=2800K. When the color of light is reddish, orange, or yellowish, it can be called a low color temperature. When the color of light is cyan, blue, or blue-purple, it can be called a high color temperature. When the color of light is white, it can be called a normal color temperature. The color of an object can only show its normal color when it is illuminated by white light.
[0037] For example, please refer to the color temperature comparison table of common light source types shown in Table 1.
[0038] Table 1, color temperature comparison table
[0039] Type of light source Color temperature (K) RGB match flame 1700 (255,124,0) candle flame 1800 (255,126,0) Incandescent light bulb 2700-3300 (255,174,84) Photography floodlight 3400 (255,198,130) moonlight 4100 (255,215,166) Horizon Sunlight 5000 (255,231,204) Electronic flash 5500-6000 (255,238,222) Fluorescent lamp 6500 (255,249,251)
[0040] As shown in Table 1, different types of light sources have different color temperatures, corresponding to different colors, and can be represented by different RGB values. Among them, the color temperature of an incandescent bulb is 2700K to 3300K, and (255, 174, 84) in Table 1 is the RGB value corresponding to 2700K; the color temperature of an electronic flash is 5500K to 6000K, and (255, 238, 222) in Table 1 is the RGB value corresponding to 5500K.
[0041] Due to the different spectral characteristics of different lighting, objects present 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. During the image acquisition process, electronic devices, such as smartphones, will experience color cast in the images generated by the electronic devices due to factors such as changes in the color temperature of the shooting environment, switching of shooting scenes, or deviations in the white balance adjustment of the camera, which will reduce the degree of restoration of the image to the real scene. Therefore, it is necessary to correct the color cast of images taken by electronic devices under light sources of different color temperatures.
[0042] Since the reflection of the red, green and blue channels in a white scene is the same, the values of the red, green and blue channels in a white scene are equal, so the color cast caused by light sources of different color temperatures can be corrected based on white. For example, before outputting the captured photos, the electronic device will perform automatic white balance (AWB) processing on the image to achieve global color cast correction. Exemplarily, usually, in the process of performing AWB on the image, the white point in the image is first determined, the color temperature of the light source is determined according to the pixel value of the white point, and then the white balance adjustment parameters of the image are determined according to the color temperature, and the image is globally white balanced using the white balance adjustment parameters. However, this correction method is only applicable to images under a single light source. For scenes with two or more mixed light sources, the white balance processing method will perform global color cast correction based on one of the light sources, or based on the weighted average of multiple light sources, which will cause local color cast in the image and fail to solve the color cast problem.
[0043] For example, the color temperature of ordinary fluorescent lamps is usually between 4500K and 6000K, and the color temperature of fluorescent lamps is usually 6500K, where K represents the color temperature unit Kelvin. In a mixed light source scene with two color temperatures of 4500K and 6500K, after determining the white point corresponding to 4500K and the white point corresponding to 6500K through the above-mentioned white balance processing method, the image will be white balanced according to the intermediate color temperature of 5500K between 4500K and 6500K. Therefore, it will inevitably cause local color cast in the image. In addition, under mixed light sources, when the image area corresponding to a certain color temperature only occupies a small part of the image, the white balance processing of this area may be lost, reducing the image quality.
[0044] In such Figure 1A In the mixed light source scene shown, the light sources come from LED light boxes, tungsten filament lamps, floor lamps, etc. Among them, the tungsten filament lamps emit yellow light; the floor lamps emit white light; the LED light strips in the LED light box originally emit white light, but the surface of the LED light box is covered with advertising content in colors including blue, orange, and yellow. The color temperatures of the above-mentioned light sources are different. Under the illumination of such mixed color light sources, electronic devices shooting such as Figure 1AThe photo obtained from the picture shown in the figure has a local color cast after AWB processing. For example, the white texts such as "Hi" and "This is a light box" on the surface of the LED light box appear grayish blue, and the RGB value of the word "Hi" can be expressed as (183, 255, 255).
[0045] In order to reduce the local color cast problem of the image caused by AWB processing in a mixed light source scene, an embodiment of the present application provides an image processing method that can be applied to local color cast correction in a mixed light source scene. It can identify the color cast area of the image and perform targeted correction on the color cast area, which can not only solve the local color cast problem of the image, but also will not affect the color effect of other areas of the image.
[0046] Exemplarily, the image processing method provided in the embodiment of the present application is used to process the image Figure 1A By processing the image shown in FIG. 1 , the color cast area in the image can be accurately identified and local color cast correction can be performed, thereby obtaining the following Figure 1B Images shown. Compare Figure 1A and Figure 1B Available, Figure 1B The local color cast problem has been significantly improved, among which, Figure 1B The white text on the LED light box shown appears white. For example, the RGB value of the word "hi" after correction can be expressed as (251, 253, 253).
[0047] First, the user interface involved in the embodiments of the present application is introduced.
[0048] like Figure 2 As shown in Figure 1, the electronic device 100 may display a home screen interface 210, in which a page with application icons is displayed. The page includes multiple application icons, for example, a camera application icon 211. The electronic device 100 may detect an operation on the camera application icon 211, for example, the electronic device 100 may detect an operation of a user clicking or touching the camera application icon 211. In response to the operation, the electronic device 100 may display a Figure 2 The shooting interface 220 is shown in FIG.
[0049] like Figure 2 As shown in Figure B, the shooting interface 220 can display a camera switching control 221, a shooting control 222, an image echo control 223, and a scene display area 224. The image echo control 223 can be used to display the captured image; the shooting control 222 is used to trigger the camera to shoot and save the image; the camera switching control 221 can be used to switch the camera for taking pictures, such as switching from the rear camera to the front camera; the scene display area 224 can display a preview image of the current scene in real time, such as Figure 2When the electronic device 100 detects an operation (such as a single click, a touch, etc.) on the shooting control 222, the electronic device 100 may call the camera to shoot and display the scene as shown in FIG. Figure 2 The shooting interface 230 is shown in middle C.
[0050] like Figure 2 As shown in Figure C, the image echo control 223 in the shooting interface 230 can display a preview photo taken in response to an operation on the shooting control 222. The preview photo is a photo after local color cast correction has been performed. When the electronic device 100 detects an operation on the image echo control 223, such as a click operation, the preview photo can be displayed as shown in Figure 2C. Figure 2 The photo preview interface 240 shown in FIG. Figure 2 As shown in D, the photo preview interface 240 displays the photo generated by the camera application icon 211. The photo displayed in the photo preview interface 240 is an image after local color cast correction.
[0051] The following is an exemplary description of the image processing method provided by the embodiment of the present application in conjunction with the accompanying drawings. The image processing method can be executed by an electronic device, or by an image processor in an electronic device, or by a chip or chip system with an image processor function. Figure 3 ,like Figure 3 As shown, the image processing method includes but is not limited to the following steps:
[0052] S301, in response to a click operation on a shooting control, acquiring an initial image.
[0053] The initial image is an image in RAW format. RAW format images include the original data of digital signals converted by image sensors in electronic devices from captured light source signals. They are lossless and contain data such as the original color information of the object.
[0054] For example, the electronic device may detect Figure 2 After the shooting control 222 shown in B is clicked, the camera is called to shoot to obtain an initial image.
[0055] Typically, the color space of the first image is an RGB color space. In other words, the color mode of the first image is an RGB mode. RGB represents the three primary colors of red, green, and blue, and the RGB color space is a color space that describes colors using the three primary colors. R, G, and B represent three channels, respectively. R refers to red, which can be called a red channel. G refers to green, which is a green channel. B refers to blue, which is a blue channel. Typically, color images captured by electronic devices such as cameras and mobile phones can be divided into three components, R, G, and B, for storage. For example, a color image can be represented by an RGB value, i.e., (R, G, B), where the values of R, G, and B all include any integers in the range of [0, 255].
[0056] S302: Perform automatic white balance processing on the initial image to obtain a first image.
[0057] The image format of the first image is different from the image format of the initial image. For example, the first image may be an image in JPEG format. The color space of the first image and the initial image is the same. For example, if the color space of the initial image is an RGB color space, the color space of the first image is also an RGB color space. The automatic white balance process (AWB) is used to perform global color cast correction on the initial image.
[0058] Optionally, image signal processing may be performed on the initial image to obtain a first image, wherein the image signal processing includes automatic white balance processing, and any one or more of noise removal, bad pixel removal, automatic exposure control, black level correction (BLC), color interpolation, non-linear gamma correction, color correction, and the like.
[0059] S303: Determine a second image based on the initial image and the first image, wherein the second image includes a color cast area and a non-color cast area of the first image.
[0060] The second image is a prior map, in which the color cast area and the non-color cast area have different marks. For example, the color cast area is marked as 1, and the non-color cast area is marked as 0. The size of the second image is a preset size, and the preset size can be configured to different values based on the accuracy requirements of different application scenarios. For example, the preset size can be 512 pixels × 512 pixels, which is not limited in this application.
[0061] The detailed steps of determining the second image are described below.
[0062] Step 1: Based on the first image and the initial image, determine the color cast area and the non-color cast area of the first image.
[0063] Exemplarily, assuming that the first image includes N pixels in total, for each pixel in the first image, taking any pixel in the first image, such as pixel i, as an example, the process of determining the color cast area and the non-color cast area of the first image may include the following steps:
[0064] ① Get the RGB value of pixel i, and get the RGB value of pixel j in the initial image.
[0065] Wherein, pixel j is any pixel in the initial image, and pixel i corresponds to pixel j. Since the first image is an image obtained after the initial image is subjected to image signal processing, the position of pixel i in the first image is the same as the position of pixel j in the initial image. Due to the influence of AWB processing, the difference between pixel i and pixel j is that the RGB value of pixel i may be different from the RGB value of pixel j.
[0066] For example, the RGB value of pixel i can be expressed as (R 1 , G 1 , B 1 ), the RGB value of pixel i can be expressed as (R 2 , G 2 , B 2 ). Among them, R 1 , G 1 , B 1 , R 2 , G 2 , B 2 The value of includes any integer in the range [0, 255].
[0067] ② Determine the channel size relationship of the RGB value of pixel i, and determine the channel size relationship of the RGB value of pixel j.
[0068] The channel size relationship refers to the size relationship between the R channel, the G channel, and the B channel in the RGB value. For example, if the RGB value of pixel i is (R 1 , G 1 , B 1 )=(121, 188, 255), then the channel size relationship of the RGB value of pixel i can be expressed as R 1 <G 1 1 Similarly, the channel size relationship of the RGB value of pixel j can also be determined based on the numerical values of the three channels R, G, and B in the RGB value of pixel j.
[0069] ③ In response to the fact that the channel size relationship of the RGB value of pixel i is different from the channel size relationship of the RGB value of pixel j, pixel i is determined to be a color-cast pixel.
[0070] For example, assuming that the RGB value of pixel i (R 1 , G 1 , B 1 ), R 1 <G 1 1 ; Assume that the RGB value of pixel j (R 2 , G 2 , B 2 ), R 2 <G 2 , R 2 >B 2 , and G 2 >B 2 It can be seen that the channel size relationship of the RGB value of pixel i is different from the channel size relationship of the RGB value of pixel j, which means that pixel i is a color cast pixel.
[0071] Or, ④ in response to the channel size relationship of the RGB value of pixel i being the same as the channel size relationship of the RGB value of pixel j, pixel i is determined to be a non-color-biased pixel.
[0072] For example, assuming that the channel size relationship is R 1 <G 1 1 , the channel size relationship is G 2 >R 2 , G 2 >B 2 And R 2 >B 2 , it can be determined that the corresponding area of pixel i is a non-color cast area.
[0073] ⑤ Based on whether the pixel i is a color cast pixel or a non-color cast pixel, determine the color cast area and the non-color cast area of the first image.
[0074] Wherein, by adopting the method shown in the above steps ①-③, or the method shown in steps ①, ②, and ④, each pixel in the first image can be determined as a color cast pixel or a non-color cast pixel. The color cast area of the first image may include multiple color cast pixels, and the non-color cast area may also include multiple non-color cast pixels. Exemplarily, if pixel i, pixel i+1, and pixel i+8 to pixel i+25 are all color cast pixels, then the area composed of pixel i and pixel i+1 can be called a color cast area; the area composed of pixel i+8 to pixel i+25 can also be called a color cast area.
[0075] Step 2: determining a second image based on the color cast area and the non-color cast area of the first image.
[0076] Specifically, by adopting the method in step one, the color cast area and the non-color cast area can be marked separately in the first image, for example, the color cast area is marked as 1, and the non-color cast area is marked as 0, and all the color cast areas and non-color cast areas are combined according to the original arrangement of each pixel in the first image, so as to obtain the second image.
[0077] For example, assuming that the first image is Figure 4C As shown, there are 64 pixels in total, including pixels 1 to 64. If 14 pixels, namely, pixels 13, 14, 21, 22, 29, 30, 37, 48, 15, 46, 53, 54, 61 and 62, are color-cast pixels, and the other pixels are non-color-cast pixels, the color-cast area formed by the above 14 pixels can be marked as 1, and the other non-color-cast areas can be marked as 0, and the following can be obtained: Figure 4D The second image is shown.
[0078] S304: down-sample the first image to obtain a first image of a preset size.
[0079] When the second image to be generated is of a preset size, the first image may be downsampled based on the preset size to obtain a first image of the preset size, so that the size of the downsampled first image is the same as the size of the second image. The first image of the preset size may be referred to as a thumbnail image of the first image. Optionally, the downsampling of the first image may be achieved by performing a max-pooling process on the first image.
[0080] Among them, by downsampling the first image, a thumbnail of the first image (i.e., the first image of a preset size) can be obtained, and obtaining the thumbnail can appropriately reduce the processing amount of the preset network model and improve processing efficiency; in addition, downsampling can retain the color cast features in the first image, that is, the color cast area and the non-color cast area in the first image will not be changed.
[0081] S305: Input the first image and the second image of the preset size into the preset network model to obtain the bilateral grid information output by the preset network model.
[0082] The electronic device is equipped with a preset network model, which is a network model constructed based on bilateral grid technology and neural network technology. The preset network model can obtain the color cast feature of the first image based on the first image and the second image of preset size, and finally obtain the bilateral grid information of the first image based on the color cast feature of the first image.
[0083] The bilateral grid information includes multiple brightness intervals, multiple grid areas, and multiple adjustment matrices. Optionally, the parameter mode of the bilateral grid information can be expressed as C×K×L×9, where C×K represents multiple grid areas; L represents multiple brightness intervals; 9 represents multiple adjustment matrices, and each adjustment matrix is a 3×3 matrix.
[0084] The following describes the three parameters of C×K, L, and 9 in the bilateral grid information.
[0085] (1) C and K represent dividing the first image of the preset size into C×K grid areas. For example, the first image of the preset size can be evenly divided into 32×32 grid areas, a total of 1024 grid areas. If a pixel belongs to the grid area of the 1st row and the 1st column in the C×K grid areas, its coordinates can be represented as (1, 1). For example, for the sake of simplicity, it is assumed that the first image of the preset size is divided into Figure 4A The 4×4 grid shown in the figure has 16 grid areas in total, and the coordinates corresponding to each grid area are as follows Figure 4A shown.
[0086] (2) L represents the brightness interval. For example, the preset network model can divide the brightness (expressed as l) with a value range of [0, 255] into 8 intervals. Then, when the brightness l of a pixel is 16, L=1, indicating that the pixel belongs to the first brightness interval. Optionally, the brightness can be divided into 16, 64, etc. brightness intervals according to different accuracy requirements, and this application does not limit this.
[0087] Among them, if the RGB value of pixel i in the first image is (r i , g i , b i ), the brightness of pixel i can be determined in the following ways:
[0088] Method 1: Randomly select any channel of the RGB value of pixel i as the brightness channel of pixel i, and the brightness of pixel i is the value of the selected channel. For example, if channel B is selected as the brightness channel, the brightness of pixel i is b 1 .
[0089] It should be noted that if the electronic device selects the B channel as the brightness channel, then when traversing all pixels in the first image, the same channel is selected as the brightness channel.
[0090] Method 2: The average value of the RGB values of pixel i is used as the brightness of pixel i. For example, the brightness l of pixel i can be calculated by the formula l = 1 / 3 × (r i +b i +g i )Sure.
[0091] Method 3: Convert the color space of the first image from RGB color space to YUV color space, and use the value of the Y channel as the brightness of pixel i. The Y channel, i.e., the brightness channel, is used to represent brightness, and the U channel and V channel are used to describe color saturation. The value of the Y channel is [0, 255], the value range of the U channel is [-112, 112], and the value range of the V channel is [-157, 157]. The YUV value of pixel i in the first image can be expressed as (y i ,u i , v i ), can be calculated by the following formula:
[0092] y i =0.299r i +0.587g i +0.114b i
[0093] u i =-0.147r i -0.289g i +0.436b i =0.492(b i -y i )
[0094] v i =0.615r i -0.289g i +0.436b i =0.877(r i -y i )
[0095] Combining C×K and L, a three-dimensional coordinate system similar to the XYZ coordinate system can be formed. Figure 4B As shown, C and K may represent the X axis and Y axis in the XYZ coordinate system, respectively, and L may represent the Z axis in the XYZ coordinate system. For example, assuming that the position of pixel i in the first image corresponds to the area of row 2 and column 3 in C×K, and the brightness interval of pixel i is L=2, the three-dimensional coordinates of pixel i in the bilateral grid information may be represented as (2, 3, 2). In other words, pixel i corresponds to a point with coordinates (2, 3, 2) in the three-dimensional coordinate system.
[0096] (3) Parameter 9 in the bilateral grid information represents the 3×3 adjustment matrix C 3×3 The RGB value of any pixel in the first image can be expressed as a 1×3 matrix. For example, the RGB matrix of pixel i can be expressed as RGB=[r i b i b i], the coefficient matrix is used to multiply the RGB matrix of the pixel to change the RGB value of the pixel. For example, a coefficient matrix can be expressed as:
[0097]
[0098] The coefficient matrix in the bilateral grid information corresponds one-to-one to the point in the three-dimensional space formed by C, K, and L. For example, if the three-dimensional coordinates of pixel i in the bilateral grid information are represented as (2, 3, 2), based on this three-dimensional coordinate, the coefficient matrix corresponding to (2, 3, 2) can be found in the bilateral grid information.
[0099] S306: Determine an adjustment matrix corresponding to the color cast area and an adjustment matrix corresponding to the non-color cast area based on the bilateral grid information.
[0100] The color cast area may include multiple color cast pixels, and the non-color cast area may also include multiple non-color cast pixels; the adjustment matrix corresponding to the color cast area includes the adjustment matrix corresponding to each color cast pixel in the color cast area, and the adjustment matrix corresponding to the non-color cast area includes the adjustment matrix corresponding to each non-color cast pixel in the non-color cast area. Specifically, for any pixel in the first image, such as pixel i in the first image, firstly, based on the position of pixel i in the first image, the grid area corresponding to pixel i is determined from the bilateral grid information, that is, it is determined to which area of C×K areas pixel i belongs; based on the RGB value of pixel i, the brightness of pixel i is determined, and based on the brightness of pixel i, the brightness interval corresponding to pixel i is determined from the bilateral grid information; based on the grid area and brightness interval corresponding to pixel i, the adjustment matrix corresponding to pixel i can be determined from the bilateral grid information.
[0101] Exemplarily, assuming that the parameter mode of the bilateral grid information of the first image is 32×32×8×9, if pixel i belongs to the area of the 3rd row and the 6th column in C×K, it can be expressed as (3, 6); based on the RGB value of pixel i, determine the brightness of pixel i, such as Y=33 of pixel i, then the brightness l of pixel i=33, belonging to the second brightness interval, then L=2, so the coordinates of pixel i in the three-dimensional space coordinate system of C×K×L can be expressed as (3, 6, 2); in the multiple adjustment matrices included in the bilateral grid information, find the adjustment matrix C corresponding to the coordinates (3, 6, 2) i , then C i is the adjustment matrix corresponding to pixel i.
[0102] If pixel i is a color cast pixel, the adjustment matrix corresponding to pixel i is a non-unit matrix; if pixel j in the first image is determined to be a non-color cast pixel in S303, the adjustment matrix corresponding to pixel j is the unit matrix C E , the identity matrix C EThe diagonal elements in are 1 and the off-diagonal elements are 0, which can be represented by the following matrix:
[0103]
[0104] In one possible implementation, after executing S303, the electronic device may directly input the first image and the second image into a preset network model. The preset network model may preprocess the input first image and the second image, for example, by resizing the first image to obtain a first image of a preset size, so that the size of the first image is the same as the size of the second image.
[0105] S307: Perform color cast correction on the first image based on the adjustment matrix to obtain a corrected image.
[0106] The adjustment matrix includes an adjustment matrix corresponding to the color cast area and an adjustment matrix corresponding to the non-color cast area. Specifically, for each pixel in the first image, such as pixel i, the RGB matrix corresponding to the RGB value of pixel i is compared with the adjustment matrix C corresponding to pixel i. i Multiply them to obtain an adjusted RGB matrix; based on the adjusted RGB matrix, the target RGB value corresponding to pixel i, that is, the adjusted RGB value, can be obtained. For example, assuming that the RGB value of pixel i is (r i , g i , b i ), the RGB matrix corresponding to the RGB value is RGB i =[r i g i b i ], then the adjusted RGB matrix, that is, the target RGB matrix RGB corresponding to pixel i i * It can be calculated by the following formula:
[0107]
[0108] Based on the above formula, the target RGB matrix RGB of pixel i is obtained i * =[r i * g i * b i * ], the target RGB value of pixel i can be determined based on the target RGB matrix. i * , g i * , b i *The values of the R channel, G channel, and B channel are converted to integers that satisfy the value range [0, 255] of the R channel, G channel, and B channel, respectively, so as to obtain the target RGB value of the pixel i. If the pixel j in the first image is a non-color-biased pixel, the adjustment matrix corresponding to the pixel j is the unit matrix C E , then the target RGB value of pixel j is the same as the target RGB value of pixel j. Based on this, it is possible to perform color cast correction only on the color cast area, while the non-color cast area can remain unchanged, thereby avoiding affecting the non-color cast area during the correction process, for example, avoiding color cast in the non-color cast area during the adjustment process.
[0109] Based on this, the target RGB value of each pixel in the first image can be determined, that is, the target RGB value of each color-cast pixel in the color-cast area and the target RGB value of each non-color-cast pixel in the non-color-cast area can be determined. In the first image, the RGB values of the color-cast pixels of the first image can be updated to the target RGB values, and the RGB values of the non-color-cast pixels are kept unchanged, so that they can be reassembled into one image, that is, the corrected image.
[0110] S308: Display the corrected image on the preview interface.
[0111] For example, the preview interface can be as follows: Figure 2 The photo preview interface 240 shown in FIG. D is optional. The preview interface may also be as follows: Figure 2 The image echo control 223 shown in C in the figure, the correction image displayed in the image echo control 223 is a thumbnail; if the electronic device detects a click operation on the image echo control 223, it can display the following Figure 2 The photo preview interface 240 is shown in FIG. 2D , and the corrected image is displayed on the photo preview interface 240 .
[0112] It can be seen that through the image processing method provided in the embodiment of the present application, in a mixed light source scene, the local color cast area in the image caused by AWB processing can be accurately identified, and the local color cast area can be efficiently corrected to restore the true color of the image and improve the image quality.
[0113] Above Figure 3 The embodiment describes the process of image processing by the electronic device. Figure 5 , for the above Figure 3 In the embodiment, the flowchart of the interaction between the modules of the electronic device is described. Figure 5 , Figure 5 This is a flowchart of the interaction between modules of an electronic device provided in an embodiment of the present application. When the electronic device performs image processing, the interaction process of the modules in the electronic device is as follows:
[0114] S501: The camera application receives an instruction associated with a click operation on a shooting control, and sends a call instruction to the camera. Accordingly, the camera receives the call instruction.
[0115] The electronic device may detect a click operation on the shooting control, and accordingly, the user may click the shooting control in the shooting interface, such as clicking the shooting control 222. When the electronic device detects a click operation on the shutter control, it may send an instruction associated with the click operation on the shooting control to the camera application to instruct the camera application to start. The call instruction is used to call the camera to shoot.
[0116] S502: The camera takes pictures to obtain an initial image, and transmits the initial image to an image processing module. Accordingly, the image processing module receives the initial image.
[0117] The initial image is a RAW format image.
[0118] S503: The image processing module performs automatic white balance processing on the initial image to obtain a first image.
[0119] Specifically, the implementation process of obtaining the first image based on the initial image can be referred to as follows: Figure 3 S302 shown.
[0120] S504: The image processing module determines a color cast area and a non-color cast area of the first image based on the first image and the initial image.
[0121] Specifically, the implementation method of determining the color cast area and the non-color cast area of the first image may refer to step 1 in S303.
[0122] S505: Determine a second image based on the color cast area and the non-color cast area of the first image.
[0123] Exemplarily, the second image of the first image may be obtained by: Figure 4D Specifically, the specific implementation process of determining the second image can refer to step 2 in S303, which will not be repeated here.
[0124] S506: The image processing module determines bilateral grid information based on the first image and the second image.
[0125] Specifically, the specific implementation process of determining the bilateral grid information may refer to S305.
[0126] S507: The image processing module determines an adjustment matrix corresponding to the color cast area and an adjustment matrix corresponding to the non-color cast area based on the bilateral grid information.
[0127] Specifically, the specific implementation process of determining the adjustment matrix may refer to S306.
[0128] S508, the image processing module performs color cast correction on the first image based on the adjustment matrix to obtain a corrected image, and transmits the corrected image to the display screen. Accordingly, the display screen receives the corrected image.
[0129] Assuming that the first image includes N pixels, the adjustment matrix corresponding to each pixel in the N pixels can be determined, that is, a total of N adjustment matrices can be obtained, and the i-th pixel in the N pixels corresponds to the i-th adjustment matrix in the N adjustment matrices. N is an integer greater than 0. Specifically, the specific implementation process of obtaining the corrected image can be referred to S307.
[0130] Optionally, the image processing module may send indication information including the corrected image to the display screen, thereby transmitting the corrected image to the display screen.
[0131] S509, the display screen displays the corrected image.
[0132] A display screen is a device in an electronic device. For example, an electronic device can display Figure 2 D shows a photo preview interface 240. The user can view the corrected image in the photo preview interface 240.
[0133] The structure of the electronic device 100 is described below. Figure 6 , Figure 6 FIG. 1 is a schematic diagram of the structure of the electronic device 100 provided in an embodiment of the present application. It should be understood that the electronic device 100 may have Figure 6 More or fewer components may be shown, two or more components may be combined, or there may be a different configuration of components. Figure 6 The various components shown in the drawings may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.
[0134] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0135] It is to be understood that the structure shown in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include Figure 6 More or fewer components may be shown, or some components may be combined or separated, or the components may be arranged differently. Figure 6 The components shown may be implemented in hardware, software or a combination of software and hardware.
[0136] The processor 110 may include one or more processing units, for example, the processor may include an application processor (AP), a modem (also called a baseband processor), a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), and / or a neural-network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors. The processor is the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.
[0137] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0138] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0139] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0140] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0141] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0142] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0143] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1. In the embodiment of the present application, the display screen 194 can be used to display, for example, Figure 2 The main screen interface shown in A includes the shooting interface of the shooting controls and the correction image.
[0144] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0145] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and light is transmitted to the camera photosensitive element through the lens, and the light signal is converted into an electrical signal. The camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. In the embodiment of the present application, the ISP can perform image signal processing on the initial image to obtain a first image.
[0146] The camera 193 is used to capture static images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. In an embodiment of the present application, the camera 193 can capture a static image to generate an initial image.
[0147] The digital signal processor is used to process digital signals, such as processing digital image signals. In the embodiment of the present application, the digital signal processor can be used to perform image signal processing on the initial image.
[0148] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. NPU can realize applications such as intelligent cognition of electronic device 100, such as image recognition, face recognition, voice recognition, text understanding, etc. In the embodiment of the present application, NPU can be applied to a preset network model.
[0149] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, applications required for at least one function (such as face recognition function, fingerprint recognition function, mobile payment function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as face information template data, fingerprint information template, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. In an embodiment of the present application, the internal memory 121 may be used to store an initial image, a first image, a second image, and a corrected image.
[0150] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0151] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be disposed on the display screen 194 .
[0152] The ambient light sensor 180L is used to sense the brightness of the ambient light. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the sensed brightness of the ambient light. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures.
[0153] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194. In an embodiment of the present application, the touch screen composed of the touch sensor 180K and the display screen 194 is used to detect touch operations on shooting controls, and pass the detected touch operations to the application processor in the camera application to determine that this touch operation is used to instruct the camera application to take a picture.
[0154] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.
[0155] In addition, an operating system runs on the above components, such as the iOS operating system, the Android open source operating system, the Windows operating system, etc.
[0156] The operating system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to illustrate the hardware and software structure of the electronic device 100. It should be noted that although the embodiment of the present application is illustrated by taking the Android system as an example, its basic principles are also applicable to electronic devices based on operating systems such as iOS or Windows.
[0157] Figure 7 It is a software structure diagram of the electronic device 100. The software structure adopts a layered architecture, which divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. Taking the Android system, the Android system running on the AP as an example, in some embodiments, the Android system is divided into five layers, from top to bottom, namely, the application layer, the application framework layer (framework), the system runtime layer, the hardware abstract layer (hardabstract layer, HAL) and the system kernel layer (kernel).
[0158] The application layer may include a series of application packages. The application package may include APPs such as camera, gallery, calendar, call, map, WLAN, Bluetooth, music, video, short message, etc. In the embodiment of the present application, the gallery in the application package may be used to store the first image and the corrected image of the first image.
[0159] The application layer may also include a system user interface (system UI), which is used to display the interface of the electronic device 100, such as displaying the signal icon corresponding to the SIM card, displaying the call interface, etc. In the embodiment of the present application, the system UI may be used to display Figure 2 The interfaces shown in Figures AD include a main screen interface 210 , a shooting interface 220 , a photographing interface 230 and a photo preview interface 240 .
[0160] The application framework layer provides an application programming interface (API) and a programming framework for the application programs in the application layer. The application framework layer includes some predefined functions. For example, the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, etc. The telephony manager is used to provide the call function of the electronic device 100, such as the management of the call status (including connecting, hanging up, etc.).
[0161] The system runtime layer is divided into two parts, namely C / C++ program library and Android runtime library. C / C++ program library mainly includes browser engine (Webkit), multimedia library (media framework), etc. Android runtime library mainly includes runtime environment (Android rontime, ART), etc.
[0162] The hardware abstraction layer is used to isolate the application framework layer from the kernel layer, preventing the Android system from being overly dependent on the kernel layer, so that the application framework layer can be developed without considering the driver. The hardware abstraction layer can include multiple functional modules. For example, display HAL, camera HAL, audio HAL, sensor HAL and other modules.
[0163] In an embodiment of the present application, the camera HAL may include an image processing module for determining a first image based on an initial image, determining a local color cast area of the first image based on the initial image and the first image, and performing color cast correction on the local color cast area to obtain a corrected image.
[0164] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, sensor driver, and shared memory driver.
[0165] In the embodiment of the present application, the camera driver is used to trigger the camera to turn on when receiving a trigger command sent by the camera application at the application layer. The camera driver is also used to call the camera to shoot and generate an initial image.
[0166] In addition, some embodiments of the present application provide an electronic device, which includes: one or more processors and a memory; the memory is used to store computer program code, and the computer program code includes computer instructions. When the one or more processors execute the computer instructions, the electronic device executes the above-mentioned image processing method.
[0167] Some embodiments of the present application provide a chip system, which is applied to an electronic device, and the chip system includes at least one processor and an interface, the interface is used to receive instructions and transmit them to the at least one processor; the at least one processor executes the instructions so that the electronic device executes the above-mentioned image processing method. Among them, the chip system can be a modem processor, or a system on chip (SOC) including a modem processor, and the above-mentioned image processing method can be implemented by a modem processor.
[0168] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0169] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0170] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0171] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0172] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0173] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc., specifically a processor in a computer device) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present application. Among them, the aforementioned storage medium may include: U disk, mobile hard disk, magnetic disk, optical disk, read-only memory (ROM) or random access memory (RAM) and other media that can store program codes.
[0174] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An image processing method, characterized in that: The method comprises: In response to a click operation on a shooting control, an initial image is acquired, and automatic white balance processing is performed on the initial image to obtain a first image; Determine a second image based on the initial image and the first image; the second image includes a color cast area and a non-color cast area of the first image; Inputting the first image and the second image into a preset network model to obtain bilateral grid information output by the preset network model; the bilateral grid information includes multiple brightness intervals, multiple grid areas, and multiple adjustment matrices; Based on the brightness of pixel i in the first image, determine the brightness interval corresponding to the pixel i from the multiple brightness intervals; the brightness of the pixel i is determined based on the RGB value of the pixel i; Based on the position of the pixel i in the first image, determining a grid area corresponding to the pixel i from the multiple grid areas; Based on the grid area corresponding to the pixel i and the brightness range corresponding to the pixel i, determining the adjustment matrix corresponding to the pixel i from the multiple adjustment matrices; Determine a target RGB matrix corresponding to the pixel i based on the RGB matrix corresponding to the RGB value of the pixel i and the adjustment matrix corresponding to the pixel i; Determine a target RGB value of the pixel i based on a target RGB matrix of the pixel i; Based on the target RGB value of the pixel i, determine the target RGB value corresponding to the color cast area and the target RGB value corresponding to the non-color cast area; Determine a corrected image based on the target RGB value corresponding to the color cast area and the target RGB value corresponding to the non-color cast area; The corrected image is displayed on the preview interface.
2. The method according to claim 1, characterized in that The step of determining a second image based on the initial image and the first image comprises: Based on the RGB value of pixel i in the first image and the RGB value of pixel j in the initial image, determining whether the pixel i is a color-biased pixel or a non-color-biased pixel; the pixel i corresponds to the pixel j; Determine a color cast area and a non-color cast area of the first image based on whether the pixel i is a color cast pixel or a non-color cast pixel; The color cast area and the non-color cast area are marked in the first image respectively to obtain a second image.
3. The method according to claim 2, characterized in that The determining whether the pixel i is a color cast pixel or a non-color cast pixel based on the RGB value of the pixel i in the first image and the RGB value of the pixel j in the initial image comprises: In response to the channel size relationship of the RGB value of pixel i in the first image being different from the channel size relationship of the RGB value of pixel j in the initial image, determining that the pixel i is a color cast pixel; In response to the channel size relationship of the RGB value of pixel i in the first image being the same as the channel size relationship of the RGB value of pixel j in the initial image, determining that the pixel i is a non-color cast pixel; The channel size relationship is used to indicate the size relationship between the channels in the RGB value.
4. The method according to claim 1, characterized in that: The method further comprises: Downsampling the first image to obtain a first image of a preset size; The step of inputting the first image and the second image into a preset network model to obtain bilateral grid information output by the preset network model includes: The first image of the preset size and the second image are input into a preset network model to obtain bilateral grid information output by the preset network model; the image size of the second image is the preset size.
5. An electronic device, characterized in that: include: Memory, processor; wherein: The memory is used to store a computer program, wherein the computer program includes program instructions; The processor is used to call the program instructions so that the electronic device executes the method according to any one of claims 1 to 4.
6. 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 method according to any one of claims 1 to 4 is implemented.
7. A computer program product comprising instructions, characterized in that When the computer program product runs on an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 4.
