Image binarization method and device, equipment, storage medium and computer program product
The threshold is determined by linear mapping and histogram analysis, and infrared images are converted into two -value images, solving the problem of complex and details in the existing technologies, and realized the two -value image two -value.
Patent Information
- Application Number
- CN202411367152.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-28
AI Technical Summary
The prior art requires preset parameters when converting high-position infrared images into binary images, and the calculation is complicated and it is difficult to preserve image details.
By map the original infrared image linearly to the gray image and generate a histogram based on the gray image, determine the global maximum point and the two local maximum value points as the threshold, divide the gray image into four interval and assign a value. Generate a dual -value image.
Without setting parameters in advance, high -level infrared images are converted into dual -value images, and details of infrared images are retained as much as possible to improve image processing efficiency.
Smart Images

Figure CN119379530A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image binarization method, device, equipment, storage medium and computer program product. Background Art
[0002] Image binarization is a basic image analysis method used to convert a color or grayscale image into an image containing only two colors (usually black and white). In resource-constrained environments, such as remote sensing, mobile devices, or other embedded systems, it is necessary to reduce the amount of data as much as possible while maintaining the details of infrared images. A common method is to quantize a high-bit-depth image into a low-bit-depth image, and in the most extreme case, convert it into a binary image.
[0003] The existing methods for converting high-bit infrared images into binary images mainly include global thresholding method, adaptive thresholding method, etc. The global thresholding method is simple and easy to understand, has fast calculation speed, and is relatively easy to implement, but it may not perform well for images under different lighting conditions. The adaptive thresholding method is usually more complex and computationally intensive than the global thresholding method because it needs to calculate the threshold separately in each small area of the image, which makes the processing time longer than using the global thresholding method, especially for images with higher resolution. In addition, the above methods all require pre-selection of parameters, such as global thresholding, adaptive window size, etc., and it is inconvenient to adjust the parameters to obtain better results. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide an image binarization method, device, equipment, storage medium and computer program product, which can convert a high-bit infrared image into a binary image without the need to pre-set parameters, while retaining the details of the infrared image as much as possible, effectively improving the image processing efficiency.
[0005] In order to achieve the above object, an embodiment of the present invention provides an image binarization method, comprising:
[0006] Linearly mapping the original infrared image to a grayscale image, and generating a histogram based on the grayscale image;
[0007] Determine a global maximum point and two local maximum points according to the histogram as a first threshold, a second threshold and a third threshold;
[0008] The grayscale image is divided into four intervals according to the first threshold, the second threshold and the third threshold, and values are assigned to the four intervals respectively to generate a binary image.
[0009] As an improvement of the above solution, the linear mapping of the original infrared image to a grayscale image and generating a histogram according to the grayscale image includes:
[0010] Linearly map the original infrared image to an eight-bit grayscale image;
[0011] Performing statistics on the eight-bit grayscale image, with the grayscale value as the horizontal coordinate and the number of pixels as the vertical coordinate, to generate a histogram;
[0012] Gaussian filtering is performed on the histogram to obtain a smoothed histogram.
[0013] As an improvement of the above solution, the step of performing Gaussian filtering on the histogram to obtain a smoothed histogram includes:
[0014] According to the Gaussian function The Gaussian kernel is calculated; where G(i) represents the Gaussian function and σ represents the standard deviation;
[0015] Performing normalization processing on the Gaussian kernel;
[0016] For each data point in the histogram, the Gaussian kernel is placed at the center of the data point, multiplied by the covered histogram data according to the weight of the Gaussian kernel, all products are summed and weighted averaged, and the obtained average value is the new value of the smoothed histogram at the data point.
[0017] As an improvement of the above solution, determining the global maximum point and two local maximum points according to the histogram as the first threshold, the second threshold and the third threshold includes:
[0018] Determine all maximum points according to the histogram, and select the largest maximum point as the global maximum point, that is, the first threshold;
[0019] Selecting the smallest maximum point from the maximum points on the left of the global maximum point as the local maximum point, i.e., the second threshold;
[0020] The largest maximum point is selected from the maximum points to the right of the global maximum point as the local maximum point, that is, the third threshold.
[0021] As an improvement of the above solution, the method further includes:
[0022] If there is no maximum point to the left of the global maximum point, then select the smallest maximum point and the largest maximum point from the maximum points to the right of the global maximum point as the second threshold and the third threshold respectively;
[0023] If there is no maximum point on the right side of the global maximum point, the smallest maximum point and the largest maximum point are selected from the maximum points on the left side of the global maximum point as the second threshold and the third threshold, respectively.
[0024] As an improvement of the above solution, the grayscale image is divided into four intervals according to the first threshold, the second threshold and the third threshold, and the four intervals are assigned values respectively to generate a binary image, including:
[0025] According to the first threshold, the second threshold and the third threshold, the grayscale image is divided into four intervals, which are a first interval, a second interval, a third interval and a fourth interval in descending order;
[0026] The grayscale values of the pixels in the first interval are assigned to be 0, the grayscale values of the pixels in the second interval are assigned to be 1, the grayscale values of the pixels in the third interval are assigned to be 0, and the grayscale values of the pixels in the fourth interval are assigned to be 1, so as to generate a binary image.
[0027] The embodiment of the present invention further provides an image binarization device, comprising:
[0028] A grayscale mapping module, used for linearly mapping the original infrared image to a grayscale image, and generating a histogram according to the grayscale image;
[0029] A threshold determination module, used to determine a global maximum point and two local maximum points according to the histogram as a first threshold, a second threshold and a third threshold;
[0030] The image binary module is used to divide the grayscale image into four intervals according to the first threshold, the second threshold and the third threshold, and assign values to the four intervals respectively to generate a binary image.
[0031] An embodiment of the present invention further provides a terminal device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements any of the above-mentioned image binarization methods when executing the computer program.
[0032] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned image binarization methods.
[0033] An embodiment of the present invention further provides a computer program product, which includes a computer program or a computer instruction. When the computer program or the computer instruction is executed by a processor, any of the above-mentioned image binarization methods is implemented.
[0034] Compared with the prior art, the beneficial effects of an image binarization method, device, equipment, storage medium and computer program product provided by the embodiments of the present invention are: by linearly mapping the original infrared image to a grayscale image, and generating a histogram based on the grayscale image; determining the global maximum point and two local maximum points based on the histogram as the first threshold, the second threshold and the third threshold; dividing the grayscale image into four intervals based on the first threshold, the second threshold and the third threshold, and assigning values to the four intervals respectively to generate a binary image. The embodiments of the present invention can convert a high-bit infrared image into a binary image without presetting parameters, while retaining the details of the infrared image as much as possible, effectively improving the image processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a flow chart of a preferred embodiment of an image binarization method provided by the present invention;
[0036] Figure 2 It is a schematic diagram of a grayscale image of an original infrared image in an image binarization method provided by the present invention;
[0037] Figure 3 It is a schematic diagram of the result after the image is binarized using the adaptive threshold method in the prior art;
[0038] Figure 4 It is a schematic diagram of the result after an image is binarized using an image binarization method provided by the present invention;
[0039] Figure 5 It is a structural schematic diagram of a preferred embodiment of an image binarization device provided by the present invention;
[0040] Figure 6 It is a structural schematic diagram of a preferred embodiment of a terminal device provided by the present invention. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] See also Figure 1 , Figure 1 The figure is a flow chart of a preferred embodiment of an image binarization method provided by the present invention. The image binarization method comprises:
[0043] S1, linearly mapping the original infrared image to a grayscale image, and generating a histogram according to the grayscale image;
[0044] S2, determining a global maximum point and two local maximum points according to the histogram as a first threshold, a second threshold and a third threshold;
[0045] S3, dividing the grayscale image into four intervals according to the first threshold, the second threshold and the third threshold, and assigning values to the four intervals respectively to generate a binary image.
[0046] Specifically, the embodiment of the present invention obtains the original infrared image to be processed, linearly maps the original infrared image to a grayscale image, and performs statistics on the grayscale image to generate a grayscale histogram. Based on the grayscale histogram, by identifying the peak value in the histogram, the global maximum point and two local maximum points on the left and right sides of the global maximum point are determined as three thresholds, namely, the first threshold, the second threshold, and the third threshold. According to the first threshold, the second threshold, and the third threshold, the grayscale image is divided into four intervals, and the four intervals are assigned values respectively to generate a binary image.
[0047] For example, see Figures 2 to 4 , Figure 2 is a schematic diagram of a grayscale image of an original infrared image in an image binarization method provided by the present invention, Figure 3 It is a schematic diagram of the result after the image is binarized using the adaptive threshold method in the prior art. Figure 4 FIG. 1 is a schematic diagram of the result of binarizing an image using an image binarization method provided by the present invention. Figure 2 , Figure 3 and Figure 4 It can be seen from the results that the image binarization method provided by the present invention has richer contour details, clearer boundaries of the target area, and more accurate geometric features of the target area.
[0048] Compared with the adaptive threshold method, the image binarization method provided by the embodiment of the present invention requires the selection of a window size at the beginning, and the effect varies according to the window size, and parameters need to be input in advance. In addition, the local statistics of each pixel must be calculated, and a threshold must be calculated for each pixel, which requires a large amount of calculation. However, the embodiment of the present invention does not require any pre-input parameters, and only needs to determine three thresholds, which greatly simplifies the amount of calculation. At the same time, by setting three thresholds, images with more details and greater contrast will not lose more details due to only a single threshold, and the final effect is better than the adaptive threshold method.
[0049] In another preferred embodiment, the step S1, linearly mapping the original infrared image to a grayscale image and generating a histogram according to the grayscale image, comprises:
[0050] S101, linearly mapping the original infrared image to an eight-bit grayscale image;
[0051] S102, performing statistics on the eight-bit grayscale image, generating a histogram with the grayscale value as the horizontal coordinate and the number of pixels as the vertical coordinate;
[0052] S103, performing Gaussian filtering on the histogram to obtain a smoothed histogram.
[0053] Specifically, the embodiment of the present invention linearly maps the original infrared image to an eight-bit grayscale image. Exemplarily, the maximum grayscale of the original infrared image is denoted as P max , the minimum gray level is P min , P i Represents the pixel value of the i-th point in the image, P ii is the gray value of the point in the normalized image, then the normalized high-bit infrared image converted into an 8-bit gray image can be expressed as:
[0054] P ii =255(P i -P min ) / (P max -P min ).
[0055] The eight-bit grayscale image is statistically processed, with the grayscale value as the horizontal axis and the number of pixels as the vertical axis to generate a grayscale histogram. In order to make the histogram smoother and reduce random fluctuations in the data, the grayscale histogram is smoothed using the Gaussian filter method to obtain a smoothed histogram.
[0056] In another preferred embodiment, the step S103, performing Gaussian filtering on the histogram to obtain a smoothed histogram, includes:
[0057] S113, according to the Gaussian function The Gaussian kernel is calculated; where G(i) represents the Gaussian function and σ represents the standard deviation;
[0058] S123, performing normalization processing on the Gaussian kernel;
[0059] S133, for each data point in the histogram, the Gaussian kernel is placed at the center of the data point, multiplied by the covered histogram data according to the weight of the Gaussian kernel, all products are summed up, and weighted average is performed, and the obtained average value is the new value of the smoothed histogram at the data point.
[0060] Specifically, when performing Gaussian filtering on a histogram, the embodiment of the present invention first generates a Gaussian kernel, which is a weight array calculated according to the Gaussian formula. For a given window size, each element of the Gaussian kernel is calculated according to the Gaussian distribution formula, that is, the Gaussian function, and the formula is as follows:
[0061]
[0062] Wherein, G(i) represents the Gaussian function, and σ represents the standard deviation. Preferably, the given window size is 10, and the standard deviation is fixed to 1 / 5 of the total window width, that is, σ is 2.
[0063] The calculated Gaussian kernel is then normalized to ensure that the sum of the data remains unchanged during the smoothing process. Finally, for each data point in the histogram, the Gaussian kernel is placed at the center of the point and multiplied with the covered histogram data according to the weight of the Gaussian kernel. Specifically, the center of the kernel is aligned to the current point, and the rest of the kernel covers the surrounding points. Then, all the products are summed up, and the result is the weighted average of all products. This average becomes the new value of the smoothed histogram at that point, and finally the smoothed histogram is obtained.
[0064] In another preferred embodiment, the step S2, determining a global maximum point and two local maximum points according to the histogram as a first threshold, a second threshold and a third threshold, comprises:
[0065] S201, determining all maximum points according to the histogram, and selecting the largest maximum point as the global maximum point, that is, the first threshold;
[0066] S202, selecting the smallest maximum point from the maximum points on the left of the global maximum point as the local maximum point, i.e., the second threshold;
[0067] S203, selecting the largest maximum point from the maximum points to the right of the global maximum point as the local maximum point, that is, the third threshold.
[0068] Specifically, the embodiment of the present invention determines all maximum points by identifying the peak value in the histogram, that is, any point that is larger than its directly adjacent data point is regarded as a potential maximum point. The largest maximum point is selected from all the maximum points as the global maximum point, and the global maximum point is set as the first threshold. After the global maximum point is determined, the smallest maximum point is selected from all the maximum points to the left of the global maximum point as the local maximum point on the left, and the local maximum point on the left is set as the second threshold. The largest maximum point is selected from all the maximum points to the right of the global maximum point as the local maximum point on the right, and the local maximum point on the right is set as the third threshold.
[0069] In another preferred embodiment, the method further comprises:
[0070] If there is no maximum point to the left of the global maximum point, then select the smallest maximum point and the largest maximum point from the maximum points to the right of the global maximum point as the second threshold and the third threshold respectively;
[0071] If there is no maximum point on the right side of the global maximum point, the smallest maximum point and the largest maximum point are selected from the maximum points on the left side of the global maximum point as the second threshold and the third threshold, respectively.
[0072] Specifically, when determining two local maximum points on the left and right sides of the global maximum point, if there is no maximum point on the left side of the global maximum point, the smallest maximum point and the largest maximum point are selected from the maximum points on the right side of the global maximum point as the second threshold and the third threshold, respectively; if there is no maximum point on the right side of the global maximum point, the smallest maximum point and the largest maximum point are selected from the maximum points on the left side of the global maximum point as the second threshold and the third threshold, respectively.
[0073] In another preferred embodiment, the step S3, dividing the grayscale image into four intervals according to the first threshold, the second threshold and the third threshold, and assigning values to the four intervals respectively to generate a binary image, includes:
[0074] S301, dividing the grayscale image into four intervals according to the first threshold, the second threshold, and the third threshold, which are a first interval, a second interval, a third interval, and a fourth interval in descending order;
[0075] S302, assigning a grayscale value of 0 to the pixel points in the first interval, assigning a grayscale value of 1 to the pixel points in the second interval, assigning a grayscale value of 0 to the pixel points in the third interval, and assigning a grayscale value of 1 to the pixel points in the fourth interval, to generate a binary image.
[0076] Specifically, in the embodiment of the present invention, three thresholds divide the grayscale value of the 8-bit grayscale image from 0 to 255 into four intervals, and the four intervals are the first interval, the second interval, the third interval, and the fourth interval, from small to large, so as to classify and assign values to the image pixels later. Then, according to the grayscale value statistics of each pixel in the grayscale image, the grayscale value of the pixel in the first interval is assigned to 0, the grayscale value of the pixel in the second interval is assigned to 1, the grayscale value of the pixel in the third interval is assigned to 0, and the grayscale value of the pixel in the fourth interval is assigned to 1, thereby generating the final binary image.
[0077] The embodiment of the present invention realizes binary quantization of infrared images by setting three thresholds based on the image quantization theory. In the grayscale image quantization theory, each pixel contains a grayscale value, and its value range depends on the number of bits of the image. The lower the number of bits, the smaller the amount of data required for the image. The image can be quantized by reassigning the grayscale value of each pixel.
[0078] Compared with the traditional binarization method, the image binarization method provided by the embodiment of the present invention does not require input and adjustment of parameters, the method is simpler, and the final result has clearer geometric features of the target area, and has higher commercial value, as follows:
[0079] 1. In resource-constrained environments, such as remote sensing, mobile devices, or other embedded systems, the amount of data must be reduced as much as possible while maintaining image details;
[0080] 2. The most extreme case is to convert it into a binary image, that is, each pixel is either black or white, which can significantly reduce the amount of data and processing requirements.
[0081] 3. Reduce the complexity of image processing, improve the processing efficiency and reliability of computer vision algorithms, and facilitate Boolean logic operations and obtaining the geometric features of the target area, such as describing the boundary of the target area, obtaining the location and size of the target area, etc. In addition, binarization also helps to reduce the file size of the image, which is very helpful for image storage and transmission.
[0082] 4. The improved binarization method does not require manual adjustment of parameters, which makes it easily integrated into a variety of different technical solutions. It is not restricted by specific scenarios and hardware and has strong adaptability and flexibility.
[0083] 5. When processing sensitive image data, such as facial recognition, binarization can effectively reduce the level of detail of personal data without losing target recognition capabilities, helping to comply with data protection regulations.
[0084] Correspondingly, the present invention also provides an image binarization device, which can implement all the processes of the image binarization method in the above embodiment.
[0085] See also Figure 5 , Figure 5 The figure is a schematic diagram of a preferred embodiment of an image binarization device provided by the present invention. The image binarization device comprises:
[0086] A grayscale mapping module 501 is used to linearly map the original infrared image to a grayscale image and generate a histogram according to the grayscale image;
[0087] A threshold determination module 502, configured to determine a global maximum point and two local maximum points according to the histogram as a first threshold, a second threshold and a third threshold;
[0088] The image binary module 503 is used to divide the grayscale image into four intervals according to the first threshold, the second threshold and the third threshold, and assign values to the four intervals respectively to generate a binary image.
[0089] Preferably, the grayscale mapping module 501 includes:
[0090] A mapping unit 511, used for linearly mapping the original infrared image to an eight-bit grayscale image;
[0091] A generating unit 521 is used to perform statistics on the eight-bit grayscale image, and generate a histogram with the grayscale value as the horizontal coordinate and the number of pixels as the vertical coordinate;
[0092] The filtering unit 531 is used to perform Gaussian filtering on the histogram to obtain a smoothed histogram.
[0093] Preferably, the filtering unit 531 is specifically used for:
[0094] According to the Gaussian function The Gaussian kernel is calculated; where G(i) represents the Gaussian function and σ represents the standard deviation;
[0095] Performing normalization processing on the Gaussian kernel;
[0096] For each data point in the histogram, the Gaussian kernel is placed at the center of the data point, multiplied by the covered histogram data according to the weight of the Gaussian kernel, all products are summed and weighted averaged, and the obtained average value is the new value of the smoothed histogram at the data point.
[0097] Preferably, the threshold determination module 502 includes:
[0098] A second threshold determination unit 512 is used to determine all maximum value points according to the histogram, and select the largest maximum value point as the global maximum value point, that is, the first threshold;
[0099] A first threshold determination unit 522 is used to select the smallest maximum point from the maximum points on the left of the global maximum point as the local maximum point, that is, the second threshold;
[0100] The third threshold determination unit 532 is used to select the largest maximum point from the maximum points to the right of the global maximum point as the local maximum point, that is, the third threshold.
[0101] Preferably, the threshold determination module 502 is further used for:
[0102] If there is no maximum point to the left of the global maximum point, then select the smallest maximum point and the largest maximum point from the maximum points to the right of the global maximum point as the second threshold and the third threshold respectively;
[0103] If there is no maximum point on the right side of the global maximum point, the smallest maximum point and the largest maximum point are selected from the maximum points on the left side of the global maximum point as the second threshold and the third threshold, respectively.
[0104] Preferably, the image binary module 503 includes:
[0105] A segmentation unit 513 is used to segment the grayscale image into four intervals according to the first threshold, the second threshold and the third threshold, which are a first interval, a second interval, a third interval and a fourth interval in descending order;
[0106] The assignment unit 523 is used to assign the grayscale value of the pixel points in the first interval to 0, assign the grayscale value of the pixel points in the second interval to 1, assign the grayscale value of the pixel points in the third interval to 0, and assign the grayscale value of the pixel points in the fourth interval to 1, so as to generate a binary image.
[0107] In the specific implementation, the working principle, control process and technical effect achieved by the image binarization device provided in the embodiment of the present invention are the same as those of the image binarization method in the above embodiment, and will not be repeated here.
[0108] See also Figure 6 , Figure 6 6 is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. The terminal device includes a processor 601, a memory 602, and a computer program stored in the memory 602 and configured to be executed by the processor 601. When the processor 601 executes the computer program, the image binarization method described in any of the above embodiments is implemented.
[0109] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory 602 and executed by the processor 601 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0110] The processor 601 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor, or the processor 601 can be any conventional processor. The processor 601 is the control center of the terminal device, and various parts of the terminal device are connected using various interfaces and lines.
[0111] The memory 602 mainly includes a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc., and the data storage area can store related data, etc. In addition, the memory 602 can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, and a flash card (Flash Card), etc., or the memory 602 can also be other volatile solid-state storage devices.
[0112] It should be noted that the above terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 6 The structural diagram is only an example of the above-mentioned terminal device and does not constitute a limitation of the above-mentioned terminal device. It may include more or less components than shown in the figure, or combine certain components, or different components.
[0113] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the image binarization method described in any of the above embodiments.
[0114] An embodiment of the present invention further provides a computer program product, which includes a computer program or a computer instruction. When the computer program or the computer instruction is executed by a processor, the image binarization method described in any of the above embodiments is implemented.
[0115] The embodiment of the present invention provides an image binarization method, device, equipment, storage medium and computer program product, which linearly maps the original infrared image to a grayscale image and generates a histogram according to the grayscale image; determines the global maximum point and two local maximum points according to the histogram as the first threshold, the second threshold and the third threshold; divides the grayscale image into four intervals according to the first threshold, the second threshold and the third threshold, and assigns values to the four intervals respectively to generate a binary image. The embodiment of the present invention can convert a high-bit infrared image into a binary image without presetting parameters, while retaining the details of the infrared image as much as possible, effectively improving the image processing efficiency.
[0116] It should be noted that the system embodiment described above is merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the system embodiment provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0117] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. An image binarization method, characterized in that: include: Linearly mapping the original infrared image to a grayscale image, and generating a histogram based on the grayscale image; Determine a global maximum point and two local maximum points according to the histogram as a first threshold, a second threshold and a third threshold; The grayscale image is divided into four intervals according to the first threshold, the second threshold and the third threshold, and values are assigned to the four intervals respectively to generate a binary image.
2. The image binarization method according to claim 1, characterized in that: The linear mapping of the original infrared image to a grayscale image and generating a histogram according to the grayscale image includes: Linearly map the original infrared image to an eight-bit grayscale image; Performing statistics on the eight-bit grayscale image, with the grayscale value as the horizontal coordinate and the number of pixels as the vertical coordinate, to generate a histogram; Gaussian filtering is performed on the histogram to obtain a smoothed histogram.
3. The image binarization method according to claim 2, characterized in that: The performing Gaussian filtering on the histogram to obtain a smoothed histogram includes: According to the Gaussian function The Gaussian kernel is calculated; where G(i) represents the Gaussian function and σ represents the standard deviation; Performing normalization processing on the Gaussian kernel; For each data point in the histogram, the Gaussian kernel is placed at the center of the data point, multiplied by the covered histogram data according to the weight of the Gaussian kernel, all products are summed and weighted averaged, and the obtained average value is the new value of the smoothed histogram at the data point.
4. The image binarization method according to claim 1, characterized in that: Determining a global maximum point and two local maximum points according to the histogram as a first threshold, a second threshold and a third threshold includes: Determine all maximum points according to the histogram, and select the largest maximum point as the global maximum point, that is, the first threshold; Selecting the smallest maximum point from the maximum points on the left of the global maximum point as the local maximum point, i.e., the second threshold; The largest maximum point is selected from the maximum points to the right of the global maximum point as the local maximum point, that is, the third threshold.
5. The image binarization method according to claim 4, characterized in that: The method further comprises: If there is no maximum point to the left of the global maximum point, then select the smallest maximum point and the largest maximum point from the maximum points to the right of the global maximum point as the second threshold and the third threshold respectively; If there is no maximum point on the right side of the global maximum point, the smallest maximum point and the largest maximum point are selected from the maximum points on the left side of the global maximum point as the second threshold and the third threshold, respectively.
6. The image binarization method according to claim 5, characterized in that: The step of dividing the grayscale image into four intervals according to the first threshold, the second threshold, and the third threshold, and assigning values to the four intervals respectively to generate a binary image includes: According to the first threshold, the second threshold and the third threshold, the grayscale image is divided into four intervals, which are a first interval, a second interval, a third interval and a fourth interval in descending order; The grayscale values of the pixels in the first interval are assigned to be 0, the grayscale values of the pixels in the second interval are assigned to be 1, the grayscale values of the pixels in the third interval are assigned to be 0, and the grayscale values of the pixels in the fourth interval are assigned to be 1, so as to generate a binary image.
7. An image binarization device, characterized in that: include: A grayscale mapping module, used for linearly mapping the original infrared image to a grayscale image, and generating a histogram according to the grayscale image; A threshold determination module, used to determine a global maximum point and two local maximum points according to the histogram as a first threshold, a second threshold and a third threshold; The image binary module is used to divide the grayscale image into four intervals according to the first threshold, the second threshold and the third threshold, and assign values to the four intervals respectively to generate a binary image.
8. A terminal device, characterized in that: The invention comprises a processor and a memory, wherein a computer program is stored in the memory and the computer program is configured to be executed by the processor, and when the processor executes the computer program, the image binarization method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the device where the computer-readable storage medium is located executes the computer program, the image binarization method according to any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program or a computer instruction, and when the computer program or the computer instruction is executed by a processor, the image binarization method according to any one of claims 1 to 6 is implemented.