Infrared image enhancement method and device and electronic equipment
By dividing the region and adjusting the grayscale value of infrared images, the details loss caused by the histogram equalization algorithm are solved, and the display effect of infrared images is improved.
Patent Information
- Application Number
- CN202510353460.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-07-11
Smart Images

Figure CN120298276A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technologies, and particularly to an infrared image enhancement method, apparatus, and electronic device. Background Art
[0002] For some specific infrared images, such as when the gray value distribution of pixel points in the infrared image is uneven, directly performing gray value equalization processing on the infrared image through the histogram equalization algorithm may compress or expand the gray value range that originally contains important information, resulting in the loss of details. For example, some subtle local information may be smoothed out, thus affecting the recognition of temperature differences between objects and resulting in a poor display effect of the infrared image. Summary of the Invention
[0003] In view of this, this application provides an infrared image enhancement method, apparatus, and electronic device to improve the display effect of infrared images.
[0004] The technical solutions provided by this application are as follows:
[0005] According to an embodiment of the first aspect of this application, an infrared image enhancement method is provided. The method includes:
[0006] Dividing the original infrared image to obtain at least two image regions;
[0007] Dividing at least one of the image regions to obtain at least two sub-regions;
[0008] For each image region, sampling the gray values of the image region according to the number of sampling intervals matched by the image region, and on the premise that the image region is subjected to the dividing operation, for each sub-region divided from the image region, statistically calculating the occurrence frequency of each gray value in the sub-region according to the frequency weight matched by the sub-region to obtain the gray value statistical result of the sub-region; wherein, the number of sampling intervals matched by at least two image regions is different, and the frequency weights matched by at least two sub-regions are different;
[0009] Adjusting the gray values of each pixel point in the original infrared image according to the gray value statistical results of each sub-region and the gray values sampled for the image regions that are not subjected to the dividing operation to obtain the target infrared image.
[0010] Optionally, the dividing the original infrared image to obtain at least two image regions includes:
[0011] Performing image segmentation on the original infrared image based on a trained image segmentation model to obtain at least two image regions, and the difference between the average gray values of pixel points in different image regions is greater than a specified threshold.
[0012] Optionally, the dividing of at least one image region to obtain at least two sub-regions includes:
[0013] For each image region to be divided, determining at least one gray-scale threshold value that the image region matches; the gray-scale threshold value is determined depending on the gray-scale values of each pixel point in the original infrared image;
[0014] Dividing the image region according to the at least one gray-scale threshold value to obtain at least two sub-regions corresponding to the image region; wherein, the gray-scale values of the pixel values in different sub-regions are different.
[0015] Optionally, the adjusting of the gray-scale values of each pixel point in the original infrared image according to the gray-scale value statistical results of each sub-region and the gray-scale values sampled for the image regions that have not been subjected to the dividing operation includes:
[0016] Determining the weighted statistical result of the gray-scale values of the original infrared image according to the gray-scale value statistical results of each sub-region and the gray-scale values sampled for the image regions that have not been subjected to the dividing operation; the weighted statistical result of the gray-scale values includes the occurrence frequency of each gray-scale value in the original infrared image;
[0017] Determining the cumulative statistical result of the gray-scale values according to the weighted statistical result of the gray-scale values; the cumulative statistical result of the gray-scale values includes the cumulative occurrence frequency of each gray-scale value in the original infrared image, and the cumulative occurrence frequency of any gray-scale value refers to the sum of the occurrence frequencies of all gray-scale values less than or equal to this gray-scale value;
[0018] For each pixel point in the original infrared image, adjusting the gray-scale value of this pixel point according to the cumulative occurrence frequency of the gray-scale value of this pixel point, the cumulative occurrence frequency of the maximum gray-scale value included in the original infrared image, the maximum gray-scale value included in the original infrared image, and the minimum gray-scale value included in the original infrared image.
[0019] Optionally, the adjusting of the gray-scale value of each pixel point in the original infrared image according to the cumulative occurrence frequency of the gray-scale value of this pixel point, the cumulative occurrence frequency of the maximum gray-scale value of the original infrared image, the maximum gray-scale value of the original infrared image, and the minimum gray-scale value of the original infrared image includes:
[0020] For each gray-scale value in the original infrared image, the adjusted gray-scale value is determined by the following formula:
[0021]
[0022] wherein, the S is the adjusted gray-scale value, the f is the cumulative occurrence frequency of this gray-scale value, the N is the cumulative occurrence frequency of the maximum gray-scale value of the original infrared image, the t max is the maximum gray-scale value of the original infrared image, the tmin is the minimum gray value of the original infrared image.
[0023] Optionally, the original infrared image is divided into a first image region and a second image region, and the average gray value of the pixel points in the first image region is less than the average gray value of the pixel points in the second image region; the dividing at least one image region to obtain at least two sub-regions includes:
[0024] Dividing the first image region into a high-temperature sub-region and a low-temperature sub-region according to the gray threshold, where the gray value of each pixel point in the high-temperature sub-region is greater than the gray threshold, and the gray value of each pixel point in the low-temperature sub-region is less than or equal to the gray threshold.
[0025] Optionally, for each image region, the gray value of the image region is sampled according to the number of sampling intervals matched by the image region, and on the premise that the image region is subjected to a dividing operation, for each sub-region obtained by dividing the image region, the occurrence frequency of each gray value in the sub-region is statistically counted according to the frequency weight matched by the sub-region, and the gray value statistical result of the sub-region is obtained, including:
[0026] Sampling the gray value of the pixel points in the first image region by the first sampling interval number; statistically counting the occurrence frequency of each gray value in the high-temperature sub-region according to the first frequency weight matched by the high-temperature sub-region to obtain the gray value statistical result of the high-temperature sub-region; statistically counting the occurrence frequency of each gray value in the low-temperature sub-region according to the second frequency weight matched by the low-temperature sub-region to obtain the gray value statistical result of the low-temperature sub-region; the first frequency weight is greater than the second frequency weight;
[0027] Sampling the gray value of the pixel points in the second image region by the second sampling interval number; the first sampling interval number is greater than the second sampling interval number.
[0028] According to an embodiment of the second aspect of the present application, an infrared image enhancement device is provided, and the device includes:
[0029] A first dividing unit, configured to divide an original infrared image to obtain at least two image regions;
[0030] A second dividing unit, configured to divide at least one image region to obtain at least two sub-regions;
[0031] A sampling and statistical unit, which is used to perform gray - value sampling on each image region according to the number of sampling intervals matched by the image region, and, on the premise that the image region is subjected to a partitioning operation, for each sub - region into which the image region is partitioned, statistically count the occurrence frequencies of the gray - values in the sub - region according to the frequency weights matched by the sub - region, to obtain the gray - value statistical result of the sub - region; wherein, the number of sampling intervals matched by at least two image regions is different, and the frequency weights matched by at least two sub - regions are different;
[0032] A gray - scale adjustment unit, which is used to adjust the gray - values of each pixel point in the original infrared image according to the gray - value statistical results of each sub - region and the gray - values sampled for the image regions that have not been subjected to the partitioning operation, to obtain the target infrared image.
[0033] Optionally, the first partitioning unit is specifically used for:
[0034] Performing image segmentation on the original infrared image based on a trained image segmentation model to obtain at least two image regions, and the difference between the average gray - values of the pixel points in different image regions is greater than a preset threshold;
[0035] And / or, the second partitioning unit is specifically used for:
[0036] For each image region to be partitioned, determining at least one gray - scale threshold matched by the image region; the gray - scale threshold is determined depending on the gray - values of each pixel point in the original infrared image;
[0037] Partitioning the image region according to the at least one gray - scale threshold to obtain at least two sub - regions corresponding to the image region; wherein, the gray - values of the pixel values in different sub - regions are different;
[0038] And / or, the gray - scale adjustment unit is specifically used for:
[0039] Determining the gray - value weighted statistical result of the original infrared image according to the gray - value statistical results of each sub - region and the gray - values sampled for the image regions that have not been subjected to the partitioning operation; the gray - value weighted statistical result includes the occurrence frequencies of each gray - value in the original infrared image;
[0040] Determining the gray - value cumulative statistical result according to the gray - value weighted statistical result; the gray - value cumulative statistical result includes the cumulative occurrence frequencies of each gray - value in the original infrared image, and the cumulative occurrence frequency of any gray - value refers to the sum of the occurrence frequencies of all gray - values less than or equal to that gray - value;
[0041] For each pixel point in the original infrared image, adjust the gray value of the pixel point according to the cumulative occurrence frequency of the gray value of the pixel point, the cumulative occurrence frequency of the maximum gray value included in the original infrared image, the maximum gray value included in the original infrared image, and the minimum gray value included in the original infrared image;
[0042] And / or, the gray value adjustment unit is specifically used for:
[0043] For each gray value in the original infrared image, the adjusted gray value is determined by the following formula:
[0044]
[0045] Wherein, the S is the adjusted gray value, the f is the cumulative occurrence frequency of the gray value, the N is the cumulative occurrence frequency of the maximum gray value of the original infrared image, and the t max is the maximum gray value of the original infrared image, and the t min is the minimum gray value of the original infrared image;
[0046] And / or, the original infrared image is divided into a first image area and a second image area, and the average value of the gray values of the pixel points in the first image area is less than the average value of the gray values of the pixel points in the second image area; the second dividing unit is specifically used for:
[0047] Divide the first image area into a high-temperature sub-area and a low-temperature sub-area according to the gray value threshold, where the gray values of the pixel points in the high-temperature sub-area are greater than the gray value threshold, and the gray values of the pixel points in the low-temperature sub-area are less than or equal to the gray value threshold;
[0048] And / or, the sampling and statistics unit is specifically used for:
[0049] Sample the gray values of the pixel points in the first image area at a first sampling interval number; statistically count the occurrence frequencies of the gray values in the high-temperature sub-area according to the first frequency weight matched with the high-temperature sub-area to obtain the gray value statistical result of the high-temperature sub-area; statistically count the occurrence frequencies of the gray values in the low-temperature sub-area according to the second frequency weight matched with the low-temperature sub-area to obtain the gray value statistical result of the low-temperature sub-area; the first frequency weight is greater than the second frequency weight;
[0050] Sample the gray values of the pixel points in the second image area at a second sampling interval number; the first sampling interval number is greater than the second sampling interval number.
[0051] According to an embodiment of the third aspect of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the first aspect is implemented.
[0052] According to an embodiment of the fourth aspect of the present application, a computer-readable storage medium is provided. A number of computer instructions are stored on the computer-readable storage medium. When the computer instructions are executed, the method described in the first aspect is implemented.
[0053] As can be seen from the above technical solutions, the present application divides the obtained original infrared image into multiple image regions, and divides at least one image region to obtain multiple sub-regions. Different sampling interval numbers are configured for at least two different image regions, and different frequency weights are configured for different sub-regions in the same image region; the frequency of occurrence of each gray value of the original infrared image is counted according to the sampling interval numbers and frequency weights configured for each image region and each sub-region, and the gray value of each pixel point in the original infrared image is adjusted to obtain a target infrared image; according to the different sampling interval numbers set for different image regions of the original infrared image, and the different frequency weights set for different sub-regions in the same region, the gray value of each pixel point in the original infrared image is adjusted to increase the display contrast of the infrared image and improve the display effect of the infrared image. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0055] Figure 1 Schematic diagram of an infrared image scene directly performing gray value equalization processing through a histogram equalization algorithm provided by an embodiment of the present application;
[0056] Figure 2 Flow chart of an infrared image enhancement method provided by an embodiment of the present application;
[0057] Figure 3 Schematic diagram of the division of the original infrared image provided by an embodiment of the present application;
[0058] Figure 4 Schematic diagram of an infrared image scene processed by the infrared enhancement method proposed by the present application provided by an embodiment of the present application;
[0059] Figure 5 Schematic diagram of the structure of an electronic device provided by an embodiment of the present application;
[0060] Figure 6 Structure diagram of an infrared image enhancement device provided by an embodiment of the present application. Detailed implementation manners
[0061] To enable those skilled in the art to better understand the technical solutions provided in the embodiments of the present application, and to make the above-mentioned objects, features, and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0062] For some specific infrared images, such as infrared images with uneven gray value distributions of pixel points, directly performing gray value equalization processing on the infrared image through the histogram equalization algorithm may cause the gray value range that originally contains important information to be compressed or expanded, resulting in the loss of details.
[0063] Please refer to Figure 1 , Figure 1 , which is a schematic diagram of the infrared image scene directly processed by the histogram equalization algorithm for gray value equalization provided by the embodiments of the present application.
[0064] As Figure 1 shown, since the high-temperature regions (high gray value regions) in the infrared image usually contain some key object features (such as Figure 1 the region corresponding to the building in
[0065] ), directly optimizing the infrared image obtained through the histogram equalization algorithm will cause the gray values of these high-temperature regions to exceed the visible range, resulting in the infrared image becoming blurred and lacking details in these regions, and giving a "whitish" feeling to the display effect of the overall image.
[0066] Based on this, the present application proposes an infrared image enhancement method. Figure 2 , Figure 2 , which is a flowchart of the infrared image enhancement provided by the embodiments of the present application.
[0067] As Figure 2 shown, the method may include the following steps:
[0068] Step 201, divide the original infrared image to obtain at least two image regions.
[0069] In this embodiment, for the obtained original infrared image, the original infrared image may be divided to obtain at least two image regions.
[0070] As an embodiment, the basis for dividing the original infrared image may be to divide according to the gray value range, or to divide according to specific scene regions, such as identifying different scene regions in the infrared image, such as grassland, lane, lake, etc., and dividing according to the scene regions.
[0071] Taking the division of the original infrared image according to the grayscale value range as an example, specifically, the method for dividing the original infrared image can be to perform image segmentation on the original infrared image based on a trained image segmentation model to obtain at least two image regions; among them, the difference between the average values of the grayscale values of the pixel points in different image regions is greater than a specified threshold.
[0072] In this embodiment, the original infrared image can be input into a trained image segmentation model to obtain at least two image regions. When the image segmentation model is trained, it can be trained according to sample images with large differences in the average grayscale values of different regions, so that the image segmentation model can identify regions with large differences in the average grayscale values of the pixel points in the image to be measured.
[0073] As an embodiment, the half-sky and half-ground infrared image can be used as a sample image for training the image segmentation model after image region annotation. Since the half-sky and half-ground infrared image includes a sky region and a ground region, and the temperature of the sky region is usually low, and the average value of its grayscale value is also small; while the temperature of the ground region is usually high, and the average value of its grayscale value is high, which meets the segmentation requirements of the image segmentation model in the embodiments of the present application.
[0074] In this embodiment, in addition to segmenting the original infrared image based on a trained image segmentation model, the original infrared image can also be segmented according to the set region segmentation line. For example, for the original infrared image in some specific scenarios, such as the original infrared image in the above half-sky and half-ground scenario, where the positions of the sky region (the region with a smaller grayscale value) and the ground region (the region with a larger grayscale value) are relatively fixed, at this time, a region segmentation line can be set for this type of specific scenario. When the original infrared image belongs to the original infrared image of this type of specific scenario, the corresponding region segmentation line of this specific scenario can be directly used to segment the original infrared image to save computing resources.
[0075] Similarly, in this embodiment, for some rare or complex-scene original infrared images, relevant personnel can also perform manual division to facilitate relevant personnel to determine the regions that need to be focused on in the original infrared image.
[0076] So far, the description of step 201 is completed, and then step 202 is executed.
[0077] Step 202, divide at least one image region to obtain at least two sub-regions.
[0078] In this embodiment, after the original infrared image is divided into at least two image regions through step 201, the at least one image region obtained by the division can be further divided into at least two sub-regions.
[0079] For infrared images, usually more attention is paid to the high-temperature regions included therein, such as the images of the ground regions in the half-sky and half-ground images. However, although the low-temperature regions, such as the sky regions, have a relatively low overall temperature, that is, the average gray value of the sky regions is relatively low, there may also be a small part of the regions with relatively high temperature in the sky regions. For this type of regions, they are actually the parts that we need to focus on in the infrared images. If the scheme of directly performing gray value equalization on the entire infrared image in the related technology is adopted, the local information corresponding to these small parts of the regions with relatively high temperature included in the low-temperature regions is easily smoothed out, resulting in the loss of details of the high-temperature levels.
[0080] For this, we can further divide the image regions that have local high-temperature regions that need to be focused on among the at least two image regions obtained by dividing in step 201, so as to highlight the local high-temperature regions and avoid the loss of details during the histogram equalization process.
[0081] Specifically, the process of dividing at least one image region to obtain at least two sub-regions may include:
[0082] For each image region to be divided, determine at least one gray threshold that the image region matches; the gray threshold is determined depending on the gray values of the pixel points in the original infrared image; divide the image region according to the at least one gray threshold to obtain at least two sub-regions corresponding to the image region; wherein, the gray values of the pixel values in different sub-regions are different.
[0083] In this embodiment, for each image region to be divided, at least one gray threshold that the image region matches can be determined according to the gray values of the pixel points in the original infrared image.
[0084] For example, N times the maximum gray value of the original infrared image can be determined as the gray threshold, where N is greater than 0 and less than 1. For example, when N is 0.9 and the maximum gray value of the original infrared image is 200, it means that the gray threshold is 200 * 0.9 = 180. At this time, the set of pixel points in the image region with gray values not higher than 180 can be determined as one sub-region of the image region, and the set of pixel points in the image region with gray values higher than 180 can be determined as another sub-region of the image region.
[0085] It should be noted that a sub-region can be a connected region or multiple non-connected regions included in the image region, and the present application does not limit this.
[0086] Please refer to Figure 3 , Figure 3 which is the schematic diagram of the division of the original infrared image provided by the embodiment of the present application.
[0087] As shown Figure 3 in the figure, the original infrared image is first divided into two parts: image region A and image region B. For each image region, it is further divided into two different sub-regions.
[0088] For image region A, it is divided into sub-region A1 and sub-region A2. Among them, sub-region A1 refers to Figure 3 the area covered by the grid in Figure 3 , and sub-region A2 refers to the dark area covered by solid color in . It is easy to understand that sub-region A1 is a connected region, while sub-region A2 includes two non-connected regions.
[0089] For image region B, it is divided into sub-region B1 and sub-region B2. Among them, sub-region B1 refers to Figure 3 the area covered by the slashes in Figure 3 , and sub-region B2 refers to the light area covered by solid color in . It is easy to understand that both sub-region B1 and sub-region B2 are connected regions.
[0090] So far, the description of the schematic diagram of the division of the original infrared image in Figure 3 is completed.
[0091] In this embodiment, for each image region to be divided, the number of determined gray-scale thresholds determines the number of sub-regions obtained by dividing the image region.
[0092] For example, if the determined gray-scale threshold is one, then according to this gray-scale threshold, the image region can be divided into two sub-regions. If the determined gray-scale threshold is M, then according to this gray-scale threshold, the image region can be divided into M + 1 sub-regions.
[0093] Therefore, according to actual needs, such as the gray-scale value range corresponding to the temperature range to be concerned about, the number and specific values of the gray-scale thresholds matched by each image region to be divided can be determined.
[0094] So far, the description of step 202 is completed, and then step 203 is executed.
[0095] Step 203: For each image region, sample the gray-scale values of the image region according to the sampling interval number matched by the image region. And on the premise that the image region is subjected to the division operation, for each sub-region obtained by dividing the image region, count the occurrence frequencies of the gray-scale values in the sub-region according to the frequency weight matched by the sub-region, and obtain the gray-scale value statistical result of the sub-region.
[0096] Among them, the sampling interval numbers matched by at least two image regions are different, and the frequency weights matched by at least two sub-regions are different.
[0097] In this embodiment, for each image area, the grayscale value of the image area can be sampled according to the sampling interval number that matches the image area. The sampling interval number here refers to the number of pixels in the image area at which the grayscale value of the pixel is sampled once. For example, if the sampling interval number is 0, it means that the grayscale value of each pixel in the image area is sampled. If the sampling interval number is 10, it means that for the image area, the grayscale value of the pixel is sampled once every 10 pixels.
[0098] As an embodiment, the number of sampling intervals may be inversely correlated with the average value of the grayscale values in the image area, that is, for an image area with a higher temperature (an image area with a higher average grayscale value), the image area is an area that requires more attention. In this case, a lower number of sampling intervals may be set for the image area to sample the grayscale values of more pixels in the image area, thereby increasing the frequency of the grayscale values in the image area and avoiding the loss of detail information during the histogram equalization process due to too few grayscale values collected in the image area.
[0099] Furthermore, for the image area on which the division operation is performed, different frequency weights can be configured for the multiple sub-areas obtained by dividing the image area. The frequency weight here refers to the frequency weight coefficient when performing frequency statistics on the grayscale values of the pixels collected in the sub-area. For example, if the frequency weight is 1, it means that every time any grayscale value is collected in the sub-area, the frequency of occurrence of the grayscale value increases by 1. The frequency weight is 10, which means that every time any grayscale value is collected in the sub-area, the frequency of occurrence of the grayscale value increases by 10.
[0100] As an embodiment, the frequency weight may be positively correlated with the average value of the grayscale value in the sub-region, that is, for a sub-region with a higher temperature (a sub-region with a higher average grayscale value) in the same image, the sub-region is an area that requires more attention. In this case, a higher frequency weight may be set for the sub-region, so that after sampling the grayscale values of the pixels in the sub-region, the frequency of occurrence of the grayscale values in the sub-region is increased when the frequency of occurrence of the grayscale values is counted, so as to avoid the loss of detail information in the histogram equalization process due to too few occurrences of the grayscale values in the sub-region.
[0101] After determining the number of sampling intervals that match each image region and the frequency weight that matches each sub-region, for each sub-region, the grayscale values of the pixels in the sub-region can be sampled according to the number of sampling intervals that match the image region to which the sub-region belongs, and the frequency of occurrence of each grayscale value in the sub-region can be counted according to the frequency weight that matches the sub-region to obtain the grayscale value statistical result of the sub-region.
[0102] As an example, the grayscale value statistical result includes each grayscale value included in the region and the occurrence frequency corresponding to each grayscale value, and the grayscale value statistical result can be presented in the form of a table.
[0103] Gray value Frequency 163 10 182 36 203 28
[0104] Table 1
[0105] As shown in Table 1, Table 1 shows the grayscale value statistical result of an exemplary sub-region, indicating the occurrence frequency of each grayscale value in the sub-region. Among them, the grayscale value 163 appears 10 times, the grayscale value 182 appears 36 times, and the grayscale value 203 appears 28 times.
[0106] So far, the description of step 203 is completed, and then step 204 is executed.
[0107] Step 204: Adjust the grayscale value of each pixel point in the original infrared image according to the grayscale value statistical result of each sub-region and the grayscale value sampled from the image region where the partitioning operation has not been performed, to obtain the target infrared image.
[0108] In this embodiment, after obtaining the grayscale value statistical result of each sub-region and the grayscale value sampled from the image region where the partitioning operation has not been performed through step 203, the grayscale value of each pixel point in the original infrared image can be adjusted according to the grayscale value statistical result of each sub-region and the grayscale value sampled from the image region where the partitioning operation has not been performed, to obtain the target infrared image.
[0109] Specifically, the weighted grayscale value statistical result of the original infrared image can be determined according to the grayscale value statistical result of each sub-region and the grayscale value sampled from the image region where the partitioning operation has not been performed; the weighted grayscale value statistical result includes the occurrence frequency of each grayscale value in the original infrared image;
[0110] Determine the cumulative grayscale value statistical result according to the weighted grayscale value statistical result; the cumulative grayscale value statistical result includes the cumulative occurrence frequency of each grayscale value in the original infrared image, and the cumulative occurrence frequency of any grayscale value refers to the sum of the occurrence frequencies of all grayscale values less than or equal to that grayscale value;
[0111] For each pixel point in the original infrared image, adjust the grayscale value of the pixel point according to the cumulative occurrence frequency of the grayscale value of the pixel point, the cumulative occurrence frequency of the maximum grayscale value included in the original infrared image, the maximum grayscale value included in the original infrared image, and the minimum grayscale value included in the original infrared image.
[0112] In this embodiment, for the partitioned image region, the grayscale value statistical results of the sub-regions it is partitioned into can be summarized to determine the grayscale value statistical result of the image region.
[0113] For an unpartitioned image region, after sampling the grayscale values of the pixel points in the image region according to the number of sampling intervals matched to the image region to obtain the grayscale values sampled from the image region where the partitioning operation has not been performed, the occurrence frequency of each grayscale value in the image region can be statistically counted according to the default frequency weight to obtain the grayscale value statistical result of the unpartitioned image region.
[0114] In this embodiment, the unpartitioned image region can correspond to the default frequency weight. After completing the sampling according to the matched number of sampling intervals, the frequency statistics can be performed according to the default frequency weight. For example, if the default frequency weight is 1, the sampling result can be directly statistically counted.
[0115] After determining the grayscale value statistical results of each image region, the grayscale value statistical results of each image region included in the original infrared image can be summarized to obtain the weighted grayscale value statistical result of the original infrared image, that is, the occurrence frequency of each grayscale value in the original infrared image.
[0116] Furthermore, according to the weighted grayscale value statistical result of the original infrared image, the cumulative calculation can be performed on the occurrence frequency of each grayscale value to determine the cumulative value of the occurrence frequency of each grayscale value, and the cumulative statistical result of each grayscale value in the original infrared image can be obtained.
[0117] Exemplarily, performing the cumulative calculation on the occurrence frequency of each grayscale value means that for each grayscale value, the sum of the occurrence frequencies of all grayscale values less than or equal to that grayscale value is used as the cumulative value of the occurrence frequency of that grayscale value.
[0118] After determining the cumulative statistical results of each grayscale value in the original infrared image, for each pixel point in the original infrared image, the grayscale value of the pixel point can be adjusted according to the cumulative occurrence frequency of the grayscale value of the pixel point, the cumulative occurrence frequency of the maximum grayscale value included in the original infrared image, the maximum grayscale value included in the original infrared image, and the minimum grayscale value included in the original infrared image.
[0119] Specifically, for each grayscale value in the original infrared image, the adjusted grayscale value is determined by the following formula:
[0120]
[0121] where S is the adjusted grayscale value, f is the cumulative occurrence frequency of the original grayscale value in the original infrared image, N is the cumulative occurrence frequency of the maximum grayscale value of the original infrared image, t max is the maximum grayscale value of the original infrared image, t min is the minimum grayscale value of the original infrared image.
[0122] According to the above formula, the adjusted gray value of each gray value in the original infrared image can be determined, and then the target infrared image can be obtained by adjusting each gray value.
[0123] Please refer to Figure 4 , Figure 4 which is a schematic diagram of an infrared image scene processed by the infrared enhancement method proposed in this application provided by an embodiment of this application.
[0124] As Figure 4 shown, different from the infrared image in Figure 1 where the gray value equalization processing is directly performed by the histogram equalization algorithm, Figure 4 for the infrared image processed by the infrared enhancement method proposed in this application, the contrast of the entire image is improved. In the high-temperature area, that is, the area where the building is located, some details of the building drawing, such as the outline of the window, can be more clearly displayed. At the same time, it also greatly reduces Figure 1 the "whitening" situation of the infrared image in
[0125] It is easy to understand that through steps 201 to 204, the high-temperature area that needs to be focused on in the original infrared image has been adjusted in terms of statistical frequency, so that after processing the adjusted infrared image by the histogram equalization algorithm, the obtained target infrared image can retain the hierarchical details of the high-temperature area and improve the display effect of the infrared image.
[0126] So far, the description of step 204 is completed.
[0127] In this embodiment, a common specific scenario is also proposed, that is, the original infrared image is divided into a first image area and a second image area, and the average value of the gray values of the pixel points in the first image area is less than the average value of the gray values of the pixel points in the second image area.
[0128] It should be noted that this scenario actually means that the original infrared image is divided into two image areas. One area (denoted as the first image area) is a low-temperature area, and most of the images in this area are images that do not need to be concerned. However, there may also be some small areas with higher temperatures in this low-temperature area. For such small areas with higher temperatures, they are also areas that need to be focused on in the infrared image; the other image area (denoted as the second image area) is a high-temperature area, that is, the area where the images in this area need to be focused on.
[0129] As an example, the above scenario can correspond to a half-sky and half-ground image scenario, that is, the infrared image includes a sky region and a ground region. The above first image region corresponds to the sky region. Generally, in an infrared image, the overall low-temperature region such as the sky region is not concerned. However, there may also be some small regions with relatively high temperatures in the sky region, such as regions where some flying animals or aircraft are located, or regions where local temperature increases are formed due to the presence of water vapor or ice crystals in the clouds. These regions are usually also the regions that need to be concerned in the infrared image.
[0130] For the infrared image in the above scenario, the present application proposes a specific infrared image enhancement method.
[0131] Exemplarily, the first image region can be divided into a high-temperature sub-region and a low-temperature sub-region according to a gray-scale threshold. The gray-scale values of the pixel points in the high-temperature sub-region are greater than the gray-scale threshold, and the gray-scale values of the pixel points in the low-temperature sub-region are less than or equal to the gray-scale threshold.
[0132] Sample the gray-scale values of the pixel points in the first image region by the first sampling interval number; count the occurrence frequencies of the gray-scale values in the high-temperature sub-region according to the first frequency weight matched by the high-temperature sub-region to obtain the gray-scale value statistical result of the high-temperature sub-region; count the occurrence frequencies of the gray-scale values in the low-temperature sub-region according to the second frequency weight matched by the low-temperature sub-region to obtain the gray-scale value statistical result of the low-temperature sub-region; the first frequency weight is greater than the second frequency weight;
[0133] Sample the gray-scale values of the pixel points in the second image region by the second sampling interval number; the first sampling interval number is greater than the second sampling interval number.
[0134] In this embodiment, since the second image region is all the image regions that need to be concerned, the second image region can no longer be further divided, but a lower sampling interval (denoted as the second sampling interval) is used. For example, the second image region is sampled by a point-by-point sampling method to sample the gray-scale value of each pixel point in the second image region to avoid missing the detection of the gray-scale values included in this region.
[0135] For the first image region, since most of the regions included in the first image region are low-temperature regions that do not require attention, a relatively high sampling interval (denoted as the first sampling interval, where the first sampling interval is greater than the second sampling interval) can be set for the first image region to avoid excessive sampling of the gray values in the regions that do not require attention in the first image region. However, since there are still some high-temperature regions that need further attention in the first image region, when its sampling interval has been set relatively high, the first image region can be further divided into a high-temperature sub-region and a low-temperature sub-region, and by adjusting the frequency weight of the high-temperature sub-region to increase the frequency of the gray values in the high-temperature sub-region, so as to avoid losing the details corresponding to the high-temperature sub-region during the process of histogram equalization.
[0136] In this embodiment, the sampling method of the first image region can be downsampling (i.e., sampling once for multiple points), and the sampling method of the second image region can be point-by-point sampling.
[0137] Consistent with the description in step 202 above, the gray value threshold set for the first image region can be determined according to the gray values in the original infrared image. For example, the gray value threshold of the first 10% of the original infrared image can be obtained, denoted as temp1, and it can be statistically analyzed by histogram or other methods, and this application does not limit this.
[0138] The image is divided into two sub-regions according to the gray value threshold temp1, denoted as the high-temperature sub-region and the low-temperature sub-region. For the high-temperature sub-region, the occurrence frequency of each gray value in the high-temperature sub-region can be statistically analyzed according to the first frequency weight matched by the high-temperature sub-region. For the low-temperature sub-region, the occurrence frequency of each gray value in the low-temperature sub-region can be statistically analyzed according to the second frequency weight matched by the low-temperature sub-region. Since the high-temperature sub-region needs to be concerned, a relatively high frequency weight can be configured for the high-temperature sub-region, while the low-temperature sub-region does not need to be concerned, and a relatively low frequency weight can be configured for the low-temperature sub-region, or the default frequency weight can be directly used.
[0139] After determining the first sampling interval matched by the first image region, the second sampling interval matched by the second image region, the first frequency weight matched by the high-temperature sub-region, and the second frequency weight matched by the low-temperature sub-region, the gray value statistical results of each sub-region and the gray values sampled for the image region that has not been divided can be determined according to the above parameters, and further adjust the gray values of each pixel point in the original infrared image to obtain the target infrared image.
[0140] In this embodiment, the process of adjusting the gray values of each pixel point in the original infrared image according to the gray value statistical results of each sub-region and the gray values sampled for the image region that has not been divided to obtain the target infrared image has been described in detail above, and will not be elaborated here.
[0141] So far, the description of the flowchart of the mid-infrared image enhancement method is completed. Figure 2
[0142] In this application, the obtained original infrared image is divided into multiple image regions, and at least one image region is further divided to obtain multiple sub-regions. Different sampling interval numbers are configured for at least two different image regions, and different frequency weights are configured for different sub-regions in the same image region. The frequency of occurrence of each gray value in the original infrared image is counted according to the sampling interval numbers and frequency weights configured for each image region and each sub-region, and the gray value of each pixel point in the original infrared image is adjusted to obtain the target infrared image. According to the different sampling interval numbers set for different image regions of the original infrared image and the different frequency weights set for different sub-regions in the same region, the gray value of each pixel point in the original infrared image is adjusted, increasing the display contrast of the infrared image and improving the display effect of the infrared image.
[0143] Please refer to Figure 5 , Figure 5 which is a schematic structural diagram of an electronic device proposed in an embodiment of this application. At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a terminal interaction device at the logical level. Of course, in addition to the software implementation method, this application does not exclude other implementation methods, such as logical devices or a combination of software and hardware. That is to say, the execution subject of the following processing flow is not limited to each logical unit, but can also be hardware or logical devices.
[0144] Please refer to Figure 6 , Figure 6 which is a structural diagram of an infrared image enhancement device proposed in an embodiment of this application. As Figure 6 shown, the device may include a first division unit 601, a second division unit 602, a sampling and statistics unit 603, and a gray value adjustment unit 604. Specifically, the device includes:
[0145] The first division unit 601 is used to divide the original infrared image to obtain at least two image regions;
[0146] The second division unit 602 is used to divide at least one image region to obtain at least two sub-regions;
[0147] A sampling and statistics unit 603, configured to perform grayscale value sampling on each image region according to the number of sampling intervals matched by the image region, and, on the premise that the image region is subjected to a partitioning operation, for each sub-region into which the image region is partitioned, perform statistics on the occurrence frequencies of the grayscale values in the sub-region according to the frequency weights matched by the sub-region, to obtain the grayscale value statistical result of the sub-region; wherein, the number of sampling intervals matched by at least two image regions is different, and the frequency weights matched by at least two sub-regions are different;
[0148] A grayscale adjustment unit 604, configured to adjust the grayscale values of the pixel points in the original infrared image according to the grayscale value statistical results of the sub-regions and the grayscale values sampled for the image regions that are not subjected to the partitioning operation, to obtain a target infrared image.
[0149] Optionally, the first partitioning unit 601 is specifically configured to:
[0150] Perform image segmentation on the original infrared image based on a trained image segmentation model, to obtain at least two image regions, and the difference between the average values of the grayscale values of the pixel points in different image regions is greater than a preset threshold;
[0151] And / or, the second partitioning unit 602 is specifically configured to:
[0152] For each image region to be partitioned, determine at least one grayscale threshold matched by the image region; the grayscale threshold is determined depending on the grayscale values of the pixel points in the original infrared image;
[0153] Partition the image region according to the at least one grayscale threshold, to obtain at least two sub-regions corresponding to the image region; wherein, the grayscale values of the pixel values in different sub-regions are different;
[0154] And / or, the grayscale adjustment unit 604 is specifically configured to:
[0155] Determine the grayscale value weighted statistical result of the original infrared image according to the grayscale value statistical results of the sub-regions and the grayscale values sampled for the image regions that are not subjected to the partitioning operation; the grayscale value weighted statistical result includes the occurrence frequencies of the grayscale values in the original infrared image;
[0156] Determine the grayscale value cumulative statistical result according to the grayscale value weighted statistical result; the grayscale value cumulative statistical result includes the cumulative occurrence frequencies of the grayscale values in the original infrared image, and the cumulative occurrence frequency of any grayscale value refers to the sum of the occurrence frequencies of all grayscale values less than or equal to the grayscale value;
[0157] For each pixel in the original infrared image, adjust the gray value of the pixel according to the cumulative occurrence frequency of the gray value of the pixel, the cumulative occurrence frequency of the maximum gray value included in the original infrared image, the maximum gray value included in the original infrared image, and the minimum gray value included in the original infrared image;
[0158] And / or, the gray value adjustment unit 604 is specifically configured to:
[0159] For each gray value in the original infrared image, the adjusted gray value is determined by the following formula:
[0160]
[0161] Where S is the adjusted gray value, f is the cumulative occurrence frequency of the gray value, N is the cumulative occurrence frequency of the maximum gray value of the original infrared image, t max is the maximum gray value of the original infrared image, t min is the minimum gray value of the original infrared image;
[0162] And / or, the original infrared image is divided into a first image area and a second image area, and the average gray value of the pixels in the first image area is less than the average gray value of the pixels in the second image area; the second division unit 602 is specifically configured to:
[0163] Divide the first image area into a high-temperature sub-area and a low-temperature sub-area according to a gray threshold, where the gray value of each pixel in the high-temperature sub-area is greater than the gray threshold, and the gray value of each pixel in the low-temperature sub-area is less than or equal to the gray threshold;
[0164] And / or, the sampling and statistics unit 603 is specifically configured to:
[0165] Sample the gray values of the pixels in the first image area at a first sampling interval; statistically count the occurrence frequencies of the gray values in the high-temperature sub-area according to the first frequency weight matched by the high-temperature sub-area to obtain the gray value statistical result of the high-temperature sub-area; statistically count the occurrence frequencies of the gray values in the low-temperature sub-area according to the second frequency weight matched by the low-temperature sub-area to obtain the gray value statistical result of the low-temperature sub-area; the first frequency weight is greater than the second frequency weight;
[0166] Sample the gray values of the pixels in the second image area at a second sampling interval; the first sampling interval is greater than the second sampling interval.
[0167] So far, the description of the mid-infrared image enhancement device is completed. Figure 6 The description of the mid-infrared image enhancement device.
[0168] Correspondingly, an embodiment of the present application further provides a computer-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed, the method disclosed in the above examples of the present application can be implemented.
[0169] Exemplarily, the above computer-readable storage medium can be any electronic, magnetic, optical or other physical storage device that can contain or store information, such as executable instructions, data, and so on. For example, the computer-readable storage medium can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), solid state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or a combination thereof.
[0170] The above are only the preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the scope of protection of the present application.
Claims
1. An infrared image enhancement method, characterized in that The method includes: Dividing the original infrared image to obtain at least two image regions; Dividing at least one of the image regions to obtain at least two sub-regions; For each image region, sampling the gray values of the image region according to the number of sampling intervals matched by the image region, and on the premise that the image region is subjected to the dividing operation, for each sub-region among the multiple sub-regions into which the image region is divided, statistically counting the occurrence frequencies of the gray values in the sub-region according to the frequency weights matched by the sub-region to obtain the gray value statistical result of the sub-region; wherein, the number of sampling intervals matched by at least two image regions is different, and the frequency weights matched by at least two sub-regions are different; Adjusting the gray values of each pixel point in the original infrared image according to the gray value statistical results of each sub-region and the gray values sampled from the image regions that have not been subjected to the dividing operation to obtain the target infrared image.
2. The method according to claim 1, characterized in that, The dividing the original infrared image to obtain at least two image regions includes: Performing image segmentation on the original infrared image based on a trained image segmentation model to obtain at least two image regions; the difference between the average gray values of the pixel points in different image regions is greater than a specified threshold.
3. The method according to claim 1, characterized in that, The dividing at least one of the image regions to obtain at least two sub-regions includes: For each image region to be divided, determining at least one gray threshold matched by the image region; the gray threshold is determined depending on the gray values of each pixel point in the original infrared image; Dividing the image region according to the at least one gray threshold to obtain at least two sub-regions corresponding to the image region; wherein, the gray values of the pixel values in different sub-regions are different.
4. The method according to claim 1, wherein The adjusting the gray values of each pixel point in the original infrared image according to the gray value statistical results of each sub-region and the gray values sampled from the image regions that have not been subjected to the dividing operation includes: Determining the weighted gray value statistical result of the original infrared image according to the gray value statistical results of each sub-region and the gray values sampled from the image regions that have not been subjected to the dividing operation; the weighted gray value statistical result includes the occurrence frequencies of each gray value in the original infrared image; Determining the cumulative gray value statistical result according to the weighted gray value statistical result; the cumulative gray value statistical result includes the cumulative occurrence frequencies of each gray value in the original infrared image, and the cumulative occurrence frequency of any gray value refers to the sum of the occurrence frequencies of all gray values less than or equal to that gray value; For each pixel point in the original infrared image, adjusting the gray value of the pixel point according to the cumulative occurrence frequency of the gray value of the pixel point, the cumulative occurrence frequency of the maximum gray value included in the original infrared image, the maximum gray value included in the original infrared image, and the minimum gray value included in the original infrared image.
5. The method according to claim 4, wherein The adjusting the gray value of each pixel point in the original infrared image according to the cumulative occurrence frequency of the gray value of the pixel point, the cumulative occurrence frequency of the maximum gray value of the original infrared image, the maximum gray value of the original infrared image, and the minimum gray value of the original infrared image includes: For each gray value in the original infrared image, the adjusted gray value is determined by the following formula: where S is the adjusted gray value, f is the cumulative occurrence frequency of this gray value, N is the cumulative occurrence frequency of the maximum gray value of the original infrared image, and t max is the maximum gray value of the original infrared image, and t min is the minimum gray value of the original infrared image.
6. The method according to claim 3, characterized in that The original infrared image is divided into a first image region and a second image region, and the average gray value of the pixel points in the first image region is less than the average gray value of the pixel points in the second image region; The dividing of at least one image region to obtain at least two sub-regions includes: Dividing the first image region into a high-temperature sub-region and a low-temperature sub-region according to the gray threshold, where the gray value of each pixel point in the high-temperature sub-region is greater than the gray threshold, and the gray value of each pixel point in the low-temperature sub-region is less than or equal to the gray threshold.
7. The method according to claim 6, wherein For each image region, the gray value of the image region is sampled according to the sampling interval number matched by the image region, and on the premise that the image region is subjected to a dividing operation, for each sub-region obtained by dividing the image region, the occurrence frequency of each gray value in the sub-region is statistically analyzed according to the frequency weight matched by the sub-region, and the gray value statistical result of the sub-region is obtained, including: Sampling the gray value of the pixel points in the first image region by the first sampling interval number; statistically analyzing the occurrence frequency of each gray value in the high-temperature sub-region according to the first frequency weight matched by the high-temperature sub-region to obtain the gray value statistical result of the high-temperature sub-region; statistically analyzing the occurrence frequency of each gray value in the low-temperature sub-region according to the second frequency weight matched by the low-temperature sub-region to obtain the gray value statistical result of the low-temperature sub-region; the first frequency weight is greater than the second frequency weight; Sampling the gray value of the pixel points in the second image region by the second sampling interval number; the first sampling interval number is greater than the second sampling interval number.
8. An infrared image enhancement device, characterized in that, The device includes: A first dividing unit for dividing the original infrared image to obtain at least two image regions; A second dividing unit for dividing at least one image region to obtain at least two sub-regions; A sampling and statistical unit for, for each image region, sampling the gray value of the image region according to the sampling interval number matched by the image region, and on the premise that the image region is subjected to a dividing operation, for each sub-region obtained by dividing the image region, statistically analyzing the occurrence frequency of each gray value in the sub-region according to the frequency weight matched by the sub-region to obtain the gray value statistical result of the sub-region; wherein, the sampling interval numbers matched by at least two image regions are different, and the frequency weights matched by at least two sub-regions are different; A gray value adjustment unit for adjusting the gray value of each pixel point in the original infrared image according to the gray value statistical result of each sub-region and the gray value sampled for the image region that has not been subjected to the dividing operation, to obtain the target infrared image.
9. The device according to claim 8, characterized in that, The first dividing unit is specifically used for: Performing image segmentation on the original infrared image based on a trained image segmentation model to obtain at least two image regions, and the difference between the average gray values of the pixel points in different image regions is greater than a specified threshold; And / or, the second dividing unit is specifically used for: For each image region to be partitioned, determine at least one gray-scale threshold value that the image region matches; the gray-scale threshold value is determined based on the gray-scale values of each pixel point in the original infrared image; Partition the image region according to the at least one gray-scale threshold value to obtain at least two sub-regions corresponding to the image region; wherein, the gray-scale values of the pixel values in different sub-regions are different; And / or, the gray-scale adjustment unit is specifically configured to: Determine the weighted statistical result of the gray-scale values of the original infrared image according to the statistical result of the gray-scale values of each sub-region and the gray-scale values sampled from the image regions that have not been partitioned; the weighted statistical result of the gray-scale values includes the occurrence frequency of each gray-scale value in the original infrared image; Determine the cumulative statistical result of the gray-scale values according to the weighted statistical result of the gray-scale values; the cumulative statistical result of the gray-scale values includes the cumulative occurrence frequency of each gray-scale value in the original infrared image, and the cumulative occurrence frequency of any gray-scale value refers to the sum of the occurrence frequencies of all gray-scale values less than or equal to this gray-scale value; For each pixel point in the original infrared image, adjust the gray-scale value of this pixel point according to the cumulative occurrence frequency of the gray-scale value of this pixel point, the cumulative occurrence frequency of the maximum gray-scale value included in the original infrared image, the maximum gray-scale value included in the original infrared image, and the minimum gray-scale value included in the original infrared image; And / or, the gray-scale adjustment unit is specifically configured to: For each gray-scale value in the original infrared image, the adjusted gray-scale value is determined by the following formula: Wherein, S is the adjusted gray value, f is the cumulative occurrence frequency of this gray value, N is the cumulative occurrence frequency of the maximum gray value of the original infrared image, and t max is the maximum gray value of the original infrared image, and t min is the minimum gray value of the original infrared image; And / or, the original infrared image is partitioned into a first image region and a second image region, and the average value of the gray-scale values of the pixel points in the first image region is less than the average value of the gray-scale values of the pixel points in the second image region; the second partitioning unit is specifically configured to: Partition the first image region into a high-temperature sub-region and a low-temperature sub-region according to the gray-scale threshold value, the gray-scale values of the pixel points in the high-temperature sub-region are greater than the gray-scale threshold value, and the gray-scale values of the pixel points in the low-temperature sub-region are less than or equal to the gray-scale threshold value; And / or, the sampling and statistical unit is specifically configured to: Sample the gray-scale values of the pixel points in the first image region at a first sampling interval number; statistically count the occurrence frequencies of the gray-scale values in the high-temperature sub-region according to the first frequency weight matched by the high-temperature sub-region to obtain the statistical result of the gray-scale values of the high-temperature sub-region; statistically count the occurrence frequencies of the gray-scale values in the low-temperature sub-region according to the second frequency weight matched by the low-temperature sub-region to obtain the statistical result of the gray-scale values of the low-temperature sub-region; the first frequency weight is greater than the second frequency weight; Sample the gray-scale values of the pixel points in the second image region at a second sampling interval number; the first sampling interval number is greater than the second sampling interval number.
10. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method described in any one of claims 1 to 7.