WO2019015553A1 - 图像色彩校正方法、装置、存储介质和计算机设备 - Google Patents

图像色彩校正方法、装置、存储介质和计算机设备 Download PDF

Info

Publication number
WO2019015553A1
WO2019015553A1 PCT/CN2018/095848 CN2018095848W WO2019015553A1 WO 2019015553 A1 WO2019015553 A1 WO 2019015553A1 CN 2018095848 W CN2018095848 W CN 2018095848W WO 2019015553 A1 WO2019015553 A1 WO 2019015553A1
Authority
WO
WIPO (PCT)
Prior art keywords
particle
image
color
optimal
color correction
Prior art date
Application number
PCT/CN2018/095848
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 深圳市道通智能航空技术有限公司
Publication of WO2019015553A1 publication Critical patent/WO2019015553A1/zh

Links

Images

Classifications

    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/64Circuits for processing colour signals
    • H04N9/643Hue control means, e.g. flesh tone control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/64Circuits for processing colour signals
    • H04N9/646Circuits for processing colour signals for image enhancement, e.g. vertical detail restoration, cross-colour elimination, contour correction, chrominance trapping filters

Definitions

  • the present invention relates to the field of image processing technologies, and in particular, to an image color correction method, apparatus, storage medium, and computer device.
  • a color correction function is added in the actual camera image processing flow.
  • the color correction matrix at a typical color temperature is used to compensate the difference between the spectral sensitivity of the camera image sensor and the spectral response of the human visual system by multiplying the color value of each pixel by the color correction matrix. , so that the image data is closer to the scene actually seen by the human eye. Therefore, how to calculate the color correction matrix with high color reproduction degree of the image is particularly important.
  • the traditional method of calculating the color correction matrix is easy to fall into the local optimum, so that the corrected color and target color difference is large, and the color reproduction is The degree is low.
  • an image color correction method, apparatus, storage medium, and computer apparatus capable of improving image color reproduction degree are provided.
  • An image color correction method comprising:
  • the method before the step of acquiring pixels in the original image, the method further includes:
  • the original image is subjected to white balance processing and demosaic processing.
  • the method further includes:
  • the color reproduction accuracy analysis is performed on the standard color card image, and if the color reproduction accuracy is determined to satisfy the preset condition, the image color correction is passed.
  • the method further includes:
  • the pixel of the original image is acquired again, and the pixel is calculated according to the particle swarm algorithm to obtain the An optimal color correction matrix of the original image; importing the optimal color correction matrix into a preset image processing flow; acquiring an image of the standard color card according to the preset image processing flow, and processing the collected image, in processing Performing color correction on the collected image by using the optimal color correction matrix to generate a standard color card image; performing color reproduction accuracy analysis on the standard color card image until the color reproduction accuracy is satisfied When the condition is set, the image color correction is passed.
  • the acquiring a pixel in the original image, calculating the pixel according to a particle swarm algorithm to obtain an optimal color correction matrix of the original image includes:
  • the pixel of the CIE color space, the initial velocity and the initial position of each particle in the particle group are calculated by the particle swarm algorithm formula to calculate the color difference of each particle in the particle group and the mean value of the color difference of each particle;
  • the velocity of all particles in the particle swarm is updated according to the particle velocity update formula, and the positions of all the particles in the particle swarm are updated according to the particle position update formula;
  • Calculating the color difference and the color difference of each particle by using the speed and position of the updated particle as the initial velocity and the initial position of the next next time, and determining the average color difference of the obtained particle as the most historical history.
  • the current position of the particle is updated to its own historical optimal position, and then the particle corresponding to the global history optimal color difference mean is selected from the particle group, and the particle's own historical optimal position is updated to the current position.
  • the global history optimal position of the wheel until the number of iterations reaches the iteration threshold, then outputs the final global history optimal position as the optimal color correction matrix for the original image.
  • the method further includes:
  • the particles are excluded from the particle group
  • Randomly generating new particles to replace the particles, setting initial velocity and initial position for the new particles, returning to update the velocity of all particles in the particle group according to the particle velocity update formula, and updating all formulas according to the particle position update formula The step of updating the position of the particle.
  • the preset image processing flow includes:
  • the sharpened and noise-reduced images are output.
  • An image color correction device comprising:
  • a standard color card original image acquisition module for acquiring an original image of a standard color card
  • An optimal color correction matrix calculation module configured to acquire pixels in the original image, and calculate the optimal color correction matrix of the original image by calculating the pixel according to a particle swarm algorithm
  • An import module configured to import the optimal color correction matrix into a preset image processing flow
  • a color correction module configured to acquire an image of a standard color card according to the preset image processing flow, and process the collected image, and use the optimal color correction matrix to color the collected image during processing Correction to generate a standard color card image.
  • a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the following steps:
  • a computer device comprising a memory, a processor, and a computer program stored on the memory and operative on the processor, the processor executing the computer program to implement the following steps:
  • the computer program prior to the step of acquiring pixels in the original image, the computer program further causes the processor to:
  • the original image is subjected to white balance processing and demosaic processing.
  • the computer program further causes the processor to:
  • the color reproduction accuracy analysis is performed on the standard color card image, and if the color reproduction accuracy is determined to satisfy the preset condition, the image color correction is passed.
  • the computer program further causes the processor to:
  • the pixel of the original image is acquired again, and the pixel is calculated according to the particle swarm algorithm to obtain the An optimal color correction matrix of the original image; importing the optimal color correction matrix into a preset image processing flow; acquiring an image of the standard color card according to the preset image processing flow, and processing the collected image, in processing Performing color correction on the collected image by using the optimal color correction matrix to generate a standard color card image; performing color reproduction accuracy analysis on the standard color card image until the color reproduction accuracy is satisfied When the condition is set, the image color correction is passed.
  • the acquiring a pixel in the original image, calculating the pixel according to a particle swarm algorithm to obtain an optimal color correction matrix of the original image includes:
  • the pixel of the CIE color space, the initial velocity and the initial position of each particle in the particle group are calculated by the particle swarm algorithm formula to calculate the color difference of each particle in the particle group and the mean value of the color difference of each particle;
  • the velocity of all particles in the particle swarm is updated according to the particle velocity update formula, and the positions of all the particles in the particle swarm are updated according to the particle position update formula;
  • Calculating the color difference and the color difference of each particle by using the speed and position of the updated particle as the initial velocity and the initial position of the next next time, and determining the average color difference of the obtained particle as the most historical history.
  • the current position of the particle is updated to its own historical optimal position, and then the particle corresponding to the global history optimal color difference mean is selected from the particle group, and the particle's own historical optimal position is updated to the current position.
  • the global history optimal position of the wheel until the number of iterations reaches the iteration threshold, then outputs the final global history optimal position as the optimal color correction matrix for the original image.
  • the computer program further causes the processor to perform after calculating the color difference of each particle in the particle population and the mean value of the color difference of each particle by a particle swarm algorithm formula:
  • the particles are excluded from the particle group
  • Randomly generating new particles to replace the particles, setting initial velocity and initial position for the new particles, returning to update the velocity of all particles in the particle group according to the particle velocity update formula, and updating all formulas according to the particle position update formula The step of updating the position of the particle.
  • the preset image processing flow includes:
  • the sharpened and noise-reduced images are output.
  • the above image color correction method, device, storage medium and computer device firstly acquire an original image of a standard color card, acquire pixels in the original image, and then calculate an optimal color correction matrix of the original image according to the particle swarm algorithm, and calculate The optimal color correction matrix is imported into the image processing flow.
  • the image of the standard color card is acquired according to the preset image processing flow, and the collected image is processed, and the collected image is color-corrected by the optimal color correction matrix during the processing to generate a standard color card image.
  • the invention adopts the particle swarm optimization algorithm to calculate the optimal color correction matrix of the original image, is not constrained by the color difference evaluation function, and is easy to obtain the global optimal solution, so that the color reproduction of the camera is more accurate.
  • 1 is a flow chart of an image color correction method in an embodiment
  • FIG. 2 is a flow chart of an image color correction method in an embodiment
  • 3 is a flow chart of calculating an optimal color correction matrix in one embodiment
  • Figure 5 is a flow chart of preset image processing in one embodiment
  • FIG. 6 is a schematic structural diagram of an image color correction device in an embodiment
  • FIG. 7 is a schematic structural diagram of an image color correction device in an embodiment
  • FIG. 8 is a schematic structural diagram of an image color correcting apparatus in an embodiment
  • FIG. 9 is a schematic structural diagram of an optimal color correction matrix calculation module of FIG. 7.
  • an image color correction method including:
  • Step 110 Acquire an original image of a standard color card.
  • the standard color card is the standard language for color. This embodiment can use the standard 24-color card produced by GretagMacbeth, which contains 24 color blocks of different colors.
  • the Raw data of the standard color card is acquired by an image sensor.
  • Raw data is the raw data of a CMOS (Complementary Metal Oxide Semiconductor) or CCD (Charge-coupled Device) image sensor that converts the captured light source signal into a digital signal.
  • Raw data is an original record of a digital camera sensor that records some of the raw data produced by the camera.
  • the original image of the standard color card is acquired under preset conditions.
  • the preset condition is that in the A light source, D50, and D75 environment of the CIE (Commission Internationale de L'Eclairage) standard light source, a standard 24-color card produced by GretagMacbeth is placed therein to ensure the illumination chart card.
  • the corner and center illumination are between 750 lux ⁇ 10 lux, and the ring mirror is all black or neutral gray with no stray light interference.
  • the camera collects Raw data the card should be located at the center of the screen, facing the optical axis of the camera, which is about 60%. It is set to manual exposure, the gain is as small as possible, and the value of the brightest white block G component of the color card in Raw is ensured. No more than 200.
  • Step 120 Acquire pixels in the original image, and calculate pixels according to the particle swarm algorithm to obtain an optimal color correction matrix of the original image.
  • the R, G, and B components of the obtained color blocks may be counted, and the obtained pixel matrix of the R, G, and B components is as follows (for example, the R of the second color block, The G and B components correspond to R pre2 , G pre2 , B pre2 ):
  • a new pixel matrix P post is obtained .
  • the color correction matrix looks like this:
  • particle swarm optimization comes from the phenomenon of gathering and spreading that occurs in the process of bird group searching for food, and in social psychology, “Every individual can learn from their own good experiences and learn from the excellent individuals around them” Theory.
  • An intelligent optimization algorithm for finding a global optimal solution is implemented according to the synergy between multiple initial solutions.
  • step 130 the optimal color correction matrix is imported into the preset image processing flow.
  • the optimal color correction matrix calculated by the particle swarm optimization algorithm is imported into the preset image processing flow of the camera, and is specifically imported into the color correction portion in the preset image processing flow.
  • the image is color corrected by an optimal color correction matrix.
  • Step 140 Acquire an image of the standard color card according to a preset image processing flow and process the collected image, and perform color correction on the collected image by using an optimal color correction matrix to generate a standard color card image.
  • the preset image processing flow of the camera needs to re-acquire the image of the standard color card, and then process the image of the collected standard color card to finally generate a standard color card image.
  • the acquired image is color corrected using an optimal color correction matrix.
  • the original image of the standard color card is first acquired, the pixels in the original image are acquired, and the optimal color correction matrix of the original image is calculated according to the particle swarm algorithm, and the calculated optimal color correction matrix is imported into the image processing.
  • the image of the standard color card is acquired according to the preset image processing flow, and the collected image is processed, and the acquired image is color-corrected by the optimal color correction matrix during the processing to generate a standard color card image.
  • the invention adopts the particle swarm optimization algorithm to calculate the optimal color correction matrix of the original image, is not constrained by the color difference evaluation function, and is easy to obtain the global optimal solution, so that the color reproduction of the camera is more accurate.
  • the method before the step of acquiring pixels in the original image, the method further comprises: performing white balance processing and demosaicing processing on the original image.
  • the Raw data of the standard color card is acquired by the image sensor.
  • Raw data is the raw data of a CMOS or CCD image sensor that converts the captured light source signal into a digital signal.
  • Raw data is unprocessed and uncompressed, and Raw can be conceptualized as "raw image encoded data" or more "digital negatives".
  • white balance correction should be done first, so that the white block in the color card is reduced to white.
  • the demosaic is restored to a Jpeg image for color correction.
  • JPEG is the abbreviation of Joint Photographic Experts Group and is the first international image compression standard.
  • the method further comprises: performing color reproduction accuracy analysis on the standard color card image, and if the color reproduction accuracy is determined to satisfy the preset condition, the image color correction is passed.
  • the image generated after the color correction by the optimal color correction matrix is subjected to color reduction accuracy analysis.
  • the generated image is generally a JPEG (Joint Photographic Experts Group) format.
  • Imatest Joint Photographic Experts Group
  • Imatest is a mature image analysis software, it can output visual graphical results, more intuitive.
  • Pre-set conditions refer to the threshold of color difference.
  • the standard is that the color difference ⁇ E 00 is less than the threshold of 5, but not all cameras can meet this requirement, depending on the characteristics of the camera itself.
  • the method further includes:
  • Color reproduction accuracy analysis is performed on the standard color card image. If the color reproduction accuracy is not satisfied, the pixel of the original image is acquired again, and the pixel is calculated according to the particle swarm algorithm to obtain the optimal color correction matrix of the original image. Importing the optimal color correction matrix into the preset image processing flow; acquiring the image of the standard color card according to the preset image processing flow and processing the collected image, and using the optimal color correction matrix to collect the collected The image is color-corrected to generate a standard color card image; the color-reduction accuracy analysis is performed on the standard color card image until the color reproduction accuracy is determined to satisfy the preset condition, and the image color correction is passed.
  • Step 210 Acquire Raw data of the standard color card, that is, Raw data, under a preset condition.
  • step 220 white balance processing and demosaic processing are performed on the original image.
  • Step 230 Acquire pixels in the original image, and calculate pixels according to the particle swarm algorithm to obtain an optimal color correction matrix of the original image.
  • step 240 the optimal color correction matrix is imported into the preset image processing flow.
  • Step 250 Acquire an image of the standard color card according to a preset image processing flow and process the collected image, and perform color correction on the collected image by using an optimal color correction matrix to generate a standard color card image.
  • Step 260 performing color reproduction accuracy analysis on the standard color card image, and analyzing whether the color reproduction accuracy satisfies the preset condition.
  • step 230 the pixels in the original image are acquired, and the pixel is calculated according to the particle swarm algorithm to obtain an optimal color correction matrix of the original image.
  • the process In order to analyze the color reproduction accuracy of the standard color card image, it is judged whether the analyzed color difference reduction accuracy satisfies the preset condition, and if the judgment result is satisfied, the image color correction is passed.
  • the process returns to step 230 to cycle, and the particle swarm algorithm is used again to calculate the optimal color correction of the original image.
  • the matrix imports the calculated optimal color correction matrix into a preset image processing flow, performs color correction on the original image using the calculated optimal color correction matrix, and determines whether the result of the color correction satisfies the preset condition.
  • the loop calculation is continued until the preset condition is met, and the image color correction is passed. If the judgment result is satisfied, the image color correction is passed. That is, the finally obtained color correction matrix is the optimal color correction matrix.
  • the loop can be used to continuously optimize the calculated optimal color correction matrix to finally obtain the optimal color correction matrix.
  • the pixels in the original image are acquired, and the pixel is calculated according to the particle swarm algorithm to obtain an optimal color correction matrix of the original image, including:
  • Step 121 Acquire pixels in the original image, and convert pixels in the original image from the RGB color space to the CIE color space.
  • pixels in the original image may be first converted from the RGB color space to the XYZ color space and then converted to the CIE color space.
  • the RGB gamut space is not a uniform color space, that is, the human eye has different photostability sharpness for different wavelength segments, and the geometric radii of the smallest identifiable chromatic aberration are different in different regions on the RGB chromaticity diagram. Therefore, the RGB space is not suitable for evaluating the degree of approximation between the optimal solution and the ideal solution.
  • the International Commission on Illumination (CIE) proposed a CIE color space suitable for human eye characteristics in 1976, which can be indirectly converted by RGB, as shown in the following equation:
  • X, Y, and Z are the tristimulus values of the color samples; X0, Y0, and Z0 are the tristimulus values of the CIE standard illuminating body; L is the psychometric brightness, and a and b are the psychometric chromaticities.
  • the XYZ chromaticity coordinates can be converted from RGB as shown in the following equation:
  • the evaluation color difference has three color difference calculation formulas proposed in 1976, 1994 and 2000 respectively.
  • the calculation formula of CIEDE2000 is relatively more complicated, but also more precise.
  • the color difference formula can be as follows.
  • K L , K C , and K H table weight factors are related to the application industry.
  • S L , S C , and S H represent the color tolerance ellipse and half.
  • Rc represents a hue angle weight.
  • step 122 the total number of particle groups, the initial velocity of each particle in the particle group, and the initial position are set.
  • step 123 the pixel of the CIE color space, the initial velocity and the initial position of each particle in the particle group are calculated by the particle swarm algorithm formula to calculate the color difference of each particle in the particle group and the mean value of the color difference of each particle.
  • Chromatic aberration refers to the color deviation, which indicates the degree of deviation of the color in the image from the actual color.
  • the chromatic aberration of each particle and the mean value of the chromatic aberration of each particle are calculated in combination with the above formulas (3), (4), (6), (7), and (8). Because the standard color card contains 24 color blocks of different colors, the color difference of each particle calculated by the particle swarm algorithm formula has 24 values, and each color block corresponds to one color difference value. The average of the 24 color difference values of each particle is calculated, that is, the average value of the color difference of each particle is obtained.
  • Step 124 When the maximum value of the color difference of the particles is less than the set threshold, the average value of the color difference of the particles is obtained, and it is determined whether the average value of the color difference is the best in its own history, and if so, the current position of the particle is updated to the best position of its own history.
  • the maximum color difference threshold ⁇ E 00max is set as the constraint condition. For example, ⁇ is set to 10 according to experience, and if it is difficult to satisfy the constraint condition in a specific case, it can be appropriately relaxed. Determining whether a maximum value among the 24 color difference values of each particle in the particle group is smaller than a maximum color difference threshold ⁇ E 00max , and when the maximum value of the color difference of the particles is less than the maximum color difference threshold ⁇ E 00max , obtaining a mean value of the color difference of the particle, and determining the color difference Whether the mean is the best in its own history, if it is, the current position of the particle is updated to its own historical best position.
  • Step 125 Filter the particles corresponding to the global mean difference of the global history from the particle swarm, and update the particle's own historical optimal position to the global historical optimal position of the current round.
  • Step 126 updating the velocity of all the particles in the particle group according to the particle velocity update formula, and updating the positions of all the particles in the particle group according to the particle position update formula.
  • the particle velocity update formula can look like this:
  • v id (k+1) v id (k)+c 1 ⁇ rand()(p id (k)-x id (k))+c 2 ⁇ rand()(p gd (k)-x id ( k)) (9)
  • v id (k+1) represents the speed update calculation formula for the d-dimensional variable of the i-th particle iterating to the K+1th time
  • c 1 and c 2 are control constants
  • rand() represents between 0 and 1.
  • a uniformly distributed random number p id (k) represents the historical optimal position of the d-dimensional variable of the i-th particle
  • p gd (k) represents the historical optimal position of the d-dimensional variable of all particles.
  • the particle position update formula can look like this:
  • xid(k+1) represents the position of the d-dimensional variable of the i-th particle iterating to the K+1th time.
  • the matrix A in the formula (2) is regarded as a vector composed of 9-dimensional variables, and the optimal solution of the matrix A is found by combining the evolution formula of the particle swarm algorithm.
  • Step 127 Iteratively calculates the chromatic aberration and the chromatic aberration mean value of each particle by using the velocity and position of the updated particle as the initial velocity and the initial position of the adjacent next time, and if the average color difference of the obtained particle is determined to be the best in its own history. , the current position of the particle is updated to its own historical best position, and then the particle corresponding to the global history optimal color difference mean is selected from the particle group, and the particle's own historical optimal position is updated to the global history of the current round. The good position, until the number of iterations reaches the iteration threshold, outputs the final global history optimal position as the optimal color correction matrix of the original image.
  • the pixels in the original image are first converted from the RGB color space to the XYZ color space, and then converted to the CIE color space.
  • the chromatic aberration of each particle is calculated by the more accurate CIEDE2000 color difference calculation formula.
  • the threshold is set as the constraint for the color difference, so that the particles that do not meet the constraint are eliminated, leaving only the particles that meet the conditions. Judging that the average color difference of the acquired particles is the best in its own history, the current position of the particle is updated to its own historical optimal position, and then the particle corresponding to the global history optimal color difference mean is selected from the particle group, and the particle itself is The historical best position is updated to the best position in the global history of this round.
  • the method further includes: when the maximum value of the color difference of the particle is greater than a set threshold, the slave particle Particles are removed from the group. Randomly generate new particle replacement particles, set initial velocity and initial position for the new particle, return to update the velocity of all particles in the particle group according to the particle velocity update formula, and perform position on all particles in the particle group according to the particle position update formula. Updated steps.
  • a specific process for calculating an optimal color correction matrix includes:
  • Step 401 Acquire pixels in the original image, and convert pixels in the original image from the RGB color space to the CIE color space.
  • step 402 the total number of particle groups, the initial velocity of each particle in the particle group, and the initial position are set.
  • Step 403 calculating the color difference of each particle in the particle group and the mean value of the color difference of each particle by using the particle swarm algorithm formula to calculate the initial velocity and initial position of each pixel in the CIE color space and the particle group.
  • Step 404 Determine whether the maximum value of the color difference of each particle is less than the maximum color difference threshold, and whether the white balance deviation is less than the threshold.
  • the constraints one of which is the maximum color difference and the other is the white balance deviation. Specifically, setting a maximum color difference threshold ⁇ E 00max to ⁇ , determining whether a maximum value among 24 color difference values of each particle in the particle group is smaller than a maximum color difference threshold ⁇ E 00max , when a maximum value of the color difference of the particles is greater than a maximum color difference threshold ⁇ E 00max removes particles from the particle swarm.
  • the maximum white balance deviation can be set to s. For example, in general, s is 0.05.
  • the particle When the white balance deviation of the particle is less than s, the particle is the particle that satisfies the constraint, and the mean value of the color difference of the particle is obtained as the current The smallest historical color difference of the particle's own history.
  • a white balance deviation constraint is introduced to ensure the accuracy of white balance after color correction of the image.
  • Step 405 when it is determined that the maximum value of the particle does not satisfy the chromatic aberration of the particle is less than the maximum chromatic aberration threshold and the white balance deviation is less than the threshold, the particle is eliminated, and a new particle is randomly generated to replace the current particle, and an initial velocity is set for the new particle and initial position.
  • the randomly generated new particles are added to the ion group for speed and position update, and then returned to the step of calculating the chromatic aberration and the chromatic aberration mean.
  • Step 406 When it is determined that the maximum value of the chromatic aberration of the particles is less than the maximum chromatic aberration threshold and the white balance deviation is less than the threshold, the current chromatic aberration mean of the particles is obtained. It is judged whether the mean value of the color difference is the best in its own history, specifically, whether the average value of the current color difference of each particle is respectively smaller than the mean value of the historical color difference of the particle calculated by each of the previous rounds. If the current mean value of the particle is calculated to be less than the previous historical color mean, the update updates the current position of the particle to its own historical best position. The particles corresponding to the global mean difference of the global history are filtered out from the particle swarm, and the best historical position of the particle is updated to the optimal position of the global history of the current round.
  • step 407 it is determined whether the number of iterations reaches an iteration threshold.
  • Step 408 If it is determined that the number of iterations does not reach the iteration threshold, the velocity of all the particles in the particle group is updated according to the particle velocity update formula, and the positions of all the particles in the particle group are updated according to the particle position update formula. Then, returning to step 403, the pixel of the CIE color space and the speed and position of each of the updated particles in the particle group are calculated by the particle swarm algorithm formula to calculate the color difference of each particle in the particle group and the mean value of the color difference of each particle.
  • the output filters out the particles corresponding to the global history optimal color difference mean from all particle swarms, and updates the particle's own historical optimal position to the final global historical optimal position.
  • the global history optimal position is converted into a 3 ⁇ 3 matrix, which is the optimal color correction matrix of the original image.
  • the preset image processing flow includes:
  • Step 510 Acquire an original image of a standard color card from an image sensor.
  • step 520 white balance and demosaic processing are performed on the original image.
  • step 530 color correction is performed on the image after the white balance and demosaic processing.
  • step 540 the color corrected image is sharpened and noise reduced.
  • step 550 the image after sharpening and noise reduction is output.
  • the original image of the standard color card is acquired under a preset condition, and specifically, the original image of the standard color card is acquired under a preset condition.
  • the standard 24-color card produced by GretagMacbeth is placed in it, ensuring that the illumination card corner and center illumination are between 750 lux ⁇ 10 lux, and the ring mirror is black all around. Or neutral gray, no stray light interference.
  • the camera collects Raw data the card should be located at the center of the screen, facing the optical axis of the camera, accounting for about 60%, set to auto exposure, the gain is as small as possible, and ensure the value of the brightest white block G component of the color card in Raw. No more than 200.
  • Preset image processing flow Under the above preset conditions, the image sensor is used to capture the standard color card, and the original image of the standard color card is obtained from the image sensor, then the original image is white balanced and demosaiced, and then the image is processed. Color correction, then sharpening and noise reduction, and finally output the image to complete the image processing flow. After the above five steps, it is possible to obtain an image which is almost reduced by the human eye.
  • an image color correction device 600 is further provided.
  • the device includes: a standard color card original image acquisition module 610, an optimal color correction matrix calculation module 620, an import module 630, and color correction. Module 640. among them:
  • the standard color card original image acquisition module 610 is configured to acquire an original image of the standard color card.
  • the optimal color correction matrix calculation module 620 is configured to acquire pixels in the original image, and calculate the optimal color correction matrix of the original image according to the particle swarm algorithm.
  • the import module 630 is configured to import the optimal color correction matrix into the preset image processing flow.
  • the color correction module 640 is configured to collect an image of the standard color card according to a preset image processing flow and process the collected image, and perform color correction on the collected image by using an optimal color correction matrix to generate a standard color. Card image.
  • the image color correction device 600 further includes a pre-processing module 650 for performing white balance processing and demosaicing processing on the original image.
  • the image color correction device 600 further includes: a color reproduction accuracy analysis module 660, configured to perform color reproduction accuracy analysis on the standard color card image, and if the color reproduction accuracy is satisfied, With the preset conditions, the image color correction passes.
  • a color reproduction accuracy analysis module 660 configured to perform color reproduction accuracy analysis on the standard color card image, and if the color reproduction accuracy is satisfied, With the preset conditions, the image color correction passes.
  • the optimal color correction matrix calculation module 620 includes:
  • a pixel obtaining module 621 configured to acquire pixels in the original image
  • a pixel conversion module 622 configured to convert pixels in the original image from the RGB color space to the CIE color space;
  • a particle swarm parameter setting module 623 configured to set a total number of particle groups, an initial velocity and an initial position of each particle in the particle group;
  • the chromatic aberration and chromatic aberration mean calculation module 624 is configured to calculate the chromatic aberration of each particle in the particle group and the particle size of each particle in the particle group by the pixel of the CIE color space and the initial velocity and initial position of each particle in the particle group. Mean value of color difference;
  • the self-historical optimal position update module 625 is configured to obtain a mean value of the color difference of the particles when the maximum value of the color difference of the particles is less than a set threshold, and determine whether the average color difference is the best in its own history, and if so, update the current position of the particle to The best position in its own history;
  • the global history optimal position module 626 is configured to filter out particles corresponding to the global history optimal color difference mean from the particle group, and update the particle's own historical optimal position to the global historical optimal position of the current round;
  • the particle velocity and position update module 627 is configured to update the velocity of all the particles in the particle group according to the particle velocity update formula, and update the positions of all the particles in the particle group according to the particle position update formula;
  • the optimal color correction matrix output module 628 is configured to iteratively calculate the color difference and the color difference mean value of each particle by using the speed and position of the updated particle as the initial velocity and the initial position of the adjacent next time, if the obtained particle is determined.
  • the mean value of the color difference is the best in its own history, then the current position of the particle is updated to its own historical best position, and then the particle corresponding to the global history optimal color difference mean is selected from the particle group, and the particle's own history is optimally positioned.
  • the global history optimal position of the current round is updated until the iteration number reaches the iteration threshold, and the final global history optimal position is output as the optimal color correction matrix of the original image.
  • a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the following steps:
  • the image processing process collects the image of the standard color card and processes the acquired image, and uses the optimal color correction matrix to perform color correction on the acquired image to generate a standard color card image.
  • the method when the above program is executed by the processor, the following steps are further implemented: before the step of acquiring pixels in the original image, the method further comprises: performing white balance processing and demosaicing processing on the original image.
  • the method when the program is executed by the processor, the following steps are further implemented: after the step of generating a standard color card image, the method further comprises: performing color reproduction accuracy analysis on the standard color card image, if the color reproduction accuracy is analyzed When the preset condition is met, the image color correction is passed.
  • the method further includes: The card image is analyzed for color reproduction accuracy. If the color reproduction accuracy is not satisfied, the pixel of the original image is acquired again, and the pixel is calculated according to the particle swarm algorithm to obtain the optimal color correction matrix of the original image; The excellent color correction matrix is imported into the preset image processing flow; the image of the standard color card is acquired according to the preset image processing flow, and the collected image is processed, and the collected image is colored by the optimal color correction matrix during the processing. Correction, generate a standard color card image; perform color reproduction accuracy analysis on the standard color card image until the color reproduction accuracy meets the preset condition, and the image color correction passes.
  • the following steps are further performed: acquiring pixels in the original image, and calculating pixels according to the particle swarm algorithm to obtain an optimal color correction matrix of the original image, comprising: acquiring the original image a pixel; converts pixels in the original image from the RGB color space to the CIE color space; sets the total number of particle groups, the initial velocity and initial position of each particle in the particle group; and the pixels in the CIE color space, each of the particle groups
  • the initial velocity and initial position of the particle are calculated by the particle swarm algorithm formula to calculate the color difference of each particle in the particle group and the mean value of the color difference of each particle; when the maximum value of the color difference of the particle is less than the set threshold, the mean value of the color difference of the particle is obtained.
  • the particles corresponding to the global mean difference of the global history are filtered out from the particle group, and the particle's own history is the most The best position is updated to the global history of the current round; the particle swarm is updated according to the particle velocity The velocity of all particles is updated, and the position of all particles in the particle group is updated according to the particle position update formula; the velocity and position of the updated particle are iteratively calculated as the initial velocity and initial position of the next next time.
  • the current position of the particles is updated to its own historical best position, and then the best historical chromatic aberration mean is selected from the particle group.
  • Corresponding particles update the particle's own historical optimal position to the global history optimal position of the current round. Until the iteration number reaches the iteration threshold, the final global historical optimal position is output as the optimal color correction matrix of the original image.
  • the method when the program is executed by the processor, the following steps are further implemented: after calculating the color difference of each particle in the particle group and the mean value of the color difference of each particle by the particle swarm algorithm formula, the method further includes: when the color difference of the particle When the maximum value is greater than the set threshold, the particles are removed from the particle group; new particles are randomly generated to replace the particles, the initial velocity and initial position are set for the new particle, and the velocity of all particles in the particle group is updated according to the particle velocity update formula. Update to update the position of all particles in the particle swarm based on the particle position update formula.
  • the preset image processing flow includes: acquiring an original image of the standard color card from the image sensor; performing white balance and demosaic processing on the original image; The image after balance and demosaic processing is color-corrected; the image after color correction is sharpened and noise-reduced; and the image after sharpening and noise reduction is output.
  • a computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor performing the following steps when executing the computer program:
  • the image processing process collects the image of the standard color card and processes the acquired image, and uses the optimal color correction matrix to perform color correction on the acquired image to generate a standard color card image.
  • the processor executes the computer program
  • the following steps are further implemented: before the step of acquiring pixels in the original image, the method further comprises: performing white balance processing and demosaicing processing on the original image.
  • the processor executes the computer program
  • the following steps are further implemented: after the step of generating a standard color card image, the method further comprises: performing color reproduction accuracy analysis on the standard color card image, if the color reproduction accuracy is analyzed When the preset condition is met, the image color correction is passed.
  • the processor executes the computer program
  • the following steps are further implemented: when the program is executed by the processor, the following steps are further implemented: after performing color reproduction accuracy analysis on the standard color card image, the method further includes: The card image is analyzed for color reproduction accuracy. If the color reproduction accuracy is not satisfied, the pixel of the original image is acquired again, and the pixel is calculated according to the particle swarm algorithm to obtain the optimal color correction matrix of the original image; The excellent color correction matrix is imported into the preset image processing flow; the image of the standard color card is acquired according to the preset image processing flow, and the collected image is processed, and the collected image is colored by the optimal color correction matrix during the processing. Correction, generate a standard color card image; perform color reproduction accuracy analysis on the standard color card image until the color reproduction accuracy meets the preset condition, and the image color correction passes.
  • the processor executes the computer program, the following steps are further performed: acquiring pixels in the original image, and calculating pixels according to the particle swarm algorithm to obtain an optimal color correction matrix of the original image, including: acquiring the original image a pixel; converts pixels in the original image from the RGB color space to the CIE color space; sets the total number of particle groups, the initial velocity and initial position of each particle in the particle group; and the pixels in the CIE color space, each of the particle groups
  • the initial velocity and initial position of the particle are calculated by the particle swarm algorithm formula to calculate the color difference of each particle in the particle group and the mean value of the color difference of each particle; when the maximum value of the color difference of the particle is less than the set threshold, the mean value of the color difference of the particle is obtained.
  • the particles corresponding to the global mean difference of the global history are filtered out from the particle group, and the particle's own history is the most Good position update is the best position of the global history of this round; update formula according to particle speed
  • the velocity of all particles in the cluster is updated, and the position of all particles in the particle group is updated according to the particle position update formula; the speed and position of the updated particle are iteratively calculated as the initial velocity and initial position of the next next time.
  • the chromatic aberration and chromatic aberration of each particle are average.
  • the current position of the particle is updated to its own historical optimal position, and then the chromatic aberration of the global history is selected from the particle group.
  • the particle corresponding to the mean value updates the particle's own historical optimal position to the global history optimal position of the current round until the number of iterations reaches the iterative threshold, and outputs the final global historical optimal position as the optimal color correction matrix of the original image. .
  • the processor executes the computer program
  • the following steps are further implemented: after calculating the color difference of each particle in the particle group and the mean value of the color difference of each particle by the particle swarm algorithm formula, the method further includes: when the color difference of the particle When the maximum value is greater than the set threshold, the particles are removed from the particle group; new particles are randomly generated to replace the particles, the initial velocity and initial position are set for the new particle, and the velocity of all particles in the particle group is updated according to the particle velocity update formula. Update to update the position of all particles in the particle swarm based on the particle position update formula.
  • the preset image processing flow includes: acquiring an original image of the standard color card from the image sensor; performing white balance and demosaic processing on the original image; The image after balance and demosaic processing is color-corrected; the image after color correction is sharpened and noise-reduced; and the image after sharpening and noise reduction is output.
  • the program can be stored in a non-volatile computer readable storage medium.
  • the program may be stored in a storage medium of the computer system and executed by at least one processor in the computer system to implement a process comprising an embodiment of the methods described above.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Image Processing (AREA)
  • Color Television Image Signal Generators (AREA)

Abstract

本发明涉及一种图像色彩校正方法、装置、存储介质和计算机设备。首先采集标准色卡的原始图像,获取经原始图像中的像素,再根据粒子群算法进行计算原始图像的最优色彩校正矩阵,将计算出的最优色彩校正矩阵导入图像处理流程中。按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像。本发明采用粒子群算法来计算原始图像的最优色彩校正矩阵,不受色差评估函数可导性约束,容易获取全局最优解,使相机的色彩还原更精准。

Description

图像色彩校正方法、装置、存储介质和计算机设备
申请要求于2017年7月17日申请的、申请号为201710582472.6、申请名称为“图像色彩校正方法、装置、存储介质和计算机设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及图像处理技术领域,特别是涉及一种图像色彩校正方法、装置、存储介质和计算机设备。
背景技术
考虑到人眼的光谱响应和相机图像传感器以及显示器的光谱响应不同,为了更好地对图像进行色彩还原,在实际的相机图像处理流程中,加入了色彩校正功能。在对图像进行色彩校正时,需要使用典型色温下的色彩校正矩阵,通过对每个像素的色彩值乘以该色彩校正矩阵,以补偿摄像机图像传感器的光谱灵敏度和人类视觉系统的光谱响应的差异,从而使图像数据更接近人类眼睛实际所看到的场景。所以如何计算出对图像的色彩还原度较高的色彩校正矩阵就显得尤为重要,然而传统的计算色彩校正矩阵的方法极易陷入局部最优,使得校正后的色彩与目标色差较大,色彩还原度较低。
发明内容
根据本申请的各种实施例,提供一种能够提高图像色彩还原度的图像色彩校正方法、装置、存储介质和计算机设备。
一种图像色彩校正方法,所述方法包括:
采集标准色卡的原始图像;
获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;
将所述最优色彩校正矩阵导入预设图像处理流程中;
按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处 理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像。
在其中一个实施例中,在获取所述原始图像中的像素的步骤之前,还包括:
对所述原始图像进行白平衡处理和去马赛克处理。
在其中一个实施例中,在所述生成标准色卡图像的步骤之后,还包括:
对所述标准色卡图像进行色彩还原准确性分析,若分析出所述色彩还原准确性满足预设条件,则图像色彩校正通过。
在其中一个实施例中,在所述对所述标准色卡图像进行色彩还原准确性分析之后,还包括:
对所述标准色卡图像进行色彩还原准确性分析,若分析出所述色彩还原准确性不满足预设条件,则再次获取原始图像的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;将所述最优色彩校正矩阵导入预设图像处理流程中;按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像;对所述标准色卡图像进行色彩还原准确性分析,直到分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
在其中一个实施例中,所述获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵,包括:
获取所述原始图像中的像素;
将所述原始图像中的像素从RGB颜色空间转换至CIE颜色空间;
设置粒子群的总数量、粒子群中每个粒子的初始速度及初始位置;
将CIE颜色空间的像素、粒子群中每个粒子的初始速度及初始位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值;
当所述粒子的色差中的最大值小于设定阈值,则获取所述粒子的色差均值,判断所述色差均值是否为自身历史最佳,若是则将所述粒子的当前位置更新为自身历史最佳位置;
从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将所述粒子的 自身历史最佳位置更新为本轮的全局历史最佳位置;
根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新;
将所述更新后的粒子的速度和位置作为相邻的下一回的初始速度和初始位置进行迭代计算每个粒子的色差和色差均值,若判断获取的所述粒子的色差均值为自身历史最佳,则将所述粒子的当前位置更新为自身历史最佳位置,再从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将所述粒子的自身历史最佳位置更新为本轮的全局历史最佳位置,直至迭代次数达到迭代阈值,则输出最终的全局历史最佳位置作为所述原始图像的最优色彩校正矩阵。
在其中一个实施例中,在通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值之后,还包括:
当所述粒子的色差中的最大值大于设定阈值,则从粒子群中剔除所述粒子;
随机产生新的粒子替代所述粒子,为所述新的粒子设置初始速度及初始位置,返回根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新的步骤。
在其中一个实施例中,所述预设图像处理流程包括:
从图像传感器获取标准色卡的原始图像;
对所述原始图像进行白平衡及去马赛克处理;
对经过白平衡及去马赛克处理后的图像进行色彩校正;
对经过色彩校正后的图像进行锐化及降噪;
将经过锐化及降噪后的图像输出。
一种图像色彩校正装置,所述装置包括:
标准色卡原始图像采集模块,用于采集标准色卡的原始图像;
最优色彩校正矩阵计算模块,用于获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;
导入模块,用于将所述最优色彩校正矩阵导入预设图像处理流程中;
色彩校正模块,用于按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集 到的图像进行色彩校正,生成标准色卡图像。
一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现以下步骤:
采集标准色卡的原始图像;
获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;
将所述最优色彩校正矩阵导入预设图像处理流程中;
按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像。
一种计算机设备,所述计算机设备包括存储器,处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现以下步骤:
采集标准色卡的原始图像;
获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;
将所述最优色彩校正矩阵导入预设图像处理流程中;
按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像。
在其中一个实施例中,在获取所述原始图像中的像素的步骤之前,所述计算机程序还使得所述处理器执行:
对所述原始图像进行白平衡处理和去马赛克处理。
在其中一个实施例中,在所述生成标准色卡图像的步骤之后,所述计算机程序还使得所述处理器执行:
对所述标准色卡图像进行色彩还原准确性分析,若分析出所述色彩还原准确性满足预设条件,则图像色彩校正通过。
在其中一个实施例中,在所述对所述标准色卡图像进行色彩还原准确性分 析之后,所述计算机程序还使得所述处理器执行:
对所述标准色卡图像进行色彩还原准确性分析,若分析出所述色彩还原准确性不满足预设条件,则再次获取原始图像的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;将所述最优色彩校正矩阵导入预设图像处理流程中;按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像;对所述标准色卡图像进行色彩还原准确性分析,直到分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
在其中一个实施例中,所述获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵,包括:
获取所述原始图像中的像素;
将所述原始图像中的像素从RGB颜色空间转换至CIE颜色空间;
设置粒子群的总数量、粒子群中每个粒子的初始速度及初始位置;
将CIE颜色空间的像素、粒子群中每个粒子的初始速度及初始位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值;
当所述粒子的色差中的最大值小于设定阈值,则获取所述粒子的色差均值,判断所述色差均值是否为自身历史最佳,若是则将所述粒子的当前位置更新为自身历史最佳位置;
从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将所述粒子的自身历史最佳位置更新为本轮的全局历史最佳位置;
根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新;
将所述更新后的粒子的速度和位置作为相邻的下一回的初始速度和初始位置进行迭代计算每个粒子的色差和色差均值,若判断获取的所述粒子的色差均值为自身历史最佳,则将所述粒子的当前位置更新为自身历史最佳位置,再从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将所述粒子的自身历史最佳位置更新为本轮的全局历史最佳位置,直至迭代次数达到迭代阈值,则 输出最终的全局历史最佳位置作为所述原始图像的最优色彩校正矩阵。
在其中一个实施例中,在通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值之后,所述计算机程序还使得所述处理器执行:
当所述粒子的色差中的最大值大于设定阈值,则从粒子群中剔除所述粒子;
随机产生新的粒子替代所述粒子,为所述新的粒子设置初始速度及初始位置,返回根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新的步骤。
在其中一个实施例中,所述预设图像处理流程包括:
从图像传感器获取标准色卡的原始图像;
对所述原始图像进行白平衡及去马赛克处理;
对经过白平衡及去马赛克处理后的图像进行色彩校正;
对经过色彩校正后的图像进行锐化及降噪;
将经过锐化及降噪后的图像输出。
上述图像色彩校正方法、装置、存储介质和计算机设备,首先采集标准色卡的原始图像,获取经原始图像中的像素,再根据粒子群算法进行计算原始图像的最优色彩校正矩阵,将计算出的最优色彩校正矩阵导入图像处理流程中。按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像。本发明采用粒子群算法来计算原始图像的最优色彩校正矩阵,不受色差评估函数可导性约束,容易获取全局最优解,使相机的色彩还原更精准。
本发明的一个或多个实施例的细节在下面的附图和描述中提出。本发明的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他实施例的附图。
图1为一个实施例中图像色彩校正方法的流程图;
图2为一个实施例中图像色彩校正方法的流程图;
图3为一个实施例中计算最优色彩校正矩阵的流程图;
图4为一个实施例中计算最优色彩校正矩阵的流程图;
图5为一个实施例中预设图像处理流程图;
图6为一个实施例中图像色彩校正装置的结构示意图;
图7为一个实施例中图像色彩校正装置的结构示意图;
图8为一个实施例中图像色彩校正装置的结构示意图;
图9为图7中最优色彩校正矩阵计算模块的结构示意图。
具体实施方式
为使本发明的上述目的、特征和优点能够更加明显易懂,下面结合附图对本发明的具体实施方式做详细的说明。在下面的描述中阐述了很多具体细节以便于充分理解本发明。但是本发明能够以很多不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本发明内涵的情况下做类似改进,因此本发明不受下面公开的具体实施的限制。
除非另有定义,本文所使用的所有的技术和科学术语与属于本发明的技术领域的技术人员通常理解的含义相同。本文中在本发明的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本发明。以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
在一个实施例中,如图1所示,提供了一种图像色彩校正方法,包括:
步骤110,采集标准色卡的原始图像。
标准色卡是色彩的标准语言。本实施例可使用GretagMacbeth美国麦克贝斯生产的标准24色卡,包含24个颜色不同的色块。用图像传感器采集标准色卡的Raw数据。Raw数据就是CMOS(Complementary Metal Oxide Semiconductor,互补金属氧化物半导体)或者CCD(Charge-coupled Device,电荷耦合元件)图 像感应器将捕捉到的光源信号转化为数字信号的原始数据。Raw数据是一种记录了数码相机传感器的原始信息,同时记录了由相机拍摄所产生的一些原始数据。
在预设条件下采集标准色卡的原始图像。具体的,预设条件为在CIE(Commission Internationale de L'Eclairage,国际照明委员会)标准光源中的A光源、D50、D75环境中,将GretagMacbeth生产的标准24色卡置于其中,保证照度图卡边角及中心照度在750lux±10lux之间,四周环镜全黑或中性灰,无杂光干扰。相机采集Raw数据时图卡要位于画面中心,正对相机光轴,占比约为60%,设置成手动曝光,增益尽可能小,同时确保Raw中色卡最亮的白块G分量的值不超过200。
步骤120,获取原始图像中的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵。
在一个实施例中,可对获取的Raw数据中的各个色块的R、G、B分量进行统计,得到的R、G、B分量组成的像素矩阵如下(例如第2个色块的R、G、B分量对应于R pre2,G pre2,B pre2):
Figure PCTCN2018095848-appb-000001
经过色彩校正矩阵线性变换后得到新的像素矩阵P post。例如,色彩校正矩阵如下所示:
Figure PCTCN2018095848-appb-000002
则新的像素矩阵P post可如下式所示:
Figure PCTCN2018095848-appb-000003
假设被拍摄的图卡各色块像素理想值组成的矩阵如下:
Figure PCTCN2018095848-appb-000004
为了使相机经过色彩校正后色彩还原准确,就需要找到最优色彩校正矩阵A,使像素矩阵Ppost与理想像素矩阵Pidea逼近,即
Figure PCTCN2018095848-appb-000005
粒子群算法的思想来源于鸟类群体寻找食物的过程中涌现的聚散现象,以及社会心理学中“每个个体都能从自身以往好的经验中学习,并通过学习周围的优秀个体进步”的理论。根据多个初始解之间的协同作用,来实现寻找全局最优解的一种智能优化算法。
步骤130,将最优色彩校正矩阵导入预设图像处理流程中。
将经过粒子群算法计算出的最优色彩校正矩阵导入相机的预设图像处理流程中,具体导入预设图像处理流程中的色彩校正部分中。通过最优色彩校正矩阵对图像进行色彩校正。
步骤140,按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像。
相机的预设图像处理流程,需要先重新采集标准色卡的图像,再对采集的标准色卡的图像进行处理,最终生成标准色卡图像。在这个处理过程中,利用最优色彩校正矩阵对采集到的图像进行色彩校正。
本实施例中,首先采集标准色卡的原始图像,获取经原始图像中的像素,再根据粒子群算法进行计算原始图像的最优色彩校正矩阵,将计算出的最优色彩校正矩阵导入图像处理流程中。按照预设图像处理流程采集标准色卡的图像 并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像。本发明采用粒子群算法来计算原始图像的最优色彩校正矩阵,不受色差评估函数可导性约束,容易获取全局最优解,使相机的色彩还原更精准。
在一个实施例中,在获取原始图像中的像素的步骤之前,还包括:对原始图像进行白平衡处理和去马赛克处理。
在本实施例中,用图像传感器采集标准色卡的Raw数据。Raw数据就是CMOS或者CCD图像感应器将捕捉到的光源信号转化为数字信号的原始数据。Raw数据是未经处理、也未经压缩的,可以把Raw概念化为“原始图像编码数据”或更形象的称为“数字底片”。根据人眼的色彩恒常特性,即人眼在不同色温下看到白色物体始终认为它是白色的。因此对采集的标准色卡Raw数据,要首先做白平衡修正,使得色卡中白块还原成白色。根据相机传感器上彩色滤波阵列排列顺序,去马赛克还原成Jpeg图像,便于做色彩校正。JPEG是Joint Photographic Experts Group(联合图像专家小组)的缩写,是第一个国际图像压缩标准。
在一个实施例中,在生成标准色卡图像的步骤之后,还包括:对标准色卡图像进行色彩还原准确性分析,若分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
在本实施例中,为了检验经过粒子群算法计算出的最优色彩校正矩阵是否达标,就对经过最优色彩校正矩阵进行色彩校正后生成的图像进行色彩还原准确性分析。具体的,生成的一般为JPEG(Joint Photographic Experts Group)格式的图片。利用软件分析色彩还原的准确性,具体的可以采用Imatest软件来分析,Imatest是一款成熟的图像分析软件,它可以输出可视化的图形结果,比较直观。当然我们也可以采用其他软件进行色彩还原准确性分析。预设条件指的是色差的阈值,一般目前没有统一认可的标准,它也受到图像传感器、镜头本身、滤光片等多种因素影响,一般是希望越小越好,比如我们自己一般定的标准是色差ΔE 00要小于阈值5,但并不是所有相机都能达到这个要求,这要根据相机本身的特性来定。
在一个实施例中,在对标准色卡图像进行色彩还原准确性分析之后,还包括:
对标准色卡图像进行色彩还原准确性分析,若分析出色彩还原准确性不满足预设条件,则再次获取原始图像的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵;将最优色彩校正矩阵导入预设图像处理流程中;按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像;对标准色卡图像进行色彩还原准确性分析,直到分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
在一个实施例中,请参阅图2所示,在对相机的色彩进行校正时候包含以下步骤:
步骤210,在预设条件下采集标准色卡的原始图像即Raw数据。
步骤220,对原始图像进行白平衡处理和去马赛克处理。
步骤230,获取原始图像中的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵。
步骤240,将最优色彩校正矩阵导入预设图像处理流程中。
步骤250,按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像。
步骤260,对标准色卡图像进行色彩还原准确性分析,分析出色彩还原准确性是否满足预设条件。
若满足条件,则本次色彩校正完成。若不满足条件,则本次色彩校正失败,返回步骤230获取原始图像中的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵。
为对标准色卡图像进行色彩还原准确性分析,判断分析出的色差还原准确性是否满足预设条件,若判断结果为满足,则图像色彩校正通过。当本次使用粒子群算法计算出的最优色彩校正矩阵对图像进行色彩校正的结果不能满足预设条件时,则返回步骤230进行循环,再次使用粒子群算法计算出原始图像的 最优色彩校正矩阵,再将计算所得的最优色彩校正矩阵导入预设图像处理流程中,用计算出的最优色彩校正矩阵对原始图像进行色彩校正,并判断此次色彩校正的结果是否满足预设条件。若不满足,则继续循环计算直到满足预设条件,则图像色彩校正通过。若判断结果为满足,则图像色彩校正通过。即最终获得的色彩校正矩阵为最优色彩校正矩阵。利用循环可以不断优化计算出的最优色彩校正矩阵,从而最终获得最优色彩校正矩阵。
在一个实施例中,如图3所示,获取原始图像中的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵,包括:
步骤121,获取原始图像中的像素,将原始图像中的像素从RGB颜色空间转换至CIE颜色空间。
在一个实施例中,可将原始图像中的像素从RGB颜色空间先转换至XYZ颜色空间,再转换至CIE颜色空间。RGB色域空间并非均匀的色彩空间,即人眼对于不同波长段的光敏锐度不一样,在RGB色度图上不同区域上,最小可辨色差的几何半径差异较大。因此RGB空间内不适用于评价最优解与理想解之间的逼近程度。国际照明委员会(CIE)于1976提出了一个适合人眼特性的CIE颜色空间,它可以由RGB间接转换,如下式所示:
Figure PCTCN2018095848-appb-000006
上式中,X、Y、Z为颜色样品的三刺激值;X0、Y0、Z0为CIE标准照明体的三刺激值;L为心理计量明度,a、b为心理计算色度。XYZ色度坐标可由RGB转换而来,如下式所示:
Figure PCTCN2018095848-appb-000007
在CIE颜色空间中,评价色差有1976年、1994年和2000年分别提出的三个色差计算公式,相对而言CIEDE2000的计算式更复杂,但也更精准,例如色差公式可为如下所示。
Figure PCTCN2018095848-appb-000008
上式中,K L、K C、K H表权重因子,跟应用行业有关,一般取K L=1.4,K C=K H=1;S L、S C、S H表示色彩容差椭圆半轴长度;ΔL *表示明度差,ΔC *表示彩度差,ΔH *表示色相角差,Rc表示色相角权重。
步骤122,设置粒子群的总数量、粒子群中每个粒子的初始速度及初始位置。
设置粒子群的总数量为N,粒子群中每个粒子的初始速度都为0,设置第i个粒子的初始位置为:[a i1a i2a i3a i4a i5a i6a i7a i8a i9]。
步骤123,将CIE颜色空间的像素、粒子群中每个粒子的初始速度及初始位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值。
色差(Chromatic aberration;chromatic aberration)是指色彩偏差,表示图像中的色彩与实际色彩的偏离程度。结合上述公式(3)、(4)、(6)、(7)、(8)计算每个粒子的色差和每个粒子的色差均值。因为标准色卡,包含24个颜色不同的色块,所以通过粒子群算法公式计算出的每个粒子的色差有24个值,每个色块对应一个色差值。再计算每个粒子的24个色差值的平均值,即获得了每个粒子的色差均值。
步骤124,当粒子的色差中的最大值小于设定阈值,则获取粒子的色差均值,判断色差均值是否为自身历史最佳,若是则将粒子的当前位置更新为自身历史最佳位置。
设置最大色差阈值ΔE 00max为ζ作为约束条件,例如,根据经验设置ζ为10,若特定的情况下难以满足约束条件,可以适当放宽。判断粒子群中的每个粒子24个色差值中的最大值是否小于最大色差阈值ΔE 00max,当粒子的色差中的最大值小于最大色差阈值ΔE 00max,则获取该粒子的色差均值,判断色差均值是否为自身历史最佳,若是则将粒子的当前位置更新为自身历史最佳位置。
步骤125,从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置。
步骤126,根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新。
例如,粒子速度更新公式可为如下所示:
v id(k+1)=v id(k)+c 1·rand()(p id(k)-x id(k))+c 2·rand()(p gd(k)-x id(k))   (9)
其中,v id(k+1)表示第i个粒子的d维变量迭代到第K+1次时的速度更新计算式,c 1和c 2为控制常数,rand()表示0到1之间均匀分布的随机数,p id(k)表示第i个粒子的d维变量的历史最优位置,p gd(k)表示所有粒子中第d维变量的历史最优位置。
例如,粒子位置更新公式可为如下所示:
x id(k+1)=x id(k)+v id(k+1)        (10)
其中,xid(k+1)表示第i个粒子的d维变量迭代到第K+1次时的位置。
根据(9)、(10)式,将公式(2)中矩阵A看做成一个9维变量组成的向量,结合粒子群算法的演化公式,寻找矩阵A的最优解。
步骤127,将更新后的粒子的速度和位置作为相邻的下一回的初始速度和初始位置进行迭代计算每个粒子的色差和色差均值,若判断获取的粒子的色差均值为自身历史最佳,则将粒子的当前位置更新为自身历史最佳位置,再从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置,直至迭代次数达到迭代阈值,则输出最终的全局历史最佳位置作为原始图像的最优色彩校正矩阵。
在本实施例中,将原始图像中的像素从RGB颜色空间先转换至XYZ颜色空间,再转换至CIE颜色空间。基于粒子群优化算法,用更精准的CIEDE2000色差计算公式来计算每一个粒子的色差。并为色差设置了阈值作为约束条件,从而剔除不符合该约束条件的粒子,只留下符合条件的粒子。判断获取的粒子的色差均值为自身历史最佳,则将粒子的当前位置更新为自身历史最佳位置,再从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置。且对粒子的速度和位置进行更新,将更新后的粒子的速度和位置作为相邻的下一回计算每个粒子的色差均值的初始速度和初始位置进行迭代计算,直至迭代次数达到迭代阈值,则输出最终的 全局历史最佳位置作为原始图像的最优色彩校正矩阵。经过预设迭代次数的迭代计算,能够获取到更加准确的最优色彩校正矩阵。这种方法可以找到色彩校正矩阵的全局最优解,不易陷入局部最优。
在一个实施例中,在通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值之后,还包括:当粒子的色差中的最大值大于设定阈值,则从粒子群中剔除粒子。随机产生新的粒子替代粒子,为新的粒子设置初始速度及初始位置,返回根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新的步骤。
如图4所示,本实施例中,计算最优色彩校正矩阵的具体过程包括:
步骤401,获取原始图像中的像素,将原始图像中的像素从RGB颜色空间转换至CIE颜色空间。
步骤402,设置粒子群的总数量、粒子群中每个粒子的初始速度及初始位置。
步骤403,将CIE颜色空间的像素、粒子群中每个粒子的初始速度及初始位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值。
步骤404,判断每个粒子色差的最大值是否小于最大色差阈值,且白平衡偏差是否小于阈值。
设置约束条件,其中一个条件是最大色差,另一个条件是白平衡偏差。具体的,设置最大色差阈值ΔE 00max为ζ,判断粒子群中的每个粒子24个色差值中的最大值是否小于最大色差阈值ΔE 00max,当粒子的色差中的最大值大于最大色差阈值ΔE 00max,则从粒子群中剔除粒子。当然,可以设置最大白平衡偏差为s,例如,一般情况下s为0.05,当粒子的白平衡偏差小于s,则该粒子就为满足约束条件的粒子,就获取该粒子的色差均值,作为当前粒子的自身历史最小色差值。引入白平衡偏差约束来确保对图像进行色彩校正后白平衡的准确性。
步骤405,当判断出粒子不满足粒子的色差中的最大值小于最大色差阈值且白平衡偏差小于阈值,则剔除该粒子,并随机产生新的粒子替代当前粒子,为新的粒子设置初始速度及初始位置。并将随机产生的新的粒子加入离子群中一起进行速度和位置的更新,从而再返回至计算色差和色差均值的步骤进行循环。
步骤406,当判断出粒子的色差中的最大值小于最大色差阈值且白平衡偏差小于阈值,则获取这些粒子的当前色差均值。判断色差均值是否为自身历史最佳,具体为分别判断每个粒子当前色差均值是否小于前面每一轮分别计算出的该粒子的历史色差均值。如果计算出粒子当前色差均值小于之前的历史色差均值,则更新将粒子的当前位置更新为自身历史最佳位置。从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置。
步骤407,判断迭代次数是否达到迭代阈值。
步骤408,若判断出迭代次数未达到迭代阈值,则根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新。然后返回步骤403,将CIE颜色空间的像素、粒子群中更新后的每个粒子的速度及位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值。
若判断出迭代次数达到迭代阈值,则输出从所有的粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为最终的全局历史最佳位置。将该全局历史最佳位置转化为3×3矩阵,该矩阵即为原始图像的最优色彩校正矩阵。
在一个实施例中,如图5所示,预设图像处理流程包括:
步骤510,从图像传感器获取标准色卡的原始图像。
步骤520,对原始图像进行白平衡及去马赛克处理。
步骤530,对经过白平衡及去马赛克处理后的图像进行色彩校正。
步骤540,对经过色彩校正后的图像进行锐化及降噪。
步骤550,将经过锐化及降噪后的图像输出。
在本实施例中,在预设条件下进行采集标准色卡的原始图像,具体的,在预设条件下采集标准色卡的原始图像。例如,在CIE标准光源中的A光源、D50、D75环境中,将GretagMacbeth生产的标准24色卡置于其中,保证照度图卡边角及中心照度在750lux±10lux之间,四周环镜全黑或中性灰,无杂光干扰。相机采集Raw数据时图卡要位于画面中心,正对相机光轴,占比约为60%,设置 成自动曝光,增益尽可能小,同时确保Raw中色卡最亮的白块G分量的值不超过200。
预设图像处理流程:在上述预设条件下,先使用图像传感器拍摄标准色卡,从图像传感器获取标准色卡的原始图像后,对原始图像进行白平衡及去马赛克处理,然后再对图像进行色彩校正,之后再进行锐化及降噪,最后将图像输出即完成这个图像处理流程。经过上述5个步骤的处理,即可获得几乎还原人眼所观察的图像。
在一个实施例中,如图6所示,还提供了一种图像色彩校正装置600,装置包括:标准色卡原始图像采集模块610、最优色彩校正矩阵计算模块620、导入模块630及色彩校正模块640。其中:
标准色卡原始图像采集模块610,用于采集标准色卡的原始图像。
最优色彩校正矩阵计算模块620,用于获取原始图像中的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵。
导入模块630,用于将最优色彩校正矩阵导入预设图像处理流程中。
色彩校正模块640,用于按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像。
在一个实施例中,如图7所示,图像色彩校正装置600还包括:预处理模块650,用于对原始图像进行白平衡处理和去马赛克处理。
在一个实施例中,如图8所示,图像色彩校正装置600还包括:色彩还原准确性分析模块660,用于对标准色卡图像进行色彩还原准确性分析,若分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
在一个实施例中,如图9所示,最优色彩校正矩阵计算模块620包括:
像素获取模块621,用于获取原始图像中的像素;
像素转换模块622,用于将原始图像中的像素从RGB颜色空间转换至CIE颜色空间;
粒子群参数设置模块623,用于设置粒子群的总数量、粒子群中每个粒子的初始速度及初始位置;
色差和色差均值计算模块624,用于将CIE颜色空间的像素、粒子群中每个粒子的初始速度及初始位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值;
自身历史最佳位置更新模块625,用于当粒子的色差中的最大值小于设定阈值,则获取粒子的色差均值,判断色差均值是否为自身历史最佳,若是则将粒子的当前位置更新为自身历史最佳位置;
全局历史最佳位置模块626,用于从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置;
粒子速度和位置更新模块627,用于根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新;
最优色彩校正矩阵输出模块628,用于将更新后的粒子的速度和位置作为相邻的下一回的初始速度和初始位置进行迭代计算每个粒子的色差和色差均值,若判断获取的粒子的色差均值为自身历史最佳,则将粒子的当前位置更新为自身历史最佳位置,再从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置,直至迭代次数达到迭代阈值,则输出最终的全局历史最佳位置作为原始图像的最优色彩校正矩阵。
在一个实施例中,还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现以下步骤:
采集标准色卡的原始图像;获取原始图像中的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵;将最优色彩校正矩阵导入预设图像处理流程中;按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像。
在一个实施例中,上述程序被处理器执行时还实现以下步骤:在获取原始图像中的像素的步骤之前,还包括:对原始图像进行白平衡处理和去马赛克处理。
在一个实施例中,上述程序被处理器执行时还实现以下步骤:在生成标准色卡图像的步骤之后,还包括:对标准色卡图像进行色彩还原准确性分析,若分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
在一个实施例中,上述程序被处理器执行时还实现以下步骤:上述程序被处理器执行时还实现以下步骤:在对标准色卡图像进行色彩还原准确性分析之后,还包括:对标准色卡图像进行色彩还原准确性分析,若分析出色彩还原准确性不满足预设条件,则再次获取原始图像的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵;将最优色彩校正矩阵导入预设图像处理流程中;按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像;对标准色卡图像进行色彩还原准确性分析,直到分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
在一个实施例中,上述程序被处理器执行时还实现以下步骤:获取原始图像中的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵,包括:获取原始图像中的像素;将原始图像中的像素从RGB颜色空间转换至CIE颜色空间;设置粒子群的总数量、粒子群中每个粒子的初始速度及初始位置;将CIE颜色空间的像素、粒子群中每个粒子的初始速度及初始位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值;当粒子的色差中的最大值小于设定阈值,则获取粒子的色差均值,判断色差均值是否为自身历史最佳,若是则将粒子的当前位置更新为自身历史最佳位置;从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置;根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新;将更新后的粒子的速度和位置作为相邻的下一回的初始速度和初始位置进行迭代计算每个粒子的色差和色差均值,若判断获取的粒子的色差均值为自身历史最佳,则将粒子的当前位置更新为自身历史最佳位置,再从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置,直至迭代次数达到迭代阈值,则输出最终的全 局历史最佳位置作为原始图像的最优色彩校正矩阵。
在一个实施例中,上述程序被处理器执行时还实现以下步骤:在通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值之后,还包括:当粒子的色差中的最大值大于设定阈值,则从粒子群中剔除粒子;随机产生新的粒子替代粒子,为新的粒子设置初始速度及初始位置,返回根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新的步骤。
在一个实施例中,上述程序被处理器执行时还实现以下步骤:预设图像处理流程包括:从图像传感器获取标准色卡的原始图像;对原始图像进行白平衡及去马赛克处理;对经过白平衡及去马赛克处理后的图像进行色彩校正;对经过色彩校正后的图像进行锐化及降噪;将经过锐化及降噪后的图像输出。
在一个实施例中,还提供了一种计算机设备,该计算机设备包括存储器,处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时实现以下步骤:
采集标准色卡的原始图像;获取原始图像中的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵;将最优色彩校正矩阵导入预设图像处理流程中;按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像。
在一个实施例中,上述处理器执行计算机程序时还实现以下步骤:在获取原始图像中的像素的步骤之前,还包括:对原始图像进行白平衡处理和去马赛克处理。
在一个实施例中,上述处理器执行计算机程序时还实现以下步骤:在生成标准色卡图像的步骤之后,还包括:对标准色卡图像进行色彩还原准确性分析,若分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
在一个实施例中,上述处理器执行计算机程序时还实现以下步骤:上述程序被处理器执行时还实现以下步骤:在对标准色卡图像进行色彩还原准确性分析之后,还包括:对标准色卡图像进行色彩还原准确性分析,若分析出色彩还 原准确性不满足预设条件,则再次获取原始图像的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵;将最优色彩校正矩阵导入预设图像处理流程中;按照预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用最优色彩校正矩阵对采集到的图像进行色彩校正,生成标准色卡图像;对标准色卡图像进行色彩还原准确性分析,直到分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
在一个实施例中,上述处理器执行计算机程序时还实现以下步骤:获取原始图像中的像素,根据粒子群算法对像素进行计算得到原始图像的最优色彩校正矩阵,包括:获取原始图像中的像素;将原始图像中的像素从RGB颜色空间转换至CIE颜色空间;设置粒子群的总数量、粒子群中每个粒子的初始速度及初始位置;将CIE颜色空间的像素、粒子群中每个粒子的初始速度及初始位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值;当粒子的色差中的最大值小于设定阈值,则获取粒子的色差均值,判断色差均值是否为自身历史最佳,若是则将粒子的当前位置更新为自身历史最佳位置;从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置;根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新;将更新后的粒子的速度和位置作为相邻的下一回的初始速度和初始位置进行迭代计算每个粒子的色差和色差均值,若判断获取的粒子的色差均值为自身历史最佳,则将粒子的当前位置更新为自身历史最佳位置,再从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将粒子的自身历史最佳位置更新为本轮的全局历史最佳位置,直至迭代次数达到迭代阈值,则输出最终的全局历史最佳位置作为原始图像的最优色彩校正矩阵。
在一个实施例中,上述处理器执行计算机程序时还实现以下步骤:在通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值之后,还包括:当粒子的色差中的最大值大于设定阈值,则从粒子群中剔除粒子;随机产生新的粒子替代粒子,为新的粒子设置初始速度及初始位置,返回根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式 对粒子群中所有粒子的位置进行更新的步骤。
在一个实施例中,上述处理器执行计算机程序时还实现以下步骤:预设图像处理流程包括:从图像传感器获取标准色卡的原始图像;对原始图像进行白平衡及去马赛克处理;对经过白平衡及去马赛克处理后的图像进行色彩校正;对经过色彩校正后的图像进行锐化及降噪;将经过锐化及降噪后的图像输出。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,程序可存储于一非易失性的计算机可读取存储介质中,如本发明实施例中,该程序可存储于计算机系统的存储介质中,并被该计算机系统中的至少一个处理器执行,以实现包括如上述各方法的实施例的流程。其中,的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。

Claims (16)

  1. 一种图像色彩校正方法,所述方法包括:
    采集标准色卡的原始图像;
    获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;
    将所述最优色彩校正矩阵导入预设图像处理流程中;
    按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像。
  2. 根据权利要求1所述的方法,其特征在于,在获取所述原始图像中的像素的步骤之前,还包括:
    对所述原始图像进行白平衡处理和去马赛克处理。
  3. 根据权利要求1所述的方法,其特征在于,在所述生成标准色卡图像的步骤之后,还包括:
    对所述标准色卡图像进行色彩还原准确性分析,若分析出所述色彩还原准确性满足预设条件,则图像色彩校正通过。
  4. 根据权利要求3所述的方法,其特征在于,在所述对所述标准色卡图像进行色彩还原准确性分析之后,还包括:
    对所述标准色卡图像进行色彩还原准确性分析,若分析出所述色彩还原准确性不满足预设条件,则再次获取原始图像的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;将所述最优色彩校正矩阵导入预设图像处理流程中;按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像;对所述标准色卡图像进行色彩还原准确性分析,直到分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
  5. 根据权利要求1所述的方法,其特征在于,所述获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正 矩阵,包括:
    获取所述原始图像中的像素;
    将所述原始图像中的像素从RGB颜色空间转换至CIE颜色空间;
    设置粒子群的总数量、粒子群中每个粒子的初始速度及初始位置;
    将CIE颜色空间的像素、粒子群中每个粒子的初始速度及初始位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值;
    当所述粒子的色差中的最大值小于设定阈值,则获取所述粒子的色差均值,判断所述色差均值是否为自身历史最佳,若是则将所述粒子的当前位置更新为自身历史最佳位置;
    从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将所述粒子的自身历史最佳位置更新为本轮的全局历史最佳位置;
    根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新;
    将所述更新后的粒子的速度和位置作为相邻的下一回的初始速度和初始位置进行迭代计算每个粒子的色差和色差均值,若判断获取的所述粒子的色差均值为自身历史最佳,则将所述粒子的当前位置更新为自身历史最佳位置,再从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将所述粒子的自身历史最佳位置更新为本轮的全局历史最佳位置,直至迭代次数达到迭代阈值,则输出最终的全局历史最佳位置作为所述原始图像的最优色彩校正矩阵。
  6. 根据权利要求5所述的方法,其特征在于,在通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值之后,还包括:
    当所述粒子的色差中的最大值大于设定阈值,则从粒子群中剔除所述粒子;
    随机产生新的粒子替代所述粒子,为所述新的粒子设置初始速度及初始位置,返回根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新的步骤。
  7. 根据权利要求1所述的方法,其特征在于,所述预设图像处理流程包括:
    从图像传感器获取标准色卡的原始图像;
    对所述原始图像进行白平衡及去马赛克处理;
    对经过白平衡及去马赛克处理后的图像进行色彩校正;
    对经过色彩校正后的图像进行锐化及降噪;
    将经过锐化及降噪后的图像输出。
  8. 一种图像色彩校正装置,其特征在于,所述装置包括:
    标准色卡原始图像采集模块,用于采集标准色卡的原始图像;
    最优色彩校正矩阵计算模块,用于获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;
    导入模块,用于将所述最优色彩校正矩阵导入预设图像处理流程中;
    色彩校正模块,用于按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像。
  9. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现如权1至7中任一项所述的图像色彩校正方法。
  10. 一种计算机设备,所述计算机设备包括存储器,处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时,使得所述处理器执行以下步骤:
    采集标准色卡的原始图像;
    获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;
    将所述最优色彩校正矩阵导入预设图像处理流程中;
    按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像。
  11. 根据权利要求10所述的计算机设备,其特征在于,在获取所述原始图像中的像素的步骤之前,所述计算机程序还使得所述处理器执行:
    对所述原始图像进行白平衡处理和去马赛克处理。
  12. 根据权利要求10所述的计算机设备,其特征在于,在所述生成标准色卡图像的步骤之后,所述计算机程序还使得所述处理器执行:
    对所述标准色卡图像进行色彩还原准确性分析,若分析出所述色彩还原准确性满足预设条件,则图像色彩校正通过。
  13. 根据权利要求12所述的计算机设备,其特征在于,在所述对所述标准色卡图像进行色彩还原准确性分析之后,所述计算机程序还使得所述处理器执行:
    对所述标准色卡图像进行色彩还原准确性分析,若分析出所述色彩还原准确性不满足预设条件,则再次获取原始图像的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵;将所述最优色彩校正矩阵导入预设图像处理流程中;按照所述预设图像处理流程采集标准色卡的图像并对采集到的图像进行处理,在处理过程中利用所述最优色彩校正矩阵对所述采集到的图像进行色彩校正,生成标准色卡图像;对所述标准色卡图像进行色彩还原准确性分析,直到分析出色彩还原准确性满足预设条件,则图像色彩校正通过。
  14. 根据权利要求10所述的计算机设备,其特征在于,所述获取所述原始图像中的像素,根据粒子群算法对所述像素进行计算得到所述原始图像的最优色彩校正矩阵,包括:
    获取所述原始图像中的像素;
    将所述原始图像中的像素从RGB颜色空间转换至CIE颜色空间;
    设置粒子群的总数量、粒子群中每个粒子的初始速度及初始位置;
    将CIE颜色空间的像素、粒子群中每个粒子的初始速度及初始位置,通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值;
    当所述粒子的色差中的最大值小于设定阈值,则获取所述粒子的色差均值,判断所述色差均值是否为自身历史最佳,若是则将所述粒子的当前位置更新为自身历史最佳位置;
    从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将所述粒子的自身历史最佳位置更新为本轮的全局历史最佳位置;
    根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新;
    将所述更新后的粒子的速度和位置作为相邻的下一回的初始速度和初始位置进行迭代计算每个粒子的色差和色差均值,若判断获取的所述粒子的色差均值为自身历史最佳,则将所述粒子的当前位置更新为自身历史最佳位置,再从粒子群中筛选出全局历史最佳的色差均值所对应的粒子,将所述粒子的自身历史最佳位置更新为本轮的全局历史最佳位置,直至迭代次数达到迭代阈值,则输出最终的全局历史最佳位置作为所述原始图像的最优色彩校正矩阵。
  15. 根据权利要求14所述的计算机设备,其特征在于,在通过粒子群算法公式计算出粒子群中每个粒子的色差和每个粒子的色差均值之后,所述计算机程序还使得所述处理器执行:
    当所述粒子的色差中的最大值大于设定阈值,则从粒子群中剔除所述粒子;
    随机产生新的粒子替代所述粒子,为所述新的粒子设置初始速度及初始位置,返回根据粒子速度更新公式对粒子群中所有粒子的速度进行更新,根据粒子位置更新公式对粒子群中所有粒子的位置进行更新的步骤。
  16. 根据权利要求10所述的计算机设备,其特征在于,所述预设图像处理流程包括:
    从图像传感器获取标准色卡的原始图像;
    对所述原始图像进行白平衡及去马赛克处理;
    对经过白平衡及去马赛克处理后的图像进行色彩校正;
    对经过色彩校正后的图像进行锐化及降噪;
    将经过锐化及降噪后的图像输出。
PCT/CN2018/095848 2017-07-17 2018-07-16 图像色彩校正方法、装置、存储介质和计算机设备 WO2019015553A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710582472.6 2017-07-17
CN201710582472.6A CN109274948B (zh) 2017-07-17 2017-07-17 图像色彩校正方法、装置、存储介质和计算机设备

Publications (1)

Publication Number Publication Date
WO2019015553A1 true WO2019015553A1 (zh) 2019-01-24

Family

ID=65015447

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/095848 WO2019015553A1 (zh) 2017-07-17 2018-07-16 图像色彩校正方法、装置、存储介质和计算机设备

Country Status (2)

Country Link
CN (1) CN109274948B (zh)
WO (1) WO2019015553A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110866877A (zh) * 2019-11-12 2020-03-06 Oppo广东移动通信有限公司 基于约束粒子群算法的色彩校正方法、装置及终端设备
CN118570099A (zh) * 2024-08-02 2024-08-30 中国人民解放军海军青岛特勤疗养中心 基于图像增强的术后康复效果监测系统

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109903256B (zh) 2019-03-07 2021-08-20 京东方科技集团股份有限公司 模型训练方法、色差校正方法、装置、介质和电子设备
CN111212277B (zh) * 2020-01-12 2021-01-15 上海明殿文化传播有限公司 智能视频数据色调调整系统及方法
CN112950485B (zh) * 2020-11-27 2023-11-03 京东科技控股股份有限公司 色卡及图像色差处理方法、装置、电子设备和存储介质
CN112839216B (zh) * 2021-01-13 2022-07-19 合肥埃科光电科技股份有限公司 一种图像色彩校正方法及装置
CN113327282A (zh) * 2021-04-12 2021-08-31 厦门大学 一种办公转椅打孔位置与连接点识别方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1568016A (zh) * 2003-06-17 2005-01-19 明基电通股份有限公司 影像形成装置的色彩修正装置及方法
CN103079076A (zh) * 2013-01-22 2013-05-01 无锡鸿图微电子技术有限公司 自适应伽玛校正曲线的色彩校正矩阵的产生方法及装置
CN104217409A (zh) * 2014-09-30 2014-12-17 南京汇川工业视觉技术开发有限公司 一种基于模拟退火最优化算法的图像色彩校正方法

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104219511A (zh) * 2013-06-03 2014-12-17 鸿富锦精密工业(深圳)有限公司 色彩校正系统及方法
CN105827897B (zh) * 2015-11-16 2019-06-07 维沃移动通信有限公司 调整卡制作方法、系统、调试色彩校正矩阵方法及设备

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1568016A (zh) * 2003-06-17 2005-01-19 明基电通股份有限公司 影像形成装置的色彩修正装置及方法
CN103079076A (zh) * 2013-01-22 2013-05-01 无锡鸿图微电子技术有限公司 自适应伽玛校正曲线的色彩校正矩阵的产生方法及装置
CN104217409A (zh) * 2014-09-30 2014-12-17 南京汇川工业视觉技术开发有限公司 一种基于模拟退火最优化算法的图像色彩校正方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CHEN, YAJUN ET AL.: "A Colorimetric Characterization Method for Display Device Based on Chaotic Particle Swarm Optimization", MECHANICAL SCIENCE AND TECHNOLOGY FOR AEROSPACE ENGINEERING, vol. 34, no. 1, 15 January 2015 (2015-01-15), pages 124 - 130, ISSN: 1003-8728 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110866877A (zh) * 2019-11-12 2020-03-06 Oppo广东移动通信有限公司 基于约束粒子群算法的色彩校正方法、装置及终端设备
CN118570099A (zh) * 2024-08-02 2024-08-30 中国人民解放军海军青岛特勤疗养中心 基于图像增强的术后康复效果监测系统

Also Published As

Publication number Publication date
CN109274948A (zh) 2019-01-25
CN109274948B (zh) 2021-03-26

Similar Documents

Publication Publication Date Title
WO2019015553A1 (zh) 图像色彩校正方法、装置、存储介质和计算机设备
US7764319B2 (en) Image processing apparatus, image-taking system, image processing method and image processing program
US20210073957A1 (en) Image processor and method
TWI293742B (zh)
US20120287286A1 (en) Image processing device, image processing method, and program
CN104023218A (zh) 摄像装置以及图像信号处理装置
US20120044380A1 (en) Image capture with identification of illuminant
JP2008113222A (ja) 画像処理装置、撮影装置、および、これらにおける画像処理方法ならびに当該方法をコンピュータに実行させるプログラム
US11451703B2 (en) Method and system for customizing camera parameters
US8471933B2 (en) Image processing apparatus, image processing method and computer program
CN113556526B (zh) 一种基于rgbw滤光阵列的彩色夜视设备色彩增强方法
US20200228770A1 (en) Lens rolloff assisted auto white balance
JP5899894B2 (ja) 撮像装置、画像処理装置、画像処理プログラムおよび画像処理方法
JP5962169B2 (ja) デジタルカメラ、色変換プログラムおよび記録制御プログラム
JP6977483B2 (ja) 画像処理装置、画像処理方法、画像処理システムおよびプログラム
US20200228769A1 (en) Lens rolloff assisted auto white balance
WO2018209984A1 (zh) 图像处理方法和装置
CN111435986B (zh) 源图像数据库的获取方法、训练装置及电子设备
US8068146B2 (en) Opponent color detail enhancement for saturated colors
Koohestani et al. Revealing Shadows: Low-Light Image Enhancement Using Self-Calibrated Illumination
CN113989138A (zh) 一种脸部肌肤图像炎症提取并形成红区光谱的方法
CN112422940A (zh) 一种自适应颜色校正方法
WO2013114802A1 (ja) 画像処理装置及びその画像処理方法、並びにコンピュータ・プログラム、および画像処理システム
CN114375569A (zh) 处理图像的方法和相关装置
US20240087128A1 (en) Adaptive auto white balancing

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: 18835307

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: 18835307

Country of ref document: EP

Kind code of ref document: A1