CN113068016A - White balance correction method and device and computer equipment - Google Patents
White balance correction method and device and computer equipment Download PDFInfo
- Publication number
- CN113068016A CN113068016A CN202110360676.1A CN202110360676A CN113068016A CN 113068016 A CN113068016 A CN 113068016A CN 202110360676 A CN202110360676 A CN 202110360676A CN 113068016 A CN113068016 A CN 113068016A
- Authority
- CN
- China
- Prior art keywords
- image
- processed
- color temperature
- dictionary
- clustering
- Prior art date
- Legal status (The legal status 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 status listed.)
- Granted
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/80—Camera processing pipelines; Components thereof
- H04N23/84—Camera processing pipelines; Components thereof for processing colour signals
- H04N23/88—Camera processing pipelines; Components thereof for processing colour signals for colour balance, e.g. white-balance circuits or colour temperature control
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Color Television Image Signal Generators (AREA)
- Processing Of Color Television Signals (AREA)
Abstract
The application relates to a white balance correction method, a white balance correction device and computer equipment, wherein the method comprises the steps of obtaining a clustering dictionary, and the clustering dictionary is obtained by clustering a plurality of white block images under different color temperatures; calculating sparse representation of the image to be processed on the clustering dictionary, and judging a color temperature scene of the image to be processed according to the sparse representation; the color temperature scene is a single color temperature scene or a mixed color temperature scene; calculating the weight occupied by each color temperature in the image to be processed according to the color temperature scene of the image to be processed; and calculating the white balance gain of the statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed, and performing white balance correction on the image to be processed according to the white balance gain. The method solves the problems of low algorithm precision and inaccurate correction effect at mixed color temperature of the white balance correction algorithm in the related technology.
Description
Technical Field
The present application relates to the field of image processing, and in particular, to a white balance correction method, device and computer apparatus.
Background
The human eye has unique adaptability, and the human eye can recognize a white object as white whether under outdoor natural light or indoor fluorescent light or mixed color temperature light source. Since the response of the camera to white is different from that of the human eye, it is necessary to correct the white balance of the image captured by the camera to correct the white object in the captured image to white.
The existing white balance correction algorithm usually calculates the gains of three R/G/B channels according to white points falling into a reference white area at a certain color temperature, and then multiplies all pixel points in a picture by the gains of the channels respectively to correct a white object in the picture into real white. The algorithm has good effect in a single color temperature, but the color temperature cannot be effectively judged in a mixed color temperature scene, so that the white balance correction effect is poor, and the requirement is difficult to meet. When the camera is actually used outdoors, a mixed color temperature scene can be inevitably encountered. The existing white balance correction algorithm of the video camera has the defects of low algorithm precision, large effect result deviation at mixed color temperature and the like.
At present, no effective solution is provided for the problems in the related art.
Disclosure of Invention
The embodiment of the application provides a white balance correction method, a white balance correction device and computer equipment, and aims to at least solve the problems that in the related art, a white balance correction algorithm is low in algorithm precision and inaccurate in correction effect at a mixed color temperature.
In a first aspect, an embodiment of the present application provides a white balance correction method, where the method includes:
acquiring a clustering dictionary, wherein the clustering dictionary is obtained by clustering a plurality of white block images under different color temperatures;
judging the color temperature scene of the image to be processed according to the sparse representation, and calculating the weight occupied by each color temperature in the image to be processed; the color temperature scene is a single color temperature scene or a mixed color temperature scene;
and calculating the white balance gain of the statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed, and performing white balance correction on the image to be processed according to the white balance gain.
In some embodiments, clustering the white block images at a plurality of different color temperatures to obtain a cluster dictionary includes:
collecting white block images in standard color card images under different color temperatures, determining a reference white point, and drawing a reference white area according to the reference white point;
calculating clustering centers of the statistic points falling into the reference white area through a clustering algorithm, and combining a plurality of clustering centers into the clustering dictionary; the white block image comprises N equal first image blocks, and each first image block is one statistic point.
In some of these embodiments, said computing a sparse representation of the image to be processed on the cluster dictionary comprises:
acquiring a statistical point falling into the reference white area in the image to be processed, and stretching the statistical point falling into the reference white area into a column vector; the image to be processed is divided into N equal second image blocks, and each second image block is an statistic point;
and calculating a sparse representation of the column vector generated by each second image block on the clustering dictionary.
In some embodiments, the obtaining the statistical point falling into the reference white region in the image to be processed includes:
acquiring a three-channel component mean value of a pixel point in each second image block, and calculating the red gain and the blue gain of the statistic point according to the three-channel component mean value;
and determining the statistic point falling into the reference white area according to the red gain and the blue gain of the statistic point.
In some embodiments, the cluster dictionary D ═ { D ═ D1,d2,…,dkK is the number of color temperatures; the calculating a sparse representation of the column vectors generated by each of the second image blocks on the cluster dictionary comprises:
calculating dictionary atom D of the second image block p in a clustering dictionary DiSparse representation of (c): p ═ a × di+m1;
If m1If the error is less than the preset error, the calculation process is ended;
if m1If the error is larger than or equal to the preset error, selecting a dictionary atom d in the clustering dictionaryiCalculating the dictionary atom d of the image block p to be processediAnd djSparse representation of (c): p ═ a × di+b*dj+m2(ii) a And so on until the reconstruction error m2Less than or equal to the preset error;
wherein, a and b respectively represent the dictionary atom d of the second image block piAnd djSparse representation coefficient of (c), m1,m2Representation-by-dictionary atom reconstructionReconstruction errors of said second image block p.
In some embodiments, the determining the color temperature scene of the image to be processed according to the sparse representation includes:
if m1If the second image block p in the image to be processed is smaller than the preset error, judging that the second image block p in the image to be processed is a monochromatic temperature scene;
if m1And if the second image block p in the image to be processed is larger than or equal to the preset error, judging that the second image block p in the image to be processed is a mixed color temperature scene, and determining a plurality of corresponding color temperatures according to the sparsely represented coefficients.
In some of these embodiments, determining the color temperature scene of the image to be processed from the sparse representation comprises:
acquiring a first reconstruction error of the second image block p with the sparsity degree of 1 and a second reconstruction error of the to-be-processed image block p with the sparsity degree of 2, and calculating a ratio of the first reconstruction error to the second reconstruction error;
if the ratio is smaller than a preset threshold, determining that the second image block p is a monochromatic temperature image block and the color temperature is a dictionary atom diA corresponding color temperature;
if the ratio is smaller than or equal to the preset threshold, determining that the second image block p is a mixed-temperature image block and the color temperature is a dictionary atom diAnd djThe corresponding color temperature.
In a second aspect, an embodiment of the present application provides a balance correction method, where the method includes:
collecting white block images in standard color card images under different color temperatures, determining a reference white point, and drawing a reference white area according to the reference white point;
calculating clustering centers of the statistic points falling into the reference white area through a clustering algorithm, and combining a plurality of clustering centers into the clustering dictionary; the cluster dictionary D ═ { D ═ D1,d2,…,dkK is the number of color temperatures; the white block image comprises N equal first image blocks, and each first image block is one statistic point;
acquiring a statistical point falling into the reference white area in an image to be processed, and stretching the statistical point falling into the reference white area into a column vector; dividing the image to be processed into N equal second image blocks, wherein each second image block is an statistic point;
calculating dictionary atom D of the second image block p in a clustering dictionary DiSparse representation of (c): p ═ a × di+m1;
If m1If the difference is less than the preset error, ending the calculation process, and judging that a second image block p in the image to be processed is a monochromatic temperature scene;
if m1If the second image block p in the image to be processed is larger than or equal to the preset error, judging that the second image block p in the image to be processed is a mixed color temperature scene, determining a plurality of corresponding color temperatures according to the sparsely represented coefficients, and selecting a dictionary atom d from the clustering dictionaryjCalculating the dictionary atom d of the image block p to be processediAnd djSparse representation of (c): p ═ a × di+b*dj+m2(ii) a Wherein, a and b respectively represent the dictionary atom d of the second image block piAnd djSparse representation coefficient of (c), m1,m2Representing a reconstruction error for reconstructing said second image block p with dictionary atoms;
calculating the weight occupied by each color temperature in the image to be processed;
and calculating the white balance gain of the statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed, and performing white balance correction on the image to be processed according to the white balance gain.
In a third aspect, an embodiment of the present application provides a white balance correction apparatus, including: the device comprises an acquisition module, a judgment module, a calculation module and a correction module; wherein:
the system comprises an acquisition module, a color temperature detection module and a color temperature detection module, wherein the acquisition module is used for acquiring a clustering dictionary, and the clustering dictionary is obtained by clustering a plurality of white block images under different color temperatures;
the judging module is used for calculating the sparse representation of the image to be processed on the clustering dictionary and judging the color temperature scene of the image to be processed according to the sparse representation; the color temperature scene is a single color temperature scene or a mixed color temperature scene;
the calculation module is used for calculating the weight occupied by each color temperature in the image to be processed according to the color temperature scene of the image to be processed;
the correction module is used for calculating the white balance gain of the statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed; and according to the white balance gain, carrying out white balance correction on the image to be processed.
In a fourth aspect, embodiments of the present application provide a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the white balance correction method according to the first and second aspects when executing the computer program.
In a fifth aspect, embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, implements the white balance correction method according to the first and second aspects.
Compared with the related art, the white balance correction method provided by the embodiment of the application comprises the steps of obtaining a clustering dictionary, wherein the clustering dictionary is obtained by clustering a plurality of white block images under different color temperatures; calculating sparse representation of the image to be processed on the clustering dictionary, judging a color temperature scene of the image to be processed according to the sparse representation, and calculating the weight occupied by each color temperature in the image to be processed; the color temperature scene is a single color temperature scene or a mixed color temperature scene; and calculating the white balance gain of the statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed, and performing white balance correction on the image to be processed according to the white balance gain. The method solves the problems of low algorithm precision and inaccurate correction effect at mixed color temperature of the white balance correction algorithm in the related technology.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a schematic structural diagram of an image capturing device provided in an embodiment of the present application;
fig. 2 is a flowchart of a white balance correction method provided in an embodiment of the present application;
FIG. 3 is a schematic diagram of a reference white region provided by an embodiment of the present application;
FIG. 4 is a schematic diagram illustrating a stretching of a second image block into column vectors according to an embodiment of the present disclosure;
FIG. 5 is a flow chart of a white balance correction method provided by the preferred embodiment of the present application;
fig. 6 is a schematic structural diagram of a white balance correction apparatus provided according to an embodiment of the present application;
fig. 7 is an internal structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments provided in the present application without any inventive step are within the scope of protection of the present application.
It is obvious that the drawings in the following description are only examples or embodiments of the present application, and that it is also possible for a person skilled in the art to apply the present application to other similar contexts on the basis of these drawings without inventive effort. Moreover, it should be appreciated that in the development of any such actual implementation, as in any engineering or design project, numerous implementation-specific decisions must be made to achieve the developers' specific goals, such as compliance with system-related and business-related constraints, which may vary from one implementation to another.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the specification. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of ordinary skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms referred to herein shall have the ordinary meaning as understood by those of ordinary skill in the art to which this application belongs. Reference to "a," "an," "the," and similar words throughout this application are not to be construed as limiting in number, and may refer to the singular or the plural. The present application is directed to the use of the terms "including," "comprising," "having," and any variations thereof, which are intended to cover non-exclusive inclusions; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to the listed steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. Reference to "connected," "coupled," and the like in this application is not intended to be limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as referred to herein means two or more. "and/or" describes an association relationship of associated objects, meaning that three relationships may exist, for example, "A and/or B" may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. Reference herein to the terms "first," "second," "third," and the like, are merely to distinguish similar objects and do not denote a particular ordering for the objects.
Fig. 1 is a schematic structural diagram of an image acquisition apparatus 100 provided in an embodiment of the present application. The image acquisition apparatus 100 may be a scanner, a digital camera, a video camera, or the like. The image capturing apparatus 100 includes an adaptive white balance correction device 200, an image sensor 110, a memory 120, and a processor 130. The elements of the image sensor 110, the memory 120, and the processor 130 are electrically connected to each other directly or indirectly to enable data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The adaptive white balance correction apparatus 200 includes at least one software functional module which may be stored in the memory 120 in the form of software (software) or firmware (firmware), and the processor 130 is configured to execute the executable module stored in the memory 120, such as the software functional module or program included in the adaptive white balance correction apparatus 200.
The memory 120 may be, but is not limited to, a random access memory RAM, a read only memory ROM, a programmable read only memory, PROM), an erasable read only memory, an electrically erasable read only memory EEPROM, or the like, for storing programs or data. The processor 130 may be a general-purpose processor including a microprocessor or any conventional processor or the like for implementing or performing the methods, steps and logic blocks disclosed in the embodiments of the present application. The image sensor 110 includes, but is not limited to, a photoconductive camera tube, a solid-state image sensor, a photosensitive circuit, or the like, and is used for converting a light image on the photosensitive surface into an electrical signal corresponding to the light image.
Fig. 2 is a flowchart of a white balance correction method according to an embodiment of the present application, which may be applied to the adaptive white balance correction apparatus 200 shown in fig. 1, as shown in fig. 2, the white balance correction method includes the following steps:
and 240, calculating the white balance gain of the statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed, and performing white balance correction on the image to be processed according to the white balance gain.
Conventionally, the white balance correction algorithm usually calculates gains of three R/G/B channels at a certain color temperature according to statistical points falling into a reference white region, and then multiplies all pixel points in the statistical points by the gains of the channels, so as to correct a white object in an image to be true white. The correction algorithm has good effect in a single color temperature, but the color temperature cannot be effectively judged in a mixed color temperature scene, so that the correction effect is poor, and the requirements are difficult to meet.
Compared with the prior art, the white balance correction algorithm provided by the application clusters the white block images under different color temperatures to generate a clustering dictionary by adopting a new sparse representation-based method, and each dictionary atom in the clustering dictionary corresponds to one color temperature. Since each dictionary atom is obtained by clustering the white block images in the standard color card image, a color temperature attribute can be accurately expressed. And after the clustering dictionary is obtained, judging whether the image to be processed is a single-color temperature scene or a mixed color temperature scene according to the sparse coefficient representation of the image to be processed on the clustering dictionary. If the mixed color temperature scene is judged, the weight occupied by each color temperature is calculated according to the sparse representation coefficient, the white balance gain is calculated according to the weight occupied by each color temperature in the image to be processed, and the white balance correction is adaptively carried out on the images in different color temperature scenes, so that the correction accuracy of the white balance correction algorithm is improved.
In some embodiments, clustering the white block images at different color temperatures to obtain a cluster dictionary includes:
collecting white block images in standard color card images under different color temperatures, determining a reference white point, and drawing a reference white area according to the reference white point;
calculating a clustering center of the statistic points falling into the reference white area through a clustering algorithm, and combining a plurality of clustering centers into a clustering dictionary; the white block image comprises N equal first image blocks, and each first image block is an statistic point.
Since the specific color and color temperature of the image to be processed are relatively complex, in order to improve the sampling accuracy, the embodiment selects the standard color card image, shoots the standard color card image under the illumination condition of different color temperatures, acquires the white block images in the standard color card image of different color temperatures, and determines the reference white point according to the preset algorithm and the white block images of the standard color card. In this embodiment, a standard color card image under color temperatures D75, D65, D50, TL84, CWF, TL83 and a may be collected, the standard color card image is divided into N first image blocks with the same size, where N is a positive integer, each first image block is a statistic point, and a reference white area is drawn according to a placement of a reference white point in the standard color card at each color temperature.
Referring to FIG. 3, a reference coordinate system is plotted with G/R and G/B as coordinate axes, respectively, and a reference curve is plotted by fitting according to the position of the reference white point in the reference coordinate system. For example, reference white points H1, H2, H3, H4, and H5 have been determined, and interpolation can be used to plot the reference curves. And setting a distance threshold value from any point in the reference coordinate system to the reference curve, forming a distance range by all coordinate points which are not more than the distance threshold value from the reference curve, and forming a reference white area by the reference curve and the distance range.
After the reference white area is determined, calculating the clustering centers of the statistic points falling into the reference white area through a clustering algorithm, and combining a plurality of clustering centers into a clustering dictionary; the white block image comprises N equal first image blocks, and each first image block is an statistic point.
Specifically, parameters are calculated by using a Kmeans clustering algorithm at each color temperatureClustering center d of statistic points in test areakWhere k denotes the kth color temperature, k being 1,2,3 … …, 7. Referring to FIG. 4, taking 7 color temperatures as an example, the clustering centers d at 7 color temperatures are shownk(k-1, 2,3 … …,7) are integrated together to form a cluster dictionary D, D-D1,d2,d3,……d7) Each dictionary atom is a column vector. The dictionary atom number of the clustering dictionary D is 7, which means that white block images are collected at 7 color temperatures.
In some of these embodiments, computing the sparse representation of the to-be-processed image on the cluster dictionary comprises:
obtaining statistical points falling into a reference white area in an image to be processed, dividing the image to be processed into N equal second image blocks, wherein each second image block is one statistical point;
stretching the statistical points falling into the reference white region into column vectors;
and calculating sparse representation of the column vector generated by each second image block on the clustering dictionary.
Specifically, the image to be processed is divided into N equal second image blocks, each second image block is an statistic point, and each statistic point includes a plurality of pixel points. Acquiring an R/G/B three-channel component mean value of each pixel point in each second image block, and calculating the red gain and the blue gain of the statistic point according to the three-channel component mean value; and determining the statistic point falling into the reference white region according to the red gain and the blue gain of the statistic point. Then, the pixel points of the second image block falling in the reference white area are rearranged, combined and stretched into column vectors, and referring to fig. 4, the sparse representation of the column vectors generated by each to-be-processed image block on the clustering dictionary can be calculated by using an OMP algorithm (orthogonal matching algorithm).
In some embodiments, calculating a sparse representation of the column vectors generated by each second image block on the cluster dictionary comprises:
calculating dictionary atom D of the second image block p in a clustering dictionary DiSparse representation of (c): p ═ a × di+m1;
If m1Less than presetIf the error is found, the calculation process is ended;
if m1If the error is larger than or equal to the preset error, selecting a dictionary atom d in the clustering dictionaryiCalculating the dictionary atom d of the image block p to be processediAnd djSparse representation of (c): p ═ a × di+b*dj+m2(ii) a And so on until the reconstruction error m2Less than or equal to the preset error;
wherein, a and b respectively represent the dictionary atom d of the second image block piAnd djSparse representation coefficient of (c), m1,m2Representing a reconstruction error for reconstructing said second image block p with dictionary atoms.
Specifically, any dictionary atom in the clustering dictionary D is selected to represent the second image block p, and according to the reconstruction error, the dictionary atom D corresponding to the minimum reconstruction error is determinediCorresponding reconstruction error m1To use any dictionary atom to represent the smallest error of the second image block p. If the error m1If the second image block p is smaller than the preset error, the second image block p can be fully represented by the dictionary atoms under one color temperature, and the second image block p can be judged to be a monochromatic temperature image block. If m1If the reconstruction error is larger than or equal to the preset error, it means that the second image block p cannot be sufficiently represented by the dictionary atoms under one color temperature, and at this time, other dictionary atoms in the cluster dictionary D are selected together to represent the second image block p until the reconstruction error is smaller than the preset error.
In some of these embodiments, determining the color temperature scene of the image to be processed from the sparse representation comprises:
if m1If the second image block p in the image to be processed is smaller than the preset error, judging that the second image block p in the image to be processed is a monochrome temperature scene;
if m1And if the second image block p in the image to be processed is larger than or equal to the preset error, judging that the second image block p in the image to be processed is a mixed color temperature scene, and determining a plurality of corresponding color temperatures according to the sparsely represented coefficients.
In this embodiment, the second image is determined according to the number of sparse representation coefficients when the reconstruction error is smaller than the preset errorColor temperature scene of block p. If the number of sparse representation coefficients is 1, for example, p ═ a × di+m1,m1If the second image block is smaller than the preset error, the second image block is a monochromatic temperature scene, and the color temperature is a dictionary atom diA corresponding color temperature; if the number of sparse representation coefficients is 2, for example, p ═ a × di+b*dj+m2,m2If the second image block is smaller than the preset error, the second image block is a mixed color temperature scene, and the color temperature is a dictionary atom diAnd djA corresponding color temperature; if the number of sparse representation coefficients is 3, for example, p ═ a × di+b*dj+c*dqThen the second image block is the dictionary atom di、djAnd dqCorresponding color temperature, and so on.
The embodiment can judge which color temperatures of the second image block are specifically mixed according to the sparse representation coefficient, so that white balance correction can be accurately performed according to the corresponding color temperatures.
In some of these embodiments, determining the color temperature scene of the image to be processed from the sparse representation comprises:
acquiring a first reconstruction error of the second image block p with the sparsity degree of 1 and a second reconstruction error of the image block p to be processed with the sparsity degree of 2, and calculating the ratio of the first reconstruction error to the second reconstruction error;
if the ratio is smaller than the preset threshold, determining that the second image block p is a monochromatic temperature image block, and the color temperature is a dictionary atom diA corresponding color temperature;
if the ratio is smaller than or equal to a preset threshold, determining that the second image block p is a mixed-temperature image block and the color temperature is a dictionary atom diAnd djThe corresponding color temperature.
Generally, a mixed color temperature scene of an image is formed by mixing two color temperatures, and the embodiment only distinguishes the color temperature and mixes the two color temperatures, so that on the basis of improving the white balance correction accuracy to a certain extent, the calculation is convenient and fast, and the correction efficiency is higher.
The embodiments of the present application are described and illustrated below by means of preferred embodiments.
Fig. 5 is a flowchart of a white balance correction method according to a preferred embodiment of the present application. The method comprises steps 510 to 580; wherein:
and 580, calculating a white balance gain of a statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed, and performing white balance correction on the image to be processed according to the white balance gain.
In the white balance correction method provided in this embodiment, a new sparse representation-based method is adopted to cluster white block images with different color temperatures to generate a cluster dictionary, where each dictionary atom in the cluster dictionary corresponds to one color temperature. Since each dictionary atom is obtained by clustering the white block images in the standard color card image, a color temperature attribute can be accurately expressed. And after the clustering dictionary is obtained, judging whether the image to be processed is a single-color temperature scene or a mixed color temperature scene according to the sparse coefficient representation of the image to be processed on the clustering dictionary. If the mixed color temperature scene is judged, the weight occupied by each color temperature is calculated according to the sparse representation coefficient, the white balance gain is calculated according to the weight occupied by each color temperature in the image to be processed, and the white balance correction is adaptively carried out on the images in different color temperature scenes, so that the correction accuracy of the white balance correction algorithm is improved.
It should be noted that the steps illustrated in the above-described flow diagrams or in the flow diagrams of the figures may be performed in a computer system, such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flow diagrams, in some cases, the steps illustrated or described may be performed in an order different than here.
This embodiment further provides a white balance correction device, which is used to implement the foregoing embodiments and preferred embodiments, and the description of which is already given is omitted. As used hereinafter, the terms "module," "unit," "subunit," and the like may implement a combination of software and/or hardware for a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 6 is a block diagram of a configuration of a white balance correction apparatus according to an embodiment of the present application, as shown in fig. 6, the apparatus including:
the acquiring module 610 is configured to acquire a clustering dictionary, where the clustering dictionary is obtained by clustering a plurality of white block images at different color temperatures;
a calculation module 620, configured to calculate a sparse representation of the to-be-processed image on the clustering dictionary;
a judging module 630, configured to judge a color temperature scene of the image to be processed according to the sparse representation, and calculate a weight occupied by each color temperature in the image to be processed; the color temperature scene is a single color temperature scene or a mixed color temperature scene;
the correcting module 640 is configured to calculate a white balance gain of a statistic point in the image to be processed according to a weight occupied by each color temperature in the image to be processed; and according to the white balance gain, carrying out white balance correction on the image to be processed.
The white balance correction algorithm provided by the application clusters white block images under different color temperatures to generate a cluster dictionary by adopting a new sparse representation-based method, wherein each dictionary atom in the cluster dictionary corresponds to one color temperature. And after the clustering dictionary is obtained, judging whether the image to be processed is a single-color temperature scene or a mixed color temperature scene according to the sparse coefficient representation of the image to be processed on the clustering dictionary. If the mixed color temperature scene is judged, the weight occupied by each color temperature is calculated according to the sparse representation coefficient, the white balance gain is calculated according to the weight occupied by each color temperature in the image to be processed, and the white balance correction is adaptively carried out on the images in different color temperature scenes, so that the correction accuracy of the white balance correction algorithm is improved.
In some embodiments, the system further comprises a clustering module, configured to collect white block images in the standard color card images at different color temperatures, determine a reference white point, and draw a reference white area according to the reference white point; calculating clustering centers of the statistic points falling into the reference white area through a clustering algorithm, and combining a plurality of clustering centers into the clustering dictionary; the white block image comprises N equal first image blocks, and each first image block is one statistic point.
In some embodiments, the calculating module 620 is further configured to obtain statistical points falling into the reference white area in the to-be-processed image, where the to-be-processed image is divided into N equal second image blocks, and each second image block is one statistical point; stretching the statistical points falling into the reference white region into column vectors; and calculating a sparse representation of the column vector generated by each second image block on the clustering dictionary.
In some embodiments, the calculating module 620 is further configured to obtain an R/G/B three-channel component mean value of a pixel point in each second image block, and calculate a red gain and a blue gain of the statistic point according to the three-channel component mean value; and determining the statistic point falling into the reference white area according to the red gain and the blue gain of the statistic point.
In some embodiments, the cluster dictionary D ═ { D ═ D1,d2,…,dkK is the number of color temperatures; the calculation module 620 is further configured to:
calculating dictionary atom D of the second image block p in a clustering dictionary DiSparse representation of (c):
p=a*di+m1;
if m1If the error is less than the preset error, the calculation process is ended;
if m1If the error is larger than or equal to the preset error, selecting a dictionary atom d in the clustering dictionaryiCalculating the dictionary atom d of the image block p to be processediAnd djSparse representation of (c): p ═ a × di+b*dj+m2(ii) a And so on until the reconstruction error m2Less than or equal to the preset error;
wherein, a and b respectively represent the dictionary atom d of the second image block piAnd djSparse representation coefficient of (c), m1,m2Representing a reconstruction error for reconstructing said second image block p with dictionary atoms.
In some embodiments, the determining module 630 is further configured to:
if m1If the error is less than the preset error, the first image in the image to be processed is judgedThe two image blocks p are in a monochromatic temperature scene;
if m1And if the second image block p in the image to be processed is larger than or equal to the preset error, judging that the second image block p in the image to be processed is a mixed color temperature scene, and determining a plurality of corresponding color temperatures according to the sparsely represented coefficients.
In some embodiments, the determining module 630 is further configured to:
acquiring a first reconstruction error of the second image block p with the sparsity degree of 1 and a second reconstruction error of the to-be-processed image block p with the sparsity degree of 2, and calculating a ratio of the first reconstruction error to the second reconstruction error;
if the ratio is smaller than a preset threshold, determining that the second image block p is a monochromatic temperature image block and the color temperature is a dictionary atom diA corresponding color temperature;
if the ratio is smaller than or equal to the preset threshold, determining that the second image block p is a mixed-temperature image block and the color temperature is a dictionary atom diAnd djThe corresponding color temperature.
The above modules may be functional modules or program modules, and may be implemented by software or hardware. For a module implemented by hardware, the modules may be located in the same processor; or the modules can be respectively positioned in different processors in any combination.
In addition, the white balance correction method of the embodiment of the present application described in conjunction with fig. 2 may be implemented by a computer device. Fig. 7 is a hardware structure diagram of a computer device according to an embodiment of the present application.
The computer device may comprise a processor 71 and a memory 72 in which computer program instructions are stored.
Specifically, the processor 71 may include a Central Processing Unit (CPU), or A Specific Integrated Circuit (ASIC), or may be configured to implement one or more Integrated circuits of the embodiments of the present Application.
The memory 72 may be used to store or cache various data files for processing and/or communication use, as well as possibly computer program instructions for execution by the processor 72.
The processor 71 realizes any one of the white balance correction methods in the above-described embodiments by reading and executing computer program instructions stored in the memory 72.
In some of these embodiments, the computer device may also include a communication interface 73 and a bus 70. As shown in fig. 7, the processor 71, the memory 72, and the communication interface 73 are connected via the bus 70 to complete mutual communication.
The communication interface 73 is used for realizing communication among modules, devices, units and/or equipment in the embodiment of the present application. The communication interface 73 may also enable communication with other components such as: the data communication is carried out among external equipment, image/data acquisition equipment, a database, external storage, an image/data processing workstation and the like.
The bus 70 comprises hardware, software, or both that couple the components of the computer device to one another. Bus 70 includes, but is not limited to, at least one of the following: data Bus (Data Bus), Address Bus (Address Bus), Control Bus (Control Bus), Expansion Bus (Expansion Bus), and Local Bus (Local Bus). By way of example, and not limitation, Bus 70 may include an Accelerated Graphics Port (AGP) or other Graphics Bus, an Enhanced Industry Standard Architecture (EISA) Bus, a Front-Side Bus (FSB), a Hyper Transport (HT) Interconnect, an ISA (ISA) Bus, an InfiniBand (InfiniBand) Interconnect, a Low Pin Count (LPC) Bus, a memory Bus, a microchannel Architecture (MCA) Bus, a PCI (Peripheral Component Interconnect) Bus, a PCI-Express (PCI-X) Bus, a Serial Advanced Technology Attachment (SATA) Bus, a Video Electronics Bus (audio Electronics Association), abbreviated VLB) bus or other suitable bus or a combination of two or more of these. Bus 70 may include one or more buses, where appropriate. Although specific buses are described and shown in the embodiments of the application, any suitable buses or interconnects are contemplated by the application.
The computer device may execute the white balance correction method in the embodiment of the present application based on the acquired program instruction, thereby implementing the white balance correction method described with reference to fig. 1.
In addition, in combination with the white balance correction method in the above embodiments, the embodiments of the present application may be implemented by providing a computer-readable storage medium. The computer readable storage medium having stored thereon computer program instructions; the computer program instructions, when executed by a processor, implement any of the white balance correction methods in the above embodiments.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (10)
1. A white balance correction method, characterized in that the method comprises:
acquiring a clustering dictionary, wherein the clustering dictionary is obtained by clustering a plurality of white block images under different color temperatures;
calculating sparse representation of the image to be processed on the clustering dictionary;
judging the color temperature scene of the image to be processed according to the sparse representation, and calculating the weight occupied by each color temperature in the image to be processed; the color temperature scene is a single color temperature scene or a mixed color temperature scene;
and calculating the white balance gain of the statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed, and performing white balance correction on the image to be processed according to the white balance gain.
2. The method of claim 1, wherein clustering the white block images at different color temperatures to obtain a cluster dictionary comprises:
collecting white block images in standard color card images under different color temperatures, determining a reference white point, and drawing a reference white area according to the reference white point;
calculating clustering centers of the statistic points falling into the reference white area through a clustering algorithm, and combining a plurality of clustering centers into the clustering dictionary; the white block image comprises N equal first image blocks, and each first image block is one statistic point.
3. The method of claim 2, wherein said computing a sparse representation of the image to be processed on the cluster dictionary comprises:
acquiring statistic points falling into the reference white area in the image to be processed, wherein the image to be processed is divided into N equal second image blocks, and each second image block is an statistic point;
stretching the statistical points falling into the reference white region into column vectors;
and calculating a sparse representation of the column vector generated by each second image block on the clustering dictionary.
4. The method according to claim 3, wherein the obtaining of the statistical point falling into the reference white region in the image to be processed comprises:
acquiring an R/G/B three-channel component mean value of a pixel point in each second image block, and calculating the red gain and the blue gain of the statistic point according to the three-channel component mean value;
and determining the statistic point falling into the reference white area according to the red gain and the blue gain of the statistic point.
5. The method of claim 3, wherein the cluster dictionary D ═ D1,d2,…,dkK is the number of color temperatures; the calculating a sparse representation of the column vectors generated by each of the second image blocks on the cluster dictionary comprises:
calculating dictionary atom D of the second image block p in a clustering dictionary DiSparse representation of (c): p ═ a × di+m1;
If m1If the error is less than the preset error, the calculation process is ended;
if m1If the error is larger than or equal to the preset error, selecting a dictionary atom d in the clustering dictionaryiCalculating the dictionary atom d of the image block p to be processediAnd djSparse representation of (c): p ═ a × di+b*dj+m2(ii) a And so on until the reconstruction error m2Less than or equal to the preset error;
wherein, a and b respectively represent the dictionary atom d of the second image block piAnd djSparse representation coefficient of (c), m1,m2Representing a reconstruction error for reconstructing said second image block p with dictionary atoms.
6. The method of claim 5, wherein the determining the color temperature scene of the image to be processed according to the sparse representation comprises:
if m1If the second image block p in the image to be processed is smaller than the preset error, judging that the second image block p in the image to be processed is a monochromatic temperature scene;
if m1And if the second image block p in the image to be processed is larger than or equal to the preset error, judging that the second image block p in the image to be processed is a mixed color temperature scene, and determining a plurality of corresponding color temperatures according to the sparsely represented coefficients.
7. The method of claim 5, wherein determining the color temperature scene of the image to be processed from the sparse representation comprises:
acquiring a first reconstruction error of the second image block p with the sparsity degree of 1 and a second reconstruction error of the to-be-processed image block p with the sparsity degree of 2, and calculating a ratio of the first reconstruction error to the second reconstruction error;
if the ratio is smaller than a preset threshold, determining that the second image block p is a monochromatic temperature image block and the color temperature is a dictionary atom diA corresponding color temperature;
if the ratio is smaller than or equal to the preset threshold, determining that the second image block p is a mixed-temperature image block and the color temperature is a dictionary atom diAnd djThe corresponding color temperature.
8. A white balance correction method, characterized in that the method comprises:
collecting white block images in standard color card images under different color temperatures, determining a reference white point, and drawing a reference white area according to the reference white point;
calculating clustering centers of the statistic points falling into the reference white area through a clustering algorithm, and combining a plurality of clustering centers into the clustering dictionary; the cluster dictionary D ═ { D ═ D1,d2,…,dkK is the number of color temperatures; the white block image comprises N equal first image blocks, and each first image block is one statistic point;
acquiring a statistical point falling into the reference white area in an image to be processed, and stretching the statistical point falling into the reference white area into a column vector; dividing the image to be processed into N equal second image blocks, wherein each second image block is an statistic point;
calculating dictionary atom D of the second image block p in a clustering dictionary DiSparse representation of (c): p ═ a × di+m1;
If m1If the difference is less than the preset error, ending the calculation process, and judging that a second image block p in the image to be processed is a monochromatic temperature scene;
if m1If the error is larger than or equal to the preset error, judging a second graph in the image to be processedThe image block p is a mixed color temperature scene, a plurality of corresponding color temperatures are determined according to the sparsely represented coefficients, and a dictionary atom d is selected from the clustering dictionaryjCalculating the dictionary atom d of the image block p to be processediAnd djSparse representation of (c): p ═ a × di+b*dj+m2(ii) a Wherein, a and b respectively represent the dictionary atom d of the second image block piAnd djSparse representation coefficient of (c), m1,m2Representing a reconstruction error for reconstructing said second image block p with dictionary atoms;
calculating the weight occupied by each color temperature in the image to be processed;
and calculating the white balance gain of the statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed, and performing white balance correction on the image to be processed according to the white balance gain.
9. A white balance correction apparatus comprising: the device comprises an acquisition module, a judgment module, a calculation module and a correction module; wherein:
the system comprises an acquisition module, a color temperature detection module and a color temperature detection module, wherein the acquisition module is used for acquiring a clustering dictionary, and the clustering dictionary is obtained by clustering a plurality of white block images under different color temperatures;
the calculation module is used for calculating sparse representation of the image to be processed on the clustering dictionary;
the judging module is used for judging the color temperature scene of the image to be processed according to the sparse representation and calculating the weight occupied by each color temperature in the image to be processed; the color temperature scene is a single color temperature scene or a mixed color temperature scene;
the correction module is used for calculating the white balance gain of the statistic point in the image to be processed according to the weight occupied by each color temperature in the image to be processed; and according to the white balance gain, carrying out white balance correction on the image to be processed.
10. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the white balance correction method according to any one of claims 1 to 8 when executing the computer program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110360676.1A CN113068016B (en) | 2021-04-02 | 2021-04-02 | White balance correction method and device and computer equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110360676.1A CN113068016B (en) | 2021-04-02 | 2021-04-02 | White balance correction method and device and computer equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113068016A true CN113068016A (en) | 2021-07-02 |
CN113068016B CN113068016B (en) | 2023-03-24 |
Family
ID=76565470
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110360676.1A Active CN113068016B (en) | 2021-04-02 | 2021-04-02 | White balance correction method and device and computer equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113068016B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113784104A (en) * | 2021-08-18 | 2021-12-10 | 杭州涂鸦信息技术有限公司 | White balance processing method and related device |
CN114745532A (en) * | 2022-04-01 | 2022-07-12 | 北京紫光展锐通信技术有限公司 | White balance processing method and device for mixed color temperature scene, storage medium and terminal |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6249601B1 (en) * | 1998-12-04 | 2001-06-19 | Samsung Electronics Co., Ltd. | Method for determining color of illuminant and apparatus therefor |
US20050286097A1 (en) * | 2004-06-25 | 2005-12-29 | Szepo Hung | Automatic white balance method and apparatus |
JP2014007449A (en) * | 2012-06-21 | 2014-01-16 | Nippon Telegr & Teleph Corp <Ntt> | Illumination light color estimation device, illumination light color estimation method, and illumination light color estimation program |
CN103929632A (en) * | 2014-04-15 | 2014-07-16 | 浙江宇视科技有限公司 | Automatic white balance correcting method and device |
JP2015146480A (en) * | 2014-01-31 | 2015-08-13 | オリンパス株式会社 | Multi-area white balance controller, multi-area white balance control method, multi-area white balance control program, computer recording multi-area white balance control program, multi-area white balance image processor, multi-area white balance image processing method, multi-area white balance image processing program, computer recording multi-area white balance image processing program, and imaging device including multi-area white balance image processor |
CN105430367A (en) * | 2015-12-30 | 2016-03-23 | 浙江宇视科技有限公司 | Automatic white balance method and device |
CN105578165A (en) * | 2015-12-30 | 2016-05-11 | 浙江大华技术股份有限公司 | Method and device for processing white balance of image, and vidicon |
CN106791758A (en) * | 2016-12-07 | 2017-05-31 | 浙江大华技术股份有限公司 | The determination methods and device of natural light mixing colour temperature in a kind of image |
CN108600725A (en) * | 2018-05-10 | 2018-09-28 | 杭州雄迈集成电路技术有限公司 | A kind of white balance correction device and method based on RGB-IR image datas |
US20190045162A1 (en) * | 2018-04-10 | 2019-02-07 | Intel Corporation | Method and system of light source estimation for image processing |
CN109361910A (en) * | 2018-10-23 | 2019-02-19 | 浙江宇视科技有限公司 | Self-adapted white balance correction method and device |
US20190158796A1 (en) * | 2016-04-25 | 2019-05-23 | Zhejiang Dahua Technology Co., Ltd. | Methods, systems, and media for image white balance adjustment |
-
2021
- 2021-04-02 CN CN202110360676.1A patent/CN113068016B/en active Active
Patent Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6249601B1 (en) * | 1998-12-04 | 2001-06-19 | Samsung Electronics Co., Ltd. | Method for determining color of illuminant and apparatus therefor |
US20050286097A1 (en) * | 2004-06-25 | 2005-12-29 | Szepo Hung | Automatic white balance method and apparatus |
JP2014007449A (en) * | 2012-06-21 | 2014-01-16 | Nippon Telegr & Teleph Corp <Ntt> | Illumination light color estimation device, illumination light color estimation method, and illumination light color estimation program |
JP2015146480A (en) * | 2014-01-31 | 2015-08-13 | オリンパス株式会社 | Multi-area white balance controller, multi-area white balance control method, multi-area white balance control program, computer recording multi-area white balance control program, multi-area white balance image processor, multi-area white balance image processing method, multi-area white balance image processing program, computer recording multi-area white balance image processing program, and imaging device including multi-area white balance image processor |
CN103929632A (en) * | 2014-04-15 | 2014-07-16 | 浙江宇视科技有限公司 | Automatic white balance correcting method and device |
CN105578165A (en) * | 2015-12-30 | 2016-05-11 | 浙江大华技术股份有限公司 | Method and device for processing white balance of image, and vidicon |
CN105430367A (en) * | 2015-12-30 | 2016-03-23 | 浙江宇视科技有限公司 | Automatic white balance method and device |
US20170195648A1 (en) * | 2015-12-30 | 2017-07-06 | Zhejiang Uniview Technologies Co., Ltd | Automatic white balance |
US20190158796A1 (en) * | 2016-04-25 | 2019-05-23 | Zhejiang Dahua Technology Co., Ltd. | Methods, systems, and media for image white balance adjustment |
CN106791758A (en) * | 2016-12-07 | 2017-05-31 | 浙江大华技术股份有限公司 | The determination methods and device of natural light mixing colour temperature in a kind of image |
US20190045162A1 (en) * | 2018-04-10 | 2019-02-07 | Intel Corporation | Method and system of light source estimation for image processing |
CN108600725A (en) * | 2018-05-10 | 2018-09-28 | 杭州雄迈集成电路技术有限公司 | A kind of white balance correction device and method based on RGB-IR image datas |
CN109361910A (en) * | 2018-10-23 | 2019-02-19 | 浙江宇视科技有限公司 | Self-adapted white balance correction method and device |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113784104A (en) * | 2021-08-18 | 2021-12-10 | 杭州涂鸦信息技术有限公司 | White balance processing method and related device |
CN114745532A (en) * | 2022-04-01 | 2022-07-12 | 北京紫光展锐通信技术有限公司 | White balance processing method and device for mixed color temperature scene, storage medium and terminal |
CN114745532B (en) * | 2022-04-01 | 2024-04-09 | 北京紫光展锐通信技术有限公司 | Mixed color temperature scene white balance processing method and device, storage medium and terminal |
Also Published As
Publication number | Publication date |
---|---|
CN113068016B (en) | 2023-03-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9794529B2 (en) | Method for acquiring image and electronic device thereof | |
CN113068016B (en) | White balance correction method and device and computer equipment | |
US10645364B2 (en) | Dynamic calibration of multi-camera systems using multiple multi-view image frames | |
US20150124059A1 (en) | Multi-frame image calibrator | |
US20150278996A1 (en) | Image processing apparatus, method, and medium for generating color image data | |
CN106454079B (en) | Image processing method and device and camera | |
US20130222645A1 (en) | Multi frame image processing apparatus | |
CN110189269B (en) | Correction method, device, terminal and storage medium for 3D distortion of wide-angle lens | |
WO2018223394A1 (en) | Method and apparatus for photographing image | |
WO2017113917A1 (en) | Imaging method, imaging apparatus, and terminal | |
WO2019029573A1 (en) | Image blurring method, computer-readable storage medium and computer device | |
US10482571B2 (en) | Dual fisheye, hemispherical image projection and stitching method, device and computer-readable medium | |
CN111028171B (en) | Method, device and server for determining noise level of image | |
CN111385461B (en) | Panoramic shooting method and device, camera and mobile terminal | |
CN109829856A (en) | A kind of Bridge Crack information fusion method | |
JP2020077165A (en) | Image processing device, image processing method, and program | |
US20190172226A1 (en) | System and method for generating training images | |
JP2015179426A (en) | Information processing apparatus, parameter determination method, and program | |
CN111563895A (en) | Picture definition determining method, device, equipment and storage medium | |
CN114359889B (en) | Text recognition method for long text data | |
CN111630569A (en) | Binocular matching method, visual imaging device and device with storage function | |
Temel et al. | BLeSS: Bio-inspired low-level spatiochromatic similarity assisted image quality assessment | |
CN110910439B (en) | Image resolution estimation method and device and terminal | |
CN110085529B (en) | Detection method, detection device, and computer-readable storage medium | |
CN112308809A (en) | Image synthesis method and device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |