Gamma curve generation method, device, equipment and medium

文档序号:170315 发布日期:2021-10-29 浏览:18次 中文

阅读说明:本技术 一种伽马曲线生成方法、装置、设备和介质 (Gamma curve generation method, device, equipment and medium ) 是由 庄宏海 周圣强 黄岗 于 2021-09-24 设计创作,主要内容包括:本申请提供了一种伽马曲线生成方法、装置、设备和介质,其中,方法包括:获取当前场景中图像的直方图,将直方图处理为亮区直方图和暗区直方图,以所包含灰度级对应的像素点数量和预设裁剪比例为依据,分别对亮区直方图和暗区直方图进行裁剪补偿处理,基于裁剪补偿处理后的亮区直方图和裁剪补偿处理后的暗区直方图,生成用于对图像进行校正的伽马曲线。本申请提供了一种伽马曲线生成方法、装置、设备和介质,可根据当前场景中图像的直方图,确定与当前场景相适应的伽马曲线,基于确定出的伽马曲线对当前场景中的图像进行校正,能够获得效果较好的图像。(The application provides a gamma curve generation method, a gamma curve generation device, gamma curve generation equipment and a medium, wherein the method comprises the following steps: the method comprises the steps of obtaining a histogram of an image in a current scene, processing the histogram into a bright area histogram and a dark area histogram, respectively carrying out cutting compensation processing on the bright area histogram and the dark area histogram according to the number of pixels corresponding to included gray levels and a preset cutting proportion, and generating a gamma curve for correcting the image based on the bright area histogram after the cutting compensation processing and the dark area histogram after the cutting compensation processing. The application provides a gamma curve generation method, a gamma curve generation device, gamma curve generation equipment and a gamma curve generation medium, wherein a gamma curve adaptive to a current scene can be determined according to a histogram of an image in the current scene, and the image in the current scene is corrected based on the determined gamma curve, so that an image with a better effect can be obtained.)

1. A gamma curve generation method, comprising:

acquiring a histogram of an image in a current scene, wherein the histogram can represent the number of pixel points of the image on a gray level;

processing the histograms into a bright area histogram and a dark area histogram, wherein the bright area histogram comprises gray levels which are all larger than a gray level threshold value, and the dark area histogram comprises gray levels which are all smaller than or equal to the gray level threshold value;

respectively carrying out cutting compensation processing on the bright area histogram and the dark area histogram according to the number of pixel points corresponding to the contained gray level and a preset cutting proportion;

and generating a gamma curve for correcting the image based on the bright area histogram after the clipping compensation processing and the dark area histogram after the clipping compensation processing.

2. The gamma curve generation method of claim 1, wherein the processing the histogram into a bright-area histogram and a dark-area histogram comprises:

preprocessing the histogram, wherein the preprocessing comprises sampling processing and/or filtering processing;

and segmenting the preprocessed histogram to obtain the bright area histogram and the dark area histogram.

3. The method of generating a gamma curve according to claim 2, wherein the segmenting the preprocessed histogram to obtain the bright-area histogram and the dark-area histogram comprises:

taking each gray level contained in the preprocessed histogram as a segmentation threshold: determining variances of a bright area histogram and a dark area histogram obtained by dividing the preprocessed histogram based on the dividing threshold value, wherein the variances are used as variances corresponding to the dividing threshold value, so as to obtain a variance corresponding to each gray level contained in the preprocessed histogram;

determining a gray level corresponding to the maximum variance in the obtained variances as the gray level threshold;

segmenting the preprocessed histogram into a bright-area histogram and a dark-area histogram based on the gray level threshold.

4. The method of claim 1, wherein the clipping compensation process is performed on the bright area histogram and the dark area histogram respectively according to the number of pixels corresponding to the included gray levels and a preset clipping ratio, and the method comprises:

taking each of the bright-area histogram and the dark-area histogram as a target histogram:

determining a cutting upper limit value corresponding to the target histogram according to the number of pixel points respectively corresponding to each gray level contained in the target histogram and a preset cutting proportion;

and performing cutting compensation processing on the target histogram according to the cutting upper limit value corresponding to the target histogram.

5. The method for generating a gamma curve according to claim 4, wherein the determining the clipping upper limit value corresponding to the target histogram according to the number of the pixel points corresponding to each gray level included in the target histogram and a preset clipping ratio comprises:

averaging the number of pixel points respectively corresponding to each gray level contained in the target histogram to obtain the average pixel number corresponding to the target histogram;

and determining a clipping upper limit value corresponding to the target histogram according to the average pixel number corresponding to the target histogram and the preset clipping proportion.

6. The method of claim 4, wherein the performing clipping compensation on the target histogram according to the clipping upper limit value corresponding to the target histogram comprises:

determining the number of clipping pixels corresponding to each gray level contained in the target histogram according to the clipping upper limit value corresponding to the target histogram and the number of pixels corresponding to each gray level contained in the target histogram;

clipping the target histogram according to the number of clipping pixels corresponding to each gray level contained in the target histogram;

determining the total number of the clipping pixels corresponding to each gray level contained in the target histogram as the total number of the clipping pixels corresponding to the target histogram;

and averagely distributing the total number of the clipping pixels corresponding to the target histogram to each gray level contained in the clipped target histogram.

7. The method of claim 4, wherein before performing clipping compensation on the bright area histogram and the dark area histogram based on the number of pixels corresponding to the included gray levels and a predetermined clipping ratio, the method further comprises:

and respectively carrying out normalization processing on the bright area histogram and the dark area histogram, and taking each histogram in the normalized bright area histogram and the normalized dark area histogram as a target histogram.

8. A gamma curve generating apparatus, comprising: the device comprises a histogram acquisition module, a histogram processing module, a histogram clipping compensation module and a gamma curve determination module;

the histogram acquisition module is used for acquiring a histogram of an image in a current scene, wherein the histogram can represent the number of pixel points of the image on a gray level;

the histogram processing module is configured to process the histogram into a bright area histogram and a dark area histogram, where gray levels included in the bright area histogram are all greater than a gray level threshold, and gray levels included in the dark area histogram are all less than or equal to the gray level threshold;

the histogram clipping compensation module is used for respectively performing clipping compensation processing on the bright area histogram and the dark area histogram according to the number of pixel points corresponding to the included gray level and a preset clipping proportion;

and the gamma curve determining module is used for generating a gamma curve for correcting the image based on the bright area histogram after the clipping compensation processing and the dark area histogram after the clipping compensation processing.

9. A gamma curve generating device characterized by comprising a memory and a processor;

the memory is used for storing programs;

the processor is used for executing the program and realizing the steps of the gamma curve generation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the gamma curve generation method according to any one of claims 1 to 7.

Technical Field

The present application relates to the field of image processing technologies, and in particular, to a gamma curve generation method, apparatus, device, and medium.

Background

When the camera is applied to different scenes, the camera can keep better image performance in different scenes, and subsequent image analysis is facilitated. For example, when the monitoring camera is applied to a long-aisle environment, the brightness of a darker scene in an image needs to be improved to obtain more image details; when the camera is applied to a street shop scene, the overexposure area needs to be suppressed while the brightness of the dark-area scene is improved, so that the image contrast is increased.

At present, in order to keep a camera in a better image performance in different scenes, one or more gamma curves are often preset inside the camera, but the preset gamma curve is usually a fixed curve and is only suitable for the scene with a fixed environment. In addition, although the existing solutions, such as the patent publication No. CN104484864A, can implement local image enhancement, there are some defects in the algorithm, and the image processing effect is yet to be further improved.

Disclosure of Invention

In view of this, the present application provides a gamma curve generating method, apparatus, device and medium to improve an image processing effect, and the technical scheme is as follows:

a gamma curve generation method, comprising:

acquiring a histogram of an image in a current scene, wherein the histogram can represent the number of pixel points of the image on a gray level;

processing the histogram into a bright area histogram and a dark area histogram, wherein the gray levels contained in the bright area histogram are all larger than a gray level threshold value, and the gray levels contained in the dark area histogram are all smaller than or equal to the gray level threshold value;

respectively carrying out cutting compensation processing on the histogram of the bright area and the histogram of the dark area according to the number of the pixel points corresponding to the contained gray level and a preset cutting proportion;

and generating a gamma curve for correcting the image based on the bright area histogram after the clipping compensation processing and the dark area histogram after the clipping compensation processing.

Optionally, processing the histogram into a bright-area histogram and a dark-area histogram includes:

preprocessing the histogram, wherein the preprocessing comprises sampling processing and/or filtering processing;

and segmenting the preprocessed histogram to obtain a bright area histogram and a dark area histogram.

Optionally, segmenting the preprocessed histogram to obtain a bright-area histogram and a dark-area histogram, including:

taking each gray level contained in the preprocessed histogram as a segmentation threshold: determining variances of a bright area histogram and a dark area histogram obtained by dividing the preprocessed histogram based on a division threshold value, wherein the variances are used as variances corresponding to the division threshold value, so as to obtain a variance corresponding to each gray level contained in the preprocessed histogram;

