Image processing method and electronic device
By acquiring shooting environment parameters from electronic devices and using corresponding correction coefficients to correct skin tone in images, the problem of differences between portrait skin tone and real skin tone is solved, thus improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-12-02
- Publication Date
- 2026-06-02
AI Technical Summary
Existing electronic devices produce images where the skin tone of the person in the image differs from the actual skin tone, resulting in a poor user experience.
By acquiring the parameters of the shooting environment, the skin tone of the human figure in the image is corrected using the corresponding correction coefficients to make it closer to the real skin tone, including the correction of brightness, chroma and hue angle.
It reduces the difference between skin tone and real skin tone in images taken by electronic devices, improving the user experience.
Smart Images

Figure CN122138060A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to an image processing method and an electronic device. Background Technology
[0002] With the continuous development of terminal technology, users can use electronic devices to capture videos or images. Users are paying increasing attention to the skin tone (skin color) in images captured by these devices. The image quality of skin tone in portraits is an important parameter for users to judge the performance of electronic devices.
[0003] The skin tone of images captured by existing electronic devices differs from the user's actual skin tone, resulting in a poor user experience. Summary of the Invention
[0004] This application provides an image processing method and an electronic device, which improves the user experience by making the skin tone of the human figure in the processed image close to the real skin tone.
[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:
[0006] In a first aspect, an image processing method is provided, applied to an electronic device. The method includes: in response to an operation of activating a camera application, acquiring a first image via a camera; correcting the color of a target region in the first image based on a first correction coefficient; wherein the first correction coefficient corresponds to the shooting environment when the first image is acquired, and the target region is an image region in the first image including the skin of a subject; the first correction coefficient is used to correct the color of the target region to the color of the subject's skin in the shooting environment; and displaying the corrected first image.
[0007] In this application, in response to opening the camera application, the electronic device can capture a first image through the camera. It then uses a first correction coefficient to correct the skin color in the first image and displays the corrected first image in a preview interface. Since the first correction coefficient corresponds to the shooting environment when the first image is captured, it is used to correct the skin color in the first image to the skin color of the subject in that shooting environment. This allows skin tones in an image taken in a specific shooting environment to be corrected to the skin color present in that environment, reducing the difference between the skin tone of the portrait in the image captured by the electronic device and the actual skin tone, thus improving the user experience.
[0008] In one possible implementation of the first aspect, the method may further include: in response to a photo-taking operation, acquiring a first image via a camera; correcting the color of a target region in the first image based on a first correction coefficient; wherein the first correction coefficient corresponds to the shooting environment when the first image is acquired, and the target region is an image region in the first image that includes the skin of the subject; the first correction coefficient is used to correct the color of the target region to the color of the subject's skin in the shooting environment; and saving the corrected first image. Thus, in a photo-taking scenario, the electronic device can use the first correction coefficient to correct the skin color in the acquired first image and save the corrected first image.
[0009] In one possible implementation of the first aspect, the method may further include: displaying a first image; in response to a preset operation, correcting the color of a target region in the first image based on a first correction coefficient; wherein the first correction coefficient corresponds to the shooting environment when the first image was acquired, and the target region is an image region in the first image that includes the skin of the subject; the first correction coefficient is used to correct the color of the target region to the color of the subject's skin in the shooting environment; and displaying the corrected first image. For example, the electronic device may display the first image on a first interface, which may be, for example, the interface of an image browsing application. The first interface may include a preset button, such as a beauty button, and the preset operation may be, for example, an operation on the preset button, such as a click operation. In response to the preset operation, the electronic device uses the first correction coefficient to correct the color of the skin in the first image and displays the corrected first image. The first image may be an image acquired by the electronic device through a camera. Alternatively, the first image may be an image obtained from other electronic devices through interaction between the electronic device and other electronic devices.
[0010] In one possible implementation of the first aspect, the electronic device stores a one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients. The multiple environmental parameters may include multiple preset color temperatures and / or multiple preset illuminances. The electronic device can acquire target environmental parameters at the time of acquiring the first image, and these target environmental parameters reflect the shooting environment at the time of acquiring the first image. Based on the mapping relationship, a first correction coefficient corresponding to the target environmental parameters is determined. This implementation provides one possible way for the electronic device to acquire the first correction coefficient.
[0011] In one possible implementation of the first aspect, the first correction coefficient includes a first coefficient, a second coefficient, and a third coefficient; the target region includes one or more pixels; wherein the first coefficient is used to correct the brightness of the pixel, the second coefficient is used to correct the chroma of the pixel, and the third coefficient is used to correct the hue angle of the pixel. A pixel is the smallest unit constituting an image, representing an image unit with a fixed position and a specific color. Correcting the brightness of a pixel can be understood as correcting the brightness of the color represented by that pixel. Correcting the chroma of a pixel can be understood as correcting the chroma of the color represented by that pixel. Correcting the hue angle of a pixel can be understood as correcting the hue angle of the color represented by that pixel.
[0012] In one possible implementation of the first aspect, correcting the color of a target region in a first image based on a first correction coefficient includes: for each pixel included in the target region, obtaining the brightness, chroma, and hue angle of the pixel based on its color value. For example, converting the color values of the pixels in the target region to color values in a second color space. The second color space can represent a color using brightness, chroma, and hue angle. After converting the color values of the pixels in the target region to color values in the second color space, the electronic device can obtain the brightness, chroma, and hue angle of each pixel. The brightness of the pixel is corrected using the first coefficient, the chroma of the pixel is corrected using the second coefficient, and the hue angle of the pixel is corrected using the third coefficient. The electronic device can use the first correction coefficient to correct each pixel in all pixels included in the target region one by one.
[0013] In one possible implementation of the first aspect, for each pixel among all pixels included in the target area, the electronic device multiplies a first coefficient by the brightness of the pixel to obtain a corrected brightness, multiplies a second coefficient by the chroma of the pixel to obtain a corrected chroma, and adds a third coefficient by the hue angle of the pixel to obtain a corrected hue angle.
[0014] In one possible implementation of the first aspect, the electronic device includes multiple correction coefficients, which can be multiple correction matrices. The first correction coefficient is a first correction matrix. For each pixel in the target region, the following correction method is performed: the pixel's color value is converted to a color value in a first color space; the first correction mean is multiplied by the pixel's color value in the first color space to obtain the corrected color value of the pixel in the first color space. The correction matrix can be a 3x3 matrix.
[0015] In one possible implementation of the first aspect, the correction coefficient corresponding to an environmental parameter in the mapping relationship is obtained based on a second image captured under the shooting environment corresponding to the environmental parameter and spectral data of the skin collected under the shooting environment corresponding to the environmental parameter. The second image includes an image of the subject's skin; the spectral data is the spectral data of the subject's skin. This implementation provides a possible way for an electronic device to acquire a one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients.
[0016] In one possible implementation of the first aspect, a first color value for the skin in a first color space is obtained based on spectral data. This first color value represents the color of the subject's skin in the environmental parameters. A second color value for the skin in the first color space is obtained based on a second image; this second color value represents the color of the subject's skin in the image acquired by the electronic device in the environmental parameters. A correction coefficient corresponding to the environmental parameters is obtained based on the first and second color values; wherein the first color space is a uniform color space. The colors represented by the first color space are close to human visual perception.
[0017] In one possible implementation of the first aspect, the correction coefficients corresponding to the environmental parameters include: a first coefficient, a second coefficient, and a third coefficient; the first coefficient is the ratio of the brightness of the first color value to the brightness of the second color value; the second coefficient is the ratio of the chroma of the first color value to the chroma of the second color value; and the third coefficient is the difference between the hue angle of the first color value and the hue angle of the second color value.
[0018] In a second aspect, an electronic device is provided, comprising: a memory, a camera, and one or more processors; the camera, the memory, and the processors are coupled; wherein the memory is used to store computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the electronic device performs the method as described in any of the first aspects.
[0019] Thirdly, a chip system is provided that can be applied to an electronic device including memory. The chip system includes one or more interface circuits and one or more processors. The interface circuits and processors are interconnected via lines. The interface circuits are used to receive signals from the aforementioned memory and send the signals to the processors, the signals including computer instructions stored in the memory. When the processor executes the computer instructions, the electronic device performs a method as described in the first aspect and any of its possible design embodiments.
[0020] Fourthly, a computer-readable storage medium is provided, including computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any of the first aspects.
[0021] Fifthly, a computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of any of the methods in the first aspect.
[0022] In understanding, the beneficial effects that the electronic device of any of the possible designs of the second aspect, the chip system of the third aspect, the computer-readable storage medium of the fourth aspect, and the computer program product of the fifth aspect can achieve can be referred to as the beneficial effects of the first aspect and any of its possible designs, which will not be repeated here. Attached Figure Description
[0023] Figure 1 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;
[0024] Figure 2 A schematic diagram of the software architecture of an electronic device provided in an embodiment of this application;
[0025] Figure 3 A top view of a data acquisition system provided in an embodiment of this application;
[0026] Figure 4 A flowchart illustrating a data acquisition method provided in an embodiment of this application;
[0027] Figure 5 A flowchart illustrating a method for generating correction coefficients provided in an embodiment of this application;
[0028] Figure 6 A schematic diagram illustrating a method for generating correction coefficients provided in an embodiment of this application;
[0029] Figure 7 A schematic flowchart of an image processing method provided in an embodiment of this application;
[0030] Figure 8 A comparative schematic diagram of different skin tone beautification methods provided in the embodiments of this application;
[0031] Figure 9 This is a schematic flowchart of another image processing method provided in an embodiment of this application. Detailed Implementation
[0032] With the rapid development of information technology, electronic devices such as mobile phones are playing an increasingly important role in people's daily lives. Users can use electronic devices to capture images or videos anytime, anywhere to record their lives. Users also have increasingly higher demands for the photographic effects of electronic devices, especially for the detail and naturalness of portrait effects. Therefore, high-quality portrait effects have become one of the important bargaining chips for improving consumer satisfaction, enhancing brand competitiveness, and even competing in the electronic device market.
[0033] Skin tone refers to the color of the skin. The imaging effect of skin tone in portraits is an important parameter for users to judge the portrait effect in images or videos taken by electronic devices. A good skin tone imaging effect can convey the health, attractiveness, and youthful vitality of the subject.
[0034] The skin tone imaging effect of current electronic devices is often less than ideal. This is because there is a difference between the skin tone of the portrait in the image captured by the electronic device and the skin tone of the subject in the shooting environment in which the image was captured. The electronic device cannot perfectly reproduce the skin tone of the portrait in the image as it would appear in the shooting environment. For example, consider a captured image. When capturing an image, the electronic device is affected by factors such as the light source of the shooting environment, skin reflectivity, and the spectral response function of the imaging system. This prevents the electronic device from accurately reproducing the true skin tone of the subject in that environment, resulting in a difference between the skin tone of the portrait in the captured image and the true skin tone of the subject in that environment. This difference can be, for example, a difference in hue angle. For instance, the hue angle of the skin tone in the image captured by the electronic device differs from the hue angle of the subject's skin tone in the shooting environment, and this difference can be perceived by the user. Hue angle is an important characteristic of color, used to accurately distinguish different colors. For example, the hue angle of red is 0 degrees, yellow is 90 degrees, and green is 180 degrees, etc.
[0035] Therefore, embodiments of this application provide an image processing method and an electronic device. The electronic device can use a first correction coefficient to correct the skin tone of a person in a first image. The first correction coefficient is matched with the shooting environment when the first image was acquired. The first correction coefficient is used to correct the skin tone of the subject in the image taken in that shooting environment to the skin tone that the subject's skin actually presents in that shooting environment. Here, "corrected to" can be understood as correcting the two to be consistent with or close to each other.
[0036] In other words, the embodiments of this application can correct the skin color in an image taken in a shooting environment to the skin color presented in that shooting environment, thereby reducing the difference between the skin color of the portrait in the image taken by the electronic device and the real skin color, and improving the user experience.
[0037] The method provided in this application can be applied to electronic devices with image processing capabilities. These electronic devices may include mobile phones, tablets, laptops, netbooks, personal digital assistants (PDAs), in-vehicle devices, etc., and this application does not impose any limitations on them. In this application, the aforementioned electronic device is an electronic device capable of running an operating system and installing applications. Optionally, the operating system running on the electronic device may be... system, system, Systems, etc.
[0038] Take a mobile phone as an example. Figure 1 As shown, the electronic device 100 may include: a processor 110, a memory 120, a universal serial bus (USB) interface 130, a power management module 140, antennas such as antenna 1 and antenna 2, a communication module 150, a display screen 160, an audio module 170, a camera 180, a sensor module 190, etc.
[0039] Processor 110 may include one or more processing units, such as: application processor (AP), central processing unit, modem processor, graphics processing unit (GPU), ISP, controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors. The controller may be the nerve center and command center of electronic device 100. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.
[0040] In this embodiment, the processor 110 can acquire a first image and identify the target shooting environment when the first image is acquired. The processor 110 can also correct the skin tone of the person in the first image using a first correction coefficient corresponding to the target shooting environment, based on the target shooting environment when the first image is acquired.
[0041] The memory 120 can be used to store computer executable program code, which includes instructions. The processor 110 executes various functional applications and data processing of the electronic device by running the instructions stored in the memory 120. The memory 120 may include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function (such as sound playback function, interface display function, etc.). The data storage area may store data created during the use of the electronic device (such as notification messages). In addition, the memory 120 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. In this embodiment, the memory 120 is not only used to store executable program code, but also to store multiple correction coefficients that correspond one-to-one with multiple environmental parameters. For example, the memory 120 may store the correspondence between multiple environmental parameters and multiple correction coefficients. The environmental parameters may be color temperature and / or illuminance.
[0042] In this embodiment, the memory 120 stores computer-executable program code, which includes instructions. The processor 110 executes a video playback method provided in this embodiment by running the instructions stored in the memory 120.
[0043] The power management module 140 is used to connect the battery to the processor 110. The power management module 140 receives battery and / or power input to power the processor 110, memory 120, communication module 150, display screen 160, and camera 180, etc. The power management module 140 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 140 may also be located within the processor 110.
[0044] The communication module 150 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR). The communication module 150 can be one or more devices integrating at least one communication processing module. The communication module 150 receives electromagnetic waves via an antenna, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to the processor 110. The communication module 150 can also receive signals to be transmitted from the processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via the antenna.
[0045] In some embodiments, the antenna of the electronic device 100 is coupled to the communication module 150, enabling the electronic device 100 to communicate with networks and other devices via wireless communication technologies. The wireless communication technologies may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BitTorrent, Global Navigation Satellite System (GNSS), WLAN, NFC, FM, and / or IR technologies. The GNSS may include Global Positioning System (GPS), BeiDou Navigation Satellite System (BDS), GLONASS, and / or Galileo.
[0046] Electronic device 100 implements display functions through a GPU, a display screen 160, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 160 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0047] The display screen 160 is used to display images, videos, etc. The display screen 160 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 (AMOLED), a flexible light-emitting diode (FLED), a Mini-LED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc.
[0048] Electronic device 100 can achieve shooting and recording functions through ISP, camera 180, video codec, GPU, display screen 160 and application processor.
[0049] The audio module 170 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0050] The camera 180 is used to capture still images or videos. An object passes through the lens, generating an optical image that is projected onto a photosensitive element. This photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP (Image Signal Processor) for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP (Digital Signal Processor) for further processing. The DSP converts the digital image signal into standard RGB, YUV, or other image formats.
[0051] In this embodiment of the application, the camera 180 can capture a first image based on the control instructions of the processor 110.
[0052] The sensor module 190 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, and bone conduction sensors, etc.
[0053] It is understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 100. In other embodiments, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0054] Taking the aforementioned electronic device 100 as a mobile phone as an example, the software system of the electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses a layered architecture... Taking the system as an example, the software structure of electronic device 100 is illustrated.
[0055] Figure 2 This is a software structure block diagram of the electronic device 100 according to an embodiment of this application.
[0056] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, [the following is omitted as the text is incomplete and likely refers to a specific implementation or feature]. The system is divided into four layers, from top to bottom: application layer, application framework layer, system library, and kernel layer.
[0057] The application layer can include a series of application packages.
[0058] like Figure 2 As shown, the application package may include applications such as camera, gallery, call, map, navigation, WLAN, Bluetooth, music, video, SMS, and social networking. Among them, the camera application can respond to user actions and trigger the camera 180 to capture images, such as the first image. The camera application can trigger the camera 180 to capture images through the kernel-level camera driver.
[0059] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0060] like Figure 2 As shown, the application framework layer may include a view system, resource manager, input system, correction module, etc.
[0061] The input system is used to monitor the phone's input modules (such as touchscreen drivers) and convert the parameters input by the input modules into usable events, which are then passed to the relevant upper-layer modules. For example, the input system is used to monitor the phone's touchscreen through the touchscreen driver and convert the touch parameters generated by the touchscreen input into usable events, which are then passed to the upper-layer APP.
[0062] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build the display interface of an application.
[0063] The correction module is used to identify the shooting environment when the image is captured, such as the first image, such as the target shooting environment, and based on the target shooting environment when the image is captured, to correct the skin color of the human figure in the image using a correction coefficient corresponding to the shooting environment when the image is captured, such as the first correction coefficient.
[0064] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0065] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0066] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0067] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0068] A 2D graphics engine is a graphics engine for 2D drawing.
[0069] The kernel layer is the layer between hardware and software. The kernel layer can contain touchscreen drivers, display drivers, camera drivers, sensor drivers, etc.
[0070] The following uses a mobile phone as an example to introduce an image processing method provided by an embodiment of this application.
[0071] In this embodiment, the mobile phone (hereinafter referred to as Mobile Phone B) can use a correction coefficient to map the skin color of a person in an image captured by the mobile phone to the skin color of the subject in the shooting environment when the image was captured. The mobile phone stores a one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients. The environmental parameters include a preset color temperature and / or a preset light intensity. Color temperature describes the warmth or coolness of the color of light emitted by a light source. The unit of color temperature can be Kelvin (K). Light intensity describes the luminous flux of visible light received per unit area. The unit of light intensity can be lux (Lux or lx). Light intensity will be referred to as illuminance below. The correction coefficient corresponding to one environmental parameter in the mapping relationship is obtained based on a second image captured in the shooting environment corresponding to the environmental parameter and the spectral data of the skin captured in the shooting environment corresponding to the environmental parameter. The second image includes an image of the subject's skin. The spectral data is the spectral data of the subject's skin.
[0072] First, with reference to the accompanying diagram, we will introduce a method for obtaining a one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients. This method includes data acquisition and data processing, which will be described in detail below.
[0073] Before collecting data, a data collection system can be set up first. Figure 3 This is a top view of a data acquisition system provided in an embodiment of this application.
[0074] For example, such as Figure 3 As shown, the acquisition system includes a spectrometer, mobile phone A, at least one light source, a back panel, a lighting control system (not shown in the figure), and a computer (not shown in the figure). The subject being photographed can be centered directly in front of the back panel.
[0075] The acquisition system includes a number of light sources, and their placement must ensure uniform illumination of the subject's facial area, avoiding shadows. For example, the system may include one light source, positioned directly in front of the subject. Alternatively, the system may include two light sources, positioned to the left and right front of the subject, respectively. Figure 3As shown, the acquisition system may include two light sources, such as light source 1 and light source 2. Light source 1 is positioned to the left front of the subject, and light source 2 is positioned to the right front of the subject. The angle between light source 1 and the subject along the X-axis is between 30° and 60°, and the angle between light source 2 and the subject along the X-axis is between -30° and -60°. Furthermore, to ensure uniform and sufficient brightness over the subject's facial area, the distance between each light source and the subject along the X-axis can be maintained, for example, between 2m and 3m. The type of light source may be, for example, a light-emitting diode (LED). The light source can be positioned above the subject; for example, the distance between the light source and the subject along the Z-axis can be between 0.5m and 1m.
[0076] The light source is connected to the lighting control system, which in turn is connected to the computer. The computer can adjust environmental parameters through the lighting control system. For example, the computer can adjust the color temperature of the light source to a preset color temperature, thus adjusting the ambient color temperature to the preset color temperature. Similarly, the computer can adjust the illuminance of the light source to a preset illuminance, thus adjusting the ambient illuminance to the preset illuminance.
[0077] A spectrometer is used to measure the spectral data of the skin in a predetermined area of a subject. For example, the predetermined area could be the face. Optionally, the predetermined area could be a portion of the face, such as the forehead. The spectral data of the skin reflects the relationship between the intensity of light reflected by the skin and its wavelength. For example, when light shines on the skin, the skin selectively absorbs some wavelengths of light and reflects others, depending on its atomic structure, molecular composition, and physical state. The spectrometer can collect the light reflected by the skin and obtain the skin's spectral data based on the collected light.
[0078] Mobile phone A is used to capture an image of the subject, i.e., a second image. Mobile phone A may include a front-facing camera or a rear-facing camera. Mobile phone A can capture an image of the subject through either the front-facing or rear-facing camera. This image can be, for example, a raw image captured by the camera. This image includes a portrait of the subject, which includes an image of the subject's face. The distance between mobile phone A and the subject in the X-axis direction is between 200cm and 300cm. To capture a portrait including a facial image, the mounting height of mobile phone A, i.e., its height in the Z-axis direction, is between 80cm and 150cm.
[0079] A backdrop is placed behind the subject to absorb light and prevent reflections. The backdrop can be dark, such as black or gray.
[0080] It should be noted that the acquisition system described above is merely an example. In practical applications, the acquisition system may include more devices, such as more light sources. Alternatively, the acquisition system may include other devices. Furthermore, the relative positions of the devices in the acquisition system may vary by distance or angle, etc., and this application does not limit these aspects.
[0081] After the data collection system is set up, mobile phone A or computer can obtain multiple sets of data that correspond one-to-one with multiple environmental parameters.
[0082] For example, a computer can acquire M sets of data corresponding to M preset color temperatures. Here, M is an integer greater than or equal to 2. Each set of data includes: spectral data of the skin at the corresponding preset color temperature and an image of the subject, such as the second image. For example, preset color temperatures include 2000K, 4500K, 6500K, and 8000K. The computer can acquire one set of data corresponding to color temperature 2000K, another set corresponding to color temperature 4500K, another set corresponding to color temperature 6500K, and yet another set corresponding to color temperature 8000K. For example, the set of data corresponding to color temperature 2000K includes: spectral data of the skin at an ambient color temperature of 2000K and an image of the subject, such as the second image. Optionally, the M preset color temperatures correspond to the same ambient illuminance. For example, these M preset color temperatures are different color temperatures at a light source illuminance of 1000 Lux.
[0083] For example, a computer can acquire N sets of data corresponding to N preset illuminance levels. Here, N is an integer greater than or equal to 2. Each set of data includes: spectral data of the skin under the corresponding preset illuminance and an image of the subject, such as the second image. For example, preset illuminance levels include 500 Lux, 1000 Lux, 1500 Lux, and 2000 Lux. The computer can acquire one set of data corresponding to illuminance 500 Lux, one set of data corresponding to illuminance 1000 Lux, one set of data corresponding to illuminance 1500 Lux, and one set of data corresponding to illuminance 2000 Lux. For example, the set of data corresponding to illuminance 500 Lux includes: spectral data of the skin when the ambient illuminance is 500 Lux and an image of the subject, such as the second image. Optionally, the N preset illuminance levels correspond to the same ambient color temperature. For example, the N preset illuminance levels could be different illuminance levels when the color temperature of the light source is 6500K.
[0084] For example, a computer can acquire M sets of data corresponding to M preset color temperatures, and N sets of data corresponding to N preset illuminance levels. That is, the computer can simultaneously acquire M sets of data corresponding to M preset color temperatures, and N sets of data corresponding to N preset illuminance levels.
[0085] For example, given environmental parameters including preset color temperature and preset illuminance, the computer can obtain P sets of data corresponding to P parameter groups. Each parameter group contains a preset color temperature and a preset illuminance. The P preset color temperatures and preset illuminances included in the P parameter groups can be different. For instance, the computer can obtain one set of data corresponding to a color temperature of 6500K and an illuminance of 500Lux, another set corresponding to a color temperature of 2500K and an illuminance of 1000Lux, another set corresponding to a color temperature of 4000K and an illuminance of 1500Lux, and yet another set corresponding to a color temperature of 8000K and an illuminance of 2000Lux.
[0086] The following describes the process of obtaining M sets of data corresponding to M preset color temperatures. For one of the M preset color temperatures, the following can be executed: Figure 4 The data acquisition method shown obtains a set of data corresponding to the preset color temperature. Here, the preset color temperature is any one of M preset color temperatures. That is, for each of the M preset color temperatures, the following method can be executed to obtain a set of data corresponding to that preset color temperature.
[0087] S41, the computer responds to operation a and adjusts the color temperature of the light source to the preset color temperature through the lighting control system.
[0088] The computer may include a settings interface that includes a color temperature adjustment control for setting the color temperature of the light source. For example, the control could be an input box. Operation 'a' could be, for example, a tester entering a preset color temperature into the input box. Alternatively, the control could include buttons corresponding to M preset color temperatures, and operation 'a' could be, for example, a tester selecting, such as clicking the button corresponding to a preset color temperature. In response to operation 'a', the computer adjusts the color temperature of the light source to the preset color temperature via the lighting control system.
[0089] S42, mobile phone A responds to operation b and acquires the second image.
[0090] Operation b is used to trigger mobile phone A to capture a second image. This second image includes a portrait of the subject, which may specifically include a facial image. Operation b can be, for example, a tester's operation on the "shutter" in the shooting preview interface, such as a tap. Operation b can also be, for example, a tester speaking a voice control command near the microphone of mobile phone A, such as "take a picture."
[0091] Before capturing the second image, the tester can adjust the shooting mode of mobile phone A to a preset mode. Mobile phone A includes multiple shooting modes, such as snapshot mode, portrait mode, professional mode, movie mode, and night mode. The preset mode can be one of these shooting modes; for example, it can be snapshot mode. After adjusting the shooting mode to the preset mode, the tester can also adjust the shooting parameters, which may include ISO, exposure time, exposure value, and focus mode. The tester can also adjust the composition. The purpose of adjusting the composition is to ensure that the second image presents the complete facial area of the subject. The adjustments to the shooting mode, shooting parameters, and composition can be made before the first capture of the second image using mobile phone A, and subsequent captures of the second image do not require further adjustments. Alternatively, adjustments can be made as needed before each capture of the second image; this embodiment does not impose specific limitations here.
[0092] S43, the spectrometer responds to operation c and acquires spectral data of the skin in a predetermined area of the subject.
[0093] The predetermined area can be an area that includes the subject's skin. For example, the predetermined area can be the face. Alternatively, it can be a portion of the face, such as the forehead.
[0094] In response to operation c, the spectrometer can emit light of a specific wavelength towards a predetermined area of the subject, such as the forehead. The spectrometer can receive the light reflected from the skin in that predetermined area, convert it into an electrical signal for recording and analysis, and generate spectral data of the skin. Operation c is used to trigger the spectrometer to acquire spectral data of the skin in the predetermined area of the subject.
[0095] S44, the computer acquires the second image captured by mobile phone A and the spectral data of the skin of the predetermined area of the subject acquired by the spectrometer.
[0096] The spectrometer can communicate with a computer. This communication connection can be wireless, such as Wi-Fi or Bluetooth. It can also be wired, for example, the spectrometer can connect to the computer via a serial bus.
[0097] When the spectrometer is connected to a computer, it can send the collected skin spectral data to the computer. After connecting to the computer, mobile phone A can send a second image it has captured to the computer. The computer can process the data to obtain a set of data, including the second image and the spectral data. The second image is an image of the subject's face region captured when the environmental parameters are at a preset color temperature. The spectral data is the spectral data of a predetermined area of the subject's skin captured when the environmental parameters are at the preset color temperature. Alternatively, when the spectrometer is connected to mobile phone A, it can send the collected skin spectral data to mobile phone A. Mobile phone A can process the data to obtain the aforementioned set of data. Then, mobile phone A can send this set of data to the computer.
[0098] Optionally, S43 can also: mobile phone A acquires spectral data of the skin in a predetermined area of the subject collected by the spectrometer. For example, when the spectrometer is connected to mobile phone A, the spectrometer can send the collected skin spectral data to mobile phone A. Mobile phone A can then process the data to obtain the aforementioned set of data.
[0099] In other words, data can be aggregated on a computer or on mobile phone A. This application does not impose specific limitations on this.
[0100] The second image can be a processed Raw image. For example, mobile phone A may include an image signal processor (ISP). The ISP can process the Raw image. For example, the second image may be a Raw image after denoising, automatic white balance (AWB), and color correction.
[0101] After executing the above data acquisition method M times, the computer can obtain M sets of data. Each of the M sets of data corresponds one-to-one with M preset color temperatures. Each set of data includes: a second image acquired at the corresponding preset color temperature and spectral data of the skin acquired at the corresponding preset color temperature.
[0102] It should be understood that the same data acquisition method can be used to acquire N sets of data corresponding one-to-one with N preset illuminance levels. Each set of data includes: a second image acquired under the corresponding preset illuminance level and spectral data of the skin acquired under the corresponding preset illuminance level. For example, in S41, the computer, in response to operation a, adjusts the illuminance of the light source to the preset illuminance level through the lighting control system. Then, mobile phone A and the spectrometer execute S42 and S43 respectively to acquire the second image and spectral data of the skin corresponding to the preset illuminance level. Similarly, the same method can be used to acquire P sets of data corresponding one-to-one with P parameter groups. Each set of data includes: a second image acquired under the corresponding preset illuminance and preset color temperature, and spectral data of the skin acquired under the corresponding preset illuminance and preset color temperature. For example, in S41, the computer, in response to operation a, adjusts the illuminance of the light source to the preset illuminance level through the lighting control system and sets the color temperature of the light source to the preset color temperature. Then, mobile phone A and the spectrometer execute S42 and S43 respectively to acquire the second image and spectral data of the skin corresponding to the preset illuminance and preset color temperature.
[0103] Optionally, when M preset color temperatures correspond to the same ambient illuminance, the computer can first fix the illuminance of the light source to the corresponding ambient illuminance and then adjust the color temperature of the light source sequentially. When N preset color temperatures correspond to the same ambient color temperature, the computer can fix the color temperature of the light source to the corresponding ambient color temperature and then adjust the illuminance of the light source sequentially. When it is necessary to collect P sets of data corresponding to P parameter groups one-to-one, the computer can adjust the color temperature and illuminance of the light source simultaneously. For example, when it is necessary to collect a set of data corresponding to a color temperature of 6500K and an illuminance of 500Lux, the computer can simultaneously adjust the color temperature of the light source to 6500K and adjust the illuminance of the light source to 500Lux.
[0104] After data acquisition is complete, the data can be processed to obtain multiple correction coefficients that correspond one-to-one with multiple environmental parameters. These multiple environmental parameters can be, for example, M preset color temperatures; or N preset illuminance levels; or M preset color temperatures and N preset illuminance levels; or P parameter groups as described above.
[0105] The following describes a method for generating M correction coefficients using a computer based on M sets of data that correspond one-to-one with M preset color temperatures. For each of the M sets of data, the computer can execute... Figure 5 The method shown yields a correction coefficient corresponding to each preset color temperature. Taking the example of a computer obtaining a correction coefficient corresponding to a preset color temperature based on a set of data, combined with... Figure 5This section will introduce the data. The preset color temperature data includes a second image and spectral data. As previously explained, the second image is an image of the subject's face, captured when the ambient color temperature is set. The spectral data is the spectral data of a predetermined area of the subject's skin, captured when the ambient color temperature is set. For example, if the preset color temperature is 2000K, the corresponding data includes a second image and spectral data. The second image is an image of the subject's face, captured when the ambient color temperature is 2000K. The spectral data is the spectral data of a predetermined area of the subject's skin, captured when the ambient color temperature is 2000K. Based on... Figure 5 The obtained correction coefficient corresponds to an ambient color temperature of 2000K. For example, a preset color temperature of 4500K corresponds to a set of data including a second image and spectral data. The second image is an image of the subject's face region acquired at an ambient color temperature of 4500K. The spectral data is the spectral data of a predetermined area of the subject's skin acquired at an ambient color temperature of 4500K. Figure 5 The obtained correction factor corresponds to an ambient color temperature of 4500K.
[0106] For example, Figure 5 The methods shown include:
[0107] S51, the computer obtains the first color value of the skin in the first color space based on the spectral data.
[0108] A color space, also known as a color model, is a model used to represent colors.
[0109] The first color space is characterized by uniformity; that is, it is a uniform color space. Uniformity means that when two or more colors represented by the first color space are measured to have a color difference, the magnitude of that difference is consistent with the difference perceived by the human eye. The colors represented by the first color space closely approximate human visual perception.
[0110] The primary color space can be, for example, the Intensity-Protan-Tritan (IPT) color space, the Lab color space (Lab), the CIE CAM02 color space, or the ICT-Cp color space. The following explanation uses the IPT color space as an example to illustrate this scheme.
[0111] The first color value represents the color of the subject's skin under corresponding environmental parameters. For example, a first color value obtained from spectral data in a set of data corresponding to a preset color temperature of 2000K represents the true color of the subject's skin when the ambient color temperature is 2000K. As another example, a first color value obtained from spectral data in a set of data corresponding to a preset color temperature of 4500K represents the true color of the subject's skin when the ambient color temperature is 4500K.
[0112] In some embodiments, a computer may perform the following three steps to obtain the first color value of the skin in a first color space.
[0113] Step 1: The computer can obtain the color value of the skin in the XYZ color space based on the spectral data.
[0114] A computer can determine the color value in the XYZ color space corresponding to spectral data. This color value can be an XYZ value, which includes the values of the X channel, Y channel, and Z channel. Specifically, the computer can obtain the XYZ value corresponding to the spectral data based on the radiant energy value S(λ), the color matching function value X(λ) for red light, the color matching function value Y(λ) for green light, and the color matching function value Z(λ) for blue light. The XYZ color space is the CIE 1931 XYZ color space.
[0115] For example, the computer calculates the values of the X channel, Y channel, and Z channel based on the following formulas: X = Σ(S(λ)*X(λ)), Y = Σ(S(λ)*Y(λ)), Z = Σ(S(λ)*Z(λ)). Then, the computer can normalize the values of the X channel, Y channel, and Z channel to obtain the final XYZ values.
[0116] Step 2: The computer performs color adaptation conversion on the skin's color values in the XYZ color space.
[0117] The purpose of color adaptation conversion is to convert the color temperature corresponding to the skin's color value in the XYZ color space to another color temperature. This other color temperature could be, for example, the color temperature corresponding to a D65 light source. This is because the ISP in a mobile phone performs white balance on the image, converting the image's color temperature to the color temperature of a D65 light source. Therefore, it is also necessary to perform color adaptation conversion on the color values corresponding to the spectral data to ensure that both undergo the same color processing.
[0118] Computers can perform color adaptation transformations on skin colors in the XYZ color space based on a color adaptation transformation matrix. The color adaptation transformation matrix can convert XYZ values at one color temperature to XYZ values at another color temperature. Optionally, this color adaptation transformation matrix can be, for example, a chromatic adaptation transform (CAT) matrix.
[0119] Step 3: The computer converts the color values that have undergone color adaptation into the first color value of the IPT color space.
[0120] The color values after color adaptation conversion are XYZ values in the XYZ color space. For example, a computer can convert XYZ color space values to Long-Medium-Short (LMS) color space values, and then convert LMS color space values to IPT color space values. The IPT color space value is the first color value for skin in the first color space. For example, the first color value can be (I... I , P1, T1) represent.
[0121] After obtaining the first color value of the skin in the first color space based on the spectral data, the computer can obtain the second color value of the skin in the first color space based on the second image. For example, the computer can execute steps S52 and S53.
[0122] S52, the computer identifies a predetermined region in the second image.
[0123] When the predetermined region is a facial region, the computer can identify the facial region in the second image. For example, the computer can detect the facial region in the second image based on a face detection algorithm. Alternatively, the computer can obtain the facial region in the second image based on a neural network model. The input to this neural network model can be an image including a face image, and the output can be a face image. When the predetermined region is the forehead region, the computer can first identify the facial region in the second image. After identifying the facial region, the computer can crop the facial region to obtain the forehead region.
[0124] S53, the computer converts the color values of the second image to the first color space, obtaining the second color value of the skin in the first color space.
[0125] The initial color space of the second image differs from that of the first color space. For example, if the second image is in RGB format, its initial color space can be RGB. Similarly, if the second image is in YUV format, its initial color space can be YUV. This application does not specifically limit the initial color space of the second image. This document uses the example of an initial color space of RGB for illustration.
[0126] For example, a computer can convert the color values of a second image to XYZ color space, then to LMS color space, and finally to IPT color space. Afterward, the computer can obtain the second color value of the skin based on the color values of a predetermined region in the IPT color space. For example, the computer can use the color value of any pixel in the predetermined region in the IPT color space as the second color value of the skin in the IPT color space. Alternatively, the computer can use the average of the color values of all pixels within the predetermined region in the IPT color space as the second color value of the skin in the IPT color space. For example, the second color value can be represented as (I², P², T²).
[0127] For the conversion methods of the various color spaces mentioned above, please refer to the existing technology; the embodiments in this application will not be described in detail.
[0128] The second color value is used to represent the skin color of the subject in an image captured by mobile phone A under corresponding environmental parameters. For example, the second color value obtained from the second image in a set of data corresponding to a preset color temperature of 2000K is used to represent the skin color of the subject in an image captured by mobile phone A when the ambient color temperature is 2000K. As another example, the second color value obtained from the second image in a set of data corresponding to a preset color temperature of 4500K is used to represent the skin color of the subject in an image captured by mobile phone A when the ambient color temperature is 4500K.
[0129] The first color value is different from the second color value.
[0130] In this way, the computer can obtain the first color value and the second color value of the skin under the corresponding environmental parameters. Then, the computer can obtain the correction coefficient corresponding to the environmental parameters based on the first and second color values of the skin under the corresponding environmental parameters. For example, the computer can execute S54.
[0131] S54, the computer obtains the correction coefficient based on the first color value and the second color value.
[0132] The correction factor is used to correct the second color value to the first color value.
[0133] In some embodiments, each of the plurality of correction coefficients includes coefficient 1, coefficient 2, and coefficient 3. Coefficient 1 is used to correct the brightness of a pixel, coefficient 2 is used to correct the saturation of a pixel, and coefficient 3 is used to correct the hue angle of a pixel. The first coefficient is the ratio of the brightness of a first color value to the brightness of a second color value. The second coefficient is the ratio of the chroma of the first color value to the chroma of the second color value. The third coefficient is the difference between the hue angle of the first color value and the hue angle of the second color value.
[0134] For example, the first color space is the IPT color space. The first color value is (I1, P1, T1), and the second color value is (I2, P2, T2). Then, coefficient 1 = I1 / I2. The sqrt() function is used to calculate the square root. The chroma of the first color value. Let H1 be the hue angle of the first color value and H2 be the hue angle of the second color value. The coefficient 3 = ΔH = H1 - H2. H1 = arctan2(T1,P1) / π*180, H2 = arctan2(T2,P2) / π*180. Here, arctan2() is the arctangent function. H1 is the hue angle of the first color value, and H2 is the hue angle of the second color value.
[0135] The above description uses the IPT color space as an example of a first color space. As described in the preceding embodiments, the first color space can also be other color spaces with uniformity characteristics. Similarly, for example, the first color space is the Lab color space. The first color value is (L1, a1, b1), and the second color value is (L2, a2, b2). Then, coefficient 1 = L1 / L2. The sqrt() function is used to calculate the square root. It is the chroma of the first color value. This is the chroma of the second color value. Coefficient 3 = ΔH = H1 - H2. H1 = arctan2(a1,b1) / π*180, H2 = arctan2(a2,b2) / π*180. Where arctan2() is the arctangent function. H1 is the hue angle of the first color value, and H2 is the hue angle of the second color value. For example, if the first color space is the ICtCp color space, and the first color value is (I1, Ct1, Cp1), and the second color value is (I2, Ct2, Cp2), then coefficient 1 = I1 / I2. The sqrt() function is used to calculate the square root. It is the chroma of the first color value. This is the chroma of the second color value. Coefficient 3 = ΔH = H1 - H2. H1 = arctan2(Ct) 1,Cp1) / π*180, H2=arctan2(Ct2,Cp2) / π*180. Where arctan2() is the arctangent function. H1 is the hue angle of the first color value, and H2 is the hue angle of the second color value.
[0136] In other embodiments, the correction coefficient can be a correction matrix. For example, second color value * correction matrix = first color value. The computer can solve the above system of equations using the least squares method to obtain the correction matrix. For example, the correction matrix can be a 3x3 matrix.
[0137] Taking the IPT color space as the first color space as an example, combined with Figure 6 To introduce it. For example, Figure 6 This demonstrates a method for obtaining the corresponding correction coefficient based on a set of data corresponding to a preset color temperature of 2000K. Figure 6 The second image is an image of the subject captured by mobile phone A when the ambient color temperature is 2000K. Figure 6 The spectral data in the image is the spectral data of the subject's skin collected by a spectrometer when the ambient color temperature is 2000K. After preprocessing, the second image can be in the RGB color space. Preprocessing may include Denoise, AWB, and color correction. This preprocessing can be a built-in workflow of the ISP. After preprocessing, the second image is converted from the RGB color space to the XYZ color space, and then from the XYZ color space to the IPT color space, obtaining the second color values of the skin in the second image, such as color values (I2, P2, T2). The color values of the skin in the XYZ color space are obtained based on the spectral data. Color adaptation conversion is performed on the color values of the skin in the XYZ color space. The purpose of color adaptation conversion is to mimic the human eye's perception of color stimuli under different color temperatures. Furthermore, by using variables such as the degree of color adaptation, it better addresses the incomplete color adaptation phenomenon in certain extreme scenarios (such as extremely low color temperatures). After color adaptation conversion, the skin's color space is converted to the IPT color space, obtaining the first color values of the skin, such as color values (I1, P1, T1). Finally, the computer can obtain a correction factor corresponding to the preset color temperature of 2000K based on the first and second color values. This correction factor includes a factor 1 such as K. I Coefficient 2, such as K C The coefficient is 3, as shown in ΔH. Where K... I =I1 / I2. △H=H1-H2.
[0138] In this way, the computer can obtain correction coefficients corresponding to the preset color temperatures. By repeating the above method, the computer can obtain M correction coefficients that correspond one-to-one with the M preset color temperatures. Figure 5 and Figure 6This demonstrates a method for a computer to generate M correction coefficients based on M sets of data corresponding to M preset color temperatures. The computer can also generate N correction coefficients based on N sets of data corresponding to N preset illuminance values using the same method. Furthermore, it can generate P correction coefficients based on P sets of data corresponding to P parameter sets. These methods will not be elaborated upon here.
[0139] The method described above for obtaining correction coefficients can be implemented during the research and development phase. The user's electronic device can have these correction coefficients built-in or downloaded. During the process of the user taking a photo using the electronic device, the device can use these correction coefficients to correct the skin tone of the portrait in the image. The user's electronic device can be, for example, mobile phone B, which may or may not be the same phone as mobile phone A. Optionally, the image processor (sensor) of mobile phone B and the image processor (sensor) of mobile phone A are the same model of image processor.
[0140] In some embodiments, mobile phone B pre-stores a one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients. For example, during the research and development phase of mobile phone B, researchers can obtain the one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients from a computer and store it in mobile phone B. In other embodiments, mobile phone B can download the one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients. The computer can store the one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients on a cloud server. After mobile phone B leaves the factory, it can actively interact with the cloud server to obtain the one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients under preset conditions. These preset conditions may include the first power-on of mobile phone B, the first launch of the camera application on mobile phone B, etc. For example, mobile phone B may include M correction coefficients corresponding one-to-one with M preset color temperatures, and / or N correction coefficients corresponding one-to-one with N preset illuminance. As another example, mobile phone B may include P correction coefficients corresponding one-to-one with P parameter groups.
[0141] For example, phone B may include correction coefficient 1 corresponding to a color temperature of 2000K, correction coefficient 2 corresponding to a color temperature of 4500K, correction coefficient 3 corresponding to a color temperature of 6500K, and correction coefficient 4 corresponding to a color temperature of 8000K. As another example, phone B may include N correction coefficients corresponding one-to-one with N preset illuminance levels. For instance, phone B may include correction coefficient a corresponding to illuminance of 500Lux, correction coefficient b corresponding to illuminance of 1000Lux, correction coefficient c corresponding to illuminance of 1500Lux, and correction coefficient d corresponding to illuminance of 2000Lux. As yet another example, phone B may include correction coefficient A corresponding to illuminance of 500Lux at a color temperature of 6500K, correction coefficient B corresponding to illuminance of 1000Lux at a color temperature of 2500K, correction coefficient C corresponding to illuminance of 1500Lux at a color temperature of 4000K, and correction coefficient D corresponding to illuminance of 2000Lux at a color temperature of 8000K.
[0142] Mobile phone B can use a first correction factor from among multiple correction factors to correct the color of a target area in the first image. The first correction factor corresponds to the shooting environment when the first image was captured, and the target area is the image region in the first image that includes the subject's skin. The first correction factor is used to correct the color of the target area to the color of the subject's skin in the shooting environment. Optionally, the target area can be, for example, a face area. Optionally, the target area can be all areas in the image that include skin.
[0143] The following is combined with Figure 7 This describes a method for mobile phone B to process images based on a first correction factor. For example, Figure 7 The methods shown may include:
[0144] S71, Mobile Phone B acquires the first image.
[0145] The first image can be a photograph or a video frame.
[0146] In some embodiments, acquiring the first image by mobile phone B may include: mobile phone B capturing the first image through its camera. That is, this solution is applicable to scenarios involving taking photos or recording videos. The first image may be captured by the camera in mobile phone B, and mobile phone B can acquire the first image captured by the camera. The camera may be a front-facing camera or a rear-facing camera. Mobile phone B can respond to user operations by using its camera to capture the first image. For example, this operation may be a "take a picture" operation on the camera application's photo preview interface, such as a tap operation. Another example is a "take a picture" operation on the camera application's video preview interface, such as a tap operation. Yet another example is that the user speaks a voice control command near the microphone of mobile phone B, such as "take a picture" or "start recording video".
[0147] Optionally, this operation can also be opening the camera application. For example, after opening the camera application, phone B can perform... Figure 7 The method shown acquires and processes a first image, and displays the processed first image on the camera preview interface. This application embodiment does not limit the specific implementation method of triggering mobile phone B to acquire the first image.
[0148] In other embodiments, the first image is an image stored in mobile phone B, and acquiring the first image by mobile phone B includes reading the first image from a storage area. In other embodiments, acquiring the first image by mobile phone B may include: mobile phone B interacting with other electronic devices to acquire the first image captured by the other electronic devices.
[0149] Optionally, the first image can be a raw image captured by a camera.
[0150] Optionally, the first image can be a processed Raw image. For example, the first image can be a Raw image after denoiseing, AWB, and color correction.
[0151] After acquiring the first image, mobile phone B can identify the shooting environment in which the first image was captured and obtain a first correction coefficient corresponding to the shooting environment. For example, the mobile phone can identify the target environment parameters in the first image and obtain the first correction coefficient corresponding to the target environment parameters.
[0152] S72, Mobile phone B acquires the target environment parameters when acquiring the first image.
[0153] The target environment parameters reflect the shooting environment when the first image was acquired. Target environment parameters can be ambient color temperature and / or ambient illuminance.
[0154] If phone B includes M correction coefficients corresponding one-to-one with M preset color temperatures, phone B can obtain the ambient color temperature when the first image was captured. For example, phone B can obtain the ambient color temperature when the first image was captured based on the color values in the first image. Alternatively, during the capture of the first image, the camera analyzes the ambient light using its built-in sensor, and calculates the ambient color temperature when the first image was captured based on the analysis results.
[0155] With mobile phone B including N correction coefficients corresponding one-to-one with N preset illuminance levels, mobile phone B can obtain the ambient brightness when the first image was captured. For example, mobile phone B can obtain the ambient brightness when the first image was captured based on the color values in the first image. Alternatively, mobile phone B can analyze the first image using an image analysis application to obtain the ambient brightness when the first image was captured. Another example is that mobile phone B can estimate the ambient brightness when the first image was captured based on the camera parameters used to capture the first image. These shooting parameters may include exposure parameters such as ISO sensitivity, exposure time, and exposure value.
[0156] When mobile phone B includes M correction coefficients corresponding to M preset color temperatures and N correction coefficients corresponding to N preset illuminance levels, mobile phone B can obtain the ambient color temperature or ambient brightness at the time of capturing the first image. Mobile phone B can obtain a first correction coefficient matching the target environment parameters based on the ambient color temperature at the time of capturing the first image, or obtain a first correction coefficient matching the target environment parameters based on the ambient brightness at the time of capturing the first image, and process the color of the skin area in the first image based on the first correction coefficient.
[0157] With mobile phone B containing P correction coefficients corresponding one-to-one with each of the P parameter groups, mobile phone B can obtain the ambient color temperature and ambient brightness at the time of capturing the first image. Mobile phone B can then obtain a first correction coefficient that matches the target environmental parameters based on the ambient color temperature and ambient brightness at the time of capturing the first image.
[0158] After obtaining the target environmental parameters of the first image, mobile phone B can determine the first correction coefficient corresponding to the target environmental parameters based on the one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients.
[0159] S73, mobile phone B obtains the first correction coefficient based on the target environment parameters when the first image is acquired.
[0160] Mobile phone B obtains a first correction coefficient based on the target environmental parameters and preset environmental parameters when capturing the first image. For example, if the target environmental parameter is the ambient color temperature, mobile phone B obtains the matching first correction coefficient based on the one-to-one correspondence between the ambient color temperature when capturing the first image and M preset color temperatures and correction coefficients stored in mobile phone B. As another example, if the target environmental parameter is the ambient brightness, mobile phone B obtains the matching first correction coefficient based on the ambient brightness when capturing the first image and N preset illuminance and correction coefficients stored in mobile phone B. The following describes a method for obtaining the first correction coefficient using the ambient color temperature as an example of the target environmental parameter.
[0161] For example, if the preset color temperature saved by mobile phone B includes the ambient color temperature when the first image was captured, mobile phone B will use the correction coefficient corresponding to the preset color temperature that matches the ambient color temperature when the first image was captured as the first correction coefficient. For example, mobile phone B saves correction coefficient 1 corresponding to a color temperature of 2000K, correction coefficient 2 corresponding to a color temperature of 4500K, correction coefficient 3 corresponding to a color temperature of 6500K, and correction coefficient 4 corresponding to a color temperature of 8000K. If the ambient color temperature when the first image was captured was 4500K, mobile phone B will use correction coefficient 2 as the first correction coefficient.
[0162] For example, if the preset color temperature saved by phone B does not include the ambient color temperature when the first image was captured, phone B can match a first correction coefficient to the first image. The following sections will describe different scenarios.
[0163] If the ambient color temperature when acquiring the first image is less than the minimum preset color temperature among the M preset color temperatures, mobile phone B uses the correction coefficient corresponding to the minimum preset color temperature among the M preset color temperatures as the first correction coefficient. For example, if the ambient color temperature when acquiring the first image is 1500K, mobile phone B uses the correction coefficient 1 corresponding to the color temperature of 2000K as the first correction coefficient.
[0164] If the ambient color temperature when acquiring the first image is greater than the maximum preset color temperature among the M preset color temperatures, mobile phone B uses the correction coefficient corresponding to the maximum preset color temperature among the M preset color temperatures as the first correction coefficient. For example, if the ambient color temperature when acquiring the first image is 9500K, mobile phone B uses the correction coefficient 4 corresponding to the color temperature of 8000K as the first correction coefficient.
[0165] When the ambient color temperature during the acquisition of the first image is between two preset color temperatures, mobile phone B can obtain a first correction coefficient based on the difference method. For example, if the ambient color temperature during the acquisition of the first image is between a first preset color temperature and a second preset color temperature, mobile phone B can obtain the first correction coefficient based on the ambient color temperature during the acquisition of the first image, the first preset color temperature, and the second preset color temperature. The second preset color temperature is greater than the first preset color temperature. For example, the ambient color temperature during the acquisition of the first image is greater than the first preset color temperature and less than the second preset color temperature. Optionally, the first preset color temperature is the maximum value among at least one preset color temperature that is less than the ambient color temperature during the acquisition of the first image. The second preset color temperature is the minimum value among at least one preset color temperature that is greater than the ambient color temperature during the acquisition of the first image. Mobile phone B calculates a weight coefficient 1 corresponding to the first preset color temperature and a weight coefficient 2 corresponding to the second preset color temperature. For example, weight coefficient 1 = (ambient color temperature during acquisition of the first image - first preset color temperature) / (second preset color temperature - first preset color temperature). Weight coefficient 2 = (second preset color temperature - ambient color temperature during acquisition of the first image) / (second preset color temperature - first preset color temperature). Mobile phone B calculates the first correction coefficient based on weighting coefficients. For example, the first correction coefficient = weighting coefficient 1 * correction coefficient corresponding to the first preset color temperature + weighting coefficient 2 * correction coefficient corresponding to the second preset color temperature. For example, the ambient color temperature when capturing the first image is 4000K. The first preset color temperature is 2000K, and the second preset color temperature could be 4500K. Weighting coefficient 1 = (4000-2000) / (4500-2000) = 0.8, weighting coefficient 2 = (4500-4000) / (4500-2000) = 0.2. The first correction coefficient = 0.8 * correction coefficient corresponding to color temperature 2000K + 0.2 * correction coefficient corresponding to color temperature 4500K. For example, the correction coefficient corresponding to color temperature 2000K includes coefficient 1 such as K. ` 1. Coefficient 2, such as K ` 2 and coefficient 3, such as ΔH ` 3. The correction factor corresponding to a color temperature of 4500K includes factor 1, such as K. ` 1 ` Coefficient 2, such as K ` 2 ` And coefficient 3, such as ΔH ` 3 ` Therefore, the first correction coefficient corresponding to the ambient color temperature when the first image was acquired includes coefficient K. ` 1 `` coefficient K ` 2 `` sum coefficient ΔH ` 3 `` Among them, K ` 1 `` =0.8*K ` 1+0.2*K ` 1` K ` 2 `` =0.8*K ` 2+0.2*K ` 2 ` ΔH ` 3 `` =0.8*ΔH ` 3+0.2*ΔH ` 3 ` For example, if the correction factor for a color temperature of 2000K is correction matrix M1, and the correction factor for a color temperature of 4500K is correction matrix M2, then the correction factor for the ambient temperature is correction matrix M3, where M3 = 0.8 * M1 + 0.2 * M2.
[0166] Optionally, mobile phone B can use the same method to obtain a first correction coefficient that matches the first image based on the ambient illumination when the first image was captured.
[0167] Optionally, if mobile phone B includes P correction coefficients corresponding one-to-one with each of the P parameter groups, mobile phone B can obtain a first correction coefficient matching the first image based on the ambient illuminance and ambient color temperature at the time of capturing the first image. For example, the mobile phone uses the correction coefficient corresponding to the parameter group whose ambient illuminance and ambient color temperature are consistent with those at the time of capturing the first image as the first correction coefficient. When the ambient illuminance and ambient color temperature at the time of capturing the first image are inconsistent with the preset color temperature and preset illuminance among the P parameters, the correction coefficient corresponding to the parameter group whose ambient illuminance and ambient color temperature are close to those at the time of capturing the first image is used as the first correction coefficient.
[0168] S74, Mobile phone B uses the first correction factor to process the first image.
[0169] The use of the first correction to process the first image by mobile phone B can be understood as: mobile phone B uses the first correction coefficient to correct the color of the target area.
[0170] Specifically, for each pixel within the target area, phone B first acquires the brightness, chroma, and hue angle of each pixel. For example, phone B can acquire these parameters through color space conversion. Then, phone B corrects each pixel in the target area using a first correction factor. See the description below.
[0171] For example, mobile phone B can convert the color space of the first image to a second color space. The initial color space of the first image differs from the second color space. For instance, if the first image is in RGB format, its initial color space can be RGB. Similarly, if the first image is in YUV format, its initial color space can be YUV. This application does not specifically limit the initial color space of the first image. This document uses the example of the first image having an initial color space of RGB for illustration.
[0172] The second color space differs from the first color space. As mentioned earlier, the first color space is a uniform color space. The parameters of the second color space include luminance, chroma, and hue angle. In other words, the second color space can represent colors using luminance, chroma, and hue angle. For example, the second color space can be an intensity, chroma, hue (ICH) color space or a lightness, chroma, hue (LCH) color space. After converting the color space of the first image to the second color space, the color value of each pixel in the second image can be represented by luminance, chroma, and hue angle. Then, phone B identifies the target region in the first image and obtains the third color value of all pixels included in the target region in the second color space. That is, phone B performs a color space conversion on the entire first image, but only corrects the color values of the pixels included in the target region.
[0173] For example, mobile phone B can convert the color space of the target region in the first image to a second color space to obtain a third color value for the target region in the second color space. For instance, mobile phone B can segment a skin image from the first image. The skin image is an image that includes the target region. For example, mobile phone B can segment the image corresponding to the target region from the first image based on a mask image. The mask image is a binary image, meaning each pixel in the image has only two values, such as 0 and 255, representing black and white respectively. The pixel value of the image corresponding to the target region in the mask image can be one of 0 and 255, and the pixel value corresponding to the images of the remaining areas besides the target region can be the other of 0 and 255. Then, mobile phone B can convert the color space of all pixels included in the target region in the first image to a second color space to obtain a third color value for all pixels included in the target region in the second color space. In this embodiment, mobile phone B can first segment the image corresponding to the target region from the first image, process the image corresponding to the target region using a first correction coefficient, and then replace the unprocessed image of the target region in the first image with the processed image of the target region to obtain a processed first image. In this context, processing the image corresponding to the target region using the first correction coefficient can be understood as processing all pixels included in the target region using the first correction coefficient.
[0174] For example, when the second color space is the ICH color space, mobile phone B can convert the color values of the first image, such as RGB values, to XYZ color space values, then to LMS color space values, and finally to IPT color space values. The color space conversion methods described above are described in existing technologies and will not be repeated in this application. After converting the color values of the first image in the IPT color space to the ICH color space, the third color values of all pixels included in the target area are obtained. For example, if the third color value adopts (I... a C a H a This is represented by (). For example, the color value of a pixel in the IPT color space is (I a P a T a ),So, H b =arctan2(T a ,P a) / π*180. Optionally, mobile phone B can convert the color space of the first image to a first color space, and then convert the color space of the target area in the first image from the first color space (e.g., IPT color space) to a second color space (e.g., ICH color space). After correction in the second color space, mobile phone B converts the color space of the target area from the second color space back to the first color space. The corrected target area is then used to replace the uncorrected target area in the first image to obtain the corrected first image.
[0175] For example, if the second color space is the LCH color space, mobile phone B can convert the color values of the first image, such as RGB values, to XYZ color space values, then to Lab color space values, and finally to LCH color space values. This allows obtaining the third color values for all pixels within the target area. The third color values can be expressed as follows: (L...) a C a H a () indicates. Optionally, mobile phone B can convert the color space of the first image to a first color space, and then convert the color space of the target area in the first image from the first color space (e.g., IPT color space) to a second color space (e.g., LCH color space). After correction in the second color space, mobile phone B converts the color space of the target area from the second color space back to the first color space. The corrected target area is then used to replace the uncorrected target area in the first image to obtain the corrected first image.
[0176] Optionally, mobile phone B segments a skin image including the target region from the first image, and only converts the skin image using the above method to obtain the third color value of the target region in the second color space. The color space conversion method described above is based on existing technology and will not be repeated in this embodiment. Specifically, converting the color space of the target region to the second color space by mobile phone B can be understood as: mobile phone B can convert the color values of multiple pixels included in the target region to the third color value in the second color space. That is, after the color space conversion, each pixel included in the target region in the first image includes a corresponding third color value.
[0177] After obtaining the third color value of the target area in the second color space (i.e., the third color value of the multiple pixels included in the target area in the second color space), a first coefficient is used to correct the pixel brightness, a second coefficient is used to correct the pixel chroma, and a third coefficient is used to correct the pixel hue angle. Specifically, the first coefficient is multiplied by the pixel brightness to obtain the corrected brightness, the second coefficient is multiplied by the pixel chroma to obtain the corrected chroma, and the third coefficient is added to the pixel hue angle to obtain the corrected hue angle.
[0178] For example, for each pixel in the target area, mobile phone B can correct the third color value of each pixel pixel by pixel. For each pixel among the multiple pixels included in the target area, the correction is performed based on the following method. For example, if the second color space is the ICH color space, the third color value of the pixel is used as (I... a C a H a ) indicates that, after correction, the fourth color value of the pixel is represented by (I b C b H b ) indicates. Where, I b =coefficient 1 * I a C b =coefficient 2 * C a H b = coefficient 3 + H a For example, when the second color space is the LCH color space, the third color value of a pixel is represented by (L... a C a H a ) indicates that, after correction, the fourth color value of the pixel is represented by (L b C b H b ) indicates. Where, L b =coefficient 1 * L a C b =coefficient 2 * C a H b = coefficient 3 + H a .
[0179] Optionally, when the correction coefficient is a correction matrix, mobile phone B obtains the fifth color value of the target region in the first color space based on the first image. For example, mobile phone B can obtain the fifth color value of all pixels included in the target region in the first color space based on the first image. For example, mobile phone B converts the color space of the first image to the first color space to obtain the fifth color value of all pixels included in the target region in the first color space. Or, for example, mobile phone B converts the color space of the skin image of the target region in the first image to the first color space to obtain the fifth color value of all pixels included in the target region in the first color space.
[0180] If the first color space is the IPT color space, the correction is performed for each pixel among the multiple pixels in the target area based on the following method.
[0181]
[0182] Among them, [I ` b ,P`b ,T` b ] is related to pixel [I a ,P a ,T a The corresponding corrected pixel. ` b =I a *M11+P a *M21+T a *M31,P` b =I a *M12+P a *M22+T a *M32,T` b =I a *M13+P a *M23+T a *M33.
[0183] It is the first correction matrix.
[0184] After pixel-by-pixel correction, and assuming the skin image is segmented for processing, phone B can convert the color space of the corrected skin image to its original color space, such as RGB, or from a second color space to RGB, or from a first color space to RGB. Then, the corrected skin image replaces the uncorrected skin image in the first image, resulting in the corrected first image. Optionally, without segmenting the skin image, the color values of pixels in the target region of the first image are corrected pixel-by-pixel to obtain the corrected first image. The phone can then convert the color space of the corrected first image back to its initial color space, such as RGB, or from an IPT color space to RGB.
[0185] As can be seen, in this embodiment, a correction coefficient is used to correct skin color in the image. Since the correction coefficient can correct the skin color in the image captured by the camera to a realistic skin color, after correction, the skin color in the image captured by the camera is close to the real skin color, which can effectively reduce the difference between the skin color in the image captured by the camera and the real skin color.
[0186] Optionally, after S74, phone B can display the corrected first image, such as in the camera app's shooting preview interface. Phone B can also save the corrected first image.
[0187] In some embodiments, after color correction of the target area in the image, mobile phone B can further adjust the color of the target area. This adjustment can be understood as skin tone beautification adjustment. After obtaining the realistic skin tone, the user may also need to adjust the realistic skin tone to the user's preferred skin tone. For example, the user's preferred skin tone could be fair skin, wheat skin, etc. Below are two methods for mobile phone B to further adjust the color of the target area.
[0188] For example, phone B uses a color lookup table (LUT) to process the corrected skin image. An LUT is a color value mapping table that represents the correspondence between color values before and after adjustment. The phone can use the LUT to adjust the color values of individual pixels in the corrected target area.
[0189] For example, phone B uses a skin tone mapping model to process the corrected skin image. The input to the skin tone mapping model is the color value of each pixel in the corrected skin image, and the output is the color value of each pixel that matches the user's preferred color. For example, the skin tone mapping model could be a neural network model. When training this model, an image including the user's skin is taken as input, the skin saturation in the image is adjusted to meet the user's preferred skin tone, and the adjusted skin tone image is used as a label. The model is trained to have the ability to correct the skin tone in an image including the user's skin to meet the user's preferred skin tone. For example, after training, the skin tone mapping model has the ability to map one skin tone in an image to another skin tone.
[0190] like Figure 8 As shown in (a), conventional skin tone beautification technology corrects multiple different skin tones to the same target skin tone, such as correcting skin tone 'a' in image a to the target skin tone, and correcting skin tone 'c' in image b to the target skin tone. Since consumers of different skin tones, ethnicities, and genders have different preferences for the skin tones in images captured by electronic devices, correcting different skin tones to the same skin tone cannot meet the preferences of different consumers. In this solution, a skin tone mapping model is used to map the skin tones in an image to the skin tone preferred by the subject in that image. Figure 8 As shown in (b), this skin color mapping model has the ability to map skin color a in image a to skin color b, and skin color c in image b to skin color d. Here, skin color b is the preferred skin color of the subject in image a, and skin color d is the preferred skin color of the subject in image b. If the preferred skin color of the subject in image a differs from that in image b, then skin color c and skin color d will be different. This allows the model to meet the diverse needs of different consumers.
[0191] The following combination Figure 9Taking the IPT color space as the first color space and the ICH color space as the second color space as an example, an image processing method provided in the embodiments of this application will be illustrated.
[0192] like Figure 9 As shown, after preprocessing, the first image can be in the RGB color space. Preprocessing may include Denoise, AWB, and color correction. This preprocessing can be a built-in workflow of the ISP. After preprocessing, the first image is converted from the RGB color space to the XYZ color space, and then from the XYZ color space to the IPT color space, obtaining the color value (IT) of the target region in the first image in the IPT color space. a P a T a Each pixel in the target area includes a corresponding color value (I). a P a T a ).
[0193] Then, phone B converts the color values of the target area in the first image to the third color value in the ICH color space, such as the color value (I... a C a H a Each pixel in the target region includes a corresponding third color value, such as the color value (I). a C a H a ).
[0194] Mobile phone B uses a first correction factor corresponding to the shooting parameters of the first image, such as (K). I K C , △H) corrects the color value of the target area (I a C a H a For example, for each pixel among multiple pixels included in the target area, mobile phone B uses a first correction factor to correct the color value (I) corresponding to that pixel. a C a H a For example, after correction, the color value of this pixel is (I). b C b H b ). Among them, I b =K I *I a C b =K C *C a H b =H a+△H. After pixel-by-pixel correction, phone B converts the color values of the target area to color values in the IPT color space (I... b P b T b Each pixel in the target area includes a corresponding color value (I). b P b T b ).
[0195] Next, phone B performs skin tone beautification adjustments on the color values of the target area. For example, phone B uses a LUT or skin tone mapping model to adjust the color value of each pixel in the target area from the color value (I... b P b T b Adjust to the color values in the IPT color space (I c P c T c ).
[0196] Finally, phone B overlays the color-adjusted target area with the non-target area in the first image to obtain the complete processed first image.
[0197] Mobile phone B can perform other image processing on the processed first image, and then display the first image after processing.
[0198] This application provides an electronic device including a memory, a display screen, and one or more processors. The display screen is coupled to the processors. The memory stores computer program code. The computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device can perform various functions or steps performed by the mobile phone in the above method embodiments. The structure of the electronic device can be referred to... Figure 1 The structure of the electronic device 100 shown.
[0199] This application embodiment also provides a computer storage medium, which includes computer instructions, when the computer instructions are executed in the aforementioned electronic device (such as...). Figure 1 When the electronic device 100 shown is run, it causes the electronic device to perform the various functions or steps in the above method embodiments.
[0200] This application also provides a computer program product that, when run on a computer, causes the computer to perform the various functions or steps described in the above method embodiments.
[0201] This application also provides a chip system including at least one processor and at least one interface circuit. The processor and the interface circuit are interconnected via lines. For example, the interface circuit can be used to receive signals from other devices (e.g., the memory of an electronic device). As another example, the interface circuit can be used to send signals to other devices (e.g., the processor). Exemplarily, the interface circuit can read instructions stored in the memory and send the instructions to the processor. When the instructions are executed by the processor, the electronic device can perform the steps in the above embodiments. Of course, the chip system may also include other discrete devices, and this application does not specifically limit this.
[0202] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0203] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0204] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0205] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0206] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0207] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An image processing method, characterized in that, Applied to electronic devices, the method includes: In response to the operation of opening the camera application, a first image is captured through the camera; Based on a first correction coefficient, the color of the target region in the first image is corrected; wherein, the first correction coefficient corresponds to the shooting environment when the first image was acquired, and the target region is the image region in the first image that includes the skin of the subject; the first correction coefficient is used to correct the color of the target region to the color of the skin of the subject in the shooting environment; The corrected first image is displayed.
2. The method according to claim 1, characterized in that, The electronic device stores a one-to-one mapping relationship between multiple environmental parameters and multiple correction coefficients; Before correcting the color of the target region in the first image based on the first correction coefficient, the method further includes: Acquire target environment parameters when acquiring the first image, the target environment parameters being used to reflect the shooting environment when acquiring the first image; Based on the mapping relationship, the first correction coefficient corresponding to the target environmental parameter is determined.
3. The method according to claim 1 or 2, characterized in that, The first correction coefficient includes a first coefficient, a second coefficient, and a third coefficient; the target region includes one or more pixels; The first coefficient is used to correct the brightness of the pixel, the second coefficient is used to correct the chroma of the pixel, and the third coefficient is used to correct the hue angle of the pixel.
4. The method according to claim 3, characterized in that, The step of correcting the color of the target region in the first image based on the first correction coefficient includes: For each pixel included in the target region: Based on the color value of the pixel, the brightness, chroma, and hue angle of the pixel are obtained; The first coefficient is used to correct the brightness of the pixel, the second coefficient is used to correct the chroma of the pixel, and the third coefficient is used to correct the hue angle of the pixel.
5. The method according to claim 4, characterized in that, The step of correcting the brightness of the pixel using the first coefficient, correcting the chroma of the pixel using the second coefficient, and correcting the hue angle of the pixel using the third coefficient includes: Multiply the first coefficient by the brightness of the pixel to obtain the corrected brightness; multiply the second coefficient by the chroma of the pixel to obtain the corrected chroma; and add the third coefficient to the hue angle of the pixel to obtain the corrected hue angle.
6. The method according to any one of claims 1-5, characterized in that, The correction coefficient corresponding to an environmental parameter in the mapping relationship is obtained based on a second image captured under the shooting environment corresponding to the environmental parameter and spectral data of the skin collected under the shooting environment corresponding to the environmental parameter. The second image includes an image of the subject's skin; the spectral data is the spectral data of the subject's skin.
7. The method according to claim 6, characterized in that, The correction coefficient corresponding to an environmental parameter in the mapping relationship is obtained based on a second image captured under the shooting environment corresponding to the environmental parameter and spectral data of the skin collected under the shooting environment corresponding to the environmental parameter, including: Based on the spectral data, a first color value for the skin is obtained in a first color space; the first color value is used to represent the color of the subject's skin in the environmental parameters. Based on the second image, a second color value for the skin is obtained in a first color space; the second color value is used to represent the color of the subject's skin in the image acquired by the electronic device in the environmental parameters. Based on the first color value and the second color value, a correction coefficient corresponding to the environmental parameter is obtained; The first color space is a uniform color space.
8. The method according to claim 7, characterized in that, The correction coefficients corresponding to the environmental parameters include: a first coefficient, a second coefficient, and a third coefficient; the first coefficient is the ratio of the brightness of the first color value to the brightness of the second color value; the second coefficient is the ratio of the chroma of the first color value to the chroma of the second color value; and the third coefficient is the difference between the hue angle of the first color value and the hue angle of the second color value.
9. An electronic device, characterized in that, The electronic device includes: a memory, a camera, and one or more processors; the camera, the memory, and the processors are coupled; wherein the memory is used to store computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the electronic device performs the method as described in any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, Includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-8.
11. A computer program product, comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method as described in any one of claims 1-8.