An improved histogram equalization method for converting 16-bit image data to 8-bit.
By improving the histogram equalization method, the problem of converting 16-bit infrared data into 8-bit image data was solved. This achieved equal differences between adjacent gray levels, avoided over-enhancement of background areas and merging of detail areas, enhanced local contrast, and improved image quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-24
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies cannot effectively convert 16-bit infrared data into 8-bit image data, resulting in areas with low pixel values having a grayscale value of 0 after conversion. Furthermore, traditional histogram equalization methods are not suitable for cross-bit conversion and cannot meet the display requirements of 16-bit infrared data.
An improved histogram equalization method is adopted, which includes steps such as determining the minimum gray level, merging histogram neighborhoods, mapping processing, local contrast enhancement, and brightness enhancement. This ensures that the difference between adjacent gray levels is equal, avoids over-enhancement of background areas and merging of detail areas, and performs local contrast enhancement.
After converting 16-bit infrared data into 8-bit image data, the difference between adjacent gray levels is equal, avoiding over-enhancement of the background area, preserving the detail area, enhancing the local contrast of the image, and improving the conversion effect.
Smart Images

Figure CN115578282B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an improved histogram equalization method for converting 16-bit infrared data into 8-bit image data. Background Technology
[0002] Infrared detectors are widely used in both civilian and military fields due to their long imaging distance, wide imaging angle, and strong penetration. Because of their powerful performance and ability to resolve extremely high grayscale levels, and to ensure rich detail in the infrared data, their raw output data is often 16-bit. However, conventional displays have limited color and grayscale capabilities and cannot match 16-bit infrared data. Therefore, to adapt to the limitations of hardware, 16-bit infrared data needs to be converted into 8-bit image data for visualization.
[0003] 16-bit infrared data has 2 16 = 66536 gray levels, while 8-bit image data only has 2 8 = 256 gray levels. The common conversion method is pixel value * 256 / 66536. However, this conversion has a problem: for 16-bit infrared data with low pixel values, such as 1, 10, 100, etc., the pixel values of the converted 8-bit image data are all between (0,1). Due to the rounding down rule, the converted pixel values all become 0, which is extremely unfavorable for reflecting the original distribution of 16-bit infrared data.
[0004] Traditional histogram equalization methods can make the grayscale distribution of an image that is either too bright or too dark more uniform, but they are not suitable for cross-bit conversion; that is, they are only applicable to the process of optimizing an 8-bit image into a new 8-bit image. Furthermore, if the original grayscale value is 0, it will remain 0 after equalization, which also fails to meet the requirement of converting 16-bit infrared data into 8-bit image data.
[0005] To address this issue, this patent proposes an improved histogram equalization method. This method not only meets the requirement of converting 16-bit infrared data into 8-bit image data, ensuring that the difference between adjacent gray levels in the converted image is equal, thus avoiding over-enhancement of background areas with a large number of pixels and merging of detail areas with a small number of pixels into adjacent gray levels, but also achieves local contrast enhancement of the converted image data. Summary of the Invention
[0006] This invention proposes an improved histogram equalization method to convert 16-bit infrared data into 8-bit image data. It features equal differences between adjacent gray levels in the converted image, avoids over-enhancing of background areas with large pixel counts and merging of detail areas with small pixel counts into adjacent gray levels, and enhances the local contrast of the converted image data. The technical solution of this invention is as follows:
[0007] An improved histogram equalization method for converting 16-bit image data to 8-bit data includes the following steps:
[0008] 1) Read the infrared information data stream file to be processed;
[0009] 2) Determine the total number of frames N in the continuous data flow based on the size of the infrared information data stream file to be processed and the output size of a single frame infrared image;
[0010] 3) Locate the position of the infrared information data stream by using the total number of frames N and the current number of frames to be displayed N′, and extract 512*512 16-bit pixel infrared data I from this starting point;
[0011] 4) Improve histogram equalization is performed on the infrared data I of the current frame, quantizing it from 16-bit data to 8-bit data. The processing method is as follows:
[0012] ① Traverse the 512*512 pixels of I, count the grayscale information, and determine the minimum grayscale value;
[0013] ② Re-traverse I, subtract min from the gray value of each pixel to obtain the new data I′;
[0014] ③ Traverse I′ and collect the histogram information Z of I′;
[0015] ④ Perform neighborhood merging on the histogram. Starting from i = 0, iterate through each pixel in Z. If Z(i) < 80, accumulate Z(i) into Z(i+1), update Z(i), and obtain Z′(i) = 0; if Z(i) ≥ 80, then Z′(i) = Z(i); where i is the pixel position, 0 < i < 2. 16 ;
[0016] ⑤ Perform mapping on Z′ to obtain a new Z′. The mapping rules are as follows:
[0017] If Z′(i) < 80, then let Z′(i) = 0;
[0018] If 80 < Z′(i) < 200, then let Z′(i) = 1;
[0019] If 200 < Z′(i) < 500, then let Z′(i) = 2;
[0020] If 500 < Z′(i) < 1200, then let Z′(i) = 4;
[0021] If Z′(i)≥1200, then let Z′(i)=6;
[0022] ⑥ Perform histogram equalization transformation to obtain the equalization matrix T, as follows:
[0023]
[0024] ⑦ Map I to obtain I″, and the mapping rules are as follows:
[0025] I″(j)=T(I(j)-min), 0<j<2 16 ;
[0026] 5) Perform local contrast enhancement on I″. Compare the gray value of the current pixel with the average gray value of the neighborhood centered on the current pixel. If the gray value of the current pixel is greater than the average gray value of the neighborhood, then enhance the pixel; otherwise, weaken the enhancement. This yields the enhanced 8-bit image K. The processing method is as follows:
[0027] ① Determine the enhancement parameter S = 255 / T(2 16 -1), neighborhood parameter n = 2, and magnification factor s = 3;
[0028] ② Iterate through I″ and calculate the average gray value of pixel I″(i) in the (2*n+1)*(2*n+1) neighborhood.
[0029] ③ Iterate through I″ and perform contrast enhancement processing on I″. The processing method is as follows:
[0030]
[0031] Where i is the pixel position, and its value range is: 0 < i < 512 * 512;
[0032] ④ Iterate through K and perform brightness enhancement processing on K. The processing method is as follows:
[0033] K(i) = K(i) * S + 20, where i is the pixel position, and its value range is as follows: 0 < i < 512 * 512;
[0034] ⑤ Traverse K, perform constraint processing, and obtain the final 8-bit image. The processing method is as follows:
[0035]
[0036] Where i is the pixel position, and its value range is as follows: 0 < i < 512 * 512. Attached Figure Description
[0037] Figure 1 The effect of traditional histogram equalization.
[0038] Figure 2 The effect of traditional histogram equalization.
[0039] Figure 3 The improved histogram equalization effect proposed in this invention is shown in the figure.
[0040] Figure 4 The improved histogram equalization effect proposed in this invention is shown in the figure. Detailed Implementation
[0041] To address the problem that traditional histogram equalization is unsuitable for converting 16-bit infrared data to 8-bit image data, this invention proposes an improved histogram equalization method for converting 16-bit infrared data to 8-bit image data. This method ensures that the differences between adjacent gray levels are equal after conversion, avoiding over-enhancement of background areas with large pixel counts and merging of detail areas with small pixel counts into adjacent gray levels, thus greatly improving the conversion effect. The method includes the following steps:
[0042] 6) Read the infrared information data stream file to be processed;
[0043] 7) Determine the total number of frames N in the continuous data flow based on the size of the infrared information data stream file to be processed and the output size of a single frame infrared image;
[0044] 8) Locate the position of the infrared information data stream by using the total number of frames N and the current number of frames to be displayed N′, and extract 512*512 16-bit pixel data I from this starting point;
[0045] 9) Improve histogram equalization for the current frame infrared data I, quantizing it from 16-bit data to 8-bit data. The processing method is as follows:
[0046] ⑧ Traverse the 512*512 pixels of I, count the grayscale information, and determine the minimum grayscale value min.
[0047] ⑨ Re-traverse I, subtract min from the gray value of each pixel to obtain the new data I′;
[0048] ⑩ Traverse I′ and collect the histogram information Z of I′;
[0049] 11. Perform neighborhood merging on the histogram. Starting from i = 0, traverse each pixel in Z sequentially. If Z(i) < 80, accumulate Z(i) to Z(i+1), update Z(i), and obtain Z′(i) = 0; if Z(i) ≥ 80, then Z′(i) = Z(i); where i is the pixel position, 0 < i < 2. 16;
[0050] 12. Perform mapping on Z′ to obtain a new Z′, the mapping rules are as follows:
[0051]
[0052] 13. Perform a histogram equalization transformation to obtain the equalization matrix T, as follows:
[0053]
[0054] 14. Mapping I to obtain I″, the mapping rules are as follows:
[0055]
[0056] 10) Perform local contrast enhancement on I″ by comparing the gray value of the current pixel with the average gray value of the neighborhood centered on the current pixel. If the gray value of the current pixel is greater than the average gray value of the neighborhood, then enhance the pixel; otherwise, weaken the enhancement. This yields the enhanced 8-bit image K. The processing method is as follows:
[0057] ⑥ Determine the enhancement parameter S = 255 / T(2 16 -1), neighborhood parameter n = 2, and magnification factor s = 3.
[0058] ⑦ Iterate through I″ and calculate the average gray value of pixel I″(i) in the (2*n+1)*(2*n+1) neighborhood.
[0059] ⑧ Iterate through I″ and perform contrast enhancement processing on I″. The processing method is as follows:
[0060]
[0061] 9. Iterate through K and perform brightness enhancement processing on K. The processing method is as follows:
[0062]
[0063] ⑩ Traverse K, perform constraint processing, and obtain the final 8-bit image. The processing method is as follows:
[0064]
Claims
1. An improved histogram equalization method for converting 16-bit to 8-bit image data, comprising the following steps: 1) Read the infrared information data stream file to be processed; 2) Determine the total number of frames N of the continuous data stream according to the size of the infrared information data stream file to be processed and the output size of a single-frame infrared image; 3) Locate the position of the infrared information data stream through the total number of frames N and the current frame number N' to be displayed, and intercept 512 * 51 / 2 16-bit pixel infrared data I starting from this point; 4) Perform improved histogram equalization on the infrared data I of the current frame, and quantize it from 16-bit data to 8-bit data. The processing method is as follows: ① Traverse the 512 * 512 pixels of I, count the gray information, and determine the minimum gray value min; ② Traverse I again, subtract min from the gray value of each pixel to obtain new data I'; ③ Traverse I', and count the histogram information Z of I'; ④ Perform neighborhood merging on the histogram. Starting from i = / 0, traverse each pixel point in Z in turn. If Z(i) < 80, then accumulate Z(i) to Z(i + 1), update Z(i), and get Z'(i) = 0; if Z(i) ≥ 80, then Z'(i) = Z(i); where, i is the pixel position, 0 <i<2 16 ; ⑤ Perform mapping processing on Z' to obtain new Z'. The mapping rule is as follows: If Z'(i) < 80, then set Z'(i) = 0; If 80 < Z'(i) < 200, then set Z'(i) = 1; If 200 < Z'(i) < 500, then set Z'(i) = 2; If 500 < Z'(i) < 1200, then set Z'(i) = 4; If Z'(i) ≥ 1200, then set Z'(i) = 6; ⑥ Perform histogram equalization transformation to obtain the equalization matrix Τ. The transformation is as follows: ⑦ Perform mapping on I to obtain I″. The mapping rule is as follows: I″(j)=T(I(j)-min),0<j<2 16 5) Perform local contrast enhancement on I″. Compare the gray value of the current pixel point with the average gray value in the neighborhood centered on the current point. If the gray value of the current pixel point is greater than the average gray value in the neighborhood, enhance this point; otherwise, weaken it to obtain the enhanced 8-bit image K with the following processing method: ① Determine the enhancement parameter S = 255 / T(2 16 -1), neighborhood parameter n = 2, and magnification factor s = 3; ② Iterate through I″ and calculate the average gray value of pixel I″(i) in the (2*n+1)*(2*n+1) neighborhood. ③ Traverse I″ and perform contrast enhancement processing on I″ with the following processing method: Where, i is the pixel position, and its value range is: 0 < i < 512 * 512; ④ Traverse K and perform brightness enhancement processing on K with the following processing method: K(i) = K(i) * S + 20, where, i is the pixel position, and its value range is as follows: 0 < i < 512 * 512; ⑤ Traverse K and perform constraint processing to obtain the final 8-bit image with the following processing method: Where, i is the pixel position, and its value range is as follows: 0 < i < 512 * 512. It should be noted that there seems to be an error in the original text where "512 * 51 / 2" in step 3 should probably be "512 * 512". This translation is based on the corrected understanding. Also, the "S" in step 21 has no prior definition in the provided text.