determining the gray level corresponding to the maximum variance in the obtained variances as a gray level threshold;

the pre-processed histogram is partitioned into a bright-area histogram and a dark-area histogram based on a gray level threshold.

Optionally, based on the number of pixels corresponding to the included gray levels and a preset clipping ratio, the clipping compensation processing is performed on the bright area histogram and the dark area histogram respectively, including:

taking each of the bright-area histogram and the dark-area histogram as a target histogram:

determining a cutting upper limit value corresponding to the target histogram according to the number of pixel points respectively corresponding to each gray level contained in the target histogram and a preset cutting proportion;

and performing cutting compensation processing on the target histogram according to the cutting upper limit value corresponding to the target histogram.

Optionally, determining a clipping upper limit value corresponding to the target histogram according to the number of pixel points corresponding to each gray level included in the target histogram and a preset clipping ratio, where the clipping upper limit value includes:

averaging the number of pixel points respectively corresponding to each gray level contained in the target histogram to obtain the average pixel number corresponding to the target histogram;

and determining a clipping upper limit value corresponding to the target histogram according to the average pixel number corresponding to the target histogram and a preset clipping proportion.

Optionally, performing clipping compensation processing on the target histogram according to the clipping upper limit value corresponding to the target histogram, including:

determining the number of clipping pixels corresponding to each gray level contained in the target histogram according to the clipping upper limit value corresponding to the target histogram and the number of pixels corresponding to each gray level contained in the target histogram;

clipping the target histogram according to the number of clipping pixels respectively corresponding to each gray level contained in the target histogram;

determining the total number of the clipping pixels corresponding to each gray level contained in the target histogram as the total number of the clipping pixels corresponding to the target histogram;

and averagely distributing the total number of the clipping pixels corresponding to the target histogram to each gray level contained in the clipped target histogram.

Optionally, before performing clipping compensation processing on the bright area histogram and the dark area histogram respectively based on the number of pixels corresponding to the included gray level and a preset clipping ratio, the method further includes:

and respectively carrying out normalization processing on the bright area histogram and the dark area histogram, and taking each histogram in the normalized bright area histogram and the normalized dark area histogram as a target histogram.

A gamma curve generating apparatus comprising: the device comprises a histogram acquisition module, a histogram processing module, a histogram clipping compensation module and a gamma curve determination module;

the histogram acquisition module is used for acquiring a histogram of an image in a current scene, wherein the histogram can represent the number of pixel points of the image on a gray level;

the histogram processing module is used for processing the histogram into a bright area histogram and a dark area histogram, wherein the gray levels contained in the bright area histogram are all larger than a gray level threshold value, and the gray levels contained in the dark area histogram are all smaller than or equal to the gray level threshold value;

the histogram clipping compensation module is used for respectively performing clipping compensation processing on the bright area histogram and the dark area histogram according to the number of pixel points corresponding to the contained gray level and a preset clipping proportion;

and the gamma curve determining module is used for generating a gamma curve for correcting the image based on the bright area histogram after the clipping compensation processing and the dark area histogram after the clipping compensation processing.

A gamma curve generating device includes a memory and a processor;

a memory for storing a program;

and a processor for executing a program to implement the steps of the gamma curve generation method as described in any one of the above.

A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the gamma curve generation method as claimed in any one of the preceding claims.

According to the technical scheme, the gamma curve generation method comprises the steps of firstly obtaining a histogram of an image in a current scene, then processing the histogram into a bright area histogram and a dark area histogram, then respectively carrying out cutting compensation processing on the bright area histogram and the dark area histogram according to the number of pixel points corresponding to included gray levels and a preset cutting proportion, and finally generating a gamma curve for correcting the image based on the bright area histogram after the cutting compensation processing and the dark area histogram after the cutting compensation processing. According to the gamma curve generation method, threshold segmentation processing and cutting compensation processing can be conducted on the histogram of the image in the current scene, so that a gamma curve adaptive to the current scene is obtained, the image in the current scene is corrected based on the determined gamma curve, and the image with a good effect can be obtained.

Drawings

In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.

Fig. 1 is a schematic flowchart of a gamma curve generation method according to an embodiment of the present disclosure;

FIG. 2 is a schematic diagram of an original image and a corrected image provided by an embodiment of the present application;

fig. 3 is a schematic structural diagram of a gamma curve generating device according to an embodiment of the present disclosure;

fig. 4 is a block diagram of a hardware structure of a gamma curve generating device according to an embodiment of the present disclosure.

Detailed Description

The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

In view of the problems in the prior art, the present inventors have conducted intensive studies, and finally propose a gamma curve generation method, which can process a histogram in a current scene into a bright area histogram and a dark area histogram, then perform clipping compensation on the bright area histogram and the dark area histogram, and then generate a gamma curve based on the bright area histogram after the clipping compensation and the dark area histogram after the clipping compensation, where the gamma curve can be used to correct an image in the current scene, and can better ensure the contrast of the image in the current scene, and can improve the detail information of the image, so that the corrected image has a better effect. The gamma curve generation method provided by the application can be applied to target equipment capable of shooting images or videos, such as monitoring cameras and other equipment. The following embodiments describe the method for generating a gamma curve in detail.

Referring to fig. 1, a flow chart of a gamma curve generation method according to an embodiment of the present disclosure is shown, where the gamma curve generation method includes:

and step S101, acquiring a histogram of the image in the current scene.

The histogram can represent the number of pixels of the image on the gray level.

Here, the current scene refers to a scene in which the target device is currently located.

There may be various methods for obtaining the histogram of the image in this step, and the following two methods are provided herein, but not limited thereto.

The first method comprises the following steps: after the target device shoots the image, histogram statistics is carried out on the image shot in real time to obtain a histogram of the image.

The second method comprises the following steps: the target device may include a System On Chip (SOC), and the histogram of the image may be obtained through a statistical module interface of the SOC.

Step S102, the histogram is processed into a bright area histogram and a dark area histogram.

In order to better correct the regions, the histogram may be processed into a bright region histogram and a dark region histogram, and then the bright region histogram and the dark region histogram are processed respectively.

In this step, the histogram may be processed into a bright area histogram and a dark area histogram based on a gray level threshold, where the bright area histogram includes gray levels greater than the gray level threshold and the dark area histogram includes gray levels less than or equal to the gray level threshold.

And step S103, respectively carrying out cutting compensation processing on the bright area histogram and the dark area histogram according to the number of pixel points corresponding to the included gray level and a preset cutting proportion.

In this step, the clipping proportion may be preset, and then the clipping compensation process may be performed on the bright area histogram and the dark area histogram, respectively, based on the number of pixels corresponding to the included gray level and the preset clipping proportion, that is, the clipping compensation process may be performed on the bright area histogram and the dark area histogram, respectively, and then the compensation process may be performed. The method comprises the steps of cutting a bright area histogram to eliminate an over-bright area in an image as much as possible, cutting a dark area histogram to eliminate an over-dark area in the image as much as possible, and compensating the bright area histogram and the dark area histogram to compensate fuzzy areas in the image and improve detailed information of the image.

And step S104, generating a gamma curve for correcting the image based on the bright area histogram after the clipping compensation processing and the dark area histogram after the clipping compensation processing.

In this step, the bright area histogram after the clipping compensation process and the dark area histogram after the clipping compensation process may be merged, and then the merged histogram may be transformed to obtain the gamma curve. Here, a method of generating a gamma curve based on the merged histogram is a related art and is not specifically described here.

According to the gamma curve generation method, firstly, a histogram of an image in a current scene is obtained, then the histogram is processed into a bright area histogram and a dark area histogram, then the bright area histogram and the dark area histogram are respectively subjected to cutting compensation processing according to the number of pixel points corresponding to included gray levels and a preset cutting proportion, and finally, a gamma curve used for correcting the image is generated based on the bright area histogram after the cutting compensation processing and the dark area histogram after the cutting compensation processing. According to the gamma curve generation method, threshold segmentation processing and cutting compensation processing can be carried out on the histogram of the image in the current scene, so that a gamma curve adaptive to the current scene is obtained, contrast correction is carried out on the image in the current scene based on the determined gamma curve, local over-dark, over-bright or fuzzy of the image can be solved more perfectly, and the image with a better effect is obtained. In addition, the gamma curve generation method provided by the application can automatically generate the gamma curve adaptive to the current scene, so that the time for debugging developers according to the field situation is saved, and the method is more friendly to the developers.

The following describes "step S102, processing the histogram into a bright area histogram and a dark area histogram" in the above embodiment.

The process of processing the histogram into a bright-area histogram and a dark-area histogram may include:

step S1021, preprocessing the histogram.

Wherein the preprocessing comprises sampling processing and/or filtering processing. Preferably, the histogram may be upsampled and/or downsampled, and then the sampled histogram may be filtered.

The following describes the sampling process and the filtering process in detail.

Considering that the number of gray levels included in the histogram obtained in step S101 may not be fixed, for example, the interface of the statistical module carried by the SOC is inconsistent, the number of gray levels included in the histogram obtained may be 256, 4096, 65536, or the like, and in order to ensure the algorithm consistency in the subsequent segmentation, the present embodiment may perform upsampling processing and/or downsampling processing on the histogram to fix the number of gray levels included in the histogram to 256, for example.

In order to make the histogram smoother, embodiments may also filter the histogram, taking into account some abrupt gray levels that may appear in the acquired histogram.

Preferably, the present embodiment may perform a1 × 3 masked mean filtering on the histogram, where the corresponding filtering formula isWherein, in the step (A),the number of pixels corresponding to the filtered gray level a is represented,representing the number of pixel points corresponding to the gray level a before filtering,the weight corresponding to the gray level a is represented,representing the number of pixels corresponding to the gray level a-1 before filtering,representing the weight corresponding to gray level a-1,representing the number of pixel points corresponding to the gray level a +1 before filtering,and a represents a weight corresponding to a gray level a +1, wherein a is any gray level except the minimum gray level and the maximum gray level in each gray level contained in the histogram before filtering.

Note that the above-described 1 × 3 mask mean filtering is an optimum mode, and in addition to the 1 × 3 mask mean filtering, 1 × 5 mask mean filtering, 1 × 7 mask mean filtering, and the like may be used.

It should be noted that, the present embodiment does not limit the weight, and the weight may be determined according to actual situations, for example, the weight may be determined according to actual situationsRespectively set to 1, 5, 1.

Step S1022, the preprocessed histogram is segmented to obtain a bright area histogram and a dark area histogram.

Specifically, the process of segmenting the preprocessed histogram to obtain the bright-area histogram and the dark-area histogram may include:

step a1, taking each gray level contained in the preprocessed histogram as a segmentation threshold: and determining the variance of the bright area histogram and the dark area histogram obtained by dividing the preprocessed histogram based on the dividing threshold value as the variance corresponding to the dividing threshold value so as to obtain the variance corresponding to each gray level contained in the preprocessed histogram.

Optionally, the specific implementation process of step a1 may include:

a1-1, determining a bright area probability density according to the total number of pixels corresponding to the gray level greater than the segmentation threshold and the total number of pixels contained in the image, wherein the bright area probability density is used as the bright area probability density corresponding to the segmentation threshold, and determining a dark area probability density according to the total number of pixels corresponding to the gray level less than or equal to the segmentation threshold and the total number of pixels contained in the image, and the dark area probability density is used as the bright area probability density corresponding to the segmentation threshold; and obtaining the bright area probability density and the dark area probability density corresponding to each gray level contained in the preprocessed histogram.

Assume that the image in the current scene has L gray levels [1,2, …, L]The number of pixels of gray level i isThen the total number of pixels isThe probability of a pixel point of gray level i is

Assuming that the gray level k is the segmentation threshold, the probability density of the dark region corresponding to the gray level k isThe probability density of bright areas is

A1-2, determining a bright area gray mean value as a bright area gray mean value corresponding to a segmentation threshold value according to the bright area probability density corresponding to the segmentation threshold value, the gray levels contained in the bright area histogram obtained by segmenting the preprocessed histogram based on the segmentation threshold value and the pixel point probabilities of the gray levels, determining a dark area gray mean value as a dark area gray mean value corresponding to the segmentation threshold value, and determining the gray levels contained in the dark area histogram obtained by segmenting the preprocessed histogram based on the segmentation threshold value and the pixel point probabilities of the gray levels as a dark area gray mean value corresponding to the segmentation threshold value; so as to obtain the bright area gray average value and the dark area gray average value corresponding to each gray level contained in the preprocessed histogram.

Assuming that the gray level k is the division threshold, the mean value of the gray levels in the dark area corresponding to the gray level k isMean value of bright area gray scale of

Step a1-3, determining the variance corresponding to each gray level contained in the histogram after the direct preprocessing according to the bright area probability density and the dark area probability density corresponding to each gray level contained in the histogram after the preprocessing, and the bright area gray level mean value and the dark area gray level mean value corresponding to each gray level contained in the histogram after the preprocessing.

Assuming that the gray level k is the division threshold, the variance corresponding to the gray level k is

Step a2, determining the gray level corresponding to the largest variance in the obtained variances as the gray level threshold.

Step a3, the preprocessed histogram is segmented into a bright-area histogram and a dark-area histogram based on a gray-level threshold.

