Image processing method and apparatus, electronic device, and storage medium
By segmenting the source grayscale histogram and equalizing the histogram of the infrared image, a segmented grayscale mapping curve is generated, which solves the brightness fluctuation problem caused by the target grayscale histogram after equalization and improves the readability of the infrared image. and video continuity.
Patent Information
- Application Number
- PCT/CN2023/143354
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-24
- Filing Date
- 2023-12-29
- Publication Date
- 2024-10-03
AI Technical Summary
In the prior art, using the equalized target grayscale histogram for image grayscale mapping will cause the brightness of the output image to fluctuate, affecting the readability of the infrared image and video continuity.
By obtaining the source grayscale histogram of the infrared image to be processed, segmenting the input and output grayscale intervals, performing histogram equalization processing, generating a segmented grayscale mapping curve, and performing grayscale mapping on the image based on the segmented mapping curve to ensure During the mapping process, the information of the source grayscale histogram is incorporated to suppress brightness fluctuations.
It improves the temporal continuity of infrared video images, avoids over-stretching of the background, retains high-precision temperature difference information, and significantly improves the visual effects and video quality of the image.
Smart Images

Figure CN2023143354_03102024_PF_FP_ABST
Abstract
Description
Image processing method, device, electronic device and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This disclosure claims priority to Chinese patent application number 202310324018.6, filed on March 24, 2023, and disclosed in the publication title “Image processing method, device, electronic device and storage medium,” which is incorporated herein by reference in its entirety. Technical Field
[0003] The present disclosure relates to the field of image processing technology, for example, to an image processing method, device, electronic device and storage medium. Background Art
[0004] A thermal infrared camera is a device that can visualize the infrared rays radiated by the object being measured. It generates infrared images that intuitively reflect the temperature field distribution on the surface of the object being measured. It has a wide range of applications in security monitoring, fire protection, and other aspects.
[0005] In monitored environments, the temperature range of the surface of the object being measured is relatively small. This results in a small dynamic range and low contrast in the raw image data output by thermal infrared cameras, affecting the readability of the infrared images. Contrast enhancement can be used to address this issue in the infrared image visualization process. This can be achieved through image grayscale mapping, which can include grayscale mapping based on function transformations and grayscale mapping based on histograms.
[0006] In histogram-based grayscale mapping, the output grayscale is a linear mapping of the cumulative distribution function (CDF) of the input grayscale. A grayscale mapping curve is generated based on the source grayscale histogram of the infrared image or the target grayscale histogram after equalization of the source grayscale histogram, and grayscale mapping is performed based on the grayscale mapping curve.
[0007] Summary of the Invention
[0008] The present disclosure provides an image processing method, device, electronic device and storage medium, which are used to solve the problem in the prior art that using a target grayscale histogram after equalization to perform image grayscale mapping will cause brightness fluctuation of the output image.
[0009] The present disclosure provides an image processing method, comprising:
[0010] Acquire an infrared image to be processed, and determine a source grayscale histogram of the infrared image to be processed;
[0011] Segmenting the input grayscale interval and the output grayscale interval of the grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each of the input grayscale sub-intervals;
[0012] Performing histogram equalization on the source grayscale histogram to obtain a target grayscale histogram, and determining a mapping relationship between each input grayscale subinterval and the corresponding output grayscale subinterval based on the target grayscale histogram to obtain a segmented grayscale mapping curve;
[0013] Grayscale mapping is performed on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast-enhanced image of the infrared image to be processed.
[0014] The present disclosure also provides an image processing device, comprising:
[0015] an acquisition module, configured to acquire an infrared image to be processed;
[0016] a first determining module configured to determine a source grayscale histogram of the infrared image to be processed;
[0017] a segmentation module configured to segment the input grayscale interval and the output grayscale interval of the grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each of the input grayscale sub-intervals;
[0018] an equalization module configured to perform histogram equalization processing on the source grayscale histogram to obtain a target grayscale histogram;
[0019] a second determining module configured to determine a mapping relationship between each of the input grayscale subintervals and the corresponding output grayscale subinterval based on the target grayscale histogram, to obtain a segmented grayscale mapping curve;
[0020] The mapping module is configured to perform grayscale mapping on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast-enhanced image of the infrared image to be processed.
[0021] The present disclosure also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-described image processing methods when executing the computer program.
[0022] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, which implements any of the above-mentioned image processing methods when executed by a processor.
[0023] The present disclosure also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the above-mentioned image processing methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] FIG1 is a flow chart of an image processing method according to an embodiment of the present disclosure;
[0025] FIG2 is a schematic diagram showing the principle of an image processing method provided by an embodiment of the present disclosure;
[0026] FIG3 is a second flow chart of the image processing method provided by an embodiment of the present disclosure;
[0027] FIG4 is a schematic diagram showing the principle of performing histogram equalization processing on a source grayscale histogram using an ADPHE algorithm to obtain a target grayscale histogram in an embodiment of the present disclosure;
[0028] FIG5a is a schematic diagram showing the enhancement effect of contrast enhancement of a pure road scene using the ADPHE algorithm in an embodiment of the present disclosure;
[0029] FIG5 b is a schematic diagram showing the enhancement effect of contrast enhancement on a pure road scene using the image processing method provided by the present disclosure in an embodiment of the present disclosure;
[0030] FIG6 a is a schematic diagram showing the enhancement effect of contrast enhancement of a large-area high-temperature target scene using the ADPHE algorithm in an embodiment of the present disclosure;
[0031] FIG6 b is a schematic diagram showing the enhancement effect of contrast enhancement of a large-area high-temperature target scene using the image processing method provided by the present disclosure in an embodiment of the present disclosure;
[0032] FIG6 c is a schematic diagram showing the enhancement effect of using the ADPHE algorithm to perform contrast enhancement on a large-area low-temperature background scene in an embodiment of the present disclosure;
[0033] FIG6 d is a schematic diagram showing the enhancement effect of contrast enhancement of a large-area low-temperature background scene using the image processing method provided by the present disclosure in an embodiment of the present disclosure;
[0034] FIG7 is a schematic structural diagram of an image processing device provided by an embodiment of the present disclosure;
[0035] FIG8 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0036] The technical solutions in the embodiments of the present disclosure will be described below in conjunction with the drawings in the present disclosure. The described embodiments are only part of the embodiments of the present disclosure, but not all of the embodiments.
[0037] It should be noted that the terms "first", "second", "target", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0038] The terms involved in the embodiments of the present disclosure are explained as follows:
[0039] Grayscale histogram is a statistical histogram that shows the frequency of occurrence of each grayscale in a grayscale image;
[0040] Histogram equalization is used to adjust the grayscale histogram of an image to a uniform distribution and enhance the contrast of the image.
[0041] Image contrast enhancement can be achieved based on image grayscale mapping, which can include grayscale mapping based on function transformation and grayscale mapping based on histogram. Function-based grayscale mapping can include linear function transformation, power function transformation, or logarithmic function transformation. In histogram-based grayscale mapping, the histogram equalization (HE) algorithm can be used to adjust the source grayscale histogram of the image to a uniform distribution, increase the information entropy of the grayscale distribution, and thus enhance the image contrast. However, because HE completely ignores the inherent characteristics of the grayscale distribution in the original image, it is very likely to introduce problems such as excessive stretching of the image background and loss of image details. To address this problem, a series of improved HE algorithms have been proposed, such as the adaptive histogram equalization (AHE) algorithm, the contrast-limited adaptive histogram equalization (CLAHE) algorithm, and the adaptive double plateau histogram equalization (ADPHE).
[0042] In the grayscale mapping based on the histogram, the output grayscale is a linear mapping of the Cumulative Distribution Function (CDF) of the input grayscale. The CDF is the cumulative value of the Probability Density Function (PDF) of the input grayscale. The physical meaning of the CDF is the position of the current grayscale value in the ascending grayscale values of all pixels. The grayscale mapping based on this is to reconstruct the mapped grayscale value according to the position of the current pixel's grayscale value after sorting the grayscale values of all pixels in ascending order. The expression for generating the grayscale mapping curve based on the CDF can be expressed as formula (1):
[0043] Where K = 2 N -1 represents the maximum grayscale value at the current image data bit depth N; CDF() represents the cumulative distribution function. In histogram-based grayscale mapping, the PDF of the input grayscale can be equivalently replaced by the source grayscale histogram of the image, or the target grayscale histogram generated by histogram equalization of the source grayscale histogram using any HE algorithm.
[0044] Experiments have found that when the source grayscale histogram of the input image is used to generate the grayscale mapping curve, the average brightness and median brightness of the image are relatively stable. However, when the target grayscale histogram is used to generate the grayscale mapping curve, the average brightness of the image will fluctuate greatly. The reason is that the source grayscale histogram of the input image is obtained by performing grayscale statistics on the input image, which directly reflects the true grayscale distribution of the input image. The target grayscale histogram generated based on the HE algorithm is an "ideal distribution" generated by interfering with the source grayscale histogram to increase the grayscale information entropy, and cannot reflect the true grayscale distribution of the input image. In the embodiment of the present disclosure, the phenomenon that the target grayscale histogram generated based on the HE algorithm deviates from the true grayscale distribution of the input image can be called a histogram distortion phenomenon. The cumulative distribution value in the distorted target grayscale histogram cannot accurately express the position of the input grayscale value in the ascending order of the grayscale values of all pixels, which causes the average brightness of the image to be significantly offset.
[0045] When a thermal infrared camera monitors scenes with low-temperature variations, such as objects made of the same material, the temperature differences on the surfaces are minimal or nonexistent. Using the target grayscale histogram generated by the HE algorithm to generate a grayscale mapping curve can easily lead to overstretching, making it unable to fully adapt to complex and changing monitoring environments. Furthermore, the output image brightness can vary significantly across different application scenarios. For example, in applications where the thermal infrared camera is stationary, the captured scene is typically static. If a high-temperature object is placed against a low-temperature background, the image brightness will fluctuate significantly, reducing the temporal continuity of the video and impacting visual quality. In applications where the thermal infrared camera is a PTZ camera, the pan / tilt (PTZ) camera's omnidirectional motion means the monitored scene may change constantly. In these cases, brightness variations in the output image can also degrade video quality. In these scenarios, histogram distortion occurs when generating the grayscale mapping curve using the target grayscale histogram generated by the HE algorithm, leading to significant brightness fluctuations and poor video continuity.
[0046] Based on this, an embodiment of the present disclosure provides an image processing method that can segment the input grayscale interval and the output grayscale interval during grayscale mapping based on the source grayscale histogram of the infrared image to be processed, obtaining at least two input grayscale subintervals and an output grayscale subinterval corresponding to each input grayscale subinterval. A mapping relationship between each input grayscale subinterval and the corresponding output grayscale subinterval is then determined using a target grayscale histogram obtained by performing histogram equalization on the source grayscale histogram, thereby obtaining a segmented grayscale mapping curve. Grayscale mapping is then performed on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast-enhanced image of the infrared image to be processed. In the process of grayscale mapping using the target grayscale histogram after histogram equalization, the grayscale mapping range of the target grayscale histogram is segmentedly constrained using a source grayscale histogram that can reflect the true grayscale distribution information of the infrared image to be processed. Information from the source grayscale histogram of the infrared image to be processed is incorporated into the grayscale mapping process, thereby suppressing brightness fluctuations in the output image caused by histogram distortion, thereby helping to improve the temporal continuity of infrared video images in video surveillance.
[0047] On the other hand, the image processing method provided by the embodiment of the present disclosure can also determine the low temperature difference scene according to the grayscale distribution of the infrared image to be processed, and limit the contrast stretching range of the low temperature difference scene to avoid excessive background stretching.
[0048] The image processing method of the present disclosure is described below with reference to Figures 1-6d. This image processing method can be applied to a thermal infrared camera, a server connected to the thermal infrared camera, a mobile phone, a computer, or other electronic device. The server may include a standalone server, a clustered server, or a cloud server. This image processing method can also be applied to an image processing device installed in a thermal infrared camera or in a server connected to the thermal infrared camera, a mobile phone, a computer, or other electronic device. This image processing device can be implemented using software, hardware, or a combination of both.
[0049] FIG1 exemplarily shows one of the flowcharts of the image processing method provided by an embodiment of the present disclosure. Referring to FIG1 , the image processing method may include the following steps 110 to 150 .
[0050] Step 110: Acquire the infrared image to be processed and determine the source grayscale histogram of the infrared image to be processed.
[0051] A thermal infrared camera can capture infrared images of a monitored area, generating an infrared image to be processed. The thermal infrared camera, or any electronic device connected to it, such as a server, mobile phone, or computer, can then perform grayscale statistics on each pixel in the infrared image to be processed, generating a source grayscale histogram. This source grayscale histogram is the original grayscale histogram of the infrared image to be processed and reflects the true grayscale distribution of the image to be processed.
[0052] Step 120: Segment the input grayscale interval and the output grayscale interval of the grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each input grayscale sub-interval.
[0053] Assuming that the image data bit depth is N bits, the maximum grayscale value that can be represented at this image data bit depth is K=2 N -1, the maximum grayscale value that can be represented in the source grayscale histogram generated by grayscale statistics for each pixel in the processed infrared image is K. This maximum grayscale value K is also the maximum grayscale level of the source grayscale histogram. Therefore, the grayscale that can be represented by the source grayscale histogram is k = {0, 1, ..., K}, for a total of K + 1 different grayscale values. For example, if N = 14, the source grayscale histogram can represent the frequency of occurrence of 16,384 different grayscale values. Based on this, the input grayscale interval of the grayscale mapping can be determined to be [0, K].
[0054] The output grayscale interval can be [0, K], or it can be determined based on the surveillance scenario of the infrared image being processed. For example, in a low-temperature-difference scenario, the output grayscale interval can be determined based on the grayscale distribution of the source grayscale histogram. For example, the output grayscale interval can be limited based on the maximum and minimum valid grayscale values in the source grayscale histogram to avoid excessive background stretching. Valid grayscale values are grayscale values in the source grayscale histogram with a statistical value greater than 0.
[0055] Based on the grayscale distribution information of the source grayscale histogram, the input grayscale interval and the output grayscale interval can be segmented, for example, into 2, 3, or 4 segments. During the segmentation process, the grayscale values of the segmentation points for segmenting the input grayscale interval can be used to determine the corresponding grayscale values of the segmentation points for segmenting the output grayscale interval, thereby obtaining at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each input grayscale sub-interval.
[0056] For example, the median grayscale value can be determined based on the cumulative distribution function value of the source grayscale histogram, and the input grayscale interval can be segmented using the median grayscale value as the segmentation point grayscale value; based on the cumulative distribution function value corresponding to the median grayscale value and the maximum grayscale value K, the corresponding segmentation point grayscale value for segmenting the output grayscale interval can be determined, and the output grayscale interval can be segmented using the segmentation point grayscale value.
[0057] Step 130: Perform histogram equalization processing on the source grayscale histogram to obtain a target grayscale histogram.
[0058] The source grayscale histogram may be subjected to histogram equalization processing based on, but not limited to, a histogram equalization algorithm such as HE, AHE, CLAHE, or ADPHE to obtain a target grayscale histogram.
[0059] Step 140: Determine a mapping relationship between each input grayscale sub-interval and a corresponding output grayscale sub-interval based on the target grayscale histogram to obtain a segmented grayscale mapping curve.
[0060] For each input grayscale subinterval and its corresponding output grayscale subinterval, the grayscale values of the input grayscale subinterval can be mapped to the corresponding output grayscale subinterval based on the cumulative distribution function of the target grayscale histogram, resulting in a segmented grayscale mapping curve. This allows each input grayscale subinterval to have a corresponding grayscale mapping curve, effectively limiting brightness fluctuations in the contrast-enhanced image.
[0061] Step 150: grayscale mapping is performed on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast-enhanced image of the infrared image to be processed.
[0062] For example, after obtaining the segmented grayscale mapping curve, for the grayscale value of each pixel in the infrared image to be processed, the input grayscale sub-interval to which the grayscale value belongs can be determined, and the segmented grayscale mapping curve corresponding to the input grayscale sub-interval can be used to calculate the target grayscale value after grayscale mapping. In this way, the grayscale mapping of the infrared image to be processed can be realized, and a contrast-enhanced image of the infrared image to be processed can be obtained.
[0063] For example, after obtaining the segmented grayscale mapping curve, a grayscale mapping lookup table corresponding to the input grayscale range can be generated based on the segmented grayscale mapping curve. Based on the grayscale value of each pixel in the infrared image to be processed, the target grayscale value corresponding to each pixel's grayscale value can be obtained from the grayscale mapping lookup table. A contrast-enhanced image can then be generated based on the target grayscale value. The grayscale mapping lookup table can store the correspondence between each grayscale value in the input grayscale range and the target grayscale value after grayscale mapping. This allows pixels with the same grayscale value in the infrared image to be processed to obtain the target grayscale value for all pixels by simply calculating the target grayscale value once, rather than calculating the target grayscale value for each pixel using the segmented mapping curve. This improves the efficiency of grayscale mapping.
[0064] The image processing method provided by the present disclosure can segment the input grayscale interval and the output grayscale interval during grayscale mapping based on the source grayscale histogram of the infrared image to be processed, and obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each input grayscale sub-interval. Then, a target grayscale histogram obtained by performing histogram equalization processing on the source grayscale histogram is used to determine the mapping relationship between each input grayscale sub-interval and the corresponding output grayscale sub-interval, and a segmented grayscale mapping curve is obtained. Then, grayscale mapping is performed on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast-enhanced image of the infrared image to be processed, and contrast enhancement of the infrared image to be processed is achieved through grayscale mapping. In the process of grayscale mapping using the target grayscale histogram after histogram equalization processing, the grayscale mapping range of the target grayscale histogram is segmentedly constrained by using the source grayscale histogram that can reflect the real grayscale distribution information of the infrared image to be processed. The information of the source grayscale histogram of the infrared image to be processed is incorporated into the grayscale mapping process, thereby suppressing the brightness fluctuation of the output image caused by the histogram distortion phenomenon, which is helpful to improve the temporal continuity of infrared video images in video surveillance.
[0065] Based on the image processing method of the embodiment corresponding to Figure 1, in an exemplary embodiment, the input grayscale interval and the output grayscale interval of the grayscale mapping are segmented based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each input grayscale sub-interval, which may include: based on the source grayscale histogram, determining at least one input grayscale segmentation point and a target mapping grayscale value corresponding to each input grayscale segmentation point; segmenting the input grayscale interval based on the input grayscale segmentation point to obtain at least two input grayscale sub-intervals; segmenting the output grayscale interval based on the target mapping grayscale value to obtain an output grayscale sub-interval corresponding to each input grayscale sub-interval.
[0066] In this way, the corresponding segmentation points for segmenting the output grayscale interval can be determined based on the input grayscale segmentation points for segmenting the input grayscale interval, so that after the input grayscale interval and the output grayscale interval are segmented, each input grayscale sub-interval obtained by segmentation has its corresponding output grayscale sub-interval. Based on this, the segmented grayscale mapping curve that maps each input grayscale sub-interval to its corresponding output grayscale sub-interval is determined, which can ensure that after the grayscale mapping, the idea of grayscale reconstruction according to the position of the ascending grayscale value can be reproduced.
[0067] In an exemplary embodiment, determining at least one input grayscale segmentation point and a target mapping grayscale value corresponding to each input grayscale segmentation point based on a source grayscale histogram may include: determining a cumulative distribution function value for each grayscale level of the source grayscale histogram; determining at least one input grayscale segmentation point based on the cumulative distribution function value and the resolution of the infrared image to be processed; and determining, for each input grayscale segmentation point, a target mapping grayscale value corresponding to each input grayscale segmentation point based on the cumulative distribution function value of the grayscale level at which each input grayscale segmentation point is located and the maximum grayscale value of the source grayscale histogram.
[0068] For example, it is assumed that the source grayscale histogram H of the infrared image to be processed is src The gray level is 0~K, and the source gray level histogram can be expressed as H src ={h s (0), h s (1),…,h s (K)}, where h s Represents the statistical value of each gray level in the source gray histogram. The source gray histogram H can be determined according to the following formula (2): src Cumulative distribution function value for each gray level:
[0069] Wherein, k = {0, 1, ..., K}, represents the gray level; F s (k) represents the cumulative distribution function value of the kth gray level.
[0070] Assuming that the input grayscale interval is divided into m (m ≥ 2) segments, the number of input grayscale segmentation points is m-1, and the input grayscale segmentation points can be determined according to the following formula (3):
[0071] Where, j = {1, 2, ..., m-1}, k j represents the jth input grayscale segmentation point; W represents the number of pixels in the horizontal direction of the infrared image to be processed, and H represents the number of pixels in the vertical direction of the infrared image to be processed.
[0072] For each input grayscale segmentation point k j , we can combine formula (2) and determine the target mapping grayscale value corresponding to each input grayscale segmentation point according to the following formula (4):
[0073] Among them, y j Indicates the jth input grayscale segmentation point k j The corresponding target mapping grayscale value, K is the source grayscale histogram H src The maximum grayscale value of . Then the target mapping grayscale values determined based on the input grayscale segmentation point are also m-1. The target mapping grayscale value is used as the segmentation point of the output grayscale interval, and the output grayscale interval can be divided into m segments.
[0074] In this way, the segmented input grayscale subinterval [k j-1 , k j ) can be combined with the output grayscale sub-interval [y j-1 ,y j ) can be used to map the input grayscale subinterval [k j-1 , k j ) is mapped to the output grayscale sub-interval [y j-1 ,y j ).
[0075] Based on the image processing method of the embodiment corresponding to Figure 1, in an exemplary embodiment, determining the mapping relationship between each input grayscale sub-interval and the corresponding output grayscale sub-interval based on the target grayscale histogram to obtain a segmented grayscale mapping curve may include: determining the cumulative distribution function of the target grayscale histogram; for each input grayscale sub-interval and the output grayscale sub-interval corresponding to each input grayscale sub-interval, determining the mapping relationship between the input grayscale sub-interval and the output grayscale sub-interval based on the first interval endpoint of each input grayscale sub-interval, the second interval endpoint of the corresponding output grayscale sub-interval and the cumulative distribution function to obtain the segmented grayscale mapping curve.
[0076] For example, assuming that the source grayscale histogram H src After histogram equalization processing, the target grayscale histogram is Hdst ={h d (0),h d (1),…,h d (K)}, where h d Represents the statistical value of each gray level in the target gray histogram. dst The cumulative distribution function F d (k) can be expressed as the following formula (5):
[0077] Wherein, k={0, 1, ..., K}, representing the gray level.
[0078] For the input grayscale subinterval [k j-1 , k j ) and its corresponding output grayscale sub-interval [y j-1 ,y j ), can be based on the input grayscale sub-interval [k j-1 , k j ) of the interval endpoint k j-1 and k j , output grayscale sub-interval [y j-1 ,y j ) of the interval endpoint y j-1 and y j , and the cumulative distribution function of formula (5), the input grayscale sub-interval [k j-1 , k j ) and the output grayscale subinterval [y j-1 ,y j ) mapping relationship between:
[0079] In this way, according to formula (6), the mapping relationship between each segmented input grayscale sub-interval and its corresponding output grayscale sub-interval can be determined, and the segmented grayscale mapping curve of each interval segment can be obtained. It can be understood that formula (6) is the segmented grayscale mapping curve of each interval segment.
[0080] Based on the image processing method of the above embodiment, in an exemplary embodiment, when the infrared image to be processed is an image of a low-temperature-difference scene, the output grayscale range can be restricted based on the distribution of the source grayscale histogram of the infrared image to be processed. For example, the input grayscale segmentation point determined based on the cumulative distribution function value of each grayscale level of the source grayscale histogram of the infrared image to be processed and the resolution of the infrared image to be processed may include a median grayscale value; accordingly, the image processing method may further include: when the infrared image to be processed is an image of a low-temperature-difference scene, determining the output grayscale range based on the median grayscale value, the target mapped grayscale value corresponding to the median grayscale value, the maximum valid grayscale value, and the minimum valid grayscale value; wherein the valid grayscale value is the grayscale value in the source grayscale histogram whose statistical value is greater than 0.
[0081] When the input grayscale interval is divided into two input grayscale subintervals using the median grayscale value as the input grayscale segmentation point, the number of pixels in the two divided input grayscale subintervals is equal or approximately equal. The median grayscale value can be determined according to formula (3) by taking m = 2 and j = 1. Based on the median grayscale value, the target mapping grayscale value corresponding to the median grayscale value can be determined according to formula (4).
[0082] The maximum effective grayscale value is the maximum grayscale value among the grayscale values corresponding to the non-zero statistical values in the source grayscale histogram, and the minimum effective grayscale value is the minimum grayscale value among the grayscale values corresponding to the non-zero statistical values.
[0083] For example, the minimum value y of the output grayscale interval can be determined according to the following formula (7): min , determine the maximum value y of the output grayscale interval according to the following formula (8) max : y min =y ref -(k med -k min )·2 N-8 (7) y max =y ref +(k max -k med )·2 N-8 (8)
[0084] Among them, k med Indicates the median gray value, y ref Indicates the target mapping gray value corresponding to the median gray value, k max Indicates the maximum effective grayscale value, k min Represents the minimum valid grayscale value, and N represents the image data bit depth.
[0085] In this way, when the infrared image to be processed is a low temperature difference scene image, by limiting the output grayscale interval using the distribution of the source grayscale histogram of the infrared image to be processed, it is possible to avoid excessive contrast stretching while retaining the temperature difference information.
[0086] In an exemplary embodiment, the image processing method may further include: when the number of valid grayscale values of the source grayscale histogram is less than or equal to a first threshold, or when the grayscale dynamic range of the infrared image to be processed is less than or equal to a second threshold, determining that the infrared image to be processed is a low-temperature difference scene image; wherein the grayscale dynamic range is determined based on the maximum valid grayscale value and the minimum valid grayscale value, for example, the difference between the maximum valid grayscale value and the minimum valid grayscale value can be determined as the grayscale dynamic range.
[0087] Based on the image processing methods of the above different embodiments, FIG2 exemplarily shows a schematic diagram of the principle of the image processing method provided by the embodiment of the present disclosure. As shown in FIG2 , the infrared image I to be processed can be in Grayscale distribution statistics are performed to obtain a source grayscale histogram, and the grayscale of the source grayscale histogram is adjusted by a histogram equalization algorithm to obtain a target grayscale histogram; at the same time, mapping interval segmentation is performed based on the source grayscale histogram, that is, the input grayscale interval and the output grayscale interval of the grayscale mapping are segmented, and the mapping relationship between each input grayscale sub-interval obtained by segmentation and the corresponding output grayscale sub-interval is determined based on the target grayscale histogram to obtain a segmented grayscale mapping curve, and the infrared image I to be processed is processed according to the segmented grayscale mapping curve. in Perform grayscale mapping to generate contrast enhanced image I out .
[0088] The image processing method provided by the embodiment of the present disclosure is described below by taking as an example a case where the resolution of the infrared image to be processed is W×H, the image data bit depth is N bits, and the input grayscale interval and the output grayscale interval are divided into two sub-intervals.
[0089] FIG3 exemplarily shows a second flowchart of the image processing method provided by an embodiment of the present disclosure. Referring to FIG3 , the image processing method may include the following steps 301 to 312 .
[0090] Step 301: Acquire an infrared image to be processed and determine a source grayscale histogram of the infrared image to be processed.
[0091] The thermal infrared camera can collect infrared images of the monitored area to obtain the infrared image to be processed. The thermal infrared camera or electronic devices such as servers, mobile phones, computers, etc. that are connected to the thermal infrared camera can obtain the infrared image to be processed and determine the source grayscale histogram of the infrared image to be processed.
[0092] In this exemplary embodiment, the image data bit depth is N bits, and the maximum grayscale value that can be represented is K=2 N -1, the grayscale that can be represented is k={0,1,…,K}, with a total of K+1 different grayscale values. Traverse each pixel of the infrared image to be processed, perform grayscale statistics, and obtain the source grayscale histogram H of the infrared image to be processed src ={h s (0), h s (1),…,h s (K)}.
[0093] For example, before determining the source grayscale histogram of the infrared image to be processed, the infrared image to be processed may be preprocessed. For example, the preprocessing may include at least one of, but not limited to, non-uniformity correction, bad pixel correction, and stripe noise correction. Grayscale statistics are then performed on the preprocessed infrared image to generate the source grayscale histogram of the infrared image to be processed.
[0094] After obtaining the source grayscale histogram, step 302 and step 304 may be performed respectively.
[0095] Step 302: Perform histogram equalization processing on the source grayscale histogram to obtain a target grayscale histogram.
[0096] After obtaining the source grayscale histogram of the infrared image to be processed, the histogram equalization algorithm can be used to adjust the source grayscale histogram H src The distribution of the target grayscale histogram H is obtained dst Among them, the histogram equalization algorithm may include but is not limited to HE, AHE, CLAHE or ADPHE. For example, taking the ADPHE algorithm as an example, FIG4 exemplarily shows a schematic diagram of the principle of using the ADPHE algorithm to perform histogram equalization processing on the source grayscale histogram to obtain the target grayscale histogram. As shown in FIG4 , the source grayscale histogram H can be searched. src The grayscale values with non-zero statistical values are searched, that is, the valid grayscale values are searched, and the histogram statistical values corresponding to each valid grayscale value are extracted to form a valid histogram H valid , which can be expressed as H valid ={h v (1), h v (2),…,h v (L)}, where L represents H valid The maximum effective grayscale value in, that is, the number of effective grayscale values, h v () represents the statistical value. Then select H valid The maximum value in generates the maximum value H polar Set. Define i∈{2,3,…,L-1}, if h v (i)≥h v(i-1) and h v (i)≥h v (i+1), then h v (i)∈H polar Get H polar Afterwards, according to H polar Determine the double platform threshold of the histogram, namely the upper platform threshold and the lower platform threshold. Upper platform threshold τ up H polar The arithmetic mean of all elements in can be calculated according to the following formula (9): up =mean(H polar ) (9)
[0097] According to the upper platform threshold τ up , the lower platform threshold τ can be calculated using formula (10) dn :
[0098] Afterwards, the upper plateau threshold τ can be used up and the lower platform threshold τ dn , adjust the source grayscale histogram H according to formula (11) src , and get H dst ={h d (0),h d (1),…,h d (K)}.
[0099] Step 303: Determine the cumulative distribution function of the target grayscale histogram.
[0100] The target grayscale histogram H can be determined according to the above formula (5): dst The cumulative distribution function F d (k).
[0101] Step 304: Determine the median grayscale value, the maximum effective grayscale value, and the minimum effective grayscale value based on the source grayscale histogram.
[0102] Get the source grayscale histogram H src Afterwards, the source grayscale histogram H can be determined according to the above formula (2): src The cumulative distribution function value of each gray level. Based on the cumulative distribution function value, m in the above formula (3) can be taken as 2 to obtain the following formula (12). According to formula (12), the median gray value k is determined med :
[0103] At the same time, we can follow the source grayscale histogram H src The gray level direction, the gray value with the first non-zero statistical value is determined as the minimum valid gray value kmin , the gray value with the last non-zero statistical value is determined as the maximum valid gray value k max .
[0104] Step 305: Determine the target mapping grayscale value corresponding to the median grayscale value.
[0105] Get the median gray value k med After that, the median gray value k med As the input grayscale segmentation point, the target mapping grayscale value y corresponding to the median grayscale value is determined according to the above formula (4) ref .
[0106] Step 306: Determine whether the infrared image to be processed is a low temperature difference scene image. If so, execute step 307; otherwise, execute step 308.
[0107] Optionally, if the number of valid grayscale values of the infrared image to be processed is L≤T num , then the infrared image to be processed is determined to be a low temperature difference scene image, otherwise it is a non-low temperature difference scene image.
[0108] Optionally, if the dynamic range of the infrared image to be processed (k max -k min )≤T range , then the infrared image to be processed is determined to be a low temperature difference scene image, otherwise it is a non-low temperature difference scene image.
[0109] Among them, T num is the first threshold, T range is the second threshold, which can be designed according to the bit depth N of the image data.
[0110] Step 307: Determine the output grayscale range based on the median grayscale value, the target mapping grayscale value corresponding to the median grayscale value, the maximum valid grayscale value, and the minimum valid grayscale value.
[0111] For example, the minimum output grayscale value y in the output grayscale interval can be determined according to the above formulas (7) and (8): min and the maximum output grayscale value y max .
[0112] Step 308: Determine the output grayscale interval to be [0, K].
[0113] For example, if the infrared image to be processed is a non-low temperature difference scene image, the minimum output grayscale value y can be determined min =0, maximum output grayscale value y max =K.
[0114] Step 309: Use the median grayscale value to segment the input grayscale interval, and use the target mapping grayscale value corresponding to the median grayscale value to segment the output grayscale interval.
[0115] For example, the median gray value k can be used med The input grayscale interval [0, K] is divided to obtain the first input grayscale subinterval [0, k med ) and the second input grayscale subinterval [k med , K]. Use the target mapping gray value y ref For the output grayscale interval [y min ,y max ] is segmented to obtain the first output grayscale subinterval [y min ,y ref ) and the second output grayscale subinterval [y ref ,y max ].
[0116] Step 310: Determine a segmented grayscale mapping curve.
[0117] For example, the first input grayscale subinterval [0, k med ) is mapped to the first output grayscale sub-interval [y min ,y ref ), the second input grayscale sub-interval [k med , K] is mapped to the second output grayscale subinterval [y ref ,y max ].
[0118] It can be understood that formula (13) is the determined segmented grayscale mapping curve.
[0119] Step 311: Generate a grayscale mapping lookup table corresponding to the input grayscale interval according to the segmented grayscale mapping curve.
[0120] For example, according to the segmented grayscale mapping curve shown in the above formula (13), the output grayscale value corresponding to each input grayscale value in the input grayscale interval [0, K] can be determined to obtain a grayscale mapping lookup table, which can be expressed as y = {y(0), y(1), ..., y(K)}.
[0121] Step 312: grayscale mapping is performed on the infrared image to be processed based on the grayscale mapping lookup table to obtain a contrast-enhanced image.
[0122] For example, traverse each pixel in the infrared image to be processed, and record the gray value of the pixel in the nth row and jth column in the infrared image to be processed as I in (n, j), the target grayscale value of the pixel in the contrast enhanced image obtained after grayscale mapping is I out (n, j), then the grayscale mapping principle expressed by the following formula (14) can be used to obtain I from the grayscale mapping lookup tableout (n, j): I out (n, j) = y(I in (n,j)) (14)
[0123] Among them, n∈[1,H],j∈[1,W].
[0124] In this way, the grayscale value of each pixel in the infrared image to be processed can be mapped through the grayscale mapping lookup table, and the contrast enhanced image of the infrared image to be processed can be obtained according to the mapped target grayscale value, thereby achieving image contrast enhancement.
[0125] According to the image processing method of this example embodiment, in a non-low temperature difference scene, the minimum grayscale value of the input infrared image to be processed is mapped to 0, and the maximum grayscale value is mapped to K; in a low temperature difference scene, if this mapping rule is still used, it will cause serious background over-stretching, and this phenomenon cannot be avoided no matter how the histogram equalization algorithm is adjusted. If the visible light image processing strategy is referred to and the contrast enhancement link is directly turned off, the temperature difference information in the high-precision infrared data will be completely lost. For example, assuming that the image data bit depth N of the infrared image to be processed is 14, the low temperature difference scene judgment strategy "(k max -k min )≤T range ", the difference between the upper and lower limits of the dynamic range of the infrared image to be processed is 50. When reflected in the 8-bit visual image, this difference will be compressed to 0 or 1, and the temperature difference information is almost completely lost. In view of this, in the process of generating the grayscale mapping curve, the embodiment of the present disclosure limits the grayscale mapping range of the low temperature difference scene according to the source grayscale histogram of the infrared image to be processed. While avoiding excessive background stretching of the infrared image to be processed collected in the low temperature difference scene, all temperature difference information of the high-precision data can be retained.
[0126] For example, Figure 5a illustrates the contrast enhancement effect of a pure road scene using the ADPHE algorithm, and Figure 5b illustrates the contrast enhancement effect of a pure road scene using the image processing method provided by an embodiment of the present disclosure. Referring to Figures 5a and 5b, the pure road surface is made of the same material and is a low-temperature difference scene. When the ADPHE algorithm is used to contrast enhance the pure road scene, the resulting contrast-enhanced image suffers from excessive background stretching. However, when the image processing method provided by an embodiment of the present disclosure is used to contrast enhance the pure road scene, the resulting contrast-enhanced image effectively avoids excessive background stretching and retains all the temperature difference information of the high-precision data.
[0127] In the image processing method of this exemplary embodiment, during the generation of the grayscale mapping curve, the median grayscale value is used to segment the input grayscale interval, and the target mapping grayscale value determined based on the median grayscale value and the source grayscale histogram of the infrared image to be processed is used to segment the output grayscale interval, thereby generating the grayscale mapping curve in segments. For example, the source grayscale histogram H src The first valid gray value exceeding 50% in the cumulative distribution of is taken as the median gray value k med , using k med The input grayscale interval is divided into the first input grayscale sub-interval [0, k med ) and the second input grayscale subinterval [k med , K]; based on the median gray value k med and source grayscale histogram H src The cumulative distribution of k med The corresponding target mapping gray value y ref , with y ref The output grayscale interval is divided into the first output grayscale sub-interval [y min ,y ref ) and the second output grayscale subinterval [y ref ,y max ]. Then according to the output grayscale and target grayscale histogram H dst The cumulative distribution function F d (k) linear correlation principle, the first input gray sub-interval [0, k med ) is mapped to the first output grayscale sub-interval [y min ,y ref ), the second input grayscale sub-interval [k med , K] is mapped to the second output grayscale subinterval [y ref ,y max ].
[0128] As mentioned above, when the target grayscale histogram adjusted by the HE algorithm is used to generate the grayscale mapping curve, the HE algorithm introduces the histogram distortion phenomenon, which leads to the problem of brightness fluctuation of the enhanced image when the grayscale mapping curve generated by the target grayscale histogram is used for contrast enhancement. In view of this, the image processing method provided by the embodiment of the present disclosure uses the source grayscale histogram H of the infrared image to be processed to generate the grayscale mapping curve. src The original statistical information in, that is, the median gray value k med and based on k med With H src The cumulative distribution F s (k) Determine the target mapping gray value y ref, to limit the mapping range of the grayscale mapping curve, that is, use the real grayscale distribution information of the image reflected in the source grayscale histogram of the infrared image to be processed to constrain the grayscale mapping range of the target grayscale histogram distorted by statistical information, so as to achieve the purpose of limiting the brightness fluctuation of the contrast enhanced image.
[0129] It can be understood that the median grayscale value is used to divide the input grayscale interval (domain) so that it falls into the first input grayscale sub-interval [0, k med ) and the second input grayscale subinterval [k med , K] are equal or approximately equal in number of pixels; based on the median gray value k med and source grayscale histogram H src The target mapping gray value y is calculated by the cumulative distribution ref The segmented grayscale mapping curve designed based on this can ensure that after grayscale mapping, the grayscale value of half of the pixels is less than y ref , half of the pixels have grayscale values greater than y ref This phenomenon of "half of the pixels occupying half of the grayscale value range" reproduces the design idea of reconstructing grayscale values according to their positions in ascending order.
[0130] According to the image processing method of this example embodiment, a PTZ camera can be used to collect infrared images in a building complex, and the contrast enhancement results of the infrared images can be output as 8-bit visualization. Taking the ADPHE algorithm as an example, the image processing method of the present invention is experimentally compared with the ADPHE algorithm in a large-area high-temperature target scene (grayscale distribution is left-biased) and a large-area low-temperature background scene (grayscale distribution is right-biased). Figure 6a exemplarily shows a schematic diagram of the enhancement effect of contrast enhancement of a large-area high-temperature target scene using the ADPHE algorithm, and Figure 6b exemplarily shows a schematic diagram of the enhancement effect of contrast enhancement of a large-area high-temperature target scene using the image processing method provided by the present disclosure. Referring to Figures 6a and 6b, when the ADPHE algorithm is used for contrast enhancement, the average brightness of the contrast-enhanced image obtained is 174.8, while when the image processing method provided by the embodiment of the present disclosure is used for contrast enhancement, the average brightness of the contrast-enhanced image obtained is 129.3.
[0131] Figure 6c illustrates the contrast enhancement effect of using the ADPHE algorithm for a large-area low-temperature background scene, and Figure 6d illustrates the contrast enhancement effect of using the image processing method provided by the present disclosure for a large-area low-temperature background scene. As shown in Figures 6c and 6d, when contrast enhancement is performed using the ADPHE algorithm, the average brightness of the resulting contrast-enhanced image is 109.1, while when contrast enhancement is performed using the image processing method provided by an embodiment of the present disclosure, the average brightness of the resulting contrast-enhanced image is 124.0.
[0132] 6a to 6d , when the ADPHE algorithm is used for contrast enhancement, the average brightness of the obtained contrast-enhanced image fluctuates between 109.1 and 174.8; while when the image processing method provided by the embodiment of the present disclosure is used for contrast enhancement, the average brightness of the obtained contrast-enhanced image fluctuates between 124.0 and 129.3. Regardless of how the scene changes, the average brightness of the obtained contrast-enhanced image is relatively stable. Compared with the ADPHE algorithm, it provides reliable brightness stability, helps to improve the temporal continuity of infrared video images, and provides good visual effects.
[0133] The image processing method provided by this example embodiment, on the one hand, in the process of generating the grayscale mapping curve, limits the grayscale mapping range of the low temperature difference scene according to the source grayscale histogram of the infrared image to be processed, while avoiding excessive contrast stretching, retaining the temperature difference information. On the other hand, in the process of generating the grayscale mapping curve, the source grayscale histogram and the corresponding cumulative distribution of the infrared image to be processed are used to determine the median grayscale value and the corresponding target mapping grayscale value, and then the median grayscale value is used to segment the input grayscale interval (domain), and the target mapping grayscale value is used to segment the output grayscale interval (range), and the grayscale mapping curve is generated in segments. The histogram distortion introduced in the histogram equalization process is suppressed by segmented mapping, thereby suppressing the brightness fluctuation of the contrast-enhanced image caused by the histogram distortion. This helps to improve the temporal continuity of infrared video images and provide good visual effects.
[0134] The image processing device provided by the present disclosure is described below. The image processing device described below and the image processing method described above can be referenced to each other.
[0135] Figure 7 exemplarily shows a structural diagram of an image processing device provided by an embodiment of the present disclosure. As shown in Figure 7, the image processing device 700 may include: an acquisition module 710, configured to acquire an infrared image to be processed; a first determination module 720, configured to determine a source grayscale histogram of the infrared image to be processed; a segmentation module 730, configured to segment an input grayscale interval and an output grayscale interval of a grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each input grayscale sub-interval; an equalization module 740, configured to perform histogram equalization processing on the source grayscale histogram to obtain a target grayscale histogram; a second determination module 750, configured to determine a mapping relationship between each input grayscale sub-interval and the corresponding output grayscale sub-interval based on the target grayscale histogram to obtain a segmented grayscale mapping curve; and a mapping module 760, configured to perform grayscale mapping on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast enhanced image of the infrared image to be processed.
[0136] In an exemplary embodiment, the segmentation module 730 may include: a first determination unit, configured to determine at least one input grayscale segmentation point and a target mapping grayscale value corresponding to each input grayscale segmentation point based on a source grayscale histogram; a first segmentation unit, configured to segment the input grayscale interval based on the input grayscale segmentation point to obtain at least two input grayscale sub-intervals; and a second segmentation unit, configured to segment the output grayscale interval based on the target mapping grayscale value to obtain an output grayscale sub-interval corresponding to each input grayscale sub-interval.
[0137] In an exemplary embodiment, the first determination unit can be configured to: determine the cumulative distribution function value of each grayscale level of the source grayscale histogram; determine at least one input grayscale segmentation point based on the cumulative distribution function value and the resolution of the infrared image to be processed; for each input grayscale segmentation point, determine the target mapping grayscale value corresponding to each input grayscale segmentation point based on the cumulative distribution function value of the grayscale level at which each input grayscale segmentation point is located and the maximum grayscale value of the source grayscale histogram.
[0138] In an exemplary embodiment, the image processing device 700 may further include: a third determination module, configured to determine the output grayscale range based on the median grayscale value, the target mapping grayscale value corresponding to the median grayscale value, the maximum valid grayscale value and the minimum valid grayscale value when the infrared image to be processed is a low temperature difference scene image; wherein the valid grayscale value is the grayscale value whose statistical value in the source grayscale histogram is greater than 0.
[0139] In an exemplary embodiment, the third determination module can also be configured to determine that the infrared image to be processed is a low-temperature difference scene image when the number of valid grayscale values of the source grayscale histogram is less than or equal to a first threshold, or when the grayscale dynamic range of the infrared image to be processed is less than or equal to a second threshold; wherein the grayscale dynamic range is determined based on the maximum valid grayscale value and the minimum valid grayscale value.
[0140] In an exemplary embodiment, the second determination module 750 may include: a second determination unit, configured to determine the cumulative distribution function of the target grayscale histogram; a third determination unit, configured to determine, for each input grayscale sub-interval and the output grayscale sub-interval corresponding to each input grayscale sub-interval, a mapping relationship between the input grayscale sub-interval and the output grayscale sub-interval based on the first interval endpoint of each input grayscale sub-interval, the second interval endpoint of the corresponding output grayscale sub-interval and the cumulative distribution function, to obtain a segmented grayscale mapping curve.
[0141] In an exemplary embodiment, the mapping module 760 may include: a generation unit, configured to generate a grayscale mapping lookup table corresponding to an input grayscale interval based on a segmented grayscale mapping curve; an acquisition unit, configured to acquire a target grayscale value corresponding to the grayscale value of each pixel point from the grayscale mapping lookup table based on the grayscale value of each pixel point in the infrared image to be processed; and a generation unit, configured to generate a contrast-enhanced image based on the target grayscale value.
[0142] Figure 8 illustrates a structural diagram of an electronic device. As shown in Figure 8, the electronic device may include: a processor (processor) 810, a communication interface (Communication Interface) 820, a memory (memory) 830 and a communication bus 840, wherein the processor 810, the communication interface 820 and the memory 830 can communicate with each other through the communication bus 840. The processor 810 can call the logic instructions in the memory 830 to execute the image processing method provided by each of the above method embodiments. The method may include, for example: obtaining an infrared image to be processed and determining a source grayscale histogram of the infrared image to be processed; segmenting the input grayscale interval and the output grayscale interval of the grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each input grayscale sub-interval; performing histogram equalization on the source grayscale histogram to obtain a target grayscale histogram, and determining the mapping relationship between each input grayscale sub-interval and the corresponding output grayscale sub-interval based on the target grayscale histogram to obtain a segmented grayscale mapping curve; performing grayscale mapping on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast enhanced image of the infrared image to be processed.
[0143] Exemplarily, the electronic device may be a thermal infrared camera, or an electronic device such as a server, a mobile phone, a computer, etc. that is communicatively connected to the thermal infrared camera.
[0144] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, and other media that can store program codes.
[0145] On the other hand, the present disclosure also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the image processing method provided by each of the above method embodiments. The method may include, for example: obtaining an infrared image to be processed and determining a source grayscale histogram of the infrared image to be processed; segmenting the input grayscale interval and the output grayscale interval of the grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each input grayscale sub-interval; performing histogram equalization on the source grayscale histogram to obtain a target grayscale histogram, and determining the mapping relationship between each input grayscale sub-interval and the corresponding output grayscale sub-interval based on the target grayscale histogram to obtain a segmented grayscale mapping curve; performing grayscale mapping on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast enhanced image of the infrared image to be processed.
[0146] On the other hand, the present disclosure also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the image processing method provided by each of the above-mentioned method embodiments. The method may, for example, include: obtaining an infrared image to be processed, and determining a source grayscale histogram of the infrared image to be processed; segmenting the input grayscale interval and the output grayscale interval of the grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each input grayscale sub-interval; performing histogram equalization on the source grayscale histogram to obtain a target grayscale histogram, and determining a mapping relationship between each input grayscale sub-interval and the corresponding output grayscale sub-interval based on the target grayscale histogram to obtain a segmented grayscale mapping curve; performing grayscale mapping on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast enhanced image of the infrared image to be processed.
[0147] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0148] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus the necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the method described in each embodiment or certain parts of the embodiment.
[0149] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in each of the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of each embodiment of the present disclosure.
Claims
1. An image processing method, comprising: Acquire an infrared image to be processed, and determine a source grayscale histogram of the infrared image to be processed; Segmenting the input grayscale interval and the output grayscale interval of the grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each of the input grayscale sub-intervals; Performing histogram equalization processing on the source grayscale histogram to obtain a target grayscale histogram, and determining a mapping relationship between each of the input grayscale sub-intervals and the corresponding output grayscale sub-interval based on the target grayscale histogram to obtain a segmented grayscale mapping curve; Grayscale mapping is performed on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast enhanced image of the infrared image to be processed.
2. The image processing method according to claim 1, wherein: The step of segmenting the input grayscale interval and the output grayscale interval of the grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each of the input grayscale sub-intervals includes: Based on the source grayscale histogram, determining at least one input grayscale segmentation point and a target mapping grayscale value corresponding to each input grayscale segmentation point; Segmenting the input grayscale interval based on the input grayscale segmentation point to obtain the at least two input grayscale sub-intervals; The output grayscale interval is segmented based on the target mapping grayscale value to obtain the output grayscale sub-interval corresponding to each input grayscale sub-interval.
3. The image processing method according to claim 2, wherein: The step of determining at least one input grayscale segmentation point and a target mapping grayscale value corresponding to each input grayscale segmentation point based on the source grayscale histogram comprises: Determine the cumulative distribution function value of each gray level of the source grayscale histogram; Determining the at least one input grayscale segmentation point based on the cumulative distribution function value and the resolution of the infrared image to be processed; For each of the input grayscale segmentation points, based on the grayscale at which each of the input grayscale segmentation points is located The target mapping grayscale value corresponding to each of the input grayscale segmentation points is determined by combining the cumulative distribution function value of the input grayscale segmentation point and the maximum grayscale value of the source grayscale histogram.
4. The image processing method according to claim 2, wherein: The at least one input grayscale segmentation point comprises a median grayscale value; the method further comprising: In the case where the infrared image to be processed is a low temperature difference scene image, determining the output grayscale interval based on the median grayscale value, the target mapping grayscale value corresponding to the median grayscale value, the maximum valid grayscale value, and the minimum valid grayscale value; The valid grayscale value is a grayscale value whose statistical value in the source grayscale histogram is greater than 0.
5. The image processing method according to claim 4, wherein: The determining the output grayscale interval based on the median grayscale value, the target mapping grayscale value corresponding to the median grayscale value, the maximum valid grayscale value, and the minimum valid grayscale value includes: Determine a minimum value of an output grayscale interval based on the median grayscale value, the target mapping grayscale value corresponding to the median grayscale value, and the minimum valid grayscale value; Determine a maximum value of an output grayscale interval based on the median grayscale value, the target mapping grayscale value corresponding to the median grayscale value, and the maximum valid grayscale value; The output grayscale interval is determined according to the minimum value and the maximum value.
6. The image processing method according to claim 4, further comprising: When the number of valid grayscale values of the source grayscale histogram is less than or equal to a first threshold, or when the grayscale dynamic range of the infrared image to be processed is less than or equal to a second threshold, determining that the infrared image to be processed is a low temperature difference scene image; The grayscale dynamic range is determined based on the maximum valid grayscale value and the minimum valid grayscale value.
7. The image processing method according to any one of claims 1 to 6, wherein: The step of determining a mapping relationship between each of the input grayscale sub-intervals and the corresponding output grayscale sub-intervals based on the target grayscale histogram to obtain a segmented grayscale mapping curve includes: Determining a cumulative distribution function of the target grayscale histogram; For each of the input grayscale sub-intervals and the input grayscale sub-intervals corresponding to each of the input grayscale sub-intervals The grayscale sub-interval is output, and the mapping relationship between the input grayscale sub-interval and the output grayscale sub-interval is determined based on the first interval endpoint of each of the input grayscale sub-intervals, the corresponding second interval endpoint of the output grayscale sub-interval and the cumulative distribution function of the target grayscale histogram to obtain the segmented grayscale mapping curve.
8. The image processing method according to any one of claims 1 to 6, wherein: The grayscale mapping of the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast enhanced image of the infrared image to be processed includes: Based on the segmented grayscale mapping curve, generating a grayscale mapping lookup table corresponding to the input grayscale interval; Based on the grayscale value of each pixel in the infrared image to be processed, obtaining a target grayscale value corresponding to the grayscale value of each pixel from the grayscale mapping lookup table; The contrast enhanced image is generated based on the target grayscale value.
9. An image processing device, comprising: An acquisition module, configured to acquire an infrared image to be processed; A first determination module, configured to determine a source grayscale histogram of the infrared image to be processed; A segmentation module, configured to segment the input grayscale interval and the output grayscale interval of the grayscale mapping based on the source grayscale histogram to obtain at least two input grayscale sub-intervals and an output grayscale sub-interval corresponding to each of the input grayscale sub-intervals; An equalization module, configured to perform histogram equalization processing on the source grayscale histogram to obtain a target grayscale histogram; A second determination module is configured to determine a mapping relationship between each of the input grayscale sub-intervals and the corresponding output grayscale sub-interval based on the target grayscale histogram to obtain a segmented grayscale mapping curve; The mapping module is configured to perform grayscale mapping on the infrared image to be processed based on the segmented grayscale mapping curve to obtain a contrast enhanced image of the infrared image to be processed.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the image processing method according to any one of claims 1 to 8 when executing the computer program.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the image processing method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Infrared-image enhancement method and system based on self-adaptive histogram segmentation
CN107945122A
Image enhancement method and device, computer equipment and storage medium
CN109801244A
Method and device for linearly enhancing image contrast
CN109961409A
Infrared digital image gray mapping method
CN114998163A
Image processing method and device, computer readable storage medium and electronic equipment
CN115375592A
Cited By
Intelligent monitoring method and system for fire mask production process
CN119090868A
A fire mask production process intelligent monitoring method and system
CN119090868B
Face on-duty monitoring terminal based on temperature sensing analysis
CN119228783A
Color image enhancement method and device based on histogram segmentation
CN119809950A
Infrared image coding method, device and equipment for pulse neural network
CN120747255A
