Method and system for displaying x-ray image, x- ray machine, and storage medium
Embodiments of the present disclosure disclose a method and system for displaying x-ray image, an x-ray machine, and a storage medium. The method includes: obtaining a captured current image of a target region; determining at least one to-be-optimized region in the current image; and for each to-be-optimized region, obtaining a maximum grayscale value and a minimum grayscale value in the to-be-optimized region, determining a window width and a window level for the to-be-optimized region according to the maximum grayscale value and the minimum grayscale value, and displaying the current image based on the window width and the window level. The technical solutions in the embodiments of the present disclosure can improve image display resolution of a current to-be-optimized region.
1 . A method for displaying an X-ray image, comprising:
obtaining a captured current image of a target region;
determining at least one to-be-optimized region in the current image, comprising:
detecting whether a to-be-optimized region exists in the current image by detecting a pixel having a brightness value less than a preset brightness threshold in the current image to obtain an underexposed pixel and, when a quantity of underexposed pixels reaches a preset quantity threshold, (i) determining that a to-be-optimized underexposed dark region exists in the current image, and (ii) determining a to-be-optimized region corresponding to the underexposed dark region based on a distribution of the underexposed pixels, and
determining each detected to-be-optimized region as a to-be-optimized region in the current image; and
for each to-be-optimized region:
obtaining a maximum grayscale value and a minimum grayscale value in the to-be-optimized region;
determining a window width and a window level for the to-be-optimized region according to the maximum grayscale value and the minimum grayscale value by:
using a difference between the maximum grayscale value and the minimum grayscale value as the window width for the to-be-optimized region; and
using (i) an average value of the maximum grayscale value and the minimum grayscale value, or (ii) an average value of all pixels in the to-be-optimized region, as the window level for the to-be-optimized region; and
displaying the current image based on the window width and the window level.
2 . The method according to claim 1 , wherein the detecting whether a to-be-optimized region exists in the current image and determining each detected to-be-optimized region as a to-be-optimized region in the current image further comprises:
detecting a pixel having a brightness value greater than a preset further brightness threshold in the current image to obtain an overexposed pixel;
when a quantity of overexposed pixels reaches a preset further quantity threshold:
determining that a to-be-optimized overexposed bright region exists in the current image;
determining a to-be-optimized region corresponding to the overexposed bright region based on a distribution of the overexposed pixels.
3 . The method according to claim 2 , wherein the preset brightness threshold is less than or equal to the preset further brightness threshold.
4 . The method according to claim 1 , wherein the determining the at least one to-be-optimized region in the current image comprises obtaining at least one to-be-optimized region that has been manually selected by a user from the current image.
5 . The method according to claim 1 , wherein detecting whether a to-be-optimized region exists in the current image is performed based on a histogram.
6 . The method according to claim 1 , wherein determining the to-be-optimized region corresponding to the underexposed dark region comprises using an image gradient calculation algorithm to detect an edge of the underexposed dark region and fitting a boundary of the underexposed dark region using an edge curve.
7 . A system for displaying an X-ray image, comprising:
first processing circuitry configured to obtain a captured current image of a target region;
second processing circuitry configured to determine at least one to-be-optimized region in the current image by:
detecting whether a to-be-optimized region exists in the current image by detecting a pixel having a brightness value less than a preset brightness threshold in the current image to obtain an underexposed pixel, and, when a quantity of underexposed pixels reaches a preset quantity threshold, (i) determining that a to-be-optimized underexposed dark region exists in the current image, and (in) determining a to-be-optimized region corresponding to the underexposed dark region based on a distribution of the underexposed pixels; and
determining each detected to-be-optimized region as a to-be-optimized region in the current image; and
third processing circuitry configured to, for each to-be-optimized region:
obtain a maximum grayscale value and a minimum grayscale value in the to-be-optimized region;
determine a window width and a window level for the to-be-optimized region according to the maximum grayscale value and the minimum grayscale value by:
using a difference between the maximum grayscale value and the minimum grayscale value as the window width for the to-be-optimized region; and
using (i) an average value of the maximum grayscale value and the minimum grayscale value, or (ii) an average value of all pixels in the to-be-optimized region, as the window level for the to-be-optimized region; and
display the current image based on the window width and the window level.
8 . The system according to claim 7 , wherein the second processing circuitry is further configured to:
detect a pixel having a brightness value greater than a preset further brightness threshold in the current image to obtain an overexposed pixel;
when a quantity of overexposed pixels reaches a preset first-further quantity threshold:
determine that a to-be-optimized overexposed bright region exists in the current image; and
determine a to-be-optimized region corresponding to the overexposed bright region based on a distribution of the overexposed pixels.
9 . The system according to claim 8 , wherein the preset brightness threshold is less than or equal to the preset further brightness threshold.
10 . The system according to claim 7 , wherein the second processing circuitry is configured to:
obtain at least one to-be-optimized region that is manually selected by a user from the current image; and
determine the at least one to-be-optimized region as at least one to-be-optimized region in the current image.
11 . The system according to claim 7 , wherein the system is part of an X-ray machine.
12 . The system according to claim 7 , wherein the second processing circuitry is configured to detect whether a to-be-optimized region exists in the current image based on a histogram.
13 . The system according to claim 7 , wherein the second processing circuitry is configured to determine the to-be-optimized region corresponding to the underexposed dark region by using an image gradient calculation algorithm to detect an edge of the underexposed dark region and fitting a boundary of the underexposed dark region using an edge curve.
14 . A non-transitory computer-readable storage medium on which a computer program is stored that, when executed by a processor, cause an X-ray image to be displayed by:
obtaining a captured current image of a target region;
determining at least one to-be-optimized region in the current image by:
detecting whether a to-be-optimized region exists in the current image by detecting a pixel having a brightness value less than a preset brightness threshold in the current image to obtain an underexposed pixel, and, when a quantity of underexposed pixels reaches a preset quantity threshold, determining that a to-be-optimized underexposed dark region exists in the current image, and determining a to-be-optimized region corresponding to the underexposed dark region based on a distribution of the underexposed pixels; and
determining each detected to-be-optimized region as a to-be-optimized region in the current image; and
for each to-be-optimized region:
obtaining a maximum grayscale value and a minimum grayscale value in the to-be-optimized region;
determining a window width and a window level for the to-be-optimized region according to the maximum grayscale value and the minimum grayscale value by:
using a difference between the maximum grayscale value and the minimum grayscale value as the window width for the to-be-optimized region; and
using (i) an average value of the maximum grayscale value and the minimum grayscale value, or (ii) an average value of all pixels in the to-be-optimized region, as the window level for the to-be-optimized region; and
displaying the current image based on the window width and the window level.
15 . The non-transitory computer-readable storage medium according to claim 14 , wherein the computer program, when executed by a processor, further causes the detection of whether the to-be-optimized region exists in the current image and the determination of each detected to-be-optimized region as a to-be-optimized region in the current image by:
detecting a pixel having a brightness value greater than a preset further brightness threshold in the current image to obtain an overexposed pixel; and
when a quantity of overexposed pixels reaches a preset further quantity threshold:
determining that a to-be-optimized overexposed bright region exists in the current image; and
determining a to-be-optimized region corresponding to the overexposed bright region based on a distribution of the overexposed pixels.
16 . The non-transitory computer-readable storage medium according to claim 15 , wherein the preset brightness threshold is less than or equal to the preset further brightness threshold.
17 . The non-transitory computer-readable storage medium according to claim 14 , wherein the computer program, when executed by a processor, further causes the at least one to-be-optimized region in the current image to be determined by obtaining at least one to-be-optimized region that has been manually selected by a user from the current image.
18 . The non-transitory computer-readable storage medium according to claim 14 , wherein the computer program, when executed by a processor, further causes the detection of whether a to-be-optimized region exists in the current image based on a histogram.
19 . The non-transitory computer-readable storage medium according to claim 14 , wherein the computer program, when executed by a processor, further causes the determination of a to-be-optimized region corresponding to the underexposed dark region by using an image gradient calculation algorithm to detect an edge of the underexposed dark region and fitting a boundary of the underexposed dark region using an edge curve.