Optionally, the process of "dividing the preprocessed histogram into a bright-area histogram and a dark-area histogram based on the gray-level threshold" in this step may include: and taking the histogram part of which the gray level is less than or equal to the gray level threshold value in the preprocessed histogram as a dark area histogram, and taking the histogram part of which the gray level is greater than the gray level threshold value as a bright area histogram.

In the above embodiment, "step S103, based on the number of pixels corresponding to the included gray scale and the preset clipping ratio, respectively perform clipping compensation processing on the bright area histogram and the dark area histogram" will be described below.

Taking any one of the histogram of the bright area and the histogram of the dark area as an example, a process of performing clipping compensation processing on the histogram based on the number of the pixels corresponding to the included gray level and a preset clipping proportion is given. For convenience of description, each of the bright area histogram and the dark area histogram is taken as a target histogram, and the process of performing clipping compensation on the target histogram based on the number of pixels corresponding to the included gray level and a preset clipping ratio may include:

and b1, determining the clipping upper limit value corresponding to the target histogram according to the pixel point quantity and the preset clipping proportion respectively corresponding to each gray level contained in the target histogram.

Optionally, the process of determining the clipping upper limit value corresponding to the target histogram according to the number of the pixel points respectively corresponding to each gray level included in the target histogram and the preset clipping ratio in this step may include:

step b1-1, averaging the number of the pixels respectively corresponding to each gray level contained in the target histogram to obtain the average number of the pixels corresponding to the target histogram.

For example, assuming that the target histogram includes 10 gray levels, and the sum of the pixel numbers corresponding to the 10 gray levels is 120, the average pixel number corresponding to the target histogram is 12.

And b1-2, determining a clipping upper limit value corresponding to the target histogram according to the average pixel number corresponding to the target histogram and a preset clipping proportion.

Here, the preset clipping ratio is an empirical value set on the basis of hardware parameters of the target device and subjective feeling of a person. Optionally, in this embodiment of the application, the preset clipping ratio is a value greater than 1.

Optionally, the product of the average pixel number corresponding to the target histogram and the preset clipping ratio may be used as the clipping upper limit value corresponding to the target histogram. For example, in the above example, assuming that the preset clipping ratio is 1.5, the clipping upper limit value corresponding to the target histogram is 18.

And b2, performing cutting compensation processing on the target histogram according to the cutting upper limit value corresponding to the target histogram.

Optionally, the process of performing clipping compensation processing on the target histogram according to the clipping upper limit value corresponding to the target histogram in this step may include:

and b2-1, determining the number of clipping pixels corresponding to each gray level contained in the target histogram according to the clipping upper limit value corresponding to the target histogram and the number of pixel points corresponding to each gray level contained in the target histogram.

In this step, for each gray level in each gray level included in the target histogram, if the number of pixels corresponding to the gray level is greater than the clipping upper limit value, the difference between the number of pixels corresponding to the gray level and the clipping upper limit value is used as the number of clipping pixels corresponding to the gray level.

For example, if the number of pixels corresponding to one gray level included in the target histogram is 100 and the clipping upper limit value is 80, the number of clipping pixels corresponding to the gray level is 20.

And b2-2, clipping the target histogram according to the number of clipping pixels corresponding to each gray level contained in the target histogram.

For example, in the above example, after the target histogram is clipped, the number of pixels corresponding to the gray level becomes 80.

And b2-3, determining the total number of the clipping pixels corresponding to each gray level contained in the target histogram as the total number of the clipping pixels corresponding to the target histogram.

And b2-4, averagely distributing the total number of the clipping pixels corresponding to the target histogram to each gray level contained in the clipped target histogram.

For example, assuming that the total number of clipped pixels corresponding to the target histogram is 100, and the clipped target histogram includes 20 gray levels in total, 100 may be equally distributed to 20 gray levels, that is, the number of pixels corresponding to each gray level is increased by 5.

It will be understood by those skilled in the art that the gamma curve is converted from a normalized histogram, and therefore, a histogram normalization process flow is required before the above-mentioned "step S104, generating a gamma curve for correcting an image based on the bright-area histogram after the clipping compensation process and the dark-area histogram after the clipping compensation process". Here, the process of normalizing the histogram includes: determining the probability density corresponding to each gray level included in the histogram, and replacing the number of pixels corresponding to the corresponding gray level with the probability density to obtain a normalized histogram, wherein the formula for calculating the probability density corresponding to a gray level may refer to the description in step a1, and will not be described herein again.

In an optional embodiment, before performing the clipping compensation processing on the bright area histogram and the dark area histogram respectively based on the number of pixels corresponding to the included gray level and the preset clipping ratio in step S103, the bright area histogram and the dark area histogram are normalized respectively, so that in this embodiment, each of the normalized bright area histogram and the normalized dark area histogram is used as a target histogram, then the clipping compensation processing is performed on the target histogram based on the number of pixels corresponding to the included gray level and the preset clipping ratio, and finally, a gamma curve for correcting the image is generated based on the clipped compensated bright area histogram and the clipped compensated dark area histogram.

In another optional embodiment, after the step S103, based on the number of pixels corresponding to the included gray levels and the preset clipping ratio, respectively perform clipping compensation processing on the bright area histogram and the dark area histogram, respectively perform normalization processing on the bright area histogram after the clipping compensation processing and the dark area histogram after the clipping compensation processing, so that the gamma curve for correcting the image may be generated based on the normalized bright area histogram and the normalized dark area histogram.

In summary, the gamma curve provided by the embodiment of the present application is used to correct the image in the current scene, and the corrected image has higher contrast, more detail information and better effect compared with the original image, and specifically, refer to the effect diagram shown in fig. 2.

Referring to fig. 2, a schematic diagram of an original image and a corrected image provided in an embodiment of the present application is shown, where the original image on the left side in (a) and (b) of fig. 2 is an image in a current scene, and the corrected image on the right side is an image obtained by correcting the original image based on a gamma curve provided in the embodiment of the present application, and it can be seen that the effect of the corrected image on the right side is better than that of the original image on the left side.

The embodiment of the present application further provides a gamma curve generating device, which is described below, and the gamma curve generating device described below and the gamma curve generating method described above may be referred to in correspondence with each other.

Referring to fig. 3, a schematic structural diagram of a gamma curve generating device according to an embodiment of the present application is shown, and as shown in fig. 3, the gamma curve generating device may include: a histogram acquisition module 301, a histogram processing module 302, a histogram clipping compensation module 303, and a gamma curve determination module 304.

The histogram obtaining module 301 is configured to obtain a histogram of an image in a current scene, where the histogram can represent the number of pixels of the image on a gray level.

The histogram processing module 302 is configured to process the histogram into a bright area histogram and a dark area histogram, where gray levels included in the bright area histogram are all greater than a gray level threshold, and gray levels included in the dark area histogram are all less than or equal to the gray level threshold.

And the histogram clipping compensation module 303 is configured to perform clipping compensation processing on the bright area histogram and the dark area histogram respectively according to the number of pixels corresponding to the included gray level and a preset clipping ratio.

And a gamma curve determining module 304, configured to generate a gamma curve for correcting the image based on the bright area histogram after the clipping compensation process and the dark area histogram after the clipping compensation process.

The gamma curve generation device provided by the application firstly obtains a histogram of an image in a current scene, then processes the histogram into a bright area histogram and a dark area histogram, then respectively cuts and compensates the bright area histogram and the dark area histogram according to the number of pixels corresponding to included gray levels and a preset cutting proportion, and finally generates a gamma curve for correcting the image based on the bright area histogram after cutting and compensating and the dark area histogram after cutting and compensating. The gamma curve generation device provided by the application can perform threshold segmentation processing and cutting compensation processing on the histogram of the image in the current scene, so that a gamma curve adaptive to the current scene is obtained, contrast correction is performed on the image in the current scene based on the determined gamma curve, local over-dark or over-bright or fuzzy of the image can be solved more perfectly, and the image with better effect is obtained. Moreover, the gamma curve generating device provided by the application can automatically generate the gamma curve adaptive to the current scene, so that the time for debugging developers according to the field situation is saved, and the device is more friendly to the developers.

In a possible implementation manner, the histogram processing module 302 may include: a preprocessing module and a histogram segmentation module.

The preprocessing module is used for preprocessing the histogram, wherein the preprocessing includes sampling processing and/or filtering processing.

And the histogram segmentation module is used for segmenting the preprocessed histogram to obtain a bright area histogram and a dark area histogram.

In a possible implementation manner, the histogram segmentation module may include: a variance determination module, a gray level threshold determination module and a histogram segmentation sub-module.

The variance determining module is configured to use each gray level included in the preprocessed histogram as a segmentation threshold: and determining the variance of the bright area histogram and the dark area histogram obtained by dividing the preprocessed histogram based on the dividing threshold value as the variance corresponding to the dividing threshold value so as to obtain the variance corresponding to each gray level contained in the preprocessed histogram.

And the gray level threshold value determining module is used for determining the gray level corresponding to the maximum variance in the obtained variances as the gray level threshold value.

And the histogram segmentation sub-module is used for segmenting the preprocessed histogram into a bright area histogram and a dark area histogram based on the gray level threshold value.

In a possible implementation manner, the histogram clipping compensation module 303 may include: the device comprises a target histogram determining module, a clipping upper limit value determining module and a clipping compensation processing module.

And the target histogram determination module is used for taking each histogram in the bright area histogram and the dark area histogram as a target histogram.

And the cutting upper limit value determining module is used for determining the cutting upper limit value corresponding to the target histogram according to the pixel point quantity and the preset cutting proportion respectively corresponding to each gray level contained in the target histogram.

And the cutting compensation processing module is used for performing cutting compensation processing on the target histogram according to the cutting upper limit value corresponding to the target histogram.

In a possible implementation manner, the clipping upper limit value determining module may include: an average pixel number determining module and a clipping upper limit value determining submodule.

The average pixel number determining module is used for averaging the number of the pixels respectively corresponding to each gray level included in the target histogram to obtain the average pixel number corresponding to the target histogram.

And the clipping upper limit value determining submodule is used for determining the clipping upper limit value corresponding to the target histogram according to the average pixel number corresponding to the target histogram and the preset clipping proportion.

In a possible implementation manner, the clipping compensation processing module may include: the device comprises a clipping pixel number determining module, a pixel number clipping module, a clipping pixel total number determining module and a pixel number compensating module.

The system comprises a target histogram, a clipping pixel number determining module and a processing module, wherein the clipping pixel number determining module is used for determining the clipping pixel number corresponding to each gray level contained in the target histogram according to the clipping upper limit value corresponding to the target histogram and the pixel number corresponding to each gray level contained in the target histogram.

And the pixel number clipping module is used for clipping the target histogram according to the clipping pixel number respectively corresponding to each gray level contained in the target histogram.

And the total clipping pixel number determining module is used for determining the total sum of the number of the clipping pixels respectively corresponding to each gray level contained in the target histogram as the total number of the clipping pixels corresponding to the target histogram.

And the pixel number compensation module is used for averagely distributing the total number of the clipping pixels corresponding to the target histogram to each gray level contained in the clipped target histogram.

In a possible implementation manner, the gamma curve generating apparatus provided in the embodiment of the present application may further include: and a normalization processing module.

Here, the normalization processing module is configured to, before the histogram clipping compensation module 303 performs the clipping compensation processing on the bright area histogram and the dark area histogram respectively based on the number of pixels corresponding to the included gray level and a preset clipping ratio, perform normalization processing on the bright area histogram and the dark area histogram respectively, and use each of the normalized bright area histogram and the normalized dark area histogram as a target histogram.

The embodiment of the application also provides gamma curve generating equipment. Alternatively, fig. 4 is a block diagram illustrating a hardware structure of the gamma curve generating apparatus, and referring to fig. 4, the hardware structure of the gamma curve generating apparatus may include: at least one processor 401, at least one communication interface 402, at least one memory 403 and at least one communication bus 404;

in the embodiment of the present application, the number of the processor 401, the communication interface 402, the memory 403 and the communication bus 404 is at least one, and the processor 401, the communication interface 402 and the memory 403 complete communication with each other through the communication bus 404;

processor 401 may be a central processing unit CPU, or an application Specific Integrated circuit asic, or one or more Integrated circuits configured to implement embodiments of the present invention, or the like;

the memory 403 may include a high-speed RAM memory, and may further include a non-volatile memory (non-volatile memory) or the like, such as at least one disk memory;

wherein the memory 403 stores a program and the processor 401 may call the program stored in the memory 403 for:

acquiring a histogram of an image in a current scene, wherein the histogram can represent the number of pixel points of the image on a gray level;

processing the histogram into a bright area histogram and a dark area histogram, wherein the gray levels contained in the bright area histogram are all larger than a gray level threshold value, and the gray levels contained in the dark area histogram are all smaller than or equal to the gray level threshold value;

respectively carrying out cutting compensation processing on the histogram of the bright area and the histogram of the dark area according to the number of the pixel points corresponding to the contained gray level and a preset cutting proportion;

and generating a gamma curve for correcting the image based on the bright area histogram after the clipping compensation processing and the dark area histogram after the clipping compensation processing.

Alternatively, the detailed function and the extended function of the program may be as described above.

The embodiment of the present application further provides a readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for generating the gamma curve is implemented.

Alternatively, the detailed function and the extended function of the program may be as described above.

Finally, it is further noted that, herein, relational terms such as, for example, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.

The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

15页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:水上水下三维点云的融合方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!