WO2022105850A1 - 光源光谱获取方法和设备 - Google Patents

光源光谱获取方法和设备 Download PDF

Info

Publication number
WO2022105850A1
WO2022105850A1 PCT/CN2021/131622 CN2021131622W WO2022105850A1 WO 2022105850 A1 WO2022105850 A1 WO 2022105850A1 CN 2021131622 W CN2021131622 W CN 2021131622W WO 2022105850 A1 WO2022105850 A1 WO 2022105850A1
Authority
WO
WIPO (PCT)
Prior art keywords
light source
information
shooting scene
light sources
spectrum
Prior art date
Application number
PCT/CN2021/131622
Other languages
English (en)
French (fr)
Inventor
周茂森
钱彦霖
何名桂
钱康
杨永兴
王妙锋
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to US18/037,723 priority Critical patent/US20230410463A1/en
Publication of WO2022105850A1 publication Critical patent/WO2022105850A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/60Extraction of image or video features relating to illumination properties, e.g. using a reflectance or lighting model
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/20Processor architectures; Processor configuration, e.g. pipelining
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/10Image acquisition
    • G06V10/12Details of acquisition arrangements; Constructional details thereof
    • G06V10/14Optical characteristics of the device performing the acquisition or on the illumination arrangements
    • G06V10/143Sensing or illuminating at different wavelengths
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/56Extraction of image or video features relating to colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/761Proximity, similarity or dissimilarity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/762Arrangements for image or video recognition or understanding using pattern recognition or machine learning using clustering, e.g. of similar faces in social networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/762Arrangements for image or video recognition or understanding using pattern recognition or machine learning using clustering, e.g. of similar faces in social networks
    • G06V10/763Non-hierarchical techniques, e.g. based on statistics of modelling distributions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/764Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/774Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/82Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72403User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality
    • H04M1/7243User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality with interactive means for internal management of messages
    • H04M1/72439User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality with interactive means for internal management of messages for image or video messaging
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/10Cameras or camera modules comprising electronic image sensors; Control thereof for generating image signals from different wavelengths
    • H04N23/13Cameras or camera modules comprising electronic image sensors; Control thereof for generating image signals from different wavelengths with multiple sensors
    • H04N23/16Optical arrangements associated therewith, e.g. for beam-splitting or for colour correction
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/70Circuitry for compensating brightness variation in the scene
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof
    • H04N23/84Camera processing pipelines; Components thereof for processing colour signals
    • H04N23/88Camera processing pipelines; Components thereof for processing colour signals for colour balance, e.g. white-balance circuits or colour temperature control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/12Picture reproducers
    • H04N9/31Projection devices for colour picture display, e.g. using electronic spatial light modulators [ESLM]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/12Picture reproducers
    • H04N9/31Projection devices for colour picture display, e.g. using electronic spatial light modulators [ESLM]
    • H04N9/3179Video signal processing therefor
    • H04N9/3182Colour adjustment, e.g. white balance, shading or gamut
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10032Satellite or aerial image; Remote sensing
    • G06T2207/10036Multispectral image; Hyperspectral image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20072Graph-based image processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20076Probabilistic image processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning

Definitions

  • the present application relates to the field of terminals, and in particular, to a method and device for acquiring a spectrum of a light source.
  • the light intensity recorded by the RGB sensor is the integration result of the light source spectrum, the reflectance spectrum of the object material and the response function.
  • the light intensity recorded by the RGB sensor is different, due to the different spectrum of the light source, the light intensity recorded by the RGB sensor is different, and the color value calculated according to the light intensity is also different, and the color of the visible image is greatly affected by the light source.
  • the influence of the light source can be removed by white balance processing and color correction processing, and the light source spectrum can be used to guide the white balance processing and color correction processing.
  • a multi-spectral sensor is added to the camera. After the multi-spectral sensor records the light intensity of the light received by each pixel, the light intensity of the light received by each pixel is subjected to interpolation processing, and the spectrum obtained after the interpolation is used as the light source. spectrum.
  • the light source spectrum obtained by the above method is essentially the integration result of the light source spectrum, the reflectivity spectrum of the object material and the response function, not a simple light source spectrum, and the accuracy of the light source spectrum obtained by the above method is not high.
  • the present application provides a light source spectrum acquisition method and device for acquiring a light source spectrum with higher accuracy.
  • the present application provides a light source spectrum acquisition method, including: acquiring first information in a current shooting scene, where the first information includes at least one of the following: a first image generated by an RGB sensor or a first multispectral sensor The light intensity of the light received by each pixel above; the first information is input into the first model to obtain the probability that the light source in the current shooting scene belongs to various light sources; the probability that the light source in the current shooting scene belongs to various light sources and The spectrum of various light sources determines the spectrum of the light source in the current shooting scene.
  • the method before the inputting the first information into the first model to obtain the probability that the light source in the current shooting scene belongs to various light sources, the method further includes: acquiring a training sample, the training sample The first information in different shooting scenes and the light source categories corresponding to the light sources in different shooting scenes are included; the first model is trained by using the training samples.
  • the acquiring training samples includes: constructing a data set, where the data set includes M ⁇ N groups of data, each group of data corresponds to a shooting scene, and each shooting scene corresponds to a light source and a subject, M is the number of light sources, N is the number of subjects, each set of data includes: the first information corresponding to the shooting scene; the spectrum of the M types of light sources in the data set is clustered and analyzed to obtain each The light source category corresponding to the light source in the shooting scene; the training sample is obtained according to the first information in each set of data and the light source category corresponding to the light source in each shooting scene.
  • each group of data in the M ⁇ N groups of data further includes: second information, where the second information includes: the spectrum of the light source corresponding to the shooting scene and the second multispectral spectrum corresponding to the shooting scene The material reflectance spectrum of the object corresponding to each pixel on the sensor; performing cluster analysis on the spectra of the M light sources in the data set to obtain the light source category corresponding to the light source in each shooting scene, including: obtaining the For the second information, M ⁇ N groups of second information are obtained; according to the M ⁇ N groups of second information, cluster analysis is performed on the spectra of the M types of light sources in the data set.
  • performing cluster analysis on the spectra of M types of light sources in the data set according to M ⁇ N sets of second information includes: determining, according to M ⁇ N sets of second information, that in the data set. Classification criteria of M kinds of light sources; according to the classification criteria, cluster analysis is performed on the spectra of the M kinds of light sources in the data set.
  • the determining the classification criteria of the M types of light sources in the data set according to the M ⁇ N sets of second information includes: for each of the N types of subjects, from the Take any two groups from the M groups of second information corresponding to the subject, and obtain pairs of combinations; for each pair of combinations, the two-dimensional data points corresponding to the combinations are calculated to obtain two-dimensional data points, the two-dimensional data points include average color distance and light source spectral similarity index; according to the two-dimensional data points to determine the classification criteria.
  • calculating the two-dimensional data points corresponding to the combination includes: calculating the first RGB value of each pixel according to a set of second information in the combination; According to another set of second information in the combination, the second RGB value of each pixel is calculated; according to the first RGB value of each pixel and the second RGB value of each pixel, the average color distance corresponding to the combination is determined.
  • the calculating, for each pair of combinations, the two-dimensional data points corresponding to the combination includes: according to the spectrum of the light source included in a set of second information in the combination and another in the combination.
  • the spectrum of the light source included in the second information group is used to determine the spectral similarity index of the light source corresponding to the combination.
  • the two-dimensional data points, and determining the classification criteria includes: according to the A two-dimensional data point is drawn, and a two-dimensional intersection diagram is drawn; the first parameter is determined from the abscissa of the two-dimensional intersection diagram, so that the ordinate is smaller than the preset value, and the abscissa is smaller than the two-dimensional point data of the first parameter The proportion of the number of points exceeds a preset threshold; the first parameter is used as the classification criterion.
  • the performing cluster analysis on the spectra of the M types of light sources in the data set according to the classification criteria includes: using a k-means clustering algorithm to perform a cluster analysis on the spectra of the M types of light sources in the data set.
  • cluster analysis the light source spectral similarity index between any two cluster centers is greater than the classification criterion, and within each cluster, the spectral similarity index between any two light sources is smaller than the classification criterion.
  • the first model includes a first branch, and the first branch is used to output the probability that the light source in the current shooting scene belongs to various types of light sources; and the light source category corresponding to the light source in each shooting scene, and obtaining a training sample includes: taking the first information in each set of data and the light source category corresponding to the light source in the corresponding shooting scene as a training sample.
  • the first model includes a first branch and a second branch, the first branch is used to output the probability that the light source in the current shooting scene belongs to various types of light sources, and the second branch is used to output the probability that the light source in the current shooting scene belongs to various light sources.
  • the first branch includes a first structure and a fully connected layer, the first structure is downsampled L times and then converted to the fully connected layer, and the first structure includes a convolution layer, activation function and maximum pooling layer, the loss function of the first branch is cross entropy, and L is greater than or equal to 1;
  • the second branch includes P residual blocks, each residual block includes the first convolution layer, the first An activation function, a second convolution layer and a second activation function, the loss function of the second branch is L2, and P is greater than or equal to 1.
  • determining the spectrum of the light source in the current shooting scene according to the probability that the light source in the current shooting scene belongs to various light sources and the spectrum of the various light sources includes: assigning the light source in the current shooting scene to the The probabilities of various light sources are used as a summation weighting weight, and the spectra of various light sources are summed to obtain the spectrum of the light source in the current shooting scene.
  • the present application provides an electronic device, including: an RGB sensor, a multispectral sensor, and a processor; the processor is configured to acquire first information in a current shooting scene, where the first information includes at least one of the following : the first image generated by the RGB sensor or the light intensity of the light received by each pixel on the multispectral sensor; the processor is further configured to input the first information into the first model to obtain the current shooting scene The probability that the light source in the current shooting scene belongs to various light sources; the processor is further configured to determine the spectrum of the light source in the current shooting scene according to the probability that the light source in the current shooting scene belongs to various light sources and the spectrum of the various light sources.
  • the processor before the processor inputs the first information into the first model, the processor is further configured to obtain training samples, where the training samples include the first information in different shooting scenarios and the first information in different shooting scenarios.
  • the light source category corresponding to the light source; use the training sample to train the first model.
  • the processor is specifically configured to: construct a data set, the data set includes M ⁇ N groups of data, each group of data corresponds to a shooting scene, and each shooting scene corresponds to a light source and a subject, M is the number of light sources, N is the number of subjects, each set of data includes: the first information corresponding to the shooting scene; the spectrum of the M types of light sources in the data set is clustered and analyzed to obtain each The light source category corresponding to the light source in the shooting scene; the training sample is obtained according to the first information in each set of data and the light source category corresponding to the light source in each shooting scene.
  • each group of data in the M ⁇ N groups of data further includes: second information, where the second information includes: the spectrum of the light source corresponding to the shooting scene and the second multispectral spectrum corresponding to the shooting scene the reflectance spectrum of the object material corresponding to each pixel on the sensor; the processor is specifically configured to: acquire the second information in each group of data, and obtain M ⁇ N groups of second information; The spectra of M light sources in the data set were clustered.
  • the processor is specifically configured to: determine classification standards of M types of light sources in the data set according to M ⁇ N sets of second information; and classify the M types of light sources in the data set according to the classification standards The spectrum of the light source is clustered.
  • the processor is specifically configured to: for each of the N types of objects, randomly select two groups from the M groups of second information corresponding to the objects, and obtain: pairs of combinations; for each pair of combinations, the two-dimensional data points corresponding to the combinations are calculated to obtain two-dimensional data points, the two-dimensional data points include average color distance and light source spectral similarity index; according to the two-dimensional data points to determine the classification criteria.
  • the processor is specifically configured to: calculate the first RGB value of each pixel according to a set of second information in the combination; calculate the first RGB value of each pixel according to another set of second information in the combination.
  • the second RGB value of the pixel; the average color distance corresponding to the combination is determined according to the first RGB value of each pixel and the second RGB value of each pixel.
  • the processor is specifically configured to: determine according to the spectrum of the light source included in one set of second information in the combination and the spectrum of the light source included in another set of second information in the combination.
  • the light source spectral similarity index corresponding to the combination is specifically configured to: determine according to the spectrum of the light source included in one set of second information in the combination and the spectrum of the light source included in another set of second information in the combination.
  • the processor is specifically configured to: according to the A two-dimensional data point is drawn, and a two-dimensional intersection diagram is drawn; the first parameter is determined from the abscissa of the two-dimensional intersection diagram, so that the ordinate is smaller than the preset value, and the abscissa is smaller than the two-dimensional point data of the first parameter The proportion of the number of points exceeds a preset threshold; the first parameter is used as the classification criterion.
  • the processor is specifically configured to: use a k-means clustering algorithm to perform cluster analysis on the spectra of M kinds of light sources in the data set; the light source spectral similarity index between any two cluster centers is Greater than the classification criteria, within each cluster, the spectral similarity index between any two light sources is smaller than the classification criteria.
  • the first model includes a first branch, and the first branch is used to output the probability that the light sources in the current shooting scene belong to various types of light sources;
  • the first information in the data and the light source category corresponding to the light source in the corresponding shooting scene are used as a training sample.
  • the first model includes a first branch and a second branch, the first branch is used to output the probability that the light source in the current shooting scene belongs to various types of light sources, and the second branch is used to output the probability that the light source in the current shooting scene belongs to various light sources.
  • the processor is specifically configured to: convert the first information in each group of data, the light source category corresponding to the light source in the corresponding shooting scene, and the second information in the corresponding shooting scene.
  • the reflectance spectrum of the object material corresponding to each pixel on the multispectral sensor is used as a training sample.
  • the first branch includes a first structure and a fully connected layer, the first structure is downsampled L times and then converted to the fully connected layer, and the first structure includes a convolution layer, activation function and maximum pooling layer, the loss function of the first branch is cross entropy, and L is greater than or equal to 1;
  • the second branch includes P residual blocks, each residual block includes the first convolution layer, the first An activation function, a second convolution layer and a second activation function, the loss function of the second branch is L2, and P is greater than or equal to 1.
  • the processor is specifically configured to: take the probability that the light sources in the current shooting scene belong to various light sources as the summation weighting weight, and perform summation processing on the spectra of the various light sources to obtain the current shooting scene.
  • the present application provides an electronic device, comprising: an RGB sensor, a multispectral sensor, a memory, and a processor, where the RGB sensor is used to generate a first image in a current shooting scene, and the multispectral sensor is used to record For the light intensity of the light received by each pixel on the multispectral sensor, the processor is configured to couple with the memory to read and execute the instructions in the memory, so as to implement the method provided in the first aspect.
  • the present application provides a readable storage medium on which a computer program is stored; when the computer program is executed, the method provided in the first aspect is implemented.
  • the RGB sensor on the mobile phone After the user triggers to turn on the camera of the terminal device, on the one hand, the RGB sensor on the mobile phone generates the original image of the current shooting scene, on the other hand, the multi-spectral sensor on the mobile phone records the multi-spectral sensor
  • the light intensity of the light received by each pixel input the original image generated by the RGB sensor and/or the light intensity of the light received by each pixel on the multispectral sensor into the pre-trained model, the model outputs the light source in the current shooting scene belongs to
  • the probability of various light sources is used as a summation weighted weight, and the spectrum of the light source in the current shooting scene is determined according to the summation weighted weight and the spectrum of each type of light source. Since the light source spectrum obtained by this method is close to the real light source spectrum, after white balance processing and color correction processing are performed according to the light source spectrum, the color of the image is closer to the true color of the subject, and the user experience is improved.
  • FIG. 1 is an application scenario diagram provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram 1 of an RGB sensor provided by an embodiment of the present application.
  • FIG. 3 is a second schematic diagram of an RGB sensor provided by an embodiment of the present application.
  • 3A is a schematic diagram of a light source spectrum provided by an embodiment of the present application.
  • 3B is a schematic diagram of an RGB sensor and a multispectral sensor provided by an embodiment of the present application;
  • FIG. 4 is a schematic diagram of a multispectral sensor provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of obtaining a light source spectrum through a multispectral sensor provided by an embodiment of the present application
  • FIG. 6 is a flowchart of an embodiment of a light source spectrum acquisition method provided by the present application.
  • Fig. 7 is the calculation principle diagram of each pixel RGB value on the RGB sensor provided by the application.
  • FIG. 8 is a flowchart of constructing a data set provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram 1 of a shooting scene provided by an embodiment of the present application.
  • FIG. 10 is a second schematic diagram of a shooting scene provided by an embodiment of the present application.
  • 11 is a flow chart of a calculation process of an average color distance provided by an embodiment of the present application.
  • FIG. 12 is a two-dimensional intersection diagram provided by an embodiment of the present application.
  • FIG. 13 is a schematic diagram of a clustering result provided by an embodiment of the present application.
  • FIG. 14 is a schematic structural diagram 1 of a first model provided by an embodiment of the present application.
  • FIG. 15 is a schematic structural diagram of a residual block provided by an embodiment of the present application.
  • FIG. 16 is a second schematic structural diagram of a first model provided by an embodiment of the present application.
  • FIG. 17 is a third schematic structural diagram of a first model provided by an embodiment of the present application.
  • FIG. 19 is a comparison diagram 1 of the light source spectrum obtained by the first model and the light source spectrum obtained by the method shown in FIG. 5 according to the embodiment of the application;
  • FIG. 20 is a comparison diagram 2 between the light source spectrum obtained by the first model and the light source spectrum obtained by the method shown in FIG. 5 according to the embodiment of the application;
  • FIG. 21 is a schematic structural diagram of an electronic device 100 according to an embodiment of the present application.
  • FIG. 1 is an application scenario diagram provided by an embodiment of the present application.
  • a color filter array Color Filter Array, CFA
  • RGB sensor a color filter array
  • the CFA is set on the RGB sensor.
  • the CFA includes filters of three colors: red, green and blue.
  • the filters of the three colors can be arranged as shown in Figure 2.
  • the RGB sensor is divided into multiple pixels.
  • the filter on the CFA There is a one-to-one correspondence between the light sheet and the pixels on the RGB sensor.
  • red filter corresponds to pixel A
  • red filter corresponds to pixel A
  • the RGB sensor is used to record the light intensity of the light received by each pixel.
  • c represents the color channel corresponding to the pixel x
  • I c represents the light intensity of the light received by the pixel x recorded by the RGB sensor
  • L( ⁇ ) is the light source spectrum
  • R( ⁇ , x) is the reflection of the object material corresponding to the pixel x Rate spectrum
  • C c ( ⁇ ) is the response function of c.
  • the response function of c refers to the function of the ratio of the light intensity recorded by the RGB sensor to the light intensity of the incident light as a function of wavelength.
  • C c ( ⁇ ) is calibrated during the development of the terminal equipment.
  • the light source spectrum L( ⁇ ) refers to the change curve of the light intensity of the light source with the wavelength in the wavelength range corresponding to the light source.
  • the wavelength range corresponding to a fluorescent lamp is 380-780 nm
  • the change curve of the light intensity of the fluorescent lamp with the wavelength is the curve shown in FIG. 3A
  • the curve shown in FIG. 3A is called the light source of the fluorescent lamp spectrum.
  • the light intensity recorded by the RGB sensor is the integral result of the light source spectrum, the reflectance spectrum of the object material and the response function.
  • the light intensity recorded by the RGB sensor is different, and the color value calculated according to the light intensity is also different. influences.
  • the color of the rendered image is close to the color of the object itself.
  • the white object is placed under the illumination of a red light-emitting diode (Light Emitting Diode, LED) lamp
  • the light source changes due to the change of the light source.
  • the color of the rendered image is reddish due to the influence of the red LED light.
  • the RGB sensor converts the light intensity of the light received by the pixel into the color value of the color channel corresponding to the pixel, and uses the color value of the color channel corresponding to the surrounding pixels as the other color channels of the pixel , to get the RGB value of the pixel.
  • the RGB sensor transmits the RGB value of each pixel to the Image Signal Processing (ISP) module, and the ISP module performs white balance processing and color correction processing on the RGB value of each pixel output by the RGB sensor, wherein the white balance processing is used for To remove the influence of the light source and avoid the color cast caused by the light source, the color correction process is used to convert the RGB values of each pixel into the standard observer space (CIE XYZ) after the white balance processing.
  • ISP Image Signal Processing
  • the light source spectrum is obtained by:
  • the multi-spectral sensor and the RGB sensor can share the same set of lenses, or the multi-spectral sensor and the RGB sensor each have independent lenses.
  • the multi-spectral sensor and the RGB sensor are used Each has an independent lens as an example, and the multispectral sensor and the RGB sensor are arranged behind their respective lenses.
  • the multispectral sensor is also provided with a CFA, and the light is incident on the CFA through the lens.
  • the light sheet is illustrated in Fig. 4 by taking the CFA including eight color filters of red, orange, yellow, green, cyan, blue and purple as an example.
  • the multispectral sensor can record the light intensity of the light received by each pixel, as shown in Figure 4, each pixel corresponds to a color channel, and the light intensity of the light received by each pixel is used as the corresponding color.
  • the light intensity of the channel, the light intensity of the eight color channels can be obtained. Plot the light intensities of the eight color channels together to obtain the eight discrete points shown in Figure 5, and perform interpolation processing on the eight discrete points shown in Figure 5 to obtain a curve of light intensity versus wavelength, which is used as the light source. spectrum.
  • the light intensity recorded by the multispectral sensor also satisfies Equation 1.
  • the light source spectrum obtained by the above method is essentially the integration result of the light source spectrum, the reflectance spectrum of the object material and the response function, not the simple light source spectrum.
  • the light source obtained by the above method Spectral accuracy is not high.
  • the embodiments of the present application provide a light source spectrum acquisition method, and the light source spectrum acquisition method is applied to a terminal device configured with an RGB sensor and a multispectral sensor, and the terminal device includes but is not limited to a mobile phone, a tablet computer, a notebook Computers, smart screens, digital cameras, etc.
  • the terminal device includes but is not limited to a mobile phone, a tablet computer, a notebook Computers, smart screens, digital cameras, etc.
  • the RGB sensor on the mobile phone generates the original image of the current shooting scene.
  • the multispectral sensor on the mobile phone records the light intensity of the light received by each pixel on the multispectral sensor, and inputs the original image generated by the RGB sensor and/or the light intensity of the light received by each pixel recorded by the multispectral sensor as input.
  • the pre-trained model the model outputs the probability that the light source in the current shooting scene belongs to various light sources, and the probability is used as the summation weighting weight. spectrum.
  • the light source spectrum obtained by the method is close to the real light source spectrum, and after white balance processing and color correction processing are performed according to the light source spectrum, the color of the image is closer to the real color of the subject, and the user experience is improved.
  • FIG. 6 is a flowchart of an embodiment of a light source spectrum acquisition method provided by the present application. As shown in FIG. 6 , the light source spectrum acquisition method provided in this embodiment is applied after the user triggers to turn on the camera of the terminal device, and the method specifically includes:
  • the RGB sensor generates an original image of the current shooting scene.
  • the original image of the current shooting scene is an image generated according to the RGB values of each pixel on the RGB sensor.
  • the original image of the current shooting scene is referred to as the first image in the current shooting scene.
  • the RGB sensor converts the light intensity of the light received by the pixel into the color value of the color channel corresponding to the pixel, and uses the color value of the color channel corresponding to the surrounding pixels as the color value of the other color channels of the pixel, thereby obtaining The RGB value of this pixel.
  • the color of filter 1 is red
  • the color of filter 2 is green
  • the color of filter 3 is blue.
  • Filter 1 corresponds to pixel A on the RGB sensor
  • filter 2 corresponds to pixel B on the RGB sensor
  • filter 3 corresponds to pixel C on the RGB sensor.
  • the RGB sensor converts the light intensity of the light received by pixel A to obtain the R value of pixel A. Converting the light intensity of the light received by the pixel B, the G value of the pixel B can be obtained. By converting the light intensity of the light received by the pixel C, the B value of the pixel C can be obtained.
  • the G value of pixel B can be used as the G value of pixel A
  • the B value of pixel C can be used as the B value of pixel A
  • the RGB value of pixel A is (R1, G1, B1).
  • the multispectral sensor records the light intensity of the light received by each pixel on the multispectral sensor.
  • the multispectral sensor in S602 is a multispectral sensor configured in the terminal device.
  • the multispectral sensor is hereinafter referred to as the first multispectral sensor.
  • the first information includes at least one of the following: the first image generated by the RGB sensor or the light intensity of light received by each pixel on the first multispectral sensor.
  • only the original image of the current shooting scene can be input into the first model, or only the light intensity of the light received by each pixel on the first multispectral sensor can be input into the first model, or the original image of the current shooting scene can be input into the first model. and the light intensity of the light received by each pixel on the first multispectral sensor are input into the first model.
  • the first model needs to be trained.
  • a training sample is obtained.
  • the training sample includes the first information in different shooting scenes and the light source category corresponding to the light source in different shooting scenes. Then, the training sample is used to train the first model. a model.
  • the known light sources can be classified and obtained according to the classification results and pre-built data sets Training samples.
  • the spectrum measured by the illuminometer is used in the subsequent process of classifying the light sources.
  • the tester places the subject under the illumination of the light source.
  • the subject is placed directly under the light source.
  • the light source used in S10 and the subject used in S11 constitute a shooting scene.
  • the terminal device can face the subject, adjust the field of view of the terminal device so that the subject is within the shooting range corresponding to the field of view of the terminal device, and then trigger the shooting.
  • the original image is acquired from the RGB sensor of the terminal device, and the light intensity of the light received by each pixel on the first multispectral sensor is acquired from the first multispectral sensor.
  • the original image and the light intensity of the light received by each pixel are used in the subsequent process of acquiring training samples.
  • S601 For the process of generating the original image by the RGB sensor, reference may be made to S601, and details are not described herein again in this embodiment.
  • the multispectral image captured by the multispectral camera is processed to obtain the object material reflectance spectrum corresponding to each pixel on the multispectral sensor in the spectral camera, and the object material reflectance spectrum is used in the subsequent process of classifying light sources.
  • a multi-spectral sensor is set in the multi-spectral camera.
  • the multi-spectral sensor is called the second multi-spectral sensor.
  • the size of the second multi-spectral sensor is the same as that of the RGB sensor.
  • the reflectance spectrum of the object material corresponding to each pixel on the second multispectral sensor can be obtained by inverse inference using formula 1. Specifically, the color value of the color channel corresponding to each pixel on the second multispectral sensor is extracted from the multispectral image.
  • the color value of the color channel corresponding to the pixel is reversed to obtain the light intensity I C of the color channel corresponding to each pixel, and L( ⁇ ) is measured in S10.
  • C c ( ⁇ ) it can be used
  • Formula 1 is inversely derived to obtain the reflectance spectrum of the object material corresponding to each pixel on the second multispectral sensor.
  • a set of data is obtained, and the set of data includes: first information and second information corresponding to the shooting scene, and the second information includes: the spectrum of the light source corresponding to the shooting scene and the corresponding shooting scene.
  • the reflectance spectrum of the object material corresponding to each pixel on the second multispectral sensor The original image generated by the RGB sensor and the light intensity of the light received by each pixel on the first multispectral sensor recorded by the first multispectral sensor are used for subsequent acquisition of training samples; the spectrum measured by the illuminometer and the second multispectral sensor The reflectance spectrum of the object material corresponding to each pixel above is used to classify known light sources.
  • the embodiment of the present application assumes that there are M types of light sources, and M groups of data corresponding to the same object can be obtained through the above S11-S14. Change the subject, and repeat S11-S14 to obtain M groups of data corresponding to another subject. Assuming that there are N kinds of subjects, M ⁇ N groups of data can be obtained.
  • the M ⁇ N groups of data constitute the above data set, Each set of data corresponds to a shooting scene, and each shooting scene corresponds to a light source and a subject.
  • classifying known light sources refers to clustering analysis of the spectra of the M kinds of light sources, and obtaining each shot in the data set.
  • the light source category corresponding to the light source in the scene.
  • the second information in each group of data is obtained from the data set, and M ⁇ N groups of second information are obtained. Spectra for cluster analysis.
  • a classification standard of the M light sources in the data set is determined, and then according to the classification standard, a cluster analysis is performed on the spectra of the M light sources in the data set.
  • the two-dimensional data points include average color distance and light source spectral similarity indicators; according to two-dimensional data points to determine the classification criteria.
  • the average color distance corresponding to the pair of combinations and the spectral similarity index of the light source corresponding to the pair of combinations constitute the two-dimensional data points of the pair of combinations. Therefore, the calculation process of the two-dimensional data points includes two aspects of calculation. On the one hand, the average color distance corresponding to the pair of combinations is calculated, and the average color distance reflects the color difference of the two images. On the other hand, the spectral similarity index of the light source corresponding to the pair combination is calculated.
  • I c ⁇ 0 ⁇ L( ⁇ )R( ⁇ ,x)C c ( ⁇ )d ⁇
  • c represents the color channel corresponding to the pixel x
  • I c represents the light intensity corresponding to the pixel x
  • L( ⁇ ) represents the spectrum of the light source in the set of second information
  • R( ⁇ , x) represents the second information in the set of
  • C c ( ⁇ ) is the response function of c.
  • the light intensity corresponding to each pixel is converted to obtain the color value of the color channel corresponding to each pixel, and for each pixel, the color value of the color channel corresponding to the pixel surrounding the pixel is used as the color value of other color channels of the pixel, Thus, the first RGB value of the pixel is obtained.
  • S601 For the specific process, reference may be made to S601, and details are not described herein again in this application.
  • the method of calculating the second RGB value of each pixel is similar to that of S20, and details are not described in this application.
  • the color distance corresponding to the pixel is calculated by the following formula:
  • (R1, G1, B1) is the RGB value of each pixel calculated in S20
  • (R2, G2, B2) is the RGB value of each pixel calculated in S21.
  • the spectral similarity index of the light source corresponding to a pair of combinations can be calculated by the following formula:
  • RMSE represents the spectral similarity index of the light source corresponding to a pair of combinations, is the light intensity of wavelength i on the spectrum of the light source in a set of second information in the pair combination, is the light intensity of wavelength i on the spectrum of the light source in the other set of second information in the pair combination, and N represents the number of wavelengths in common on the spectrum of the light source in the two sets of second information.
  • the above is the calculation process of the spectral similarity index of the light source.
  • the average color distance corresponding to a pair of combinations can be obtained, and through the calculation in the second aspect above, the spectral similarity index of the light source corresponding to a pair of combinations can be obtained.
  • the corresponding relationship between the average color distance and the spectral similarity index of the light source can be used as the two-dimensional data point corresponding to the pair of combinations.
  • a two-dimensional data point is drawn, and a two-dimensional intersection diagram is drawn.
  • the abscissa represents the spectral similarity index of the light source, and the ordinate represents the average color distance.
  • the distribution of the two-dimensional data points determines the classification criteria.
  • a threshold can be preset, for example: 95%.
  • the average color distance is less than 5 degrees, the color difference between the two images is not significant, and 5 degrees can be used as the default value to determine the first parameter from the abscissa of the two-dimensional intersection diagram, so that the ordinate is less than the preset value, and the abscissa
  • the first parameter can be used as the above-mentioned classification criterion. Referring to FIG. 12 , if the number of two-dimensional point data points whose ordinate is less than 5 degrees and whose abscissa is less than 0.004 exceeds 95%, 0.004 can be used as the classification standard.
  • the following describes the process of clustering and analyzing the spectra of M kinds of light sources according to the classification criteria.
  • the K-means clustering algorithm (k-means) is used to cluster and analyze the spectra of M kinds of light sources.
  • the light source spectral similarity index between any two light sources is smaller than the above classification criteria, and the number of light sources and the corresponding light source categories of the M light sources are obtained.
  • FIG. 13 shows a clustering result.
  • five types of light sources are obtained. They are indicated by category 1, category 2, category 3, category 4, and category 5, respectively.
  • the above is the process of performing cluster analysis on the spectra of M kinds of light sources according to the classification criteria.
  • the training samples may be obtained according to the first information in each group of data in the data set and the light source category corresponding to the light source in each shooting scene.
  • the training samples to be obtained are different.
  • the training samples to be obtained are different.
  • the first model includes eight residual blocks and a first branch, and each pixel on the first multispectral sensor obtained in S601 and/or the original image obtained in S602 is received. After the light intensity of the light is input to the first residual block, after eight residual blocks and the processing of the first branch, the first branch will output the probability that the light source in the current shooting scene belongs to various light sources.
  • the first branch is downsampled 4 times through the first structure and then converted to a fully connected layer.
  • the first structure includes: a convolution layer, an activation function, and a maximum pooling layer.
  • the convolutional layer can be C(3,3,64), C(3,3,64) represents a convolutional layer with 64 channels and a kernel size of 3*3, the activation function can be ReLu, and the maximum pooling layer can be Max_pool2d (2,2), Max_pool2d(2,2) represents a max pooling layer with a kernel size of 2*2.
  • the size of the fully connected layer is (1*number of spectral classes).
  • the loss function of the first branch is cross entropy.
  • the number of training samples captured in one training batch size is set to 64, the optimizer is Adam, the learning rate obeys polynomial decay, and the initial value of the learning rate is set to 1 ⁇ 10 -5 .
  • the number of spectral categories is set to the number obtained by the above cluster analysis.
  • each residual block is W*H*64.
  • W and H are the width and height of the image, and 64 represents the number of channels.
  • Each residual block includes: convolution layer 1, activation function 1, convolution layer 2, activation function 2, convolution layer 1 and convolution layer 2 can be C(3, 3, 64), activation function 1 and activation function 2 Function 2 can use ReLu.
  • the data contained in the training sample needs to include: the original image generated by the RGB sensor, the light intensity of the light received by each pixel on the first multispectral sensor, and the light source type.
  • the first information in each set of data and the light source category corresponding to the light source in the corresponding shooting scene may be used as a training sample.
  • the result of the cluster analysis is: the light source category corresponding to this group of data is category A; the original image generated by the RGB sensor in this group of data is the original image A, In this set of data, the light intensity of the light received by each pixel on the first multispectral sensor is vector A, then the original image A, vector A and category A constitute a training sample, as shown in Table 1.
  • the first model includes eight residual blocks, a first branch and a second branch, and the original image obtained in S601 and/or the first multispectral sensor obtained in S602
  • the first branch After the light intensity of the light received by each pixel above is input into the first residual block, the first branch outputs the probability that the light source in the current shooting scene belongs to various light sources, and the second branch outputs the object material corresponding to each pixel in the current shooting scene reflectance spectrum.
  • the structures of the eight residual blocks and the first branch are shown in FIG. 14 and FIG. 15 , and details are not described herein again in this embodiment.
  • the second branch includes eight residual blocks, and the structure of each residual block is the same as that of the residual block shown in FIG. 15 .
  • the loss function of the second branch is L2.
  • the batch size is set to 64
  • the optimizer is Adam
  • the learning rate is subject to polynomial decay
  • the initial value of the learning rate is set to 1 ⁇ 10 -5
  • the material reflectance spectrum of the object is 31 channels.
  • the above-mentioned second branch including eight residual blocks is only an example, and the present application does not limit the number of residual blocks in the second branch.
  • the data contained in the training samples need to include: the original image generated by the RGB sensor, the light intensity of the light received by each pixel on the first multispectral sensor, the light source type, and the second multispectral sensor.
  • the first information in each set of data, the light source category corresponding to the light source in the corresponding shooting scene, and the object material reflectance spectrum corresponding to each pixel on the second multispectral sensor in the corresponding shooting scene can be used as a training sample.
  • the result of the cluster analysis is: the light source category corresponding to this group of data is category A; the original image generated by the RGB sensor in this group of data is the original image A,
  • the light intensity of the light received by each pixel on the first multispectral sensor is vector A1
  • the reflectance spectrum of the object material corresponding to each pixel on the second multispectral sensor in this set of data is vector A2, then the original image A.
  • Vector A1, vector A2 and category A constitute a training sample, as shown in Table 2.
  • the first model may include eight residual blocks and the second branch.
  • the second branch After inputting the original image obtained in S601 and/or the light intensity of the light received by each pixel on the first multispectral sensor obtained in S602 into the first residual block, the second branch outputs the reflection of the object material corresponding to each pixel on the RGB sensor. Rate spectrum.
  • FIG. 15 The structure of the eight residual blocks is shown in FIG. 15 , and the structure of the second branch is shown in FIG. 16 , and details are not described herein again in this embodiment.
  • the data in the training sample needs to include: the original image generated by the RGB sensor, the light intensity of the light received by each pixel on the first multispectral sensor, and the corresponding data of each pixel on the second multispectral sensor.
  • the object material reflectance spectrum.
  • the original image generated by the RGB sensor, the light intensity of the light received by each pixel on the first multispectral sensor, and the reflectance spectrum of the object material corresponding to each pixel on the second multispectral sensor can be extracted from the data set constructed above.
  • the original image generated by the RGB sensor in this group of data is the original image A
  • the light intensity of the light received by each pixel on the first multispectral sensor in this group of data is vector A1
  • the reflectance spectrum of the object material corresponding to each pixel on the second multispectral sensor in this set of data is vector A2
  • the original image A, vector A1 and vector A2 constitute a training sample, as shown in Table 3.
  • S604. Determine the spectrum of the light source in the current shooting scene according to the probability that the light source in the current shooting scene belongs to various light sources and the spectrum of the various light sources.
  • the probability that the light source in the current shooting scene belongs to various light sources is used as a summation weighting weight, and the spectra of various light sources are summed to obtain the spectrum of the light source in the current shooting scene.
  • the spectrum of various light sources may be the spectrum of each cluster center obtained by the above cluster analysis.
  • the probability that the light sources in the current photographing scene belong to various types of light sources are A%, B%, C%, D% and E% respectively. See Figure 18 for the spectrum of various light sources. Taking A%, B%, C%, D%, and E% as summation weights, the spectrum of the light source in the current shooting scene is obtained by the method of Figure 18.
  • the input of the first model can be the original image generated by the RGB sensor, the light intensity of the light received by each pixel on the first multispectral sensor, and the original image and the first multispectral image can also be generated for the RGB sensor.
  • the output of the first model is different, and the spectrum obtained in S604 is also different accordingly.
  • Table 4 shows the spectral similarity indicators of the light sources corresponding to the three inputs.
  • the light intensity of the light received by each pixel on the first multispectral sensor is abbreviated as light intensity
  • the original image generated by the RGB sensor is abbreviated as light intensity. for the original image.
  • the original image generated by the RGB sensor and the light intensity received by each pixel on the first multispectral sensor are compared.
  • the light intensity of the obtained light is input into the first model, the light source spectrum determined in S604 is most similar to the spectrum actually measured by the illuminometer.
  • FIG. 19 shows a comparison diagram 1 between the light source spectrum obtained by the first model and the light source spectrum obtained by the method shown in FIG. 5 .
  • AMS is the light source spectrum obtained by the method shown in Figure 5
  • Estimated is the light source spectrum obtained by the first model
  • Ground Truth is the light source spectrum actually measured by the illuminometer.
  • the abscissa is the wavelength, and the ordinate is the normalized value of the light intensity.
  • FIG. 20 shows a comparison diagram 2 between the light source spectrum obtained by the first model and the light source spectrum obtained by the method shown in FIG. 5 .
  • AMS in Figure 15 is the light source spectrum obtained by the method shown in Figure 5
  • Estimated is the light source spectrum obtained by the first model
  • Ground Truth is the light source spectrum actually measured by the illuminometer.
  • the abscissa is the wavelength, and the ordinate is the normalized value of the light intensity.
  • RMSE_G 0.0093
  • the spectrum of the light source obtained by the first model is close to the spectrum of the real light source, after white balance processing and color correction processing are performed according to the spectrum of the light source, the color of the image is closer to the real color of the subject, which improves the user experience.
  • the RGB sensor on the mobile phone after the user triggers to turn on the camera of the terminal device, on the one hand, the RGB sensor on the mobile phone generates the original image of the current shooting scene, and on the other hand, the multi-spectral sensor on the mobile phone records the multi-spectral sensor
  • the light intensity of the light received by each pixel input the original image generated by the RGB sensor and/or the light intensity of the light received by each pixel on the multispectral sensor into the pre-trained model, the model outputs the light source in the current shooting scene belongs to
  • the probability of various light sources is used as a summation weighted weight, and the spectrum of the light source in the current shooting scene is determined according to the summation weighted weight and the spectrum of each type of light source. Since the light source spectrum obtained by this method is close to the real light source spectrum, after white balance processing and color correction processing are performed according to the light source spectrum, the color of the image is closer to the true color of the subject, and the user experience is improved.
  • FIG. 21 shows a schematic structural diagram of the electronic device 100 .
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an audio module 170, a speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, buttons 190, motor 191, indicator 192, camera 193, display screen 194, etc.
  • USB universal serial bus
  • the camera 193 includes an RGB sensor, a multispectral sensor and an ISP processor. Both the RGB sensor and the multispectral sensor are connected to the ISP processor.
  • the RGB sensor is used to generate the original image of the current shooting scene, and the multispectral sensor is used to record the light intensity of the light received by each pixel on the multispectral sensor.
  • the first model is installed in the RGB sensor, the RGB sensor is connected to the multispectral sensor, the multispectral sensor sends the recorded light intensity of the light received by each pixel to the RGB sensor, and the RGB sensor generates the current shot.
  • the first information is input into the first model to obtain the probability that the light source in the current shooting scene belongs to various light sources. Spectrum, to determine the spectrum of the light source in the current shooting scene. The spectrum of this light source is sent to the ISP processor, which is used to guide the white balance processing and color correction processing.
  • the first model is installed in a multispectral sensor
  • the RGB sensor is connected to the multispectral sensor
  • the RGB sensor sends the generated original image of the current shooting scene to the multispectral sensor
  • the multispectral sensor records the multispectral image
  • the light intensity of the light received by each pixel on the sensor, and the first information is input into the first model to obtain the probability that the light source in the current shooting scene belongs to various types of light sources, and the multispectral sensor is further based on the current shooting scene.
  • the probability of the light source and the spectrum of various light sources determine the spectrum of the light source in the current shooting scene.
  • the spectrum of this light source is sent to the ISP processor, which is used to guide the white balance processing and color correction processing.
  • the first model is installed in the ISP processor, both the RGB sensor and the multispectral sensor are connected to the ISP processor, and the multispectral sensor sends the recorded light intensity of the light received by each pixel to the ISP
  • the processor, the RGB sensor sends the generated original image of the current shooting scene to the ISP processor, and the ISP processor inputs the first information into the first model to obtain the probability that the light source in the current shooting scene belongs to various light sources, and further according to the current shooting scene
  • the probability that the light source in the scene belongs to various light sources and the spectrum of the various light sources determine the spectrum of the light source in the current shooting scene.
  • the spectrum of this light source is used to guide the white balance and color correction processes.
  • the first model is installed in the processor 110, the RGB sensor and the multispectral sensor are both connected to the processor 110, and the multispectral sensor sends the recorded light intensity of the light received by each pixel to the processor 110.
  • the RGB sensor sends the generated original image of the current shooting scene to the processor 110, and the processor 110 inputs the first information into the first model to obtain the probability that the light source in the current shooting scene belongs to various light sources, and further according to the current shooting scene
  • the probability that the light source in the scene belongs to various light sources and the spectrum of the various light sources determine the spectrum of the light source in the current shooting scene.
  • the spectrum of this light source is sent to the ISP processor, which is used to guide the white balance processing and color correction processing.
  • the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or less components than shown, or combine some components, or separate some components, or arrange different components.
  • the illustrated components may be implemented in hardware, software or a combination of software and hardware.
  • the processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • modem processor graphics processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • baseband processor baseband processor
  • neural-network processing unit neural-network processing unit
  • the controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in processor 110 is cache memory. This memory may hold instructions or data that have just been used or recycled by the processor 110 . If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
  • the processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transceiver
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL).
  • the processor 110 may contain multiple sets of I2C buses.
  • the processor 110 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193 and the like through different I2C bus interfaces.
  • the processor 110 may couple the touch sensor 180K through the I2C interface, so that the processor 110 and the touch sensor 180K communicate with each other through the I2C bus interface, so as to realize the touch function of the electronic device 100 .
  • the I2S interface can be used for audio communication.
  • the processor 110 may contain multiple sets of I2S buses.
  • the processor 110 may be coupled with the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170 .
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
  • the PCM interface can also be used for audio communications, sampling, quantizing and encoding analog signals.
  • the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface.
  • the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • a UART interface is typically used to connect the processor 110 with the wireless communication module 160 .
  • the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function.
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface, so as to realize the function of playing music through the Bluetooth headset.
  • the MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193 .
  • MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc.
  • the processor 110 communicates with the camera 193 through a CSI interface, so as to realize the photographing function of the electronic device 100 .
  • the processor 110 communicates with the display screen 194 through the DSI interface to implement the display function of the electronic device 100 .
  • the GPIO interface can be configured by software.
  • the GPIO interface can be configured as a control signal or as a data signal.
  • the GPIO interface may be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and the like.
  • the GPIO interface can also be configured as I2C interface, I2S interface, UART interface, MIPI interface, etc.
  • the USB interface 130 is an interface that conforms to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like.
  • the USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones.
  • the interface can also be used to connect other electronic devices, such as AR devices.
  • the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 .
  • the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
  • the charging management module 140 is used to receive charging input from the charger.
  • the charger may be a wireless charger or a wired charger.
  • the charging management module 140 may receive charging input from the wired charger through the USB interface 130 .
  • the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142 , it can also supply power to the electronic device through the power management module 141 .
  • the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160.
  • the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, battery health status (leakage, impedance).
  • the power management module 141 may also be provided in the processor 110 .
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • the electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
  • Display screen 194 is used to display images, videos, and the like.
  • Display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light).
  • LED diode AMOLED
  • flexible light-emitting diode flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (quantum dot light emitting diodes, QLED) and so on.
  • the electronic device 100 may include one or N display screens 194 , where N is a positive integer greater than one.
  • the electronic device 100 may implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
  • the ISP is used to process the data fed back by the camera 193 .
  • the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye.
  • ISP can also perform algorithm optimization on image noise, brightness, and skin tone.
  • ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera 193 .
  • Camera 193 is used to capture still images or video.
  • the object is projected through the lens to generate an optical image onto the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
  • the ISP outputs the digital image signal to the DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
  • the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
  • a digital signal processor is used to process digital signals, in addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy and so on.
  • Video codecs are used to compress or decompress digital video.
  • the electronic device 100 may support one or more video codecs.
  • the electronic device 100 can play or record videos of various encoding formats, such as: Moving Picture Experts Group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
  • MPEG Moving Picture Experts Group
  • MPEG2 moving picture experts group
  • MPEG3 MPEG4
  • MPEG4 Moving Picture Experts Group
  • the NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • Applications such as intelligent cognition of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
  • the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100 .
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example to save files like music, video etc in external memory card.
  • Internal memory 121 may be used to store computer executable program code, which includes instructions.
  • the internal memory 121 may include a storage program area and a storage data area.
  • the storage program area can store an operating system, an application program required for at least one function (such as a sound playback function, an image playback function, etc.), and the like.
  • the storage data area may store data (such as audio data, phone book, etc.) created during the use of the electronic device 100 and the like.
  • the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (UFS), and the like.
  • the processor 110 executes various functional applications and data processing of the electronic device 100 by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
  • the electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playback, recording, etc.
  • the audio module 170 is used for converting digital audio information into analog audio signal output, and also for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110 , or some functional modules of the audio module 170 may be provided in the processor 110 .
  • Speaker 170A also referred to as a "speaker" is used to convert audio electrical signals into sound signals.
  • the electronic device 100 can listen to music through the speaker 170A, or listen to a hands-free call.
  • the receiver 170B also referred to as "earpiece" is used to convert audio electrical signals into sound signals.
  • the voice can be answered by placing the receiver 170B close to the human ear.
  • the microphone 170C also called “microphone” or “microphone” is used to convert sound signals into electrical signals.
  • the user can make a sound by approaching the microphone 170C through a human mouth, and input the sound signal into the microphone 170C.
  • the electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can implement a noise reduction function in addition to collecting sound signals. In other embodiments, the electronic device 100 may further be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions.
  • the earphone jack 170D is used to connect wired earphones.
  • the earphone interface 170D may be the USB interface 130, or may be a 3.5mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.
  • OMTP open mobile terminal platform
  • CTIA cellular telecommunications industry association of the USA
  • the keys 190 include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key.
  • the electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
  • Motor 191 can generate vibrating cues.
  • the motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback.
  • touch operations acting on different applications can correspond to different vibration feedback effects.
  • the motor 191 can also correspond to different vibration feedback effects for touch operations on different areas of the display screen 194 .
  • Different application scenarios for example: time reminder, receiving information, alarm clock, games, etc.
  • the touch vibration feedback effect can also support customization.
  • the indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.
  • the SIM card interface 195 is used to connect a SIM card.
  • the SIM card can be contacted and separated from the electronic device 100 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195 .
  • the electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • the SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the plurality of cards may be the same or different.
  • the SIM card interface 195 can also be compatible with different types of SIM cards.
  • the SIM card interface 195 is also compatible with external memory cards.
  • the electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication.
  • the electronic device 100 employs an eSIM, ie: an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Software Systems (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Medical Informatics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Signal Processing (AREA)
  • Probability & Statistics with Applications (AREA)
  • Business, Economics & Management (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • General Business, Economics & Management (AREA)
  • Human Computer Interaction (AREA)
  • Spectrometry And Color Measurement (AREA)
  • Image Analysis (AREA)
  • Color Television Image Signal Generators (AREA)

Abstract

本申请提供一种光源光谱获取方法和设备。该方法包括:获取当前拍摄场景下的第一信息,所述第一信息包括以下至少一种:RGB传感器生成的第一图像或者第一多光谱传感器上各个像素接收到的光线的光强度;将所述第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率;根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。该方法得到的光源光谱接近真实光源光谱,依据该光源光谱进行白平衡处理和色彩矫正处理后,图像的色彩更加接近被摄物真实色彩,提升了用户体验。

Description

光源光谱获取方法和设备
本申请要求于2020年11月23日提交中国专利局、申请号为202011325598.3、申请名称为“光源光谱获取方法和设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及终端领域,尤其涉及一种光源光谱获取方法和设备。
背景技术
用户拍照时,RGB传感器记录的光强度是光源光谱、物体材质反射率谱和响应函数的积分结果。光源不同时,由于光源光谱不同,导致RGB传感器记录的光强度不同,根据该光强度计算得到的色彩值也不同,可见图像的颜色受光源的影响较大。可通过白平衡处理以及色彩矫正处理去除光源的影响,而光源光谱可用于指导白平衡处理以及色彩矫正处理。
现有技术中,在相机中增加多光谱传感器,多光谱传感器记录各个像素接收到的光线的光强度后,对各个像素接收到的光线的光强度进行插值处理,将插值后得到的光谱作为光源光谱。
然而,上述方法得到的光源光谱实质是光源光谱、物体材质反射率谱和响应函数的积分结果,并不是单纯的光源光谱,上述方法得到的光源光谱准确度不高。
发明内容
本申请提供一种光源光谱获取方法和设备,用于获取准确度更高的光源光谱。
第一方面,本申请提供一种光源光谱获取方法,包括:获取当前拍摄场景下的第一信息,所述第一信息包括以下至少一种:RGB传感器生成的第一图像或者第一多光谱传感器上各个像素接收到的光线的光强度;将所述第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率;根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。
一种可能的实现方式中,所述将所述第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率之前,所述方法还包括:获取训练样本,所述训练样本包括不同拍摄场景下的第一信息以及不同拍摄场景下的光源对应的光源类别;使用所述训练样本训练所述第一模型。
一种可能的实现方式中,所述获取训练样本,包括:构建数据集,所述数据集包括M×N组数据,每组数据对应一种拍摄场景,每种拍摄场景对应一种光源和一种被摄物,M为光源的数量,N为被摄物数量,每组数据包括:对应拍摄场景下的第一信息;对所述数据集中M种光源的光谱进行聚类分析,得到每种拍摄场景下的光源对应的光源类别;根据每组数据中的第一信息以及每种拍摄场景下的光源对应的光源类别,获取训练样本。
一种可能的实现方式中,所述M×N组数据中每组数据还包括:第二信息,所述第二信息包括:对应拍摄场景下的光源的光谱以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱;所述对所述数据集中M种光源的光谱进行聚类分析,得到每种拍摄场景下的光源对应的光源类别,包括:获取每组数据中的第二信息,得到M×N组第二信息;根据M×N组第二信息,对所述数据集中M种光源的光谱进行聚类分析。
一种可能的实现方式中,所述根据M×N组第二信息,对所述数据集中M种光源的光谱进行聚类分析,包括:根据M×N组第二信息,确定所述数据集中M种光源的分类标准;根据所述分类标准,对所述数据集中M种光源的光谱进行聚类分析。
一种可能的实现方式中,所述根据M×N组第二信息,确定所述数据集中M种光源的分类标准,包括:针对N种被摄物中的每种被摄物,从所述被摄物对应的M组第二信息中任取两组,得到
Figure PCTCN2021131622-appb-000001
对组合;针对每对组合,计算所述组合对应的二维数据点,得到
Figure PCTCN2021131622-appb-000002
个二维数据点,所述二维数据点包括平均颜色距离和光源光谱相似指标;根据所述
Figure PCTCN2021131622-appb-000003
个二维数据点,确定所述分类标准。
一种可能的实现方式中,所述针对每对组合,计算所述组合对应的二维数据点,包括:根据所述组合中一组第二信息,计算各个像素的第一RGB值;根据所述组合中另一组第二信息,计算各个像素的第二RGB值;根据各个像素的第一RGB值和各个像素的第二RGB值,确定所述组合对应的平均颜色距离。
一种可能的实现方式中,所述针对每对组合,计算所述组合对应的二维数据点,包括:根据所述组合中一组第二信息包含的光源的光谱和所述组合中另一组第二信息中包含的光源的光谱,确定所述组合对应的光源光谱相似指标。
一种可能的实现方式中,所述根据所述
Figure PCTCN2021131622-appb-000004
个二维数据点,确定所述分类标准,包括:根据所述
Figure PCTCN2021131622-appb-000005
个二维数据点,绘制二维交会图;从所述二维交会图的横坐标上确定第一参数,使得纵坐标小于预设值,且横坐标小于所述第一参数的二维点数据点的数量所占的比例超过预设阈值;将所述第一参数作为所述分类标准。
一种可能的实现方式中,所述根据所述分类标准,对所述数据集中M种光源的光谱进行聚类分析,包括:采用k均值聚类算法对所述数据集中M种光源的光谱进行聚类分析,任意两个聚类中心之间的光源光谱相似指标大于所述分类标准,在每个聚类内部,任意两个光源之间的光谱相似指标小于所述分类标准。
一种可能的实现方式中,所述第一模型包括第一分支,所述第一分支用于输出当前拍摄场景下的光源属于各类光源的概率;所述根据每组数据中的第一信息以及每种拍摄场景下的光源对应的光源类别,获取训练样本,包括:将每组数据中的第一信息以及对应拍摄场景下的光源对应的光源类别作为一个训练样本。
一种可能的实现方式中,所述第一模型包括第一分支和第二分支,所述第一分支用于输出当前拍摄场景下的光源属于各类光源的概率,所述第二分支用于输出当前拍摄场景下各个像素对应的物体材质反射率谱;所述根据每组数据中的第一信息以及每种拍摄场景下的光源对应的光源类别,获取训练样本,包括:将每组数据中的第一信息、对应拍摄场景下的光源对应的光源类别以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱作为一个训练样本。
一种可能的实现方式中,所述第一分支包括第一结构和全连接层,所述第一结构下 采样L次后转为所述全连接层,所述第一结构包括卷积层、激活函数以及最大池化层,所述第一分支的损失函数为交叉熵,L大于等于1;所述第二分支包括P个残差块,每个残差块包括第一卷积层、第一激活函数、第二卷积层以及第二激活函数,所述第二分支的损失函数为L2,P大于等于1。
一种可能的实现方式中,所述根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱,包括:将当前拍摄场景下的光源属于各类光源的概率作为求和加权权重,对各类光源的光谱进行求和处理,得到当前拍摄场景下的光源的光谱。
第二方面,本申请提供一种电子设备,包括:RGB传感器、多光谱传感器以及处理器;所述处理器用于,获取当前拍摄场景下的第一信息,所述第一信息包括以下至少一种:所述RGB传感器生成的第一图像或者所述多光谱传感器上各个像素接收到的光线的光强度;所述处理器还用于,将所述第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率;所述处理器还用于,根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。
一种可能的实现方式中,所述处理器将所述第一信息输入第一模型之前,还用于:获取训练样本,所述训练样本包括不同拍摄场景下的第一信息以及不同拍摄场景下的光源对应的光源类别;使用所述训练样本训练所述第一模型。
一种可能的实现方式中,所述处理器具体用于:构建数据集,所述数据集包括M×N组数据,每组数据对应一种拍摄场景,每种拍摄场景对应一种光源和一种被摄物,M为光源的数量,N为被摄物数量,每组数据包括:对应拍摄场景下的第一信息;对所述数据集中M种光源的光谱进行聚类分析,得到每种拍摄场景下的光源对应的光源类别;根据每组数据中的第一信息以及每种拍摄场景下的光源对应的光源类别,获取训练样本。
一种可能的实现方式中,所述M×N组数据中每组数据还包括:第二信息,所述第二信息包括:对应拍摄场景下的光源的光谱以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱;所述处理器具体用于:获取每组数据中的第二信息,得到M×N组第二信息;根据M×N组第二信息,对所述数据集中M种光源的光谱进行聚类分析。
一种可能的实现方式中,所述处理器具体用于:根据M×N组第二信息,确定所述数据集中M种光源的分类标准;根据所述分类标准,对所述数据集中M种光源的光谱进行聚类分析。
一种可能的实现方式中,所述处理器具体用于:针对N种被摄物中的每种被摄物,从所述被摄物对应的M组第二信息中任取两组,得到
Figure PCTCN2021131622-appb-000006
对组合;针对每对组合,计算所述组合对应的二维数据点,得到
Figure PCTCN2021131622-appb-000007
个二维数据点,所述二维数据点包括平均颜色距离和光源光谱相似指标;根据所述
Figure PCTCN2021131622-appb-000008
个二维数据点,确定所述分类标准。
一种可能的实现方式中,所述处理器具体用于:根据所述组合中一组第二信息,计算各个像素的第一RGB值;根据所述组合中另一组第二信息,计算各个像素的第二RGB值;根据各个像素的第一RGB值和各个像素的第二RGB值,确定所述组合对应的平均颜色距离。
一种可能的实现方式中,所述处理器具体用于:根据所述组合中一组第二信息包含的光源的光谱和所述组合中另一组第二信息中包含的光源的光谱,确定所述组合对应的光源 光谱相似指标。
一种可能的实现方式中,所述处理器具体用于:根据所述
Figure PCTCN2021131622-appb-000009
个二维数据点,绘制二维交会图;从所述二维交会图的横坐标上确定第一参数,使得纵坐标小于预设值,且横坐标小于所述第一参数的二维点数据点的数量所占的比例超过预设阈值;将所述第一参数作为所述分类标准。
一种可能的实现方式中,所述处理器具体用于:采用k均值聚类算法对所述数据集中M种光源的光谱进行聚类分析;任意两个聚类中心之间的光源光谱相似指标大于所述分类标准,在每个聚类内部,任意两个光源之间的光谱相似指标小于所述分类标准。
一种可能的实现方式中,所述第一模型包括第一分支,所述第一分支用于输出当前拍摄场景下的光源属于各类光源的概率;所述处理器具体用于:将每组数据中的第一信息以及对应拍摄场景下的光源对应的光源类别作为一个训练样本。
一种可能的实现方式中,所述第一模型包括第一分支和第二分支,所述第一分支用于输出当前拍摄场景下的光源属于各类光源的概率,所述第二分支用于输出当前拍摄场景下各个像素对应的物体材质反射率谱;所述处理器具体用于:将每组数据中的第一信息、对应拍摄场景下的光源对应的光源类别以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱作为一个训练样本。
一种可能的实现方式中,所述第一分支包括第一结构和全连接层,所述第一结构下采样L次后转为所述全连接层,所述第一结构包括卷积层、激活函数以及最大池化层,所述第一分支的损失函数为交叉熵,L大于等于1;所述第二分支包括P个残差块,每个残差块包括第一卷积层、第一激活函数、第二卷积层以及第二激活函数,所述第二分支的损失函数为L2,P大于等于1。
一种可能的实现方式中,所述处理器具体用于:将当前拍摄场景下的光源属于各类光源的概率作为求和加权权重,对各类光源的光谱进行求和处理,得到当前拍摄场景下的光源的光谱。
第三方面,本申请提供一种电子设备,包括:RGB传感器、多光谱传感器、存储器以及处理器,所述RGB传感器用于生成当前拍摄场景下的第一图像,所述多光谱传感器用于记录所述多光谱传感器上各个像素接收到的光线的光强度,所述处理器用于和所述存储器耦合,读取并执行所述存储器中的指令,以实现上述第一方面提供的方法。
第四方面,本申请提供一种可读存储介质,所述可读存储介质上存储有计算机程序;所述计算机程序在被执行时,实现上述第一方面提供的方法。
本申请提供的光源光谱获取方法和设备,用户触发打开终端设备的相机后,一方面,手机上的RGB传感器生成当前拍摄场景的原图,另一方面,手机上的多光谱传感器记录多光谱传感器上各个像素接收到的光线的光强度,将RGB传感器生成的原图和/或多光谱传感器上各个像素接收到的光线的光强度输入预先训练的模型,该模型输出当前拍摄场景下的光源属于各类光源的概率,将该概率作为求和加权权重,依据该求和加权权重和各类光源的光谱,确定当前拍摄场景下的光源的光谱。由于该方法得到的光源光谱接近真实光源光谱,依据该光源光谱进行白平衡处理和色彩矫正处理后,图像的色彩更加接近被摄物真实色彩,提升了用户体验。
附图说明
图1为本申请实施例提供的应用场景图;
图2为本申请实施例提供的RGB传感器的示意图一;
图3为本申请实施例提供的RGB传感器的示意图二;
图3A为本申请实施例提供的光源光谱的示意图;
图3B为本申请实施例提供的RGB传感器和多光谱传感器的示意图;
图4为本申请实施例提供的多光谱传感器的示意图;
图5为本申请实施例提供的通过多光谱传感器获取光源光谱的原理图;
图6为本申请提供的光源光谱获取方法的一实施例的流程图;
图7为本申请提供的RGB传感器上各像素RGB值的计算原理图;
图8为本申请实施例提供的构建数据集的流程图;
图9为本申请实施例提供的拍摄场景示意图一;
图10为本申请实施例提供的拍摄场景示意图二;
图11为本申请实施例提供的平均颜色距离的计算过程流程图;
图12为本申请实施例提供的二维交会图;
图13为本申请实施例提供的聚类结果示意图;
图14为本申请实施例提供的第一模型的结构示意图一;
图15为本申请实施例提供的残差块的结构示意图;
图16为本申请实施例提供的第一模型的结构示意图二;
图17为本申请实施例提供的第一模型的结构示意图三;
图18为本申请实施例提供的当前拍摄场景下的光源的光谱的计算原理图;
图19为本申请实施例提供的通过第一模型得到的光源光谱和通过图5所示方式得到的光源光谱的对比图一;
图20为本申请实施例提供的通过第一模型得到的光源光谱和通过图5所示方式得到的光源光谱的对比图二;
图21为本申请实施例提供的电子设备100的结构示意图。
具体实施方式
图1为本申请实施例提供的应用场景图。参见图1所示,用户拍照时,光源发出的光线照射到被摄物上,被摄物的反射光线入射到相机。参见图2所示,相机内设置有色彩滤镜阵列(Color Filter Array,CFA)和RGB传感器。CFA设置在RGB传感器上,CFA包括红、绿蓝三种颜色的滤光片,三种颜色的滤光片可按照图2所示方式排列,RGB传感器被划分为多个像素,CFA上的滤光片和RGB传感器上的像素一一对应。参见图3所示,以一红色滤光片为例,假设该红色滤光片对应像素A,经过该红色滤光片的过滤后,只有红色光线能到达像素A,因此像素A对应的颜色通道为红色通道。RGB传感器用于记录各个像素接收到的光线的光强度。
图2中,RGB传感器记录的光强度满足公式1:
Figure PCTCN2021131622-appb-000010
其中,c表示像素x对应的颜色通道,I c表示RGB传感器记录的像素x接收到的光线 的光强度,L(λ)为光源光谱,R(λ,x)为像素x对应的物体材质反射率谱,C c(λ)为c的响应函数。c的响应函数指的是RGB传感器记录的光强度与入射光线的光强度的比值随波长变化的函数,C c(λ)在终端设备开发过程中标定得到。
光源光谱L(λ)是指在光源对应的波长范围内,光源的光强度随波长的变化曲线。比如,参见图3A所示,一日光灯对应的波长范围为380~780nm,该日光灯的光强度随波长的变化曲线为图3A所示意的曲线,则图3A所示意的曲线称为该日光灯的光源光谱。
由公式1可以看出,RGB传感器记录的光强度是光源光谱、物体材质反射率谱和响应函数的积分结果。光源不同时,由于光源光谱不同,导致RGB传感器记录的光强度不同,根据该光强度计算得到的色彩值也不同,该色彩值用于渲染形成图像,可见渲染形成的图像的颜色会受光源的影响。比如:一白色物体在日光灯的照射下,渲染形成的图像的颜色接近物体本身的颜色,但是,把该白色物体放在红色发光二极管(Light Emitting Diode,LED)灯的照射下,由于光源发生变化,渲染形成的图像的颜色受红色LED灯的影响偏红。
在一些实施例中,针对每个像素,RGB传感器将该像素接收到的光线的光强度转换为该像素对应颜色通道的色彩值,将周围像素对应的颜色通道的色彩值作为该像素其他颜色通道的色彩值,从而得到该像素的RGB值。RGB传感器将各个像素的RGB值传输给图像信号处理(Image Signal Processing,ISP)模块,ISP模块对RGB传感器输出的各个像素的RGB值进行白平衡处理以及色彩矫正处理,其中,白平衡处理用于去除光源的影响,避免因光源而引起的偏色,色彩矫正处理用于在白平衡处理后,把各个像素的RGB值转换为标准观察者空间(CIE XYZ)。准确的光源光谱可以指导上述两个处理过程。
在一些实施例中,通过如下方式获取光源光谱:
参见图3B所示,在相机中增加多光谱传感器,多光谱传感器和RGB传感器可以共用同一组镜头,或者,多光谱传感器和RGB传感器各自有独立的镜头,图3B中以多光谱传感器和RGB传感器各自有独立的镜头为例示意,多光谱传感器和RGB传感器设置在各自的镜头后面。参见图4所示,和RGB传感器类似,多光谱传感器上也设置有CFA,光线通过镜头入射到CFA上,与RGB传感器上的CFA不同的是,多光谱传感器上的CFA包含多种颜色的滤光片,图4中以CFA包含赤、橙、黄、绿、青、蓝、紫八种颜色滤光片为例示意。
与RGB传感器类似,多光谱传感器可记录各个像素接收到的光线的光强度,参见图4所示,每个像素对应的一种颜色通道,将每个像素接收到的光线的光强度作为对应颜色通道的光强度,可得到八种颜色通道的光强度。将八种颜色通道的光强度绘制在一起,得到图5示意的八个离散点,对图5所示八个离散点进行插值处理,可得到光强度随波长的变化曲线,将该曲线作为光源光谱。
然而,多光谱传感器记录的光强度也满足公式1,通过上述方法得到的光源光谱实质是光源光谱、物体材质反射率谱和响应函数的积分结果,并不是单纯的光源光谱,上述方法得到的光源光谱准确度不高。
为解决上述技术问题,本申请实施例提供一种光源光谱获取方法,该光源光谱获取方法应用于配置有RGB传感器和多光谱传感器的终端设备,该终端设备包括但不限于手机、平板电脑、笔记本电脑、智慧屏、数码相机等。以手机为例,用户触发打开手机的相机后,一方面,手机上的RGB传感器生成当前拍摄场景的原图。另一方面,手机上的多光谱传 感器记录多光谱传感器上各个像素接收到的光线的光强度,将RGB传感器生成的原图和/或多光谱传感器记录的各个像素接收到的光线的光强度输入预先训练的模型,模型输出当前拍摄场景下的光源属于各类光源的概率,将该概率作为求和加权权重,依据该求和加权权重和各类光源的光谱,确定当前拍摄场景下的光源的光谱。该方法得到的光源光谱接近真实光源光谱,依据该光源光谱进行白平衡处理和色彩矫正处理后,图像的色彩更加接近被摄物真实色彩,提升了用户体验。
图6为本申请提供的光源光谱获取方法的一实施例的流程图。如图6所示,本实施例提供的光源光谱获取方法应用在用户触发打开终端设备的相机后,该方法具体包括:
S601、RGB传感器生成当前拍摄场景的原图。
当前拍摄场景的原图为根据RGB传感器上各个像素的RGB值生成的图片。本申请实施例中,将当前拍摄场景的原图称为当前拍摄场景下的第一图像。
针对每个像素,RGB传感器将该像素接收到的光线的光强度转换为该像素对应颜色通道的色彩值,将周围像素对应的颜色通道的色彩值作为该像素其他颜色通道的色彩值,从而得到该像素的RGB值。
举例来说:
参见图7所示,滤光片1的颜色为红色,滤光片2的颜色为绿色,滤光片3的颜色为蓝色。滤光片1对应RGB传感器上的像素A,滤光片2对应RGB传感器上的像素B,滤光片3对应RGB传感器上的像素C。RGB传感器对像素A接收到的光线的光强度进行转换,可得到像素A的R值。对像素B接收到的光线的光强度进行转换,可得到像素B的G值。对像素C接收到的光线的光强度进行转换,可得到像素C的B值。可将像素B的G值作为像素A的G值,将像素C的B值作为像素A的B值,则像素A的RGB值为(R1,G1,B1)。
S602、多光谱传感器记录多光谱传感器上各个像素接收到的光线的光强度。
S602中多光谱传感器为终端设备内配置的多光谱传感器,为方便区分,下文将该多光谱传感器称为第一多光谱传感器。
S603、将第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率。
其中,第一信息包括以下至少一种:RGB传感器生成的第一图像或者第一多光谱传感器上各个像素接收到的光线的光强度。
需要说明的是:可以仅将当前拍摄场景的原图输入第一模型,或者仅将第一多光谱传感器上各个像素接收到的光线的光强度输入第一模型,或者将当前拍摄场景的原图和第一多光谱传感器上各个像素接收到的光线的光强度均输入第一模型。
在S603之前,需对第一模型进行训练,首先,获取训练样本,该训练样本包括不同拍摄场景下的第一信息以及不同拍摄场景下的光源对应的光源类别,然后,使用该训练样本训练第一模型。
下面介绍获取训练样本的过程:
由于已知光源有很多,有的光源的光谱和其他光源的光谱很相似,因此,为了减小第一模型的计算压力,可对已知光源进行分类,根据分类结果和预先构建的数据集获取训练样本。
下面对构建数据集的过程、对已知光源进行分类的过程以及根据分类结果和数据集获 取训练样本的过程逐一介绍。
首先介绍构建数据集的过程:
在终端设备开发过程中,针对任一已知光源,该已知光源包括但不限于:日光、阴影、阴天、钨丝灯、白色荧光灯或者闪光灯,执行如下操作,参见图8所示:
S10、打开光源,测试人员使用照度计测量光源的光谱。
照度计测量得到的光谱在后续对光源进行分类的过程中使用。
S11、测试人员将被摄物放置在光源照射下。
一种可能的实现方式中,将被摄物放置在光源正下方。S10使用的光源和S11使用的被摄物构成一种拍摄场景。
S12、使用终端设备拍摄被摄物。
参见图9所示,可将终端设备正对被摄物,调整终端设备的视场角,使得被摄物处于终端设备的视场角对应的拍摄范围内,然后再触发拍照。
从终端设备的RGB传感器中获取原图,从第一多光谱传感器中获取第一多光谱传感器上各个像素接收到的光线的光强度。该原图和各个像素接收到的光线的光强度在后续获取训练样本的过程中使用。RGB传感器生成原图的过程参见S601,本实施例在此不再赘述。
S13、在终端设备拍摄被摄物的同一位置处,使用多光谱相机拍摄被摄物。
对多光谱相机拍摄得到的多光谱图像进行处理,得到光谱相机内多光谱传感器上各个像素对应的物体材质反射率谱,该物体材质反射率谱在后续对光源进行分类的过程中使用。
一种可能的实现方式中,多光谱相机内设置有多光谱传感器,为方便区分,将该多光谱传感器称为第二多光谱传感器,第二多光谱传感器的尺寸和RGB传感器尺寸相同,第二多光谱传感器上的像素和RGB传感器上的像素一一对应。可利用公式1反推得到第二多光谱传感器上各个像素对应的物体材质反射率谱,具体的,从多光谱图像中提取第二多光谱传感器上各个像素对应的颜色通道的色彩值,根据各个像素对应的颜色通道的色彩值反推得到各个像素对应的颜色通道的光强度I C,S10中测量得到了L(λ),如前文所述,C c(λ)为已知,则可利用公式1反推得到第二多光谱传感器上各个像素对应的物体材质反射率谱。
参见图10所示,使用多光谱相机拍摄被摄物之前,将多光谱相机的视场角调整为终端设备拍摄被摄物时所用的视场角,将多光谱相机的拍摄角度调整为终端设备拍摄被摄物时所用的拍摄角度,然后再触发拍照。
经过S10-S13的采集过程,得到一组数据,该组数据包括:对应拍摄场景下的第一信息和第二信息,该第二信息包括:对应拍摄场景下的光源的光谱以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱。其中,RGB传感器生成的原图以及第一多光谱传感器记录的第一多光谱传感器上各个像素接收到的光线的光强度用于后续获取训练样本;照度计测量得到的光谱以及第二多光谱传感器上各个像素对应的物体材质反射率谱用于对已知光源进行分类。
S14、保持被摄物不变,改变已知光源,重复S10-S13。
本申请实施例假设有M种光源,通过上述S11-S14可得到同一被摄物对应的M组数据。改变被摄物,重复S11-S14可得到另一被摄物对应的M组数据,假设被摄物有N种,则可得到M×N组数据,该M×N组数据构成上述数据集,每组数据对应一种拍摄场景, 每种拍摄场景对应一种光源和一种被摄物。
以上为构建数据集的过程。
下面介绍对已知光源进行分类的过程:
一种可能的实现方式中,参见上文数据集构建过程,数据集中有M种光源,对已知光源进行分类指的是对该M种光源的光谱进行聚类分析,得到数据集中每种拍摄场景下的光源对应的光源类别。
对M种光源的光谱进行聚类分析时,从数据集中获取每组数据中的第二信息,得到M×N组第二信息,根据M×N组第二信息,对数据集中M种光源的光谱进行聚类分析。
具体的,首先根据M×N组第二信息,确定数据集中M种光源的分类标准,然后根据该分类标准,对数据集中M种光源的光谱进行聚类分析。
下面对分类标准的确定过程以及根据分类标准对M种光源的光谱进行聚类分析的过程逐一介绍。
下面介绍分类标准的确定过程:
针对N种被摄物中的每种被摄物,从该被摄物对应的M组第二信息中任取两组,得到
Figure PCTCN2021131622-appb-000011
对组合,针对每对组合,通过下文提供的方法计算对应的二维数据点。该二维数据点包括平均颜色距离和光源光谱相似指标;根据
Figure PCTCN2021131622-appb-000012
个二维数据点,确定分类标准。
下面介绍二维数据点的计算过程:
以一对组合为例,该对组合对应的平均颜色距离和该对组合对应的光源光谱相似指标构成该对组合的二维数据点。因此,二维数据点的计算过程包括两个方面的计算,一方面,计算该对组合对应的平均颜色距离,该平均颜色距离反映两张图像的色彩的差异。另一方面,计算该对组合对应的光源光谱相似指标。
下面介绍平均颜色距离的计算过程,参见图11所示:
S20、根据该对组合中一组第二信息,计算各个像素的第一RGB值。
首先,采用如下公式计算各个像素对应的的光强度:
I c=∫ 0 λL(λ)R(λ,x)C c(λ)dλ
其中,c表示像素x对应的颜色通道,I c表示像素x对应的光强度,L(λ)表示该组第二信息中的光源的光谱,R(λ,x)表示该组第二信息中第二多光谱传感器上各个像素对应的物体材质反射率谱,C c(λ)为c的响应函数。
然后,对各个像素对应的光强度进行转换,得到各个像素对应的颜色通道的色彩值,针对每个像素,将该像素周围像素对应的颜色通道的色彩值作为该像素其他颜色通道的色彩值,从而得到该像素的第一RGB值。具体过程可参见S601,本申请在此不再赘述。
S21、根据该对组合中另一组第二信息,计算各个像素的第二RGB值。
根据另一组第二信息,计算各个像素的第二RGB值的方式和S20类似,本申请不再赘述。
S22、根据S20计算的各个像素的第一RGB值以及S21计算的各个像素的第二RGB值,计算每个像素对应的颜色距离。
针对任一像素,通过如下公式计算该像素对应的颜色距离:
Figure PCTCN2021131622-appb-000013
其中,(R1,G1,B1)为S20计算的各个像素的RGB值,(R2,G2,B2)为S21计算的各个像素的RGB值。
S23、对所有像素均进行上述S22的计算,得到所有像素对应的颜色距离,然后对所有像素对应的颜色距离求取平均,将得到的平均值作为上述平均颜色距离。
以上为平均颜色距离的计算过程。
下面介绍光源光谱相似指标的计算过程:
可通过如下公式计算一对组合对应的光源光谱相似指标:
Figure PCTCN2021131622-appb-000014
其中,RMSE表示一对组合对应的光源光谱相似指标,
Figure PCTCN2021131622-appb-000015
为该对组合中一组第二信息中光源的光谱上波长i的光强度,
Figure PCTCN2021131622-appb-000016
为该对组合中另一组第二信息中光源的光谱上波长i的光强度,N表示两组第二信息中光源的光谱上共有波长的数量。该光源光谱相似指标越小,光源光谱相似度越大。
以上为光源光谱相似指标的计算过程。
通过上述第一方面的计算,可以得到一对组合对应的平均颜色距离,通过上述第二方面的计算,可以得到一对组合对应的光源光谱相似指标。该平均颜色距离和该光源光谱相似指标的对应关系可作为该对组合对应的二维数据点。
Figure PCTCN2021131622-appb-000017
对组合均做如上处理,得到
Figure PCTCN2021131622-appb-000018
个二维数据点。
以上为二维数据点的计算过程。
下面介绍确定分类标准的过程:
根据
Figure PCTCN2021131622-appb-000019
个二维数据点,绘制二维交会图,横坐标代表光源光谱相似指标,纵坐标代表平均颜色距离,根据图上
Figure PCTCN2021131622-appb-000020
个二维数据点的分布确定分类标准。
举例来说:
将上述
Figure PCTCN2021131622-appb-000021
个二维数据点绘制在一张图上后,得到图12所示二维交会图。可预先设置一个阈值,比如:95%。平均颜色距离小于5度时,两个图像的色彩差异不显著,可将5度作为预设值,从二维交会图的横坐标上确定第一参数,使得纵坐标小于预设值,横坐标小于第一参数的二维点数据点的数量所占的比例超过预设阈值,该第一参数则可作为上述分类标准。参见图12所示,纵坐标小于5度,横坐标小于0.004的二维点数据点的数量所占的比例超过了95%,则可将该0.004作为分类标准。
以上为确定分类标准的过程。
下面介绍根据分类标准对M种光源的光谱进行聚类分析的过程。
采用k均值聚类算法(k-means clustering algorithm,k-means)对M种光源的光谱进行聚类分析,在聚类分析的过程中保证任意两个聚类中心之间的光源光谱相似指标大于上述分类标准,在每个聚类内部,任意两个光源之间的光源光谱相似指标小于上述分类标准,得到光源的类别数量以及M种光源各自对应的光源类别。
示例性的,图13示出了一种聚类结果,参见图13所示,通过上述聚类分析,得到5类光源。分别用类别1、类别2、类别3、类别4、类别5示意。
以上为根据分类标准对M种光源的光谱进行聚类分析的过程。
下面介绍根据分类结果和数据集获取训练样本的过程:
可根据数据集中每组数据中的第一信息以及每种拍摄场景下的光源对应的光源类别,获取训练样本。
第一模型的结构不同时,需要获取的训练样本不同,下面介绍第一模型的几种可能的设计结构。
一种可能的实现方式中,参见图14所示,第一模型包括八个残差块和第一分支,将S601得到的原图和/或S602得到的第一多光谱传感器上各个像素接收到的光线的光强度输入第一个残差块后,经过八个残差块和第一分支的处理,第一分支便会输出当前拍摄场景下的光源属于各类光源的概率。
参见图14所示,第一分支通过第一结构下采样4次后转为全连接层,第一结构包括:卷积层、激活函数以及最大池化层。卷积层可以为C(3,3,64),C(3,3,64)表示64通道且核大小为3*3的卷积层,激活函数可采用ReLu,最大池化层可以为Max_pool2d(2,2),Max_pool2d(2,2)表示核大小为2*2的最大池化层。全连接层尺寸为(1*光谱类别数量)。第一分支的损失函数为交叉熵。一次训练所抓取的训练样本数量batch size设为64,优化器为Adam,学习率服从多项式衰减,学习率的初始值设为1×10 -5。光谱类别数量设为上述聚类分析得到的数量。
需要说明的是:上述下采样4次仅是一种示例,本申请对下采样次数不限制。
参见图15所示,每个残差块的图像尺寸为W*H*64。W与H为图像的宽和高,64表示通道数量。每个残差块包括:卷积层1、激活函数1、卷积层2、激活函数2,卷积层1和卷积层2可以为C(3,3,64),激活函数1和激活函数2可采用ReLu。
训练图14所示第一模型时,训练样本中包含数据需要有:RGB传感器生成的原图、第一多光谱传感器上各个像素接收到的光线的光强度以及光源类别。可将每组数据中的第一信息以及对应拍摄场景下的光源对应的光源类别作为一个训练样本。以数据集中M×N组数据中一组数据为例,假设聚类分析的结果为:该组数据对应的光源类别为类别A;该组数据中的RGB传感器生成的原图为原图A,该组数据中第一多光谱传感器上各个像素接收到的光线的光强度为向量A,则该原图A、向量A和类别A构成一个训练样本,如表1所示。
表1
训练样本 原图A 向量A 类别A
训练第一模型时,每次一个batch数量的样本输入,计算梯度,更新模型参数,迭代多次之后,模型达到最优。
另一种可能的实现方式中,参见图16所示,第一模型包括八个残差块、第一分支以及第二分支,将S601得到的原图和/或S602得到的第一多光谱传感器上各个像素接收到的光线的光强度输入第一个残差块后,第一分支输出当前拍摄场景下的光源属于各类光源的概率,第二分支输出当前拍摄场景下各个像素对应的物体材质反射率谱。
其中,八个残差块和第一分支的结构参见图14和图15,本实施例在此不再赘述。第二分支包括八个残差块,每个残差块结构和图15所示残差块的结构相同。第二分支的损失函数为L2。batch size设为64,优化器为Adam,学习率服从多项式衰减,学习率的初始 值设为1×10 -5,物体材质反射率谱为31通道。
需要说明的是:上述第二分支包括八个残差块仅是一种示例,本申请对第二分支中残差块的数量不限制。
训练图16所示第一模型时,训练样本中包含数据需要有:RGB传感器生成的原图、第一多光谱传感器上各个像素接收到的光线的光强度、光源类别以及第二多光谱传感器上各个像素对应的物体材质反射率谱。可将每组数据中的第一信息、对应拍摄场景下的光源对应的光源类别以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱作为一个训练样本。以数据集中M×N组数据中一组数据为例,假设聚类分析的结果为:该组数据对应的光源类别为类别A;该组数据中的RGB传感器生成的原图为原图A,该组数据中第一多光谱传感器上各个像素接收到的光线的光强度为向量A1,该组数据中第二多光谱传感器上各个像素对应的物体材质反射率谱为向量A2,则该原图A、向量A1、向量A2和类别A构成一个训练样本,如表2所示。
表2
训练样本 原图A 向量A1 向量A2 类别A
训练第一模型时,每次一个batch数量的样本输入,计算梯度,更新模型参数,迭代多次之后,模型达到最优。
又一种可能的实现方式中,参见图17所示,第一模型可包括八个残差块和第二分支。将S601得到的原图和/或S602得到的第一多光谱传感器上各个像素接收到的光线的光强度输入第一个残差块后,第二分支输出RGB传感器上各个像素对应的物体材质反射率谱。
其中,八个残差块结构参见图15,第二分支的结构参见图16,本实施例在此不再赘述。
训练图17所示第一模型时,训练样本中包含数据需要有:RGB传感器生成的原图、第一多光谱传感器上各个像素接收到的光线的光强度以及第二多光谱传感器上各个像素对应的物体材质反射率谱。其中,RGB传感器生成的原图、第一多光谱传感器上各个像素接收到的光线的光强度以及第二多光谱传感器上各个像素对应的物体材质反射率谱可以从上文构建的数据集中提取。以数据集中M×N组数据中一组数据为例,该组数据中的RGB传感器生成的原图为原图A,该组数据中第一多光谱传感器上各个像素接收到的光线的光强度为向量A1,该组数据中第二多光谱传感器上各个像素对应的物体材质反射率谱为向量A2,则该原图A、向量A1和向量A2构成一个训练样本,如表3所示。
表3
训练样本 原图A 向量A1 向量A2
S604、根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。
一种可能的实现方式中,将当前拍摄场景下的光源属于各类光源的概率作为求和加权权重,对各类光源的光谱进行求和处理,得到当前拍摄场景下的光源的光谱。
一种可能的实现方式中,各类光源的光谱可以为上述聚类分析得到的各个聚类中心的 光谱。
下面举例说明:
假设上述聚类分析得到5类光源,当前拍照场景下的光源属于各类光源的概率分别为A%,B%,C%,D%以及E%。各类光源的光谱分为参见图18所示,将A%,B%,C%,D%以及E%作为求和加权权重,通过图18方式求取当前拍摄场景下的光源的光谱。
如前文所描述,第一模型的输入可以为RGB传感器生成原图,也可以为第一多光谱传感器上各个像素接收到的光线的光强度,还可以为RGB传感器生成原图和第一多光谱传感器上各个像素接收到的光线的光强度。第一模型的输入不同的,第一模型的输出有差异,S604得到的光谱相应的也有差异。针对每种输入,计算S604得到的光谱和照度计实际测量的光谱之间的光源光谱相似指标。示例性的,表4示出了三种输入对应的光源光谱相似指标,表4中将第一多光谱传感器上各个像素接收到的光线的光强度简称为光强度,将RGB传感器生成原图简称为原图。从表4可以看出,和仅输入RGB传感器生成原图或第一多光谱传感器上各个像素接收到的光线的光强度相比,将RGB传感器生成原图和第一多光谱传感器上各个像素接收到的光线的光强度均输入第一模型时,S604确定的光源光谱和照度计实际测量的光谱最相似。
表4
输入 RMSE
原图 0.0057
原图+光强度 0.0038
光强度 0.0041
图19示出了通过第一模型得到的光源光谱和通过图5所示方式得到的光源光谱的对比图一。图19中AMS为通过图5所示方式得到的光源光谱,Estimated为通过第一模型得到的光源光谱,Ground Truth为照度计实际测量的光源光谱。横坐标为波长,纵坐标为光强度的归一化值。经计算,AMS和Ground Truth之间的光源光谱相似指标RMSE_G=0.0083,Estimated和Ground Truth之间的光源光谱相似指标RMSE_G=0.0041,可见,相比于图5所示方式得到的光源光谱,通过第一模型得到的光源光谱和照度计实际测量的光源光谱更接近。
图20示出了通过第一模型得到的光源光谱和通过图5所示方式得到的光源光谱的对比图二。同样的,图15中AMS为通过图5所示方式得到的光源光谱,Estimated为通过第一模型得到的光源光谱,Ground Truth为照度计实际测量的光源光谱。横坐标为波长,纵坐标为光强度的归一化值。经计算,AMS和Ground Truth之间的相似指标RMSE_G=0.0093,Estimated和Ground Truth之间的相似指标RMSE_G=0.0050,可见,相比于图5所示方式得到的光源光谱,通过第一模型得到的光源光谱和照度计实际测量的光源光谱更接近。
由于通过第一模型得到的光源光谱接近真实光源光谱,依据该光源光谱进行白平衡处理和色彩矫正处理后,图像的色彩更加接近被摄物真实色彩,提升了用户体验。
本申请实施例提供的光源光谱获取方法,用户触发打开终端设备的相机后,一方面,手机上的RGB传感器生成当前拍摄场景的原图,另一方面,手机上的多光谱传感器记录多光谱传感器上各个像素接收到的光线的光强度,将RGB传感器生成的原图和/或多光谱传感器上各个像素接收到的光线的光强度输入预先训练的模型,该模型输出当前拍摄场景 下的光源属于各类光源的概率,将该概率作为求和加权权重,依据该求和加权权重和各类光源的光谱,确定当前拍摄场景下的光源的光谱。由于该方法得到的光源光谱接近真实光源光谱,依据该光源光谱进行白平衡处理和色彩矫正处理后,图像的色彩更加接近被摄物真实色彩,提升了用户体验。
图21示出了电子设备100的结构示意图。电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,按键190,马达191,指示器192,摄像头193,显示屏194等。
其中,摄像头193包括RGB传感器、多光谱传感器以及ISP处理器。RGB传感器和多光谱传感器均和ISP处理器连接。RGB传感器用于生成当前拍摄场景的原图,多光谱传感器用于记录多光谱传感器上各个像素接收到的光线的光强度。
一种可能的实现方式中,第一模型安装在RGB传感器中,RGB传感器和多光谱传感器相连,多光谱传感器将记录的各个像素接收到的光线的光强度发送给RGB传感器,RGB传感器生成当前拍摄场景的原图后,将第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率,RGB传感器进一步根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。并将该光源的光谱发送给ISP处理器,用于指导白平衡处理和色彩矫正处理过程。
另一种可能的实现方式中,第一模型安装在多光谱传感器中,RGB传感器和多光谱传感器相连,RGB传感器将生成的当前拍摄场景的原图发送给多光谱传感器,多光谱传感器记录多光谱传感器上各个像素接收到的光线的光强度,并将第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率,多光谱传感器进一步根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。并将该光源的光谱发送给ISP处理器,用于指导白平衡处理和色彩矫正处理过程。
另一种可能的实现方式中,第一模型安装在ISP处理器中,RGB传感器和多光谱传感器均和ISP处理器连接,多光谱传感器将记录的各个像素接收到的光线的光强度发送给ISP处理器,RGB传感器将生成的当前拍摄场景的原图发送给ISP处理器,ISP处理器将第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率,进一步根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。该光源的光谱用于指导白平衡处理和色彩矫正处理过程。
另一种可能的实现方式中,第一模型安装在处理器110中,RGB传感器和多光谱传感器均和处理器110连接,多光谱传感器将记录的各个像素接收到的光线的光强度发送给处理器110,RGB传感器将生成的当前拍摄场景的原图发送给处理器110,处理器110将第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率,进一步根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。并将该光源的光谱发送给ISP处理器,用于指导白平衡处理和色彩矫正处理过程。
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬 件的组合实现。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。
MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI 接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。
GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。
可以理解的是,本发明实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP 处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行电子设备100的各种功能应用以及数据处理。
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接 听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (31)

  1. 一种光源光谱获取方法,其特征在于,所述方法包括:
    获取当前拍摄场景下的第一信息,所述第一信息包括以下至少一种:RGB传感器生成的第一图像或者第一多光谱传感器上各个像素接收到的光线的光强度;
    将所述第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率;
    根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。
  2. 根据权利要求1所述的方法,其特征在于,所述将所述第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率之前,所述方法还包括:
    获取训练样本,所述训练样本包括不同拍摄场景下的第一信息以及不同拍摄场景下的光源对应的光源类别;
    使用所述训练样本训练所述第一模型。
  3. 根据权利要求2所述的方法,其特征在于,所述获取训练样本,包括:
    构建数据集,所述数据集包括M×N组数据,每组数据对应一种拍摄场景,每种拍摄场景对应一种光源和一种被摄物,M为光源的数量,N为被摄物数量,每组数据包括:对应拍摄场景下的第一信息;
    对所述数据集中M种光源的光谱进行聚类分析,得到每种拍摄场景下的光源对应的光源类别;
    根据每组数据中的第一信息以及每种拍摄场景下的光源对应的光源类别,获取训练样本。
  4. 根据权利要求3所述的方法,其特征在于,所述M×N组数据中每组数据还包括:第二信息,所述第二信息包括:对应拍摄场景下的光源的光谱以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱;
    所述对所述数据集中M种光源的光谱进行聚类分析,得到每种拍摄场景下的光源对应的光源类别,包括:
    获取每组数据中的第二信息,得到M×N组第二信息;
    根据M×N组第二信息,对所述数据集中M种光源的光谱进行聚类分析。
  5. 根据权利要求4所述的方法,其特征在于,所述根据M×N组第二信息,对所述数据集中M种光源的光谱进行聚类分析,包括:
    根据M×N组第二信息,确定所述数据集中M种光源的分类标准;
    根据所述分类标准,对所述数据集中M种光源的光谱进行聚类分析。
  6. 根据权利要求5所述的方法,其特征在于,所述根据M×N组第二信息,确定所述数据集中M种光源的分类标准,包括:
    针对N种被摄物中的每种被摄物,从所述被摄物对应的M组第二信息中任取两组,得到
    Figure PCTCN2021131622-appb-100001
    对组合;
    针对每对组合,计算所述组合对应的二维数据点,得到
    Figure PCTCN2021131622-appb-100002
    个二维数据点,所述二维数据点包括平均颜色距离和光源光谱相似指标;
    根据所述
    Figure PCTCN2021131622-appb-100003
    个二维数据点,确定所述分类标准。
  7. 根据权利要求6所述的方法,其特征在于,所述针对每对组合,计算所述组合对 应的二维数据点,包括:
    根据所述组合中一组第二信息,计算各个像素的第一RGB值;
    根据所述组合中另一组第二信息,计算各个像素的第二RGB值;
    根据各个像素的第一RGB值和各个像素的第二RGB值,确定所述组合对应的平均颜色距离。
  8. 根据权利要求6所述的方法,其特征在于,所述针对每对组合,计算所述组合对应的二维数据点,包括:
    根据所述组合中一组第二信息包含的光源的光谱和所述组合中另一组第二信息中包含的光源的光谱,确定所述组合对应的光源光谱相似指标。
  9. 根据权利要求6-8任一项所述的方法,其特征在于,所述根据所述
    Figure PCTCN2021131622-appb-100004
    个二维数据点,确定所述分类标准,包括:
    根据所述
    Figure PCTCN2021131622-appb-100005
    个二维数据点,绘制二维交会图;
    从所述二维交会图的横坐标上确定第一参数,使得纵坐标小于预设值,且横坐标小于所述第一参数的二维点数据点的数量所占的比例超过预设阈值;
    将所述第一参数作为所述分类标准。
  10. 根据权利要求5-9任一项所述的方法,其特征在于,所述根据所述分类标准,对所述数据集中M种光源的光谱进行聚类分析,包括:
    采用k均值聚类算法对所述数据集中M种光源的光谱进行聚类分析,任意两个聚类中心之间的光源光谱相似指标大于所述分类标准,在每个聚类内部,任意两个光源之间的光谱相似指标小于所述分类标准。
  11. 根据权利要求3-10任一项所述的方法,其特征在于,所述第一模型包括第一分支,所述第一分支用于输出当前拍摄场景下的光源属于各类光源的概率;
    所述根据每组数据中的第一信息以及每种拍摄场景下的光源对应的光源类别,获取训练样本,包括:
    将每组数据中的第一信息以及对应拍摄场景下的光源对应的光源类别作为一个训练样本。
  12. 根据权利要求3-10任一项所述的方法,其特征在于,所述第一模型包括第一分支和第二分支,所述第一分支用于输出当前拍摄场景下的光源属于各类光源的概率,所述第二分支用于输出当前拍摄场景下各个像素对应的物体材质反射率谱;
    所述根据每组数据中的第一信息以及每种拍摄场景下的光源对应的光源类别,获取训练样本,包括:
    将每组数据中的第一信息、对应拍摄场景下的光源对应的光源类别以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱作为一个训练样本。
  13. 根据权利要求12所述的方法,其特征在于,
    所述第一分支包括第一结构和全连接层,所述第一结构下采样L次后转为所述全连接层,所述第一结构包括卷积层、激活函数以及最大池化层,所述第一分支的损失函数为交叉熵,L大于等于1;
    所述第二分支包括P个残差块,每个残差块包括第一卷积层、第一激活函数、第二卷积层以及第二激活函数,所述第二分支的损失函数为L2,P大于等于1。
  14. 根据权利要求1-13任一项所述的方法,其特征在于,所述根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱,包括:
    将当前拍摄场景下的光源属于各类光源的概率作为求和加权权重,对各类光源的光谱进行求和处理,得到当前拍摄场景下的光源的光谱。
  15. 一种电子设备,其特征在于,包括:RGB传感器、多光谱传感器以及处理器;
    所述处理器用于,获取当前拍摄场景下的第一信息,所述第一信息包括以下至少一种:所述RGB传感器生成的第一图像或者所述多光谱传感器上各个像素接收到的光线的光强度;
    所述处理器还用于,将所述第一信息输入第一模型,得到当前拍摄场景下的光源属于各类光源的概率;
    所述处理器还用于,根据当前拍摄场景下的光源属于各类光源的概率以及各类光源的光谱,确定当前拍摄场景下的光源的光谱。
  16. 根据权利要求15所述的电子设备,其特征在于,所述处理器将所述第一信息输入第一模型之前,还用于:
    获取训练样本,所述训练样本包括不同拍摄场景下的第一信息以及不同拍摄场景下的光源对应的光源类别;
    使用所述训练样本训练所述第一模型。
  17. 根据权利要求16所述的电子设备,其特征在于,所述处理器具体用于:
    构建数据集,所述数据集包括M×N组数据,每组数据对应一种拍摄场景,每种拍摄场景对应一种光源和一种被摄物,M为光源的数量,N为被摄物数量,每组数据包括:对应拍摄场景下的第一信息;
    对所述数据集中M种光源的光谱进行聚类分析,得到每种拍摄场景下的光源对应的光源类别;
    根据每组数据中的第一信息以及每种拍摄场景下的光源对应的光源类别,获取训练样本。
  18. 根据权利要求17所述的电子设备,其特征在于,所述M×N组数据中每组数据还包括:第二信息,所述第二信息包括:对应拍摄场景下的光源的光谱以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱;
    所述处理器具体用于:
    获取每组数据中的第二信息,得到M×N组第二信息;
    根据M×N组第二信息,对所述数据集中M种光源的光谱进行聚类分析。
  19. 根据权利要求18所述的电子设备,其特征在于,所述处理器具体用于:
    根据M×N组第二信息,确定所述数据集中M种光源的分类标准;
    根据所述分类标准,对所述数据集中M种光源的光谱进行聚类分析。
  20. 根据权利要求19所述的电子设备,其特征在于,所述处理器具体用于:
    针对N种被摄物中的每种被摄物,从所述被摄物对应的M组第二信息中任取两组,得到
    Figure PCTCN2021131622-appb-100006
    对组合;
    针对每对组合,计算所述组合对应的二维数据点,得到
    Figure PCTCN2021131622-appb-100007
    个二维数据点,所述二 维数据点包括平均颜色距离和光源光谱相似指标;
    根据所述
    Figure PCTCN2021131622-appb-100008
    个二维数据点,确定所述分类标准。
  21. 根据权利要求20所述的电子设备,其特征在于,所述处理器具体用于:
    根据所述组合中一组第二信息,计算各个像素的第一RGB值;
    根据所述组合中另一组第二信息,计算各个像素的第二RGB值;
    根据各个像素的第一RGB值和各个像素的第二RGB值,确定所述组合对应的平均颜色距离。
  22. 根据权利要求20所述的电子设备,其特征在于,所述处理器具体用于:
    根据所述组合中一组第二信息包含的光源的光谱和所述组合中另一组第二信息中包含的光源的光谱,确定所述组合对应的光源光谱相似指标。
  23. 根据权利要求20-22任一项所述的电子设备,其特征在于,所述处理器具体用于:
    根据所述
    Figure PCTCN2021131622-appb-100009
    个二维数据点,绘制二维交会图;
    从所述二维交会图的横坐标上确定第一参数,使得纵坐标小于预设值,且横坐标小于所述第一参数的二维点数据点的数量所占的比例超过预设阈值;
    将所述第一参数作为所述分类标准。
  24. 根据权利要求19-23任一项所述的电子设备,其特征在于,所述处理器具体用于:
    采用k均值聚类算法对所述数据集中M种光源的光谱进行聚类分析;任意两个聚类中心之间的光源光谱相似指标大于所述分类标准,在每个聚类内部,任意两个光源之间的光谱相似指标小于所述分类标准。
  25. 根据权利要求17-24任一项所述的电子设备,其特征在于,所述第一模型包括第一分支,所述第一分支用于输出当前拍摄场景下的光源属于各类光源的概率;
    所述处理器具体用于:
    将每组数据中的第一信息以及对应拍摄场景下的光源对应的光源类别作为一个训练样本。
  26. 根据权利要求17-24任一项所述的电子设备,其特征在于,所述第一模型包括第一分支和第二分支,所述第一分支用于输出当前拍摄场景下的光源属于各类光源的概率,所述第二分支用于输出当前拍摄场景下各个像素对应的物体材质反射率谱;
    所述处理器具体用于:
    将每组数据中的第一信息、对应拍摄场景下的光源对应的光源类别以及对应拍摄场景下第二多光谱传感器上各个像素对应的物体材质反射率谱作为一个训练样本。
  27. 根据权利要求26所述的电子设备,其特征在于,
    所述第一分支包括第一结构和全连接层,所述第一结构下采样L次后转为所述全连接层,所述第一结构包括卷积层、激活函数以及最大池化层,所述第一分支的损失函数为交叉熵,L大于等于1;
    所述第二分支包括P个残差块,每个残差块包括第一卷积层、第一激活函数、第二卷积层以及第二激活函数,所述第二分支的损失函数为L2,P大于等于1。
  28. 根据权利要求15-27任一项所述的电子设备,其特征在于,所述处理器具体用于:
    将当前拍摄场景下的光源属于各类光源的概率作为求和加权权重,对各类光源的光谱进行求和处理,得到当前拍摄场景下的光源的光谱。
  29. 一种电子设备,其特征在于,包括:RGB传感器、多光谱传感器、存储器以及处理器,所述RGB传感器用于生成当前拍摄场景下的第一图像,所述多光谱传感器用于记录所述多光谱传感器上各个像素接收到的光线的光强度,所述处理器用于和所述存储器耦合,读取并执行所述存储器中的指令,以实现权利要求1-14中任一项所述的方法。
  30. 一种可读存储介质,其特征在于,所述可读存储介质上存储有计算机程序;所述计算机程序在被执行时,实现上述权利要求1-14任一项所述的方法。
  31. 一种程序产品,其特征在于,所述程序产品包括计算机程序,所述计算机程序存储在可读存储介质中,通信装置的至少一个处理器可以从所述可读存储介质读取所述计算机程序,所述至少一个处理器执行所述计算机程序使得通信装置实施如权利要求1-14任意一项所述的方法。
PCT/CN2021/131622 2020-11-23 2021-11-19 光源光谱获取方法和设备 WO2022105850A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/037,723 US20230410463A1 (en) 2020-11-23 2021-11-19 Method for Obtaining Light Source Spectrum and Device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011325598.3A CN114531578B (zh) 2020-11-23 2020-11-23 光源光谱获取方法和设备
CN202011325598.3 2020-11-23

Publications (1)

Publication Number Publication Date
WO2022105850A1 true WO2022105850A1 (zh) 2022-05-27

Family

ID=81619320

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/131622 WO2022105850A1 (zh) 2020-11-23 2021-11-19 光源光谱获取方法和设备

Country Status (3)

Country Link
US (1) US20230410463A1 (zh)
CN (1) CN114531578B (zh)
WO (1) WO2022105850A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118057830A (zh) * 2022-11-18 2024-05-21 华为技术有限公司 图像处理方法、电子设备、计算机程序产品及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102572211A (zh) * 2010-12-20 2012-07-11 三星泰科威株式会社 估计光源的方法和设备
CN108388905A (zh) * 2018-03-21 2018-08-10 合肥工业大学 一种基于卷积神经网络和邻域上下文的光源估计方法
US20190045163A1 (en) * 2018-10-02 2019-02-07 Intel Corporation Method and system of deep learning-based automatic white balancing
CN111294576A (zh) * 2020-02-13 2020-06-16 展讯通信(上海)有限公司 一种自动白平衡处理方法、装置及电子设备
WO2020172888A1 (zh) * 2019-02-28 2020-09-03 华为技术有限公司 一种图像处理方法和装置

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH10145619A (ja) * 1996-11-11 1998-05-29 Toyo Ink Mfg Co Ltd 色シミュレーション方法
DE19904940A1 (de) * 1999-02-06 2000-12-21 Sel Alcatel Ag Optisches Übertragungssystem sowie Sender und Empfänger
JP3767541B2 (ja) * 2002-11-12 2006-04-19 ソニー株式会社 光源推定装置、光源推定方法、撮像装置および画像処理方法
US7269297B2 (en) * 2003-11-25 2007-09-11 Xerox Corporation Illuminant-neutral gray component replacement in systems for spectral multiplexing of source images to provide a composite image, for rendering the composite image, and for spectral demultiplexing of the composite image
JP2010517460A (ja) * 2007-01-29 2010-05-20 ジョンイル パク マルチスペクトル映像取得方法およびその装置
CN100563297C (zh) * 2007-06-26 2009-11-25 北京中星微电子有限公司 实现白平衡校正的方法及装置
JP6462990B2 (ja) * 2014-03-07 2019-01-30 キヤノン株式会社 画像処理装置およびその方法
US9307214B1 (en) * 2014-12-19 2016-04-05 Omnivision Technologies, Inc. Automatic white balance methods and systems for electronic cameras
US10607329B2 (en) * 2017-03-13 2020-03-31 Adobe Inc. Illumination estimation from a single image
WO2019104047A1 (en) * 2017-11-22 2019-05-31 Gopro, Inc. Global tone mapping
CN110248081A (zh) * 2018-10-12 2019-09-17 华为技术有限公司 图像捕捉方法及电子设备
CN109885890B (zh) * 2019-01-23 2020-08-07 中国地质大学(武汉) 一种基于颜色熵的光源光谱优化方法及系统
CN110602403A (zh) * 2019-09-23 2019-12-20 华为技术有限公司 一种暗光下拍照的方法及电子设备
CN110830794B (zh) * 2019-11-29 2021-11-16 Oppo广东移动通信有限公司 光源检测方法、终端及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102572211A (zh) * 2010-12-20 2012-07-11 三星泰科威株式会社 估计光源的方法和设备
CN108388905A (zh) * 2018-03-21 2018-08-10 合肥工业大学 一种基于卷积神经网络和邻域上下文的光源估计方法
US20190045163A1 (en) * 2018-10-02 2019-02-07 Intel Corporation Method and system of deep learning-based automatic white balancing
WO2020172888A1 (zh) * 2019-02-28 2020-09-03 华为技术有限公司 一种图像处理方法和装置
CN111294576A (zh) * 2020-02-13 2020-06-16 展讯通信(上海)有限公司 一种自动白平衡处理方法、装置及电子设备

Also Published As

Publication number Publication date
US20230410463A1 (en) 2023-12-21
CN114531578A (zh) 2022-05-24
CN114531578B (zh) 2023-11-07

Similar Documents

Publication Publication Date Title
CN111179282B (zh) 图像处理方法、图像处理装置、存储介质与电子设备
WO2021036991A1 (zh) 高动态范围视频生成方法及装置
WO2020015147A1 (zh) 一种皮肤检测方法和电子设备
WO2021135707A1 (zh) 机器学习模型的搜索方法及相关装置、设备
US20220319077A1 (en) Image-text fusion method and apparatus, and electronic device
CN112887582A (zh) 一种图像色彩处理方法、装置及相关设备
CN112533115B (zh) 一种提升扬声器的音质的方法及装置
CN112954251B (zh) 视频处理方法、视频处理装置、存储介质与电子设备
CN107025441B (zh) 肤色检测方法及装置
CN111462170A (zh) 运动估计方法、运动估计装置、存储介质与电子设备
CN113766204A (zh) 图像的光源色彩的调整方法、电子设备及存储介质
CN112419167A (zh) 图像增强方法、装置及存储介质
WO2022105850A1 (zh) 光源光谱获取方法和设备
CN113744257A (zh) 图像融合方法、装置、终端设备以及存储介质
CN113052056A (zh) 一种视频处理的方法以及装置
CN113727085B (zh) 一种白平衡处理方法、电子设备、芯片系统和存储介质
CN116668656B (zh) 图像处理方法及电子设备
EP4181016A1 (en) Image processing method, electronic device, image processing system and chip system
WO2021179142A1 (zh) 一种图像处理方法及相关装置
CN113066020A (zh) 图像处理方法及装置、计算机可读介质和电子设备
CN113660369B (zh) 来电处理及模型训练方法、装置、终端设备和存储介质
CN112308202A (zh) 一种确定卷积神经网络的决策因素的方法及电子设备
CN117135471A (zh) 一种图像处理方法和电子设备
WO2022095752A1 (zh) 帧解复用方法、电子设备及存储介质
WO2022068598A1 (zh) 成像方法和装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21893997

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21893997

Country of ref document: EP

Kind code of ref document: A1