X-ray image brightness adjusting method based on gamma correction
By performing Log transformation on the X-ray image and calculating the average value of the local window, the gamma correction parameters are dynamically automatically calculated, and the effective brightness adjustment of high and low illuminance images is solved, and the problem of preset parameters and poor correction effects in the prior art is solved.
Patent Information
- Application Number
- CN202510035383.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-07
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art gamma correction method requires preset parameters and is only suitable for images with uniform distribution of grayscale histograms, and cannot effectively adjust the high and low illuminance images.
The brightness adjustment method of X-ray image based on gamma correction is adopted, and the X-ray image is log transformed and the local window average calculation is calculated dynamically and the gamma correction parameters are automatically calculated to perform brightness adjustment.
Effective brightness adjustment for high and low illuminance images is realized, and no preset parameters are required, and correction parameters are automatically calculated based on each image, solving the problem of poor correction effect in the prior art.
Smart Images

Figure CN119893005A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of X-ray scattered rays, and in particular to a method for adjusting the brightness of an X-ray image based on gamma correction. Background Art
[0002] The human eye's perception of brightness is nonlinear. Specifically, the human eye is more sensitive to low-brightness areas and less sensitive to high-brightness areas. This means that if the brightness of an image is unevenly distributed, some details may be difficult to observe. X-ray images are colorless grayscale images, and different brightness represents different grayscales. For such images, the brightness can be adjusted through gamma correction.
[0003] The existing gamma correction technology currently mainly performs global brightness adjustment or segmented brightness adjustment. However, both methods have preset correction parameters. When the grayscale histogram of the X-ray image is evenly distributed, this effect is better. Once the grayscale frequency is concentrated, or there are pixels with high or extremely low illumination in the image, the general method will not work well.
[0004] Problems solved by the present invention: 1. Effective adjustment can be performed on images with high or low illumination (low or high grayscale frequency overall). 2. No preset parameters are required, and the correction parameters are automatically calculated based on each image. Summary of the invention
[0005] The purpose of the present invention is to provide a method for adjusting the brightness of an X-ray image based on gamma correction, aiming to solve the problem that the gamma correction method in the prior art requires preset parameters and is only applicable to the versatility of uneven grayscale histograms.
[0006] To achieve the above object, the present invention provides a method for adjusting the brightness of an X-ray image based on gamma correction, comprising the following steps:
[0007] Place the sample at the testing position and use the software acquisition module to obtain X-ray images in real time I;
[0008] Performing Log transformation on the X-ray image I to obtain image L;
[0009] Calculate the average value of each pixel window based on each pixel in the image L as the center;
[0010] Performing normalization processing on the X-ray image I and adjusting the brightness of the image using a gamma correction formula;
[0011] Output the rectified image.
[0012] The specific method of placing the sample at the detection position and using the software acquisition module to obtain the X-ray image I in real time is as follows:
[0013] Place the sample at the testing position and turn on the radiation source and the detector's collection device;
[0014] Adjust the voltage and current of the radiation source until it can penetrate the sample to be tested, and use the software acquisition module to obtain X-ray images in real time.
[0015] In the process of calculating the average value of each pixel window, the average value of the window grayscale is not directly used, but the grayscale value after Log transformation is used to calculate the window average value.
[0016] The maximum grayscale value of the image in the gamma correction formula is 65535.
[0017] The specific method of outputting the corrected image is as follows:
[0018] For the corrected image, if it is an 8-bit image, it will be displayed directly. If it is a 16-bit deep image, the software will use proportional mapping to display it in an 8-bit image.
[0019] The invention discloses a method for adjusting brightness of an X-ray image based on gamma correction. The method comprises the following steps: placing a sample at a detection position, acquiring an X-ray image I in real time by using a software acquisition module; performing Log transformation on the X-ray image I to obtain an image L; calculating the average value of each pixel window based on each pixel in the image L as the center; performing normalization processing on the X-ray image I, and adjusting the brightness of the image by using a gamma correction formula; and outputting a corrected image. The method introduces a spatial domain calculation method to effectively solve the problem that the grayscale frequency has a poor correction effect when it is concentrated. A gamma correction parameter is calculated for each pixel according to different conditions in the spatial domain, so that dynamic and automatic adjustment can be achieved without preset. Local log transformation is used instead of global log change. In the local space, contrast enhancement is achieved. The method can effectively adjust images of high and low illumination (low or high grayscale frequency overall) without preset parameters. The correction parameters are automatically calculated according to each image, so that the problem that the gamma correction method in the prior art needs preset parameters and is only applicable to the versatility of uneven grayscale histogram distribution is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1The present invention provides a flowchart of a method for adjusting the brightness of an X-ray image based on gamma correction.
[0022] Figure 2 The present invention provides a flow chart of a method for adjusting the brightness of an X-ray image based on gamma correction.
[0023] Figure 3 It is a flowchart of a specific method of placing a sample at a detection position and using a software acquisition module to obtain an X-ray image I in real time. DETAILED DESCRIPTION
[0024] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0025] See also Figures 1 to 3 The present invention provides a method for adjusting the brightness of an X-ray image based on gamma correction, comprising the following steps:
[0026] S1 places the sample at the testing position and uses the software acquisition module to obtain X-ray images I in real time;
[0027] Specific method:
[0028] S11 places the sample at the testing position and turns on the radiation source and the collection device of the detector;
[0029] S12 adjusts the voltage and current of the radiation source until it can penetrate the sample to be tested, and uses the software acquisition module to obtain X-ray images in real time.
[0030] S2 performs Log transformation on the X-ray image I to obtain an image L;
[0031] In the embodiment of the present invention, the software performs Log transformation on the X-ray image I(x, y) collected in real time to obtain the image L(x, y). x represents the horizontal coordinate of the pixel, and y represents the vertical coordinate of the pixel, as shown in Formula 1:
[0032] L(x, y)=log(1+I(x, y)) (Formula 1).
[0033] S3 calculates the average value of each pixel window based on each pixel in the image L as the center;
[0034] In the embodiment of the present invention, the average value A(x, y) of the local window is calculated with each pixel as the center in the image L(x, y), where m*n is the window size, and x and y are the horizontal and vertical coordinates of the current pixel respectively. The average value of the window grayscale is not directly used here, but the grayscale value after Log transformation is used to calculate the window average value. This is because Log transformation can effectively suppress the highlight part and enhance the dark part, so that the average pixel calculated can be more consistent with the grayscale value of the dark part. As shown in Formula 2:
[0035]
[0036] S4 performs normalization processing on the X-ray image I and adjusts the brightness of the image using a gamma correction formula;
[0037] In an embodiment of the present invention, a gamma correction formula is used to adjust the brightness of an image. The software uses the value after normalization of the original image I(x, y) as the base, and uses the local window average value obtained in step 3 as the power value. If the local window is brighter, that is, the A(x, y) value is large, it will have a lowering effect on the current I(x, y) grayscale value. If the local window is darker, that is, the A(x, y) value is small, it will have a higher effect on the current I(x, y) grayscale value. In the formula, max is the maximum grayscale value of the image. For a 16-bit depth image, 216-1=65535 is taken, and for an 8-bit depth image, 28-1=255 is taken. Because X-ray images are usually 16-bit depth images, max is 65535 here. Finally, the automatically corrected image I`(x, y) is obtained, as shown in Formula 3:
[0038]
[0039] S5 outputs the corrected image.
[0040] In the embodiment of the present invention, for the corrected image, the 8-bit image is directly displayed. If it is a 16-bit deep image, the software needs to map it to an 8-bit image before it can be displayed. Here, the proportional mapping method is adopted, and the specific operation is to divide each gray value by 255. The 2N4 steps are repeated to achieve the brightness adjustment of the real-time X-ray image.
[0041] The above disclosure is only a preferred embodiment of the X-ray image brightness adjustment method based on gamma correction of the present invention. Of course, it cannot be used to limit the scope of rights of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiments and equivalent changes made according to the claims of the present invention still fall within the scope of the invention.
Claims
1. A method for adjusting the brightness of an X-ray image based on gamma correction, characterized in that: The following steps are involved: Place the sample at the testing position and use the software acquisition module to obtain X-ray images in real time I; Performing Log transformation on the X-ray image I to obtain image L; Calculate the average value of each pixel window based on each pixel in the image L as the center; Performing normalization processing on the X-ray image I and adjusting the brightness of the image using a gamma correction formula; Output the rectified image.
2. The X-ray image brightness adjustment method based on gamma correction as claimed in claim 1, It is characterized by: The specific method of placing the sample at the detection position and using the software acquisition module to obtain the X-ray image I in real time is: Place the sample at the testing position and turn on the radiation source and the detector's collection device; Adjust the voltage and current of the radiation source until it can penetrate the sample to be tested, and use the software acquisition module to obtain X-ray images in real time.
3. The X-ray image brightness adjustment method based on gamma correction as claimed in claim 1, It is characterized by: In the process of calculating the average value of each pixel window, the average value of the window grayscale is not directly used, but the grayscale value after Log transformation is used to calculate the window average value.
4. The X-ray image brightness adjustment method based on gamma correction as claimed in claim 1, characterized in that ; The maximum grayscale value of the image in the gamma correction formula is 65535.
5. The X-ray image brightness adjustment method based on gamma correction as claimed in claim 1, It is characterized by: The specific method of outputting the corrected image is as follows: For the corrected image, if it is an 8-bit image, it will be displayed directly. If it is a 16-bit deep image, the software will use proportional mapping to display it in an 8-bit image.