Disclosure of Invention
In order to solve the technical problem that the coronary artery detection accuracy is low due to the fact that the histogram equalization has an unobvious enhancement effect on the coronary artery angiography image, the invention aims to provide a coronary artery angiography lesion detection method and system based on image processing, and the adopted technical scheme is as follows:
Acquiring a coronary angiography gray image to be detected;
Mapping the pixels in the coronary angiography gray image and preset neighborhood pixels to different degrees through a histogram equalization algorithm, and obtaining an optimal mapping value of the pixels according to the structure difference characteristics before and after mapping and the contrast characteristics after mapping;
Obtaining a gradient value of a pixel point according to gray difference characteristics of the pixel point and other pixel points in a preset neighborhood range in the coronary angiography gray image, obtaining a first gradient characteristic value of the pixel point according to change characteristics of the gradient value in a preset window range of the pixel point, obtaining a second gradient characteristic value of the pixel point according to distribution characteristics of the gradient value in the preset window range of the pixel point, obtaining gradient coefficients of the pixel point according to the first gradient characteristic value and the second gradient characteristic value, and obtaining brightness coefficients according to gray characteristics of the pixel point;
Obtaining a blood vessel-like coefficient according to the gradient coefficient and the brightness coefficient of the pixel point, obtaining a global mapping value according to the specific gravity characteristic of the blood vessel-like coefficient corresponding to the pixel point with the same optimal mapping value, and enhancing the coronary angiography gray level image through a histogram equalization algorithm according to the global mapping value to obtain a coronary angiography enhanced image.
Further, the step of mapping the pixels in the coronary angiography gray image with preset neighborhood pixels in different degrees through a histogram equalization algorithm, and obtaining an optimal mapping value of the pixels according to the structure difference features before and after mapping and the contrast features after mapping includes:
The method comprises the steps of selecting a value in a closed interval of a gray value of a pixel point and a constant 255 as a gray level value in a histogram equalization algorithm to map, obtaining mapped images with different mapping degrees, calculating an average value of gray difference absolute values of the pixel point and a preset neighborhood pixel point in the mapped images, normalizing the average value to obtain a mapping contrast of the pixel point, calculating structural similarity of the mapped images and a corresponding image before mapping, obtaining an image similarity characteristic value, calculating a product of a preset first scale factor and the mapping contrast, obtaining a first factor, calculating a product of a preset second scale factor and the image similarity characteristic value, obtaining a second factor, calculating a sum value of the first factor and the second factor, obtaining a mapping effect characteristic value of the mapped image, and taking a gray level value corresponding to the maximum value of the mapping effect characteristic value as an optimal mapping value of the pixel point.
Further, the step of obtaining the gradient value of the pixel point according to the gray difference characteristic of the pixel point in the coronary angiography gray image and other pixel points in the preset neighborhood range includes:
and calculating the absolute value of the difference value of the gray level value of the pixel point and other pixel points in a preset neighborhood range to obtain the gray level difference value of the pixel point, and taking the maximum value of the gray level difference value as the gradient value of the pixel point.
Further, the step of obtaining the first gradient characteristic value of the pixel point according to the variation characteristic of the gradient value within the preset window range of the pixel point includes:
The method comprises the steps of constructing a change curve according to gradient values of all pixel points in any preset window range of the pixel points, calculating the change rate of gradient values of adjacent pixel points in the pixel points and any preset window range according to the change curve to obtain gradient change characteristic values of the pixel points and the adjacent pixel points, and calculating the ratio of the gradient change characteristic values of the pixel points and the previous adjacent pixel points and the gradient change characteristic values of the pixel points and the next adjacent pixel points to obtain a first gradient characteristic value of the pixel points.
Further, the step of obtaining the second gradient characteristic value of the pixel point according to the distribution characteristic of the gradient value within the preset window range of the pixel point includes:
calculating the sum value of gradient values of all pixel points in any preset window range of the pixel points to obtain a gradient sum value, calculating the ratio of the gradient value of the pixel points to the gradient sum value to obtain a gradient occupation characteristic value, and taking the maximum value of the gradient occupation characteristic values corresponding to different preset window ranges as a second gradient characteristic value of the pixel points.
Further, the step of obtaining the gradient coefficient of the pixel point according to the first gradient eigenvalue and the second gradient eigenvalue includes:
The method comprises the steps of calculating the sum value of first gradient characteristic values corresponding to all preset window ranges of the pixel points to obtain comprehensive first gradient characteristic values of the pixel points, calculating the absolute sum value of the comprehensive first gradient characteristic values and the number of the preset window ranges to obtain first mapping values of the pixel points, calculating the sum value of the opposite number of the first mapping values and the second gradient characteristic values and normalizing the sum value of the opposite number of the first mapping values to obtain gradient coefficients of the pixel points.
Further, the step of obtaining the brightness coefficient according to the gray scale characteristics of the pixel point includes:
And calculating the reciprocal of the gray value of the pixel point in the coronary angiography gray image to obtain the brightness coefficient of the pixel point.
Further, the step of obtaining the blood vessel-like coefficient according to the gradient coefficient and the brightness coefficient of the pixel point comprises the following steps:
The method comprises the steps of calculating the product of a preset first weight and the gradient coefficient to obtain a first coefficient, calculating the product of a preset second weight and the brightness coefficient to obtain a second coefficient, wherein the sum of the preset first weight and the preset second weight is constant 1, the preset first weight is larger than the preset second weight, and calculating the sum of the first coefficient and the second coefficient to obtain the vascular-like coefficient of the pixel point.
Further, the step of obtaining the global mapping value according to the gravity characteristics of the blood vessel-like coefficients corresponding to the pixel points with the same optimal mapping value includes:
and calculating the sum value of the blood vessel-like coefficients corresponding to the pixel points with the same optimal mapping value to obtain a blood vessel-like total coefficient, and taking the optimal mapping value corresponding to the maximum value of the blood vessel-like total coefficient as the global mapping value.
The invention also provides a coronary angiography lesion detection system based on image processing, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the computer program to realize any one of the steps of the coronary angiography lesion detection method based on image processing.
The invention has the following beneficial effects:
According to the method, the image of the coronary angiography gray level and the image of the preset neighborhood are mapped to different degrees through a histogram equalization algorithm, contrast and detail retention characteristics under different equalization degrees can be judged, the optimal mapping value is obtained, the optimal mapping ranges of different pixels and the corresponding preset neighborhood pixels can be determined, and a proper selection range is provided for global mapping of the final integral coronary angiography gray level image. Because the gray level difference between the blood vessel region and other tissue regions in the coronary angiography gray level image is obvious, the position of the pixel point can be represented by the gradient value of the obtained pixel point, the position of the pixel point can be analyzed according to the change characteristic of the gradient value by obtaining the first gradient characteristic value, the position of the pixel point can be analyzed according to the gradient distribution characteristic of the gradient value by obtaining the second gradient characteristic value, and the position of the pixel point in the image can be accurately analyzed by obtaining the gradient coefficient. Because the color of the blood vessel region in the coronary angiography gray level image is darker, the obtained brightness coefficient can reflect the position of the pixel point, and the obtained blood vessel-like coefficient can accurately represent the possibility that the pixel point is positioned in the blood vessel region. Finally, the global mapping value can be obtained to map according to the mapping degree of the pixel points in the blood vessel region in the image, the contrast of the blood vessel region and other tissue regions can be increased, meanwhile, details can be reserved, and the accuracy of the coronary angiography enhanced image is higher when a doctor is assisted in coronary analysis.
Detailed Description
In order to further describe the technical means and effects adopted by the present invention to achieve the preset purpose, the following detailed description refers to specific implementation, structure, features and effects of a coronary angiography lesion detection method based on image processing according to the present invention with reference to the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The following specifically describes a specific scheme of the coronary angiography lesion detection method based on image processing.
Referring to fig. 1, a flowchart of a method for detecting coronary angiography lesions based on image processing according to an embodiment of the invention is shown, the method includes the following steps:
Step S1, acquiring a coronary angiography gray image to be detected.
In the embodiment of the invention, the implementation scene is to carry out image enhancement on the coronary angiography gray level image of the coronary artery health analyzed by a doctor, so as to improve the judgment accuracy of the doctor, firstly, the coronary angiography gray level image to be detected is acquired, the graying and denoising treatment is carried out after the coronary angiography image is acquired by an instrument, and the coronary angiography gray level image is obtained.
The contrast of blood vessels and other tissue areas in the image needs to be improved and the blood vessel characteristics are highlighted because the characteristics of tiny blood vessels in the acquired coronary angiography gray level image are not obvious, and the situation of increasing the contrast of non-blood vessel areas and reducing the contrast of blood vessel areas possibly occurs in the process of carrying out image enhancement on the coronary angiography gray level image, so that the quality of image enhancement is not high. In order to improve the effect of image enhancement and the accuracy of analysis of coronary artery health status, the process of image enhancement by using histogram equalization needs to be improved, and the image enhancement quality of the coronary angiography gray-scale image needs to be improved.
And S2, mapping the pixels in the coronary angiography gray level image and the preset neighborhood pixels to different degrees through a histogram equalization algorithm, and obtaining an optimal mapping value of the pixels according to the structural difference characteristics before and after mapping and the contrast characteristics after mapping.
The prior histogram equalization is to determine the gray level cumulative distribution frequency of different gray levels according to the gray level histogram of the original image, obtain an equalized image according to the gray level cumulative distribution frequency and the maximum gray level of the original image, so that the equalized image is consistent with the gray level range of the original image, but the contrast between a vascular area and other tissue areas is not obvious when the equalized image is consistent with the gray level range of the original image, so that the gray level range of the equalized image can be improved, the contrast between pixels is increased, the pixels in the coronary angiography gray image and the preset neighborhood pixels are mapped to different degrees through a histogram equalization algorithm, and the optimal mapping value of the pixels is obtained according to the structure difference characteristics before and after mapping and the contrast characteristics after mapping.
Preferably, in the embodiment of the invention, the step of obtaining the optimal mapping value comprises the steps of arbitrarily selecting one value from the closed interval of the gray value of the pixel point and the constant 255 as the gray level value in a histogram equalization algorithm to obtain the mapping image with different mapping degrees, namely, equalizing according to the gray accumulation distribution frequency of the pixel point and the preset neighborhood pixel point and any selected gray level value to obtain an equalized mapping image, wherein the gray level range of the mapping image is different from that of the corresponding original image, the gray level difference between the pixel points in the mapping image is larger, and the characteristic difference of different areas in the image is more obvious. After different mapping images are obtained, the contrast of the mapping images and the retention degree of image details need to be analyzed, and proper gray level values are selected.
Further, the average value of the gray difference absolute value of the pixel point and the preset neighborhood pixel point is calculated in the mapping image and normalized to obtain the mapping contrast of the pixel point, when the mapping contrast is larger, the gray difference in the mapping image is more obvious, and compared with the contrast of the original image, the mapping image is more suitable for coronary artery analysis. However, excessive contrast may result in loss of some details in the image, resulting in reduced accuracy of the coronary analysis, so that it is necessary to ensure that details are not lost while improving the image contrast. The method comprises the steps of calculating the structural similarity of a mapping image and a corresponding image before mapping to obtain an image similarity characteristic value, wherein the calculation of the structural similarity belongs to the prior art, specific steps are not repeated, and when the structural similarity is closer to 1, the more similar the images in the two images are, the more the details of the images are reserved. The method comprises the steps of calculating a product of a preset first scale factor and a mapping contrast ratio to obtain a first factor, calculating a product of a preset second scale factor and an image similar characteristic value to obtain a second factor, wherein in the embodiment of the invention, the preset first scale factor is 0.4, and the preset second scale factor is 0.6. And when the mapping effect characteristic value is larger, the detail texture in the image is reserved as much as possible while the image contrast of the mapping image is increased, and the contrast and the image detail are balanced. The method comprises the steps of taking a gray level value corresponding to the maximum value of a mapping effect characteristic value as an optimal mapping value of a pixel point, balancing contrast and image details to the greatest extent by using a mapping image obtained by balancing the pixel point and a preset neighborhood pixel point through the optimal mapping value, wherein each pixel point in the coronary angiography gray image corresponds to one optimal mapping value, and the optimal mapping values of different pixel points are possibly different.
Step S3, obtaining a gradient value of the pixel point according to gray difference characteristics of the pixel point in the coronary angiography gray image and other pixel points in a preset neighborhood range, obtaining a first gradient characteristic value of the pixel point according to change characteristics of the gradient value in a preset window range of the pixel point, obtaining a second gradient characteristic value of the pixel point according to distribution characteristics of the gradient value in the preset window range of the pixel point, obtaining gradient coefficients of the pixel point according to the first gradient characteristic value and the second gradient characteristic value, and obtaining brightness coefficients according to gray characteristics of the pixel point.
In step S2, an optimal mapping value is obtained for each pixel point in the coronary angiography gray level image, so that the equalization mapping degrees of different areas in the coronary angiography gray level image are different, and the vascular areas in the image play a decisive role in analyzing the coronary artery state, so that in order to determine the mapping range of the whole coronary angiography gray level image, the vascular areas in the image need to be determined, and the mapping range of the coronary angiography gray level image is determined according to the optimal mapping values of the pixel points of the vascular areas. The method comprises the steps of obtaining a gradient value of a pixel point according to gray difference characteristics of the pixel point in the coronary angiography gray image and other pixel points in a preset neighborhood range, wherein preferably, the step of obtaining the gradient value of the pixel point comprises the steps of calculating the absolute value of the difference value of the gray value of the pixel point and the gray value of other pixel points in the preset neighborhood range to obtain the gray difference value of the pixel point, taking the maximum value of the gray difference value as the gradient value of the pixel point, and the preset neighborhood range is eight neighborhood of the pixel point in the embodiment of the invention. When the gray level difference value is larger, the more likely the boundary between the blood vessel and other tissue areas is, so the maximum value of the gray level difference value is taken as the gradient value of the pixel point, and the larger the gradient value is, the more obvious the gray level change at the pixel point is, and the more likely the boundary area of the blood vessel is.
Further, when the gradient values of the pixel point and other surrounding pixel points change more obviously, the pixel point is more likely to be a blood vessel edge region, so that a first gradient characteristic value of the pixel point is obtained according to the change characteristics of the gradient values in a preset window range of the pixel point, preferably, in the embodiment of the invention, the step of obtaining the first gradient characteristic value comprises the steps of constructing a change curve according to the gradient values of all the pixel points in any preset window range of the pixel point, in the embodiment of the invention, one preset window range is 7 pixel points in the horizontal direction with the pixel point as the center, the other preset window range is 7 pixel points in the vertical direction with the pixel point as the center, and if the condition that the pixel point is the center is not met, constructing the preset window range with the position of the pixel point closest to the window center, and the implementer can determine according to implementation scenes. And calculating the change rate of the gradient values of the pixel point and the adjacent pixel points within the range of any preset window according to the change curve to obtain gradient change characteristic values of the pixel point and the adjacent pixel points, wherein the adjacent pixel points are left and right pixel points or upper and lower pixel points of the pixel point in the embodiment of the invention. And calculating the ratio of the gradient change characteristic values of the pixel point to the previous adjacent pixel point and the gradient change characteristic values of the pixel point to the next adjacent pixel point to obtain a first gradient characteristic value of the pixel point, wherein the previous adjacent pixel point and the next adjacent pixel point are the pixel points which are arranged in front of and behind the pixel point in the change curve respectively. If the pixel point is a pixel point in the blood vessel edge area, the larger the difference between the gradient values of the pixel point and the adjacent pixel point is, the smaller the gradient change characteristic value is, the gradient change characteristic value of the pixel point is not close to 0, the gradient change characteristic value of the pixel point and the previous adjacent pixel point is in an ascending characteristic, the gradient characteristic change value of the pixel point and the next adjacent pixel point is in a descending characteristic, and the first gradient characteristic value is close to-1.
When the pixel point is more likely to be at the edge of the blood vessel, the gradient value of the pixel point is larger, and when the pixel point is less likely to be at the edge of the blood vessel, the gradient value of the pixel point is smaller, so that a second gradient characteristic value of the pixel point can be obtained according to the distribution characteristic of the gradient value in the preset window range of the pixel point; preferably, in the embodiment of the present invention, the step of obtaining the second gradient feature value includes calculating a sum value of gradient values of all pixel points within any preset window range of the pixel point to obtain a gradient sum value, calculating a ratio of the gradient value of the pixel point to the gradient sum value to obtain a gradient occupancy feature value, and when the pixel point is more likely to be located at the edge of a blood vessel, the gradient occupancy feature value of the pixel point is larger. And taking the maximum value of the gradient duty ratio characteristic values corresponding to different preset window ranges as a second gradient characteristic value of the pixel point, wherein when the second gradient characteristic value is larger, the pixel point is more likely to be positioned at the boundary of the blood vessel and other tissue areas.
Preferably, in the embodiment of the invention, the step of obtaining the gradient coefficient comprises the steps of calculating the sum value of the first gradient characteristic values corresponding to all preset window ranges of the pixel point to obtain a comprehensive first gradient characteristic value of the pixel point, calculating the absolute value of the sum value of the comprehensive first gradient characteristic value and the number of the preset window ranges to obtain a first mapping value of the pixel point, wherein in the embodiment of the invention, the number of the preset window ranges is two, when the comprehensive first gradient characteristic value is closer to-2, the pixel point is more likely to be a vascular edge pixel point, and when the first mapping value is closer to 0, the pixel point is more likely to be a vascular edge pixel point. And when the gradient coefficient of the pixel point is larger, which means that the pixel point is more likely to be positioned at the boundary of a blood vessel and other tissue areas, the image contrast can be increased and the image details can be reserved when the optimal mapping value of the pixel point is used as the mapping value of the whole coronary angiography gray image, so that the accuracy of coronary analysis is improved. The formula for obtaining the gradient coefficient comprises:
wherein R represents the gradient coefficient of the pixel point, A represents the number of preset window ranges,A first gradient characteristic value representing an a-th preset window range,Representing the integrated first gradient feature value,Representing a first mapped value, W representing a second gradient eigenvalue,Representing the normalization function.
Further, since the color of the blood vessel region in the coronary angiography gray image is darker, the smaller the gray value of the pixel point is, the more likely the pixel point is to be the blood vessel region, and the brightness coefficient can be obtained according to the gray characteristic of the pixel point.
Step S4, obtaining a blood vessel-like coefficient according to the gradient coefficient and the brightness coefficient of the pixel point, obtaining a global mapping value according to the specific gravity characteristic of the blood vessel-like coefficient corresponding to the pixel point with the same optimal mapping value, and enhancing the coronary angiography gray level image through a histogram equalization algorithm according to the global mapping value to obtain a coronary angiography enhanced image.
After the gradient coefficient and the brightness coefficient which can represent whether the pixel point is in the blood vessel region are obtained, whether the pixel point is in the blood vessel region can be analyzed by combining the gradient coefficient and the brightness coefficient, so that the blood vessel-like coefficient is obtained according to the gradient coefficient and the brightness coefficient of the pixel point; preferably, in the embodiment of the present invention, the step of obtaining the vessel-like coefficient includes calculating a product of a preset first weight and a gradient coefficient to obtain the first coefficient, calculating a product of a preset second weight and a luminance coefficient to obtain the second coefficient, and setting a sum of the preset first weight and the preset second weight to be a constant 1. And calculating the sum value of the first coefficient and the second coefficient to obtain the vascular-like coefficient of the pixel point. In the embodiment of the invention, the preset first weight is 0.7, the preset second weight is 0.3, and the implementation can be determined by the implementation scene. When the blood vessel-like coefficient of the pixel point is larger, which means that the pixel point is more likely to be in a blood vessel region, the optimal mapping value corresponding to the pixel point is more suitable to be used as the mapping value when the whole coronary angiography gray level image is balanced, so that the global mapping value is obtained according to the specific gravity characteristics of the blood vessel-like coefficient corresponding to the pixel point with the same optimal mapping value.
Preferably, in the embodiment of the invention, the step of obtaining the global mapping value comprises the steps of calculating the sum value of the blood vessel-like coefficients corresponding to the pixel points with the same optimal mapping value to obtain the blood vessel-like total coefficient, and taking the optimal mapping value corresponding to the maximum value of the blood vessel-like total coefficient as the global mapping value. When the total coefficient of the blood vessel is larger, which means that the number of the pixel points corresponding to the optimal mapping value is larger in the blood vessel region, when global histogram equalization is carried out, the mapping degree of the blood vessel region is required to be used for carrying out integral mapping, so that the contrast ratio of the blood vessel region and other tissue regions is ensured to be more obvious, and certain image details are reserved. Further, the coronary angiography gray level image can be enhanced according to the global mapping value by a histogram equalization algorithm to obtain a coronary angiography enhanced image, that is, the global mapping value and the gray level cumulative distribution frequency of the pixel points in the coronary angiography gray level image are equalized, and it is noted that the histogram equalization belongs to the prior art, and specific steps are not repeated. The coronary angiography enhanced image assists a doctor in analyzing the coronary artery state, the contrast of the finally obtained coronary angiography enhanced image is more obvious compared with that of the original image, and the contrast of a blood vessel area and other tissue areas can be reserved, so that the accuracy of the coronary angiography enhanced image assisting the doctor in analyzing the coronary artery is improved.
In summary, the embodiment of the invention provides a coronary angiography lesion detection method based on image processing, which comprises the steps of mapping pixel points in a coronary angiography gray level image and preset neighborhood pixel points through a histogram equalization algorithm, obtaining an optimal mapping value of the pixel points according to structural difference characteristics before and after mapping and contrast characteristics after mapping, obtaining gradient coefficients of the pixel points according to change characteristics and distribution characteristics of gradient values in a preset window range of the pixel points, obtaining brightness coefficients according to gray level characteristics of the pixel points, and obtaining blood vessel-like coefficients according to the gradient coefficients and the brightness coefficients of the pixel points. The method obtains the global mapping value according to the blood vessel-like coefficients corresponding to the pixel points with the same optimal mapping value, enhances the coronary angiography gray image according to the global mapping value through a histogram equalization algorithm, and can keep details while increasing the contrast of a blood vessel area and other tissue areas.
The invention also provides a coronary angiography lesion detection system based on image processing, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the computer program to realize any one of the steps of the coronary angiography lesion detection method based on image processing.
It should be noted that the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments.