Method and device for processing infrared images
By truncating the number of grayscale pixels in the infrared image and then performing histogram equalization, the problem of overexposure in infrared image processing is solved and the visual effect of the image is improved.
Patent Information
- Application Number
- CN202111482382.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2041-12-06
AI Technical Summary
In the prior art, after histogram equalization processing, infrared images are prone to overexposure due to excessive contrast between the target and the background.
By determining the initial number of pixels corresponding to each grayscale value in the target infrared image and truncating it, the truncated pixel number is generated and then processed by the histogram equalization algorithm to avoid the excessive initial pixel number of the background part leading to a large cumulative probability of the target part.
It effectively avoids excessive contrast between the target and the background in the processed infrared image, prevents overexposure of the image, and improves the visual effect of the image.
Smart Images

Figure CN114359067B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a method and device for processing infrared images. Background Art
[0002] As we all know, raw infrared images captured by infrared detectors have poor resolution, low contrast, and a blurred visual effect. Traditional histogram equalization (HE) algorithms are typically used to enhance raw infrared images. However, after processing with these histogram equalization algorithms, the contrast between the target and the background is excessive, resulting in overexposure.
[0003] Therefore, how to avoid overexposure of processed images is an urgent problem that needs to be solved. Summary of the Invention
[0004] The present application provides a method and apparatus for processing infrared images, which can avoid overexposure of processed images.
[0005] In a first aspect, a method for processing infrared images is provided, including: determining the initial number of pixels corresponding to each grayscale value in a target infrared image; truncating the initial number of pixels corresponding to each grayscale value to obtain the truncated number of pixels corresponding to each grayscale value, wherein, when the initial number of pixels of a first grayscale value is greater than a number threshold, the truncated number of pixels of the first grayscale value is the number threshold; when the initial number of pixels of the first grayscale value is less than or equal to the number threshold, determining the truncated number of pixels of the first grayscale value to be the initial number of pixels of the first grayscale value; the first grayscale value is any one of the grayscale values; processing the truncated number of pixels corresponding to each grayscale value by a histogram equalization algorithm to generate a processed image.
[0006] The method provided in the present application can be executed by a chip in a terminal device. Since the number of pixels occupied by the background portion of the target infrared image is much larger than the number of pixels occupied by the target portion, and the grayscale value of the background portion is smaller than the grayscale value of the target portion, when the target infrared image is processed using the traditional HE algorithm, the cumulative probability corresponding to each grayscale value of the background portion will make the cumulative probability of each grayscale value of the target portion larger; however, the present method uses a quantity threshold to truncate the initial number of pixels of each grayscale value in the target and background, so that the number of pixels occupied by the background portion and the number of pixels occupied by the target portion will not differ greatly, thereby avoiding the situation where the initial number of pixels of the background portion is too large, resulting in a larger cumulative probability corresponding to each grayscale value of the target portion, and further avoiding the problem of excessive contrast between the target and the background after the HE algorithm processes the target infrared image, resulting in overexposure of the image.
[0007] Optionally, the quantity threshold is the product of the number of pixels of the target infrared image and a truncation coefficient.
[0008] Optionally, before determining the initial number of pixels corresponding to each grayscale value in the target infrared image, the method further includes: generating an original grayscale histogram based on the original infrared image, the original grayscale histogram including the number of pixels of multiple grayscale values; determining the target infrared image based on a grayscale threshold, the target infrared image being an image in which the grayscale value in the original grayscale histogram is less than or equal to the grayscale threshold, or the target infrared image being an image in which the grayscale value in the original grayscale histogram is greater than the grayscale threshold.
[0009] Since the number of pixels occupied by the background part of the original infrared image is much larger than the number of pixels occupied by the target part, and the grayscale value of the background part is smaller, and the grayscale value of the target part is larger; if the HE algorithm is directly used to calculate the cumulative probability of each grayscale value on the original grayscale histogram, the larger number of pixels corresponding to each grayscale value in the background part will cause the cumulative probability of each grayscale value in the target part to be too large, resulting in a situation where the contrast between the target and the background is too large; and this embodiment can divide the original grayscale histogram into grayscale histograms with different grayscale value ranges according to the grayscale threshold, for example, the original grayscale histogram is divided into a grayscale histogram of the background part and a grayscale histogram of the target part, and the grayscale histograms of different grayscale value ranges are processed respectively using the HE algorithm, which can avoid the situation where the number of pixels in the background part causes the cumulative probability of each grayscale value in the target part to be too large, thereby avoiding the situation where the contrast between the target and the background is too large after the HE algorithm processes the target infrared image.
[0010] Optionally, before determining the target infrared image according to the grayscale threshold, the method further includes: determining the number of pixels N of the original infrared image; determining the grayscale threshold according to the number of pixels of the multiple grayscale values and N, wherein, when the number of pixels of the minimum grayscale value among the multiple grayscale values is greater than or equal to N / M, the grayscale threshold is the minimum grayscale value; when the number of pixels of the minimum grayscale value among the multiple grayscale values is less than N / M, the grayscale threshold is the kth grayscale value when the multiple grayscale values are arranged from small to large, the number of pixels of the smaller first k-1 grayscale values among the multiple grayscale values is less than N / M, and the number of pixels of the smaller first k+1 grayscale values among the multiple grayscale values is greater than N / M, wherein k is a positive integer greater than 1, and M is a positive number greater than 1 and less than N.
[0011] Optionally, the processing of the number of truncated pixels corresponding to each grayscale value by a histogram equalization algorithm to generate a processed image includes: determining the cumulative number of truncated pixels for each grayscale value based on the number of truncated pixels corresponding to each grayscale value; determining the mapping coefficient of each grayscale value based on the cumulative number of truncated pixels for each grayscale value, wherein the mapping coefficient of the first grayscale value is the cumulative number of truncated pixels of the first grayscale value divided by the sum of the cumulative number of truncated pixels corresponding to each grayscale value; determining the mapping grayscale value of each grayscale value based on the mapping coefficient of each grayscale value and a preset grayscale value, wherein the mapping grayscale value of the first grayscale value is the mapping coefficient of the first grayscale value multiplied by the preset grayscale value; and generating the processed image based on the mapping grayscale value of each grayscale value.
[0012] In a second aspect, a device for processing infrared images is provided, the device comprising:
[0013] A determination module is used to determine the initial number of pixels corresponding to each grayscale value in the target infrared image;
[0014] a processing module, configured to perform truncation processing on the initial number of pixels corresponding to each grayscale value to obtain the truncated number of pixels corresponding to each grayscale value, wherein when the initial number of pixels of a first grayscale value is greater than a number threshold, the truncated number of pixels of the first grayscale value is the number threshold; when the initial number of pixels of the first grayscale value is less than or equal to the number threshold, the truncated number of pixels of the first grayscale value is determined to be the initial number of pixels of the first grayscale value; the first grayscale value is any one of the grayscale values;
[0015] The generating module processes the number of truncated pixels corresponding to each grayscale value through a histogram equalization algorithm to generate a processed image.
[0016] In a third aspect, a terminal device is provided, comprising a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the terminal device executes any one of the methods described in the first aspect.
[0017] According to a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the method according to any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0019] Figure 1 This is a flow chart of a method for processing infrared images according to an embodiment of the present invention;
[0020] Figure 2 Schematic diagram of the results of processing a target infrared image using the method of the present application and a traditional histogram equalization algorithm in an embodiment of the present invention;
[0021] Figure 3 Schematic diagram of an original grayscale histogram in an embodiment of the present invention;
[0022] Figure 4 Schematic diagram of a first truncated grayscale histogram and a second truncated grayscale histogram in an embodiment of the present invention;
[0023] Figure 5 Schematic diagram of an apparatus for processing infrared images according to an embodiment of the present invention;
[0024] Figure 6 Schematic diagram of the structure of the terminal device in an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.
[0026] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0027] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0028] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0029] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Therefore, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0030] Due to the poor resolution, low contrast, and blurred visual effects of raw infrared images, the traditional histogram equalization (HE) algorithm is usually used to enhance the raw infrared images. However, the number of pixels occupied by the background portion of the raw infrared image is much larger than the number of pixels occupied by the target portion, and the grayscale values in the background portion are relatively small, while the grayscale values in the target portion are relatively large. The core of the histogram equalization (HE) algorithm is to calculate the cumulative probability of each grayscale value based on the number of pixels corresponding to each grayscale value in the raw infrared image. The extremely large number of pixels in the background portion will cause the cumulative probability of each grayscale value in the target portion to be too large, resulting in the infrared image processed by the histogram equalization algorithm to have a large contrast between the target and the background, resulting in overexposure of the image. Therefore, how to avoid overexposure in the processed image is an urgent problem that needs to be solved.
[0031] The present application is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0032] Figure 1 This is a flow chart of a method for processing infrared images in an embodiment of the present application. The method for processing infrared images provided in an embodiment of the present application is applied to a terminal device, and the execution subject of the method is the terminal device. The method includes:
[0033] S101, determining the initial number of pixels corresponding to each grayscale value in the target infrared image.
[0034] Exemplarily, the target infrared image includes the original infrared image and the non-original infrared image collected by the infrared detector, wherein the non-original infrared image refers to the image after preprocessing the original infrared image. The above preprocessing includes image segmentation, smoothing, 2D noise reduction, 3D noise reduction, sharpening, etc. The above initial number of pixels refers to the number of pixels of the target infrared image itself. Since the grayscale value of the original infrared image collected by the infrared detector is stored in a 14-bit binary number, the grayscale value range of the original infrared image is 0 to 16383 (i.e. 2 14 -1).
[0035] For example, the target infrared image is an original infrared image with a size of 224×224, that is, the initial number of pixels of the original infrared image is 50176, and the grayscale value range is 0 to 16383; the terminal device counts the initial number of pixels corresponding to each grayscale value in the original infrared image, that is, counts the number of pixels corresponding to each grayscale value from 0 to 16383; for example, the initial number of pixels with a grayscale value of 50 is 800, the initial number of pixels with a grayscale value of 1677 is 600, the initial number of pixels with a grayscale value of 8000 is 800, and so on, until the initial number of pixels corresponding to each grayscale value in the original infrared image is counted.
[0036] As an optional embodiment, before determining the initial number of pixels corresponding to each grayscale value in the target infrared image, the method further includes: generating an original grayscale histogram based on the original infrared image, the original grayscale histogram including the number of pixels of multiple grayscale values; determining the target infrared image based on a grayscale threshold, the target infrared image being an image in the original grayscale histogram having grayscale values less than or equal to the grayscale threshold, or the target infrared image being an image in the original grayscale histogram having grayscale values greater than the grayscale threshold. The grayscale threshold refers to the grayscale dividing value that divides the original infrared image into different grayscale value ranges. The original grayscale histogram is a grayscale histogram obtained by counting the number of times each grayscale value appears in the original infrared image. The original grayscale histogram not only includes the number of pixels of multiple grayscale values, but also represents the number of pixels corresponding to each grayscale value in the form of a histogram.
[0037] The grayscale threshold can be one or more. For example, if the grayscale threshold is only T1, and T1 = 8000, and the grayscale value range of the original grayscale histogram is 0 to 16383, then the first sub-original infrared image corresponding to the grayscale histogram with grayscale values less than or equal to 8000 in the original grayscale histogram is the target infrared image; or, the second sub-original infrared image corresponding to the grayscale histogram with grayscale values greater than 8000 in the original grayscale histogram is the target infrared image. That is, the sub-original infrared image obtained by performing image segmentation on the original infrared image using the grayscale threshold is the target infrared image.
[0038] For another example, the grayscale thresholds are T1 and T2, and T1=6000 and T2=10000, and the grayscale value range of the original grayscale histogram is still 0 to 16383; for the grayscale histogram with grayscale values less than or equal to T1=6000 in the original grayscale histogram, the first sub-original infrared image corresponding to the grayscale histogram is the target infrared image; or, for the grayscale histogram with grayscale values greater than T1=6000 and less than or equal to T2=8000 in the original grayscale histogram, the second sub-original infrared image corresponding to the grayscale histogram is the target infrared image; or, for the grayscale histogram with grayscale values greater than T2=8000 in the original grayscale histogram, the third sub-original infrared image corresponding to the grayscale histogram is the target infrared image.
[0039] As an optional embodiment, before determining the target infrared image according to the grayscale threshold, it also includes: determining the number of pixels N of the original infrared image; determining the grayscale threshold according to the number of pixels of multiple grayscale values and N, wherein, when the number of pixels of the minimum grayscale value among the multiple grayscale values is greater than or equal to N / M, the grayscale threshold is the minimum grayscale value; when the number of pixels of the minimum grayscale value among the multiple grayscale values is less than N / M, the grayscale threshold is the kth grayscale value when the multiple grayscale values are arranged from small to large, the number of pixels of the smaller first k-1 grayscale values among the multiple grayscale values is less than N / M, and the number of pixels of the smaller first k+1 grayscale values among the multiple grayscale values is greater than N / M, k is a positive integer greater than 1, and M is a positive number greater than 1 and less than N.
[0040] For example, taking M=2 as an example, the original infrared image with a size of 224×224 has N=50176 pixels, and the grayscale value range is 0 to 16383 (i.e., 16384 grayscale values); M=2 divides the number of pixels of the original infrared image into two segments of pixel numbers, wherein the dividing point F between the first segment and the second segment of pixel numbers is 25088 (i.e., N / M=50176 / 2); if the number of pixels with the minimum grayscale value of 0 in the 16384 grayscale values is 26000 (greater than the dividing point F=25088), then the terminal device sets the grayscale threshold Set to 0; if the number of pixels with the minimum grayscale value of 0 among the 16384 grayscale values is 8000 (less than the dividing point F = 25088), the terminal device calculates the number of pixels of each grayscale value in order from small to large, until the cumulative sum of the number of pixels corresponding to the k-th grayscale value is greater than the dividing point F = 25088, and the cumulative sum of the number of pixels corresponding to the k-1-th grayscale value is less than the dividing point F = 25088, and the cumulative sum of the number of pixels corresponding to the k+1-th grayscale value is greater than the dividing point F = 25088. Finally, the terminal device determines that the k-th grayscale value is the grayscale threshold.
[0041] For example, if the first grayscale value is the minimum grayscale value 0 and the number of pixels is 8305, the second grayscale value is 5 and the number of pixels is 4022, the third grayscale value is 9 and the number of pixels is 6032, the fourth grayscale value is 21 and the number of pixels is 2088, the fifth grayscale value is 23 and the number of pixels is 6301, and the sixth grayscale value is 43 and the number of pixels is 3320, then the cumulative sum of the number of pixels corresponding to the first grayscale value 0 is 8305, and the number of pixels corresponding to the second grayscale value 5 is 8305. The cumulative sum is 12327 (that is, the sum of the number of pixels with the first gray value of 0, 8305, and the number of pixels with the second gray value of 5, 4022). The cumulative sum of the number of pixels corresponding to the third gray value of 9 is 18359 (that is, the number of pixels with the first gray value of 0, 8305, plus the number of pixels with the second gray value of 5, 4022, plus the number of pixels with the third gray value of 9, which is 6032). Similarly, the cumulative sum of the number of pixels corresponding to the fourth gray value of 21 is 20447 (that is, 8305). +4022+6032+2088), the cumulative sum of the number of pixels corresponding to the fifth grayscale value of 23 is 26748 (i.e. 8305+4022+6032+2088+6301), and the cumulative sum of the number of pixels corresponding to the sixth grayscale value of 43 is 30068 (i.e. 8305+4022+6032+2088+6301+3320); the terminal device learns by analyzing the cumulative sum of the number of pixels corresponding to the above six grayscale values that the fourth (i.e. the kth -1) The cumulative sum of the number of pixels corresponding to the grayscale value of 21 is 20447, which is less than the dividing point F=25088; the cumulative sum of the number of pixels corresponding to the fifth (i.e. k-th) grayscale value of 23 is 26748, which is greater than the dividing point F=25088; the cumulative sum of the number of pixels corresponding to the sixth (i.e. k+1-th) grayscale value of 43 is 30068, which is greater than the dividing point F=25088. It can be seen that the terminal device determines the fifth grayscale value 23 as the grayscale threshold, that is, the grayscale threshold is 23.
[0042] For example, taking M=3 as an example, the original infrared image with a size of 224×224 has N=50176 pixels, and the grayscale value range is 0 to 16383 (i.e., 16384 grayscale values); M=3 divides the number of pixels of the original infrared image into three segments, wherein the dividing point F1 between the first segment and the second segment is 16725 (i.e., N / M=50176 / 3); the dividing point F2 between the second segment and the third segment is 33451 (i.e., the number of pixels in the first segment is 16725 plus 50176 / 3); if the number of pixels with the minimum grayscale value of 0 in the 16384 grayscale values is 18000 (greater than the dividing point point F1=16725), the terminal device sets the grayscale threshold to 0; if the number of pixels with the minimum grayscale value of 0 among the 16384 grayscale values is 8000 (less than the dividing point F1=16725), the terminal device calculates the number of pixels of each grayscale value in order from small to large, until the cumulative sum of the number of pixels corresponding to the k1th grayscale value is greater than the dividing point F1=16725, and the cumulative sum of the number of pixels corresponding to the k1-1th grayscale value is less than the dividing point F1=16725, and the cumulative sum of the number of pixels corresponding to the k1+1th grayscale value is greater than the dividing point F1=16725. Finally, the terminal device determines that the k1th grayscale value is the first grayscale threshold.
[0043] Similarly, if the cumulative sum of the number of pixels corresponding to the k1+1th grayscale value is 18000 (greater than the dividing point F2=33451), the terminal device sets the grayscale threshold to k1+1; if the cumulative sum of the number of pixels corresponding to the k1+1th grayscale value is 9000 (less than the dividing point F2=33451), the terminal device calculates the number of pixels of each grayscale value in order from small to large, until the cumulative sum of the number of pixels corresponding to the k2th grayscale value is greater than the dividing point F2=33451, and the cumulative sum of the number of pixels corresponding to the k2-1th grayscale value is less than the dividing point F2=33451, and the cumulative sum of the number of pixels corresponding to the k2+1th grayscale value is greater than the dividing point F2=33451. Finally, the terminal device determines that the k2th grayscale value is the second grayscale threshold.
[0044] For example, if the first grayscale value is the minimum grayscale value 0 and the number of pixels is 8305, the second grayscale value is 7 and the number of pixels is 4022, the third grayscale value is 18 and the number of pixels is 6032, the fourth grayscale value is 34 and the number of pixels is 2088, the fifth grayscale value is 57 and the number of pixels is 6301, the sixth grayscale value is 103 and the number of pixels is 3320, the seventh grayscale value is 143 and the number of pixels is 2120, the eighth grayscale value is 152 and the number of pixels is 1320, the ninth grayscale value is 258 and the number of pixels is 700, and the tenth grayscale value is 345 and the number of pixels is 689 , the cumulative sum of the number of pixels corresponding to the first grayscale value 0 is 8305, the cumulative sum of the number of pixels corresponding to the second grayscale value 7 is 12327 (that is, the sum of the number of pixels of the first grayscale value 0 8305 and the number of pixels of the second grayscale value 7 4022), the cumulative sum of the number of pixels corresponding to the third grayscale value 18 is 18359 (that is, the number of pixels of the first grayscale value 0 8305 plus the number of pixels of the second grayscale value 7 4022 plus the number of pixels of the third grayscale value 18 is 6032), similarly, the cumulative sum of the number of pixels corresponding to the fourth grayscale value 34 is 20447 (that is, 8305 +4022+6032+2088), the cumulative sum of the number of pixels corresponding to the fifth grayscale value of 57 is 26748 (i.e. 8305+4022+6032+2088+6301), the cumulative sum of the number of pixels corresponding to the sixth grayscale value of 103 is 30068 (i.e. 8305+4022+6032+2088+6301+3320); the cumulative sum of the number of pixels corresponding to the seventh grayscale value of 143 is 35188 (i.e. 8305+4022+6032+2088+6301+3320+2120); the cumulative sum of the number of pixels corresponding to the eighth grayscale value of 152 is 30068 (i.e. 8305+4022+6032+2088+6301+3320+2120); The cumulative sum of the number of pixels is 36508 (i.e. 8305+4022+6032+2088+6301+3320+2120+1320); the cumulative sum of the number of pixels corresponding to the ninth grayscale value of 258 is 37208 (i.e. 8305+4022+6032+2088+6301+3320+2120+1320+700); the cumulative sum of the number of pixels corresponding to the tenth grayscale value of 345 is 37897 (i.e. 8305+4022+6032+2088+6301+3320+2120+1320+700+689).
[0045] By analyzing the cumulative sum of the number of pixels corresponding to the above ten grayscale values, the terminal device finds that the cumulative sum of the number of pixels corresponding to the second (i.e., k1-1) grayscale value 7 is 12327, which is less than the dividing point F1 (=16725), the cumulative sum of the number of pixels corresponding to the third (i.e., k1) grayscale value 18 is 18359, which is greater than the dividing point F1 (=16725), and the cumulative sum of the number of pixels corresponding to the fourth (i.e., k1+1) grayscale value 34 is 20447, which is greater than the dividing point F1 (=16725). Therefore, the terminal device determines that the third (i.e., k1) grayscale value 18 is the first grayscale threshold, that is, the first grayscale threshold is 23. The cumulative sum of the number of pixels corresponding to the sixth (i.e. k2-1) grayscale value of 103 is 30068, which is less than the dividing point F2 (=33451), the cumulative sum of the number of pixels corresponding to the seventh (i.e. k2) grayscale value of 143 is 35188, which is greater than the dividing point F2 (=33451), and the cumulative sum of the number of pixels corresponding to the eighth (i.e. k2+1) grayscale value of 152 is 36508, which is greater than the dividing point F2 (=33451). Therefore, the terminal device determines that the seventh (i.e. k2) grayscale value 143 is the second grayscale threshold, that is, the second grayscale threshold is 143.
[0046] It is hereby explained that when M is greater than 3, the method for the terminal device to determine M-1 grayscale thresholds is similar to the method for determining the two grayscale thresholds when M=3, and will not be repeated here.
[0047] S102, truncate the initial number of pixels corresponding to each grayscale value to obtain the truncated number of pixels corresponding to each grayscale value, wherein when the initial number of pixels of the first grayscale value is greater than the number threshold, the truncated number of pixels of the first grayscale value is the number threshold; when the initial number of pixels of the first grayscale value is less than or equal to the number threshold, determine that the truncated number of pixels of the first grayscale value is the initial number of pixels of the first grayscale value; the first grayscale value is any one of the grayscale values.
[0048] For example, the target infrared image is an original infrared image with a size of 224×224, and the grayscale values of the original infrared image are 6 in total and the number threshold is 5000. The initial number of pixels of the original infrared image is 50176, of which the initial number of pixels with a grayscale value of 45 is 14802, the initial number of pixels with a grayscale value of 354 is 10241, the initial number of pixels with a grayscale value of 1234 is 12430, the initial number of pixels with a grayscale value of 4754 is 4110, the initial number of pixels with a grayscale value of 8841 is 5030, and the initial number of pixels with a grayscale value of 10786 is 3563; due to the grayscale value The initial number of pixels with a grayscale value of 45, 14802, is greater than the number threshold (i.e., 5000). Therefore, the terminal device truncates the initial number of pixels with a grayscale value of 45, 14802, to 5000, i.e., the initial number of pixels with a grayscale value of 45 is 5000; the initial number of pixels with a grayscale value of 45, 10241, is greater than the number threshold (i.e., 5000). Therefore, the terminal device truncates the initial number of pixels with a grayscale value of 354, 10241, to 5000, i.e., the initial number of pixels with a grayscale value of 354 is 5000; similarly, the initial number of pixels with a grayscale value of 1234 is 5000; and the initial number of pixels with a grayscale value of 8841 is 5000. Since the initial number of pixels 4110 with a grayscale value of 4754 is less than the quantity threshold (i.e., 5000), the terminal device does not process the initial number of pixels 4110 with a grayscale value of 354, i.e., the initial number of pixels with a grayscale value of 354 remains 4110; similarly, the initial number of pixels with a grayscale value of 10786 remains 3563.
[0049] For example, the target image is the first sub-original infrared image corresponding to the grayscale histogram whose grayscale value in the above original grayscale histogram is less than the grayscale threshold value 8000, the grayscale value of the first sub-original infrared image is 4 in total, the number threshold value is 3000, and the initial number of pixels of the first sub-original infrared image is 25000 in total. Among them, the initial number of pixels of the grayscale value 25 is 10321, the initial number of pixels of the grayscale value 254 is 9241, the initial number of pixels of the grayscale value 3234 is 2634, and the initial number of pixels of the grayscale value 5432 is 2634. The number of pixels is 2804; since the initial number of pixels with a grayscale value of 25, 10321, is greater than the number threshold (i.e., 3000), the terminal device truncates the initial number of pixels with a grayscale value of 25, 10321, to 3000, i.e., the initial number of pixels with a grayscale value of 25 is 3000; the initial number of pixels with a grayscale value of 254, 9241, is greater than the number threshold (i.e., 3000), so the terminal device truncates the initial number of pixels with a grayscale value of 254, 9241, to 3000, i.e., the initial number of pixels with a grayscale value of 254 is 3000. Since the initial number of pixels 2634 with a grayscale value of 3234 is less than the quantity threshold (i.e., 3000), the terminal device does not process the initial number of pixels 2634 with a grayscale value of 3234, i.e., the initial number of pixels with a grayscale value of 3234 remains 2634; similarly, the initial number of pixels with a grayscale value of 5432 remains 2804.
[0050] The terminal device processes the second sub-original infrared image corresponding to the grayscale histogram in which the grayscale value of the target infrared image in the original grayscale histogram is greater than the grayscale threshold value (for example, 8000) in the above-mentioned target infrared image, which is the same as the processing process of the first sub-original infrared image corresponding to the grayscale histogram in which the grayscale value of the target image in the original grayscale histogram is less than the grayscale threshold value 8000, and will not be repeated here.
[0051] Exemplarily, the quantity threshold is the product of the number of pixels in the target infrared image and the truncation coefficient. The quantity threshold is the maximum number of pixels corresponding to each grayscale value in the target infrared image; the truncation coefficient refers to the ratio of the initial number of pixels in the target infrared image to be truncated. For example, if the initial number of pixels in the target infrared image is N = 50176 and the truncation coefficient is 0.02, the terminal device sets the quantity threshold to 1004 (i.e., 50176 × 0.02). This means that the initial number of pixels corresponding to each grayscale value in the target infrared image is truncated using the quantity threshold, ensuring that the number of pixels corresponding to each grayscale value in the target infrared image does not exceed 1004. For example, if the initial number of pixels corresponding to the grayscale value 34 in the target infrared image is 1800, the initial number of pixels corresponding to the grayscale value 44 is 1200, and the initial number of pixels corresponding to the grayscale value 84 is 600, then the terminal device uses the number threshold 1004 to truncate the initial number of pixels corresponding to the grayscale value 34, the grayscale value 44, and the grayscale value 84 respectively. Finally, the number of pixels corresponding to these three grayscale values is 1004 for the grayscale value 34, 1004 for the grayscale value 44, and 600 for the grayscale value 84.
[0052] S103: Processing the number of truncated pixels corresponding to each grayscale value by a histogram equalization algorithm to generate a processed image.
[0053] For example, a target infrared image is an original infrared image with a grayscale value range of 0 to 16383 and a size of 224×224. The grayscale threshold is 8000 and the number threshold is 1000. The target infrared image has a total of 50176 pixels. Now, only 6 grayscale values are taken as an example. The terminal device uses the histogram equalization algorithm to process the truncated pixel number corresponding to each grayscale value to generate a processed image. The process is as follows:
[0054] (a) Use the following formula (1) to count the initial number of pixels corresponding to each grayscale value in the target infrared image and obtain the original grayscale histogram.
[0055] h(k)=n k (1)
[0056] Among them, k=0,1,2,…L-1, L is the maximum grayscale value 16383, n kis the number of pixels corresponding to the grayscale value k, and h(k) is the number of pixels corresponding to the grayscale value k. The terminal device uses formula (1) to count the initial number of pixels corresponding to each of the above six grayscale values: the initial number of pixels for the grayscale value 12 is 1200, the initial number of pixels for the grayscale value 133 is 1800, the initial number of pixels for the grayscale value 341 is 900, the initial number of pixels for the grayscale value 3413 is 2200, the initial number of pixels for the grayscale value 4532 is 600, and the initial number of pixels for the grayscale value 8764 is 400, thus obtaining the original grayscale histogram.
[0057] (b) Use the number threshold of 1000 to truncate the initial number of pixels corresponding to each grayscale value in the above original grayscale histogram to obtain a truncated grayscale histogram; the number of truncated pixels corresponding to each grayscale value in the truncated grayscale histogram is 1000 for the grayscale value of 12, 1000 for the grayscale value of 133, 900 for the grayscale value of 341, 1000 for the grayscale value of 3413, 600 for the grayscale value of 4532, and 400 for the grayscale value of 8764.
[0058] (c) Calculate the cumulative number of truncated pixels corresponding to each grayscale value using the following formula (2):
[0059]
[0060] Where H(k) is the cumulative result of the number of truncated pixels corresponding to grayscale value k, and h′(i) is the cumulative result of the number of truncated pixels corresponding to grayscale value i. The cumulative results of the number of truncated pixels corresponding to the above six grayscale values are shown in Table 1.
[0061] Table 1 Cumulative results of the number of truncated pixels corresponding to six grayscale values
[0062]
[0063] (d) Grayscale mapping is performed on the accumulated result H(k) of the number of truncated pixels corresponding to the six grayscale values using the following formula (3) to obtain a mapped grayscale value.
[0064] y=GrayRange*H(k) / H(T) (3)
[0065] Where y is the grayscale mapping value corresponding to the grayscale value k, GrayRange is the preset grayscale value, H(k) is the cumulative result of the number of truncated pixels corresponding to the grayscale value k, and H(T) is the sum of the cumulative results of the number of truncated pixels corresponding to all grayscale values in the target infrared image. is the grayscale mapping coefficient, T is the number of grayscale values, and "*" represents multiplication. For example, if the grayscale values of the target infrared image are mapped to the range of 0 to 255, the GrayRange value is 255; if the grayscale values of the target infrared image are mapped to the range of 0 to 127, the GrayRange value is 127.
[0066] For example, if the user wants to map the grayscale value of the target infrared image to the grayscale range of 0 to 255, then the GrayRange value is 255, H(T=6)=H(k=12)+H(k=133)+H(k=341)+H(k=3413)+H(k=4532)+H(k=8764)=1000+2000+2900+3900+4500+4900=19200; the grayscale mapping value y(k= 12) = 255 × (1000 / 19200) ≈ 13; the grayscale mapping value y (k = 133) corresponding to the grayscale value 133 = 255 × (2000 / 19200) ≈ 27; the grayscale mapping value y (k = 341) corresponding to the grayscale value 341 = 255 × (2900 / 19200) ≈ 39; the grayscale mapping value y (k = 3413) corresponding to the grayscale value 3413 = 255 × (3900 / 19200) ≈ 52; the grayscale mapping value y (k = 4532) corresponding to the grayscale value 4532 The grayscale mapping value y(k=4532)=255×(4500 / 19200)≈60; the grayscale mapping value y(k=8764) corresponding to the grayscale value 8764=255×(4900 / 19200)≈65; the grayscale mapping value y(k=12) (i.e., 13) is used to replace the grayscale value 12 in the target infrared image, the grayscale mapping value y(k=133) (i.e., 27) is used to replace the grayscale value 133 in the target infrared image, and the grayscale mapping value y(k=341) (i.e., 39) is used to replace the grayscale value 133 in the target infrared image. The grayscale value 341 in the external image is replaced by the grayscale mapping value y(k=3413) (i.e., 52) in the target infrared image. The grayscale mapping value y(k=4532) (i.e., 60) replaces the grayscale value 4532 in the target infrared image. The grayscale mapping value y(k=8764) (i.e., 65) replaces the grayscale value 8764 in the target infrared image. The grayscale value of the target infrared image is mapped to the grayscale range of 0 to 255, and the processed image with grayscale values in the range of 0 to 255 is obtained, as shown in FIG. Figure 2 (b) shows that the grayscale value of the processed image can be stored using an 8-bit binary number, that is, the grayscale value of the target infrared image is converted from a 14-bit binary number to an 8-bit binary number. In addition, Figure 2 (a) is the result of traditional histogram equalization algorithm on the original infrared image. Figure 2 (a) The target (i.e., the person in the image) is overexposed compared to the background. The method of processing infrared images in this application is used to obtain Figure 2 (b) The target in the image is not overexposed compared to the background.
[0067] For another example, take an original infrared image with a grayscale value range of 0 to 16383 and a size of 224×224, a grayscale threshold of 8000, and a number threshold of 1000. The original infrared image has a total of 50176 pixels. Now, taking only 6 grayscale values as an example, the terminal device uses the histogram equalization algorithm to process the truncated pixel number corresponding to each grayscale value to generate a processed image:
[0068] (a) Use formula (1) to count the initial number of pixels corresponding to each grayscale value in the original infrared image to obtain the original grayscale histogram. The terminal device uses formula (1) to count the initial number of pixels corresponding to each of the above 6 grayscale values: the initial number of pixels for grayscale value 42 is 1800, the initial number of pixels for grayscale value 63 is 2000, the number of truncated pixels for grayscale value 103 is 900, the initial number of pixels for grayscale value 8401 is 1020, the number of truncated pixels for grayscale value 9030 is 1540, and the number of truncated pixels for grayscale value 10340 is 600, obtaining the original grayscale histogram, as shown in Figure 1. Figure 3 shown.
[0069] (b) Divide the original grayscale histogram into two sub-grayscale histograms using a grayscale threshold of 8000, wherein the first sub-grayscale histogram of the two sub-grayscale histograms has grayscale values less than or equal to the grayscale threshold of 8000, and the second sub-grayscale histogram of the two sub-grayscale histograms has grayscale values greater than the grayscale threshold of 8000. The target image is the first sub-original infrared image corresponding to the first sub-grayscale histogram, or the target image is the second sub-original infrared image corresponding to the second sub-grayscale histogram.
[0070] (c) Using the number threshold of 1000, the initial number of pixels corresponding to each gray value in the first sub-grayscale histogram is truncated to obtain the first truncated grayscale histogram, as shown in Figure 4 (a); At the same time, the number of initial pixels corresponding to each gray value in the second sub-grayscale histogram is truncated using the number threshold 1000 to obtain the second truncated grayscale histogram, as shown in Figure 4 (b) shows that the number of truncated pixels corresponding to each grayscale value in the first truncated grayscale histogram is 1000 for grayscale value 42, 1000 for grayscale value 63, and 900 for grayscale value 103; the number of truncated pixels corresponding to each grayscale value in the second truncated grayscale histogram is 1000 for grayscale value 8401, 1000 for grayscale value 9030, and 600 for grayscale value 10340.
[0071] (d) Using formula (2), calculate the cumulative number of truncated pixels corresponding to each grayscale value in the first truncated grayscale histogram and the second truncated grayscale histogram. The cumulative number of truncated pixels corresponding to the six grayscale values is shown in Table 2.
[0072] Table 2 Cumulative results of the number of truncated pixels corresponding to each gray value
[0073]
[0074] (e) Grayscale mapping is performed on the cumulative result of the number of truncated pixels corresponding to each grayscale value in the first truncated grayscale histogram using formula (3) to obtain a mapped grayscale value. For example, if the grayscale value of the first sub-original infrared image (i.e., the target infrared image) is mapped to a range of 0 to 127, then GrayRange takes a value of 127. Furthermore, the grayscale value of the second sub-original infrared image (i.e., the target infrared image) can be mapped to a range of 128 to 255 using formula (4).
[0075]
[0076] Where y′ is the grayscale mapping value corresponding to the grayscale value k, GrayRange1 is the preset grayscale value and GrayRange1 is 127, H1(k) is the cumulative result of the number of truncated pixels corresponding to the grayscale value k, and H1(T) is the sum of the cumulative results of the number of truncated pixels corresponding to all grayscale values in the target infrared image. is the grayscale mapping coefficient, T is the number of grayscales, and “*” means multiplication.
[0077] The grayscale values in the first truncated grayscale histogram are mapped to the grayscale range of 0 to 127 using formula (3), where H1(T=3)=H(k=42)+H(k=63)+H(k=103)=1000+2000+2900=5900; the grayscale mapping value y(k=42) corresponding to the grayscale value 42 is 127×(1000 / 5900)≈22; the grayscale mapping value y(k=63) corresponding to the grayscale value 63 is 127×(2 000 / 5900)≈43; the grayscale mapping value y(k=103) corresponding to the grayscale value 103 is 127×(2900 / 5900)≈62; the grayscale mapping value y(k=42) (i.e., 22) is used to replace the grayscale value 42 in the first sub-original infrared image, the grayscale mapping value y(k=63) (i.e., 43) replaces the grayscale value 63 in the first sub-original infrared image, and the grayscale mapping value y(k=103) (i.e., 62) replaces the grayscale value 103 in the first sub-original infrared image.
[0078] Similarly, the grayscale values in the second truncated grayscale histogram are mapped to the grayscale range of 128 to 255 using formula (4), where H1(T=3)=H(k=8401)+H(k=9030)+H(k=10340)=1000+2000+2600=5600; the grayscale mapping value y′(k=8401) corresponding to the grayscale value 8401 is 127×(1000 / 5600)+127≈150; the grayscale mapping value y′(k=9030) corresponding to the grayscale value 9030 is 127×(2000 / The grayscale mapping value y′(k=10340) corresponding to the grayscale value 10340 is 127×(2600 / 5600)+127≈186; the grayscale mapping value y′(k=8401) (i.e., 150) is used to replace the grayscale value 8401 in the second sub-original infrared image, the grayscale mapping value y′(k=9030) (i.e., 172) is used to replace the grayscale value 9030 in the second sub-original infrared image, and the grayscale mapping value y′(k=10340) (i.e., 186) is used to replace the grayscale value 10340 in the second sub-original infrared image. The pixels of the first sub-original infrared image and the pixels of the second sub-original infrared image are spliced to obtain a processed image with a grayscale value in the range of 0 to 255; the grayscale value of the processed image can be stored using an 8-bit binary number, that is, the conversion of the grayscale value of the original infrared image from being stored by a 14-bit binary number to the grayscale value of the processed image from being stored by an 8-bit binary number is completed.
[0079] Since the number of pixels occupied by the background part of the original infrared image is much larger than the number of pixels occupied by the target part, and the grayscale value of the background part is smaller, and the grayscale value of the target part is larger; if the HE algorithm is directly used to calculate the cumulative probability of each grayscale value on the original grayscale histogram, the larger number of pixels corresponding to each grayscale value in the background part will cause the cumulative probability of each grayscale value in the target part to be too large, resulting in a situation where the contrast between the target and the background is too large; and this embodiment can divide the original grayscale histogram into grayscale histograms with different grayscale value ranges according to the grayscale threshold, for example, the original grayscale histogram is divided into a grayscale histogram of the background part and a grayscale histogram of the target part, and the grayscale histograms of different grayscale value ranges are processed respectively using the HE algorithm, which can avoid the situation where the number of pixels in the background part causes the cumulative probability of each grayscale value in the target part to be too large, thereby avoiding the situation where the contrast between the target and the background is too large after the HE algorithm processes the target infrared image.
[0080] It is hereby clarified that for two or more grayscale thresholds, the original grayscale histogram is divided into three or more sub-grayscale histograms, and the method in which the terminal device performs a histogram equalization algorithm on the three or more sub-grayscale histograms to generate a processed image is the same as the method in which the above-mentioned terminal device performs a histogram equalization algorithm on two sub-grayscale histograms to generate a processed image, and will not be repeated here.
[0081] As an optional embodiment, a histogram equalization algorithm is used to process the number of truncated pixels corresponding to each grayscale value to generate a processed image, including: determining the cumulative number of truncated pixels for each grayscale value based on the number of truncated pixels corresponding to each grayscale value; determining a mapping coefficient for each grayscale value based on the cumulative number of truncated pixels for each grayscale value, wherein the mapping coefficient for a first grayscale value is the cumulative number of truncated pixels for the first grayscale value divided by the sum of the cumulative numbers of truncated pixels corresponding to each grayscale value; determining a mapped grayscale value for each grayscale value based on the mapping coefficient for each grayscale value and a preset grayscale value, wherein the mapped grayscale value for the first grayscale value is the mapping coefficient for the first grayscale value multiplied by the preset grayscale value; and generating a processed image based on the mapped grayscale values for each grayscale value. The first grayscale value is any one of the grayscale values. The sum of the cumulative number of truncated pixels corresponding to each grayscale value is the sum of the cumulative results of the number of truncated pixels corresponding to all grayscale values in the target infrared image (e.g., H(T)).
[0082] For example, taking the target infrared image as the original infrared image and the preset grayscale value as 255, the terminal device uses formula (1) to count the initial number of pixels corresponding to each grayscale value in the target infrared image to obtain the original grayscale histogram. The number threshold truncates the initial number of pixels corresponding to each grayscale value in the original grayscale histogram to obtain a truncated grayscale histogram. The terminal device uses formula (2) to accumulate the number of truncated pixels corresponding to each grayscale value in the truncated grayscale histogram to obtain the accumulated number of truncated pixels corresponding to each grayscale value. Taking the cumulative truncation number corresponding to the three gray values in the truncated gray histogram as an example, the number of truncated pixels for gray value 1 is 1000, the number of truncated pixels for gray value 2 is 900, and the number of truncated pixels for gray value 3 is 400; the cumulative truncation number of the gray value 1 is 1000 (i.e., the cumulative truncation number of the first gray value), the cumulative truncation number of the gray value 2 is 1900 (i.e., 1000+900), and the cumulative truncation number of the gray value 3 is 2300 (i.e., 1000+900+40 0); the sum of the accumulated numbers of truncated pixels corresponding to the three grayscale values in the target infrared image is 5200 (i.e., 1000+1900+2300), that is, the sum of the accumulated numbers of truncated pixels corresponding to each grayscale value in the target infrared image; the mapping coefficients of each of the three grayscale values in the target infrared image are 1000 / 5200 for grayscale value 1, 1900 / 5200 for grayscale value 2, and 2300 / 5200 for grayscale value 3. The terminal device determines the mapping grayscale value of each grayscale value according to the mapping coefficients of the three grayscale values and the preset grayscale value, that is, the mapping grayscale values corresponding to the three grayscale values in the target infrared image are determined according to the above formula (3); wherein, the grayscale mapping value y(k=1) corresponding to the grayscale value 1 is 255×(1000 / 5200)≈49 (that is, the mapping grayscale value of the grayscale value 1 is the mapping coefficient 1000 / 5200 of the grayscale value 1 multiplied by the preset grayscale value 255), and the grayscale value The grayscale mapping value y(k=2) corresponding to grayscale value 2 is 255×(1900 / 5200)≈93 (i.e., the mapped grayscale value of grayscale value 2 is the mapping coefficient 1900 / 5200 of grayscale value 2 multiplied by the preset grayscale value 255), and the grayscale mapping value y(k=3) corresponding to grayscale value 3 is 255×(2300 / 5200)≈113 (i.e., the mapped grayscale value of grayscale value 3 is the mapping coefficient 2300 / 5200 of grayscale value 3 multiplied by the preset grayscale value 255). The grayscale mapping value 49 corresponding to grayscale value 1 is used to replace the grayscale value 1 in the target infrared image, the grayscale mapping value 93 corresponding to grayscale value 2 is used to replace the grayscale value 2 in the target infrared image, and the grayscale mapping value 113 corresponding to grayscale value 3 is used to replace the grayscale value 3 in the target infrared image, thereby obtaining a processed image with grayscale values ranging from 0 to 255.The grayscale value of the processed image can be stored using an 8-bit binary number, that is, the conversion of the grayscale value of the target infrared image stored by a 14-bit binary number to the grayscale value of the processed image stored by an 8-bit binary number is completed.
[0083] Since the number of pixels occupied by the background part of the target infrared image is much larger than the number of pixels occupied by the target part, and the grayscale value of the background part is smaller, and the grayscale value of the target part is larger, when the traditional HE algorithm is used to process the target infrared image, the cumulative probability corresponding to each grayscale value of the background part will make the cumulative probability of each grayscale value of the target part too large; however, this method truncates the initial number of pixels of each grayscale value in the target and background through a quantity threshold, so that the number of pixels occupied by the background part is not much different from the number of pixels occupied by the target part, thereby avoiding the situation where the initial number of pixels of the background part is too large, resulting in a large cumulative probability corresponding to each grayscale value of the target part, and thus avoiding the problem of excessive contrast between the target and the background after the HE algorithm processes the target infrared image, resulting in overexposure of the picture.
[0084] Figure 5 Schematic diagram of the structure of the device for processing infrared images provided in this application. The device 500 includes a determination module 501, a processing module 502 and a generation module 503;
[0085] A determination module 501 is used to determine the initial number of pixels corresponding to each grayscale value in the target infrared image;
[0086] The processing module 502 is configured to perform truncation processing on the initial number of pixels corresponding to each grayscale value to obtain the truncated number of pixels corresponding to each grayscale value, wherein when the initial number of pixels of a first grayscale value is greater than a number threshold, the truncated number of pixels of the first grayscale value is the number threshold; when the initial number of pixels of the first grayscale value is less than or equal to the number threshold, the truncated number of pixels of the first grayscale value is determined to be the initial number of pixels of the first grayscale value; the first grayscale value is any one of the grayscale values;
[0087] The generating module 503 processes the number of truncated pixels corresponding to each grayscale value through a histogram equalization algorithm to generate a processed image.
[0088] The specific manner in which the device 500 performs the method for processing infrared images and the beneficial effects produced can be found in Figure 1 Related description in the method embodiment shown.
[0089] Figure 6 The present application provides a schematic structural diagram of a terminal device. Figure 6The dashed line in the figure indicates that the unit or module is optional. The terminal device 600 can be used to implement the method described in the above method embodiment. The terminal device 600 can be a server or a chip.
[0090] The terminal device 600 includes one or more processors 601, which can support the terminal device 600 to implement Figure 1 The method in the corresponding method embodiment. The processor 601 can be a general-purpose processor or a dedicated processor. For example, the processor 601 can be a central processing unit (CPU). The CPU can be used to control the terminal device 600, execute software programs, and process data of the software programs. The terminal device 600 can also include a communication unit 605 to implement signal input (reception) and output (transmission).
[0091] For example, the terminal device 600 may be a chip, and the communication unit 605 may be an input and / or output circuit of the chip, or the communication unit 605 may be a communication interface of the chip, and the chip may be a component of the terminal device.
[0092] For another example, the communication unit 605 may be a transceiver of the terminal device 600 , or the communication unit 605 may be a transceiver circuit of the terminal device 600 .
[0093] The terminal device 600 may include one or more memories 602, on which a program 604 is stored. The program 604 can be executed by the processor 601 to generate instructions 603, so that the processor 601 performs the method described in the above method embodiment according to the instructions 603. Optionally, data may also be stored in the memory 602. Optionally, the processor 601 may also read the data stored in the memory 602. The data may be stored at the same storage address as the program 604, or the data may be stored at a different storage address than the program 604.
[0094] The processor 601 and the memory 602 may be provided separately or integrated together, for example, integrated on a system on chip (SOC) of a terminal device.
[0095] The specific manner in which the processor 601 executes the fault code display method can refer to the relevant description in the method embodiment.
[0096] It should be understood that each step of the above method embodiment can be completed by hardware logic circuits or software instructions in the processor 601. The processor 601 can be a CPU, a digital signal processor (DSP), a field programmable gate array (FPGA), or other programmable logic devices, such as discrete gates, transistor logic devices, or discrete hardware components.
[0097] The present application also provides a computer program product, which, when executed by the processor 601, implements the method described in any method embodiment of the present application.
[0098] The computer program product may be stored in the memory 602 , for example, a program 604 , which is converted into an executable target file that can be executed by the processor 601 after undergoing processes such as preprocessing, compilation, assembly, and linking.
[0099] The present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer, implements the method described in any method embodiment of the present application. The computer program can be a high-level language program or an executable target program.
[0100] The computer-readable storage medium is, for example, memory 602. Memory 602 may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SynchLink DRAM, SLDRAM), and direct RAM bus random access memory (DRRAM).
[0101] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and equipment and the technical effects produced can refer to the corresponding processes and technical effects in the aforementioned method embodiments, and will not be repeated here.
[0102] In the several embodiments provided in this application, the disclosed systems, devices, and methods can be implemented in other ways. For example, some features of the method embodiments described above can be ignored or not executed. The device embodiments described above are merely schematic, and the division of units is merely a logical function division. In actual implementation, there may be other division methods, and multiple units or components may be combined or integrated into another system. In addition, the coupling between the units or the coupling between the components may be direct coupling or indirect coupling, and the above coupling includes electrical, mechanical or other forms of connection.
[0103] The above embodiments are intended only to illustrate the technical solutions of the present application and are not intended to limit the same. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein with equivalents, and that such modifications or replacements do not deviate from the spirit and scope of the technical solutions of the various embodiments of the present application and are therefore intended to be included within the scope of protection of the present application.
Claims
1. A method for processing infrared images, characterized in that: The method comprises: Generating an original grayscale histogram according to the original infrared image, wherein the original grayscale histogram includes the number of pixels of multiple grayscale values; Determine a target infrared image according to a grayscale threshold, wherein the target infrared image is an image whose grayscale value in the original grayscale histogram is less than or equal to the grayscale threshold, or the target infrared image is an image whose grayscale value in the original grayscale histogram is greater than the grayscale threshold; Determine the initial number of pixels corresponding to each grayscale value in the target infrared image; performing truncation processing on the initial number of pixels corresponding to each grayscale value to obtain the truncated number of pixels corresponding to each grayscale value, wherein when the initial number of pixels of a first grayscale value is greater than a number threshold, the truncated number of pixels of the first grayscale value is the number threshold; when the initial number of pixels of the first grayscale value is less than or equal to the number threshold, determining the truncated number of pixels of the first grayscale value to be the initial number of pixels of the first grayscale value; the first grayscale value is any one of the grayscale values, and the number threshold is the product of the number of pixels of the target infrared image and the truncation coefficient; The number of truncated pixels corresponding to each grayscale value is processed by a histogram equalization algorithm to generate a processed image.
2. The method according to claim 1, characterized in that Before determining the target infrared image according to the grayscale threshold, the method further includes: Determining the number N of pixels of the original infrared image; Determine the grayscale threshold according to the number of pixels of the multiple grayscale values and N, wherein when the number of pixels of the minimum grayscale value among the multiple grayscale values is greater than or equal to N / M, the grayscale threshold is the minimum grayscale value; When the number of pixels of the minimum grayscale value among the multiple grayscale values is less than N / M, the grayscale threshold is the kth grayscale value when the multiple grayscale values are arranged from small to large, the number of pixels of the smaller first k-1 grayscale values among the multiple grayscale values is less than N / M, and the number of pixels of the smaller first k+1 grayscale values among the multiple grayscale values is greater than N / M, where k is a positive integer greater than 1, and M is a positive number greater than 1 and less than N.
3. The method according to claim 1, characterized in that The step of processing the number of truncated pixels corresponding to each grayscale value by a histogram equalization algorithm to generate a processed image includes: Determining the accumulated number of truncated pixels for each grayscale value according to the number of truncated pixels corresponding to each grayscale value; Determining a mapping coefficient for each grayscale value according to the accumulated number of truncated pixels for each grayscale value, wherein the mapping coefficient for the first grayscale value is the accumulated number of truncated pixels for the first grayscale value divided by the sum of the accumulated numbers of truncated pixels corresponding to each grayscale value; Determining a mapped grayscale value of each grayscale value according to a mapping coefficient of each grayscale value and a preset grayscale value, wherein the mapped grayscale value of the first grayscale value is the mapping coefficient of the first grayscale value multiplied by the preset grayscale value; The processed image is generated according to the mapped grayscale values of the respective grayscale values.
4. A device for processing infrared images, characterized in that: The device comprises: a determination module for generating an original grayscale histogram based on an original infrared image, the original grayscale histogram including the number of pixels of multiple grayscale values; further for determining a target infrared image based on a grayscale threshold, the target infrared image being an image having a grayscale value in the original grayscale histogram less than or equal to the grayscale threshold, or the target infrared image being an image having a grayscale value in the original grayscale histogram greater than the grayscale threshold; and further for determining an initial number of pixels corresponding to each grayscale value in the target infrared image; a processing module, configured to perform truncation processing on the initial number of pixels corresponding to each grayscale value to obtain the truncated number of pixels corresponding to each grayscale value, wherein when the initial number of pixels of a first grayscale value is greater than a number threshold, the truncated number of pixels of the first grayscale value is the number threshold; when the initial number of pixels of the first grayscale value is less than or equal to the number threshold, the truncated number of pixels of the first grayscale value is determined to be the initial number of pixels of the first grayscale value; the first grayscale value is any one of the grayscale values, and the number threshold is the product of the number of pixels of the target infrared image and the truncation coefficient; The generating module is used to process the number of truncated pixels corresponding to each grayscale value by a histogram equalization algorithm to generate a processed image.
5. A terminal device, characterized in that: The terminal device includes a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the terminal device executes the method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Infrared image enhancement method
CN109712101A