A method for detecting intestinal lesion areas in children based on machine vision
Through threshold segmentation, cluster partitioning and adaptive histogram equalization processing, the problem of difficulty in highlighting the ulcer area in the endoscopic images of children with Crohn's disease is solved, and more accurate image enhancement and diagnostic assistance are achieved.
Patent Information
- Application Number
- CN202411747781.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2044-12-02
AI Technical Summary
The existing histogram equalization method is difficult to accurately highlight the ulcer area in the endoscopic images of children with Crohn's disease, and may highlight the reflective area, affecting the accuracy of diagnosis.
Reference points are obtained through threshold segmentation, cluster partitioning, edge points and target points are obtained, abnormal points are determined based on grayscale differences characteristics, and adaptive histogram equalization is performed to adjust the grayscale value to highlight the ulcer area.
It improves the accuracy of image enhancement, reduces the impact of reflective areas, enhances the contrast of ulcer areas, and improves the reliability of doctors' diagnosis.
Smart Images

Figure CN119600007B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image enhancement technology, and in particular to a method for detecting children's intestinal lesion areas based on machine vision. Background Art
[0002] The incidence of intestinal diseases has remained high in recent years, and the number of children suffering from intestinal diseases has been steadily increasing. To diagnose gastrointestinal diseases, white light endoscopy is required to examine the intestinal tract. Under ideal conditions, endoscopy-derived gastrointestinal images can provide doctors with auxiliary information for lesion diagnosis. However, in practice, endoscopy suffers from a series of serious imaging issues, such as insufficient lighting and blurred displays, which hinder lesion identification. Therefore, image enhancement is required to improve the contrast of endoscopic images and highlight lesion characteristics.
[0003] Histogram equalization is commonly used to enhance endoscopic images. However, endoscopic images of Crohn's disease, a common ailment in children, often show ulcers. In the early stages of an ulcer, the ulcer darkens and is difficult to detect in low light. Later, the ulcer develops into a white pustule, which can be mistaken for a white pustule due to excessive light. Therefore, directly using histogram equalization may not only fail to highlight the diseased area, but may even highlight some reflective areas and other normal areas, affecting the accuracy of the endoscopic image and the reliability of the diagnostic aid. Summary of the Invention
[0004] In order to solve the technical problem that the endoscopic image enhancement directly through histogram equalization may not accurately highlight the lesion area, the present invention aims to provide a method for detecting pediatric intestinal lesion areas based on machine vision. The technical solution adopted is as follows:
[0005] Acquire a grayscale image of the intestine through an endoscope; perform threshold segmentation on the grayscale image to obtain reference points; perform density clustering on the reference points to obtain different clusters; obtain partition side lengths based on shape features of the clusters; partition the grayscale image based on the partition side lengths to obtain different block areas;
[0006] Obtain edge points and the area to be optimized based on the gradient distribution characteristics of the pixel points in the block area; obtain target points based on the grayscale difference characteristics between the pixel points in the area to be optimized and the edge points, and the grayscale difference characteristics between other pixel points in the neighborhood of the pixel points and the edge points;
[0007] Obtain an outlier point based on the grayscale difference characteristics between the target point and other target points in the neighborhood and the grayscale difference characteristics of the edge point neighborhood closest to the target point; obtain a grayscale adjustment range value based on the grayscale difference characteristics between the outlier point in the area to be optimized and the nearest edge point neighborhood; obtain a final grayscale value of the outlier point based on the grayscale adjustment range value and the grayscale discrete characteristics of the edge point neighborhood in the area to be optimized;
[0008] The block area is subjected to histogram equalization processing according to the grayscale value of the pixel point and the final grayscale value of the abnormal point to obtain a local enhanced grayscale image; all the local enhanced grayscale images are spliced to obtain an intestinal detection enhanced image.
[0009] Furthermore, the step of performing threshold segmentation on the grayscale image to obtain reference points includes:
[0010] Threshold segmentation is performed on the grayscale image according to a preset grayscale threshold, and pixel points in an area exceeding the preset grayscale threshold are used as the reference points.
[0011] Furthermore, the step of obtaining the partition side length according to the shape characteristics of the cluster includes:
[0012] Calculate the ratio of the width to the length of the minimum circumscribed rectangle of the cluster to obtain the shape feature value of the cluster; use the cluster whose shape feature value exceeds the preset shape threshold as the preliminary cluster; use the maximum value of the Euclidean distance between any reference point and the cluster center in any preliminary cluster as the partition reference; calculate the product of the partition reference and a preset multiple to obtain the partition side length; the preset multiple exceeds the constant 2.
[0013] Furthermore, the step of obtaining edge points and areas to be optimized based on the gradient distribution characteristics of the pixels in the block area includes:
[0014] Calculating the average of the gradient values of the first quartile and the second quartile in the block area according to the quartile method to obtain a gradient reference value; calculating the absolute value of the difference between the gradient value of any pixel point in the block area and the gradient reference value and normalizing the difference to obtain a gradient difference characteristic value of the any pixel point; and determining the pixel point whose gradient difference characteristic value exceeds a preset gradient threshold as the edge point;
[0015] The average value of the gradient difference eigenvalues of all pixels in the block area and the sum of the maximum value of the gradient difference eigenvalues are calculated to obtain a probability eigenvalue; and the block area whose probability eigenvalue exceeds a preset probability threshold is used as the area to be optimized.
[0016] Furthermore, the step of obtaining the target point according to the grayscale difference characteristics between the pixel point and the edge point in the area to be optimized and the grayscale difference characteristics between other pixel points in the neighborhood of the pixel point and the edge point includes:
[0017] Calculate the absolute value of the grayscale difference between the pixel point and the nearest edge point in the area to be optimized and perform negative correlation mapping to obtain a grayscale similarity coefficient; calculate the average value of the absolute value of the grayscale difference between other pixel points that are not edge points in the preset neighborhood range of the pixel point and the nearest edge point and normalize them to obtain a neighborhood grayscale similarity coefficient; calculate the absolute value of the difference between the neighborhood grayscale similarity coefficient and the grayscale similarity coefficient to obtain a neighborhood difference eigenvalue; calculate the product of a preset first weight and the grayscale similarity coefficient to obtain a first factor; calculate the product of a preset second weight and the neighborhood difference eigenvalue to obtain a second factor; the preset first weight is greater than the preset second weight; calculate the sum of the first factor and the second factor to obtain a target index of the pixel point; and take the pixel point whose target index exceeds a preset target threshold as the target point.
[0018] Furthermore, the step of obtaining an outlier point based on the grayscale difference characteristics between the target point and other target points in the neighborhood and the grayscale difference characteristics of the neighborhood of the edge point closest to the target point includes:
[0019] Calculate the grayscale average of all target points and all edge points within a preset neighborhood range of the edge point closest to the target point to obtain a first average grayscale value; calculate the grayscale average of all non-target points and non-edge points within a preset neighborhood range of the edge point closest to the target point to obtain a second average grayscale value; calculate the reciprocal of the absolute value of the difference between the first average grayscale value and the second average grayscale value to obtain a first grayscale difference factor; calculate the variance of the grayscale values within the preset neighborhood range of the target point and normalize it to obtain a second grayscale difference factor; calculate the average of the first grayscale difference factor and the second grayscale difference factor to obtain a mutation probability value of the target point; and take the target point whose mutation probability value exceeds a preset mutation threshold as the abnormal point.
[0020] Furthermore, the step of obtaining a grayscale adjustment range value according to grayscale difference characteristics between the abnormal point in the area to be optimized and the nearest neighborhood of the edge point includes:
[0021] The minimum grayscale value of the outlier in the area to be optimized is used as the lower limit value; the maximum grayscale value of the outlier in the area to be optimized is used as the upper limit value; if the upper limit value is less than the minimum grayscale value of the non-target point within the preset neighborhood range of the nearest edge point, the difference between the minimum grayscale value and the upper limit value is calculated to obtain a first adjustment reference; the difference between the lower limit value and the first adjustment reference is calculated to obtain a minimum adjustment range; the difference between the minimum adjustment range and the grayscale value of any outlier in the area to be optimized is calculated to obtain a grayscale adjustment range value of any outlier;
[0022] If the lower limit value is greater than the maximum grayscale value of the non-target point within the preset neighborhood range of the nearest edge point, calculate the difference between the lower limit value and the maximum grayscale value to obtain the second adjustment reference; calculate the difference between the upper limit value and the second adjustment reference to obtain the maximum adjustment range; calculate the difference between the maximum adjustment range and the grayscale value of any outlier in the area to be optimized to obtain the grayscale adjustment range value of the any outlier.
[0023] Furthermore, the step of obtaining the final grayscale value of the outlier point according to the grayscale adjustment range value and the grayscale discrete characteristics of the edge point neighborhood of the area to be optimized includes:
[0024] Calculate the average grayscale value of non-outlier points within the preset neighborhood range of the edge point to obtain the neighborhood grayscale average value; calculate the average absolute value of the difference between the grayscale value of non-outlier points within the preset neighborhood range of the edge point and the neighborhood grayscale average value to obtain the grayscale discrete eigenvalue of the edge point; calculate the average grayscale discrete eigenvalue of all edge points in the area to be optimized and normalize them to obtain the average grayscale discrete eigenvalue; calculate the product of the grayscale adjustment range value and the average grayscale discrete eigenvalue to obtain the grayscale adjustment factor; calculate the sum of the grayscale value of the outlier point and the grayscale adjustment factor and round them to obtain the final grayscale value of the outlier point.
[0025] The present invention has the following beneficial effects:
[0026] In the present invention, obtaining reference points can identify some obvious ulcer areas, providing a basis for image partitioning. Obtaining clusters can determine the actual ulcer area based on the shape characteristics of the ulcer area, so that the partition side length can be selected slightly larger than the ulcer area, thereby ensuring that each block area contains a type of ulcer area as much as possible, initially improving the accuracy of image enhancement. Obtaining edge points and areas to be optimized can distinguish ulcer areas from normal intestine based on the difference characteristics, further determining the block areas requiring adaptive histogram equalization. Obtaining target points can select specific pixels that need adjustment based on the grayscale difference characteristics of pixels in normal intestine and ulcer areas, further improving the accuracy of image enhancement. Obtaining outliers can further distinguish target points based on the characteristic differences between ulcer areas and reflective areas in the image, and further determine the pixels in the ulcer area that need adjustment. Obtaining the grayscale adjustment range value can further limit the grayscale adjustment degree of pixels based on the degree of lesion in the ulcer area, improving the accuracy of the final histogram equalization. Obtaining the final grayscale value can be corrected based on the grayscale characteristics of the outlier's neighborhood to avoid over-enhancement. Finally, different levels of image enhancement are applied to different block areas, improving the accuracy of image enhancement. Obtaining enhanced intestinal detection images can reduce reflective areas while increasing the contrast of ulcer areas, making histogram equalization more accurate and improving the reliability of auxiliary doctor diagnosis. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. 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 any creative work.
[0028] Figure 1 A flow chart of a method for detecting intestinal lesions in children based on machine vision according to one embodiment of the present invention;
[0029] Figure 2 This is an example diagram of an enhanced image for intestinal detection provided by one embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to further illustrate the technical means and effects adopted by the present invention to achieve the predetermined purpose of the invention, the following, in conjunction with the accompanying drawings and preferred embodiments, describes in detail the specific implementation, structure, features and effects of a method for detecting intestinal lesions in children based on machine vision proposed by the present invention. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics of one or more embodiments may be combined in any suitable form.
[0031] 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.
[0032] The following describes in detail a specific scheme of a method for detecting intestinal lesion areas in children based on machine vision provided by the present invention in conjunction with the accompanying drawings.
[0033] See also Figure 1 , which shows a flow chart of a method for detecting intestinal lesions in children based on machine vision according to an embodiment of the present invention. The method comprises the following steps:
[0034] Step S1, obtain a grayscale image of the intestine in the endoscope; perform threshold segmentation on the grayscale image to obtain reference points; perform density clustering on the reference points to obtain different clusters; obtain partition side lengths based on the shape characteristics of the clusters; and partition the grayscale image based on the partition side lengths to obtain different block areas.
[0035] In an embodiment of the present invention, the implementation scenario is to perform image enhancement on the endoscopic image of the intestine through the histogram equalization method to improve the accuracy of image enhancement and the reliability of assisting doctors in diagnosis. First, a grayscale image of the intestine in the endoscope is obtained. In order to highlight the ulcer lesion area in the image, it is necessary to determine the location of the ulcer area, thereby improving the accuracy of the histogram equalization. Usually, obvious ulcer areas will appear circular or elliptical, and the shape is relatively regular. Therefore, the pixels representing the ulcer will appear in a clustered state within a certain range, and then the ulcer can be partitioned according to the size of the ulcer, and the image enhancement can be adaptively performed on different areas in the grayscale image to improve the accuracy of image enhancement.
[0036] Furthermore, since obvious ulcer areas will appear as white pustules, which appear as obvious circular shapes in grayscale images, the grayscale image can be threshold segmented to obtain reference points, specifically including: threshold segmenting the grayscale image according to a preset grayscale threshold, and using the pixel points in the area exceeding the preset grayscale threshold as reference points; in the embodiment of the present invention, the preset grayscale threshold is 120, which can be determined by the implementer according to the implementation scenario. The areas with higher grayscale values in the grayscale image may be reflective areas and ulcer areas caused by endoscopic illumination, so the reference points obtained are the pixel points of the ulcer area and the pixel points of the reflective area; then, it is necessary to distinguish the reference points and determine the reference points that represent the ulcer area. Since the shape of the ulcer area is circular and relatively regular, the reference points can be clustered, and the obvious ulcer area is determined according to the cluster shape. Therefore, the reference points are density clustered to obtain different cluster clusters. In the embodiment of the present invention, the existing DBSCAN density clustering algorithm is used for clustering, and the specific steps are not repeated here. Some of the clusters are different ulcer areas in the intestine. The shapes of these clusters are close to circles, so the partition side lengths can be obtained based on the shape characteristics of the clusters.
[0037] Preferably, in an embodiment of the present invention, the step of obtaining the partition side length includes: calculating the ratio of the width to the length of the minimum circumscribed rectangle of the cluster to obtain the shape feature value of the cluster; when the width and length are closer, the shape feature value is closer to the constant 1, which means that the minimum circumscribed rectangle is closer to a square, the cluster is more likely to be circular, and the more likely it is to be an obvious ulcer area. The cluster whose shape feature value exceeds the preset shape threshold is used as the preliminary cluster; in an embodiment of the present invention, the preset shape threshold is 0.8, which can be determined by the implementer according to the implementation scenario. The preliminary cluster represents the cluster of obvious ulcer areas. The maximum value of the Euclidean distance between any reference point in any preliminary cluster and the cluster center is used as the partition benchmark; the partition benchmark is close to the radius of the ulcer area. The partition base is multiplied by a preset multiple to obtain the partition side length. The preset multiple exceeds the constant 2, and in this embodiment of the present invention, the preset multiple is 2.5. This ensures that the partition side length is slightly larger than the length of the largest ulcer area, ensuring that each partition contains only one ulcer area, and that ulcer areas of varying severity are distinguished as much as possible, so that image enhancement better reflects the characteristics of the ulcer area within the partition. The grayscale image is then partitioned according to the partition side length to obtain different block regions. A grid with a length equal to the partition side length is constructed, with each grid representing a block region.
[0038] Step S2, obtaining edge points and the area to be optimized based on the gradient distribution characteristics of the pixel points in the block area; obtaining the target point based on the grayscale difference characteristics between the pixel points and the edge points in the area to be optimized, and the grayscale difference characteristics between other pixel points in the pixel neighborhood and the edge points.
[0039] After obtaining different block areas, it is necessary to obtain pixel points representing ulcer areas of different degrees in each block area; when an ulcer area appears in the block area, it will be different from the normal gastrointestinal area, and the grayscale value will change to a certain extent, which easily produces edge pixels; therefore, if there are edge points in the block area, it means that there are ulcer areas or reflective areas in the area, so the edge points and areas to be optimized are obtained based on the gradient distribution characteristics of the pixel points in the block area.
[0040] Preferably, in an embodiment of the present invention, the step of obtaining edge points and areas to be optimized includes: calculating the average of the gradient values of the first quartile and the second quartile in the block area according to the quartile method to obtain a gradient reference value; since the gradient value of the edge point is often greater than the gradient value of the remaining pixel points, and the number of edge points is less than half of the pixel points in the block area, the edge point can be judged by the quartile method, and the gradient reference value represents the lower-middle level of the gradient value in the block area. Calculate the absolute value of the difference between the gradient value of any pixel point in the block area and the gradient reference value and normalize them to obtain the gradient difference characteristic value of the arbitrary pixel point; the larger the gradient difference characteristic value, the more likely the arbitrary pixel point is an edge point. Pixel points whose gradient difference characteristic value exceeds the preset gradient threshold are regarded as edge points; in an embodiment of the present invention, the preset gradient threshold is 0.7, which can be determined by the implementer according to the implementation scenario. Calculate the sum of the average value of the gradient difference eigenvalues of all pixels in the block area and the maximum value of the gradient difference eigenvalue to obtain the probability eigenvalue; when the average value of the gradient difference eigenvalue is larger, it means that there are more pixels with larger gradient values in the block area; when the maximum value of the gradient difference eigenvalue is larger, it means that there are more obvious edge points in the block area; therefore, the larger the probability eigenvalue, the more likely it is that there are edge points in the block area. The block area whose probability eigenvalue exceeds the preset probability threshold is regarded as the area to be optimized; in the embodiment of the present invention, the preset probability threshold is 1.3, which can be determined by the implementer according to the implementation scenario. If the block area is not an area to be optimized, it means that the block area is a normal gastrointestinal image area and there is no need to perform adaptive image enhancement on the area.
[0041] After obtaining the different regions to be optimized, we need to identify the pixels that may be ulcer areas. The grayscale differences between edge points caused by ulcers and reflective areas and pixels in the normal stomach and intestines are significant, while the grayscales of pixels in the normal area are similar. Therefore, we can determine the target point based on the grayscale difference characteristics between the pixels in the region to be optimized and the edge points, as well as the grayscale difference characteristics between other pixels in the pixel's neighborhood and the edge points.
[0042] Preferably, in an embodiment of the present invention, the step of obtaining the target point includes: calculating the absolute value of the grayscale difference between the pixel point in the area to be optimized and the nearest edge point and negatively mapping them to obtain a grayscale similarity coefficient; the greater the grayscale difference between the pixel point and the nearest edge point, the more likely the pixel point is to be a normal gastrointestinal pixel point, and the smaller the grayscale similarity coefficient. Calculate the average of the absolute value of the grayscale difference between other non-edge points and the nearest edge point within the preset neighborhood range of the pixel point and normalize them to obtain a neighborhood grayscale similarity coefficient; the neighborhood grayscale similarity coefficient characterizes the grayscale difference characteristics between the neighboring pixels of the pixel point and the nearest edge point. In an embodiment of the present invention, the preset neighborhood range is the eight neighborhoods of the pixel point. Calculate the absolute value of the difference between the neighborhood grayscale similarity coefficient and the grayscale similarity coefficient to obtain a neighborhood difference feature value; the smaller the neighborhood difference feature value, the more similar the grayscale characteristics of the pixel point and the neighboring pixels are. Calculate the product of the preset first weight and the grayscale similarity coefficient to obtain the first factor; calculate the product of the preset second weight and the neighborhood difference characteristic value to obtain the second factor; the preset first weight is greater than the preset second weight; in the embodiment of the present invention, the preset first weight is 0.7, and the preset second weight is 0.3. Calculate the sum of the first factor and the second factor to obtain the target index of the pixel point; when the first factor and the second factor are smaller, it means that the grayscale difference between the pixel point and the edge point is greater, and the more similar the grayscale characteristics of the pixel point and the neighborhood pixel point are, the more likely the pixel point is a normal gastrointestinal pixel point. The pixel point whose target index exceeds the preset target threshold is taken as the target point; in the embodiment of the present invention, the preset target threshold is 0.6, and the implementer can determine it by himself according to the implementation scenario. The target point represents the pixel point of the abnormal gastrointestinal tract, which may be the pixel point of the ulcer area or the pixel point of the reflective area. The formula for obtaining the target index includes:
[0043]
[0044] Where W represents the target index of the pixel point, Indicates the preset first weight, Indicates the preset second weight, represents an exponential function with a natural constant as the base, R represents the grayscale value of the pixel, and T represents the grayscale value of the nearest edge point to the pixel. represents the grayscale similarity coefficient, H represents the neighborhood grayscale similarity coefficient, represents the neighborhood difference eigenvalue, represents the first factor, represents the second factor.
[0045] Step S3, obtaining an outlier point based on the grayscale difference characteristics between the target point and other target points in the neighborhood and the grayscale difference characteristics of the edge point neighborhood closest to the target point; obtaining a grayscale adjustment range value based on the grayscale difference characteristics between the outlier point in the area to be optimized and the nearest edge point neighborhood; and obtaining a final grayscale value of the outlier point based on the grayscale adjustment range value and the grayscale discrete characteristics of the edge point neighborhood in the area to be optimized.
[0046] Since target points may be pixels in both ulcer and reflective areas, further identification of target points is required to accurately increase the contrast of the ulcer area, distinguishing between those in the ulcer area and those in the reflective area. The reflective area is illuminated by the endoscope, so the brightness within this illuminated area is relatively uniform. The grayscale value of the illuminated area is large, significantly different from the grayscale values of the surrounding normal intestinal pixels. However, the grayscale value of the ulcer area exhibits some variation, and the grayscale difference from the surrounding normal intestinal pixels is small. Therefore, outliers can be identified based on the grayscale difference characteristics between the target point and other neighboring target points, as well as the grayscale difference characteristics of the neighboring edge points closest to the target point.
[0047] Preferably, in an embodiment of the present invention, the step of obtaining an abnormal point includes: calculating the grayscale average of all target points and all edge points within a preset neighborhood of the edge point closest to the target point to obtain a first average grayscale value. Since the target point may be located at the center of an ulcer area or a reflective area, and the other pixels in its neighborhood are all target points of the same type, it is necessary to rely on the nearest edge point of the same type as the target point. The neighborhood of the edge point contains both target points of the same type and pixels of normal gastrointestinal tract. Calculating the grayscale average of all non-target points and non-edge points within a preset neighborhood of the edge point closest to the target point to obtain a second average grayscale value; calculating the inverse of the absolute value of the difference between the first average grayscale value and the second average grayscale value to obtain a first grayscale difference factor; the greater the difference between the first average grayscale value and the second average grayscale value, the smaller the first grayscale difference factor, which means that the target point is more likely to be in the reflective area; conversely, the larger the first grayscale difference factor, the more likely the target point is to be in the ulcer area. Calculate the variance of the grayscale values within the preset neighborhood of the target point and normalize it to obtain the second grayscale difference factor; when the second grayscale difference factor is larger, it means that the difference in grayscale value between the target point and the pixel points within the preset neighborhood is larger, and the more likely it is an ulcer area. Calculate the average value of the first grayscale difference factor and the second grayscale difference factor to obtain the variation probability value of the target point; when the variation probability value is larger, it means that the target point is more likely to be in the ulcer area of the lesion. The target point whose variation probability value exceeds the preset variation threshold is regarded as an outlier. In an embodiment of the present invention, the preset variation threshold is 0.6, which can be determined by the implementer according to the implementation scenario. The outlier represents the pixel point where the ulcer area is located in the area to be optimized. The grayscale value of the outlier needs to be adjusted later to increase the contrast after image enhancement. The formula for obtaining the variation probability value includes:
[0048]
[0049] Where Q represents the mutation probability value of the target point, B represents the number of target points and edge points in the preset neighborhood range of the edge point closest to the target point, represents the grayscale value of the bth target point or edge point, D represents the number of non-target points and non-edge points within the preset neighborhood of the edge point closest to the target point, Represents the gray value of the dth non-target point or non-edge point, represents the first average gray value, represents the second average gray value, represents the first grayscale difference factor, E represents the variance of the grayscale value within the preset neighborhood range of the target point, represents the normalization function, Represents the second grayscale difference factor.
[0050] Furthermore, after obtaining the outliers representing the ulcer area in the region to be optimized, the grayscale values of the outliers can be adjusted so that the contrast of the ulcer area is increased through the histogram equalization method. Because different ulcer areas in the intestine are at different levels of lesions, there are differences in the grayscale values in the image. The grayscale values of some early ulcers are lower than those of normal intestinal pixels, while the grayscale values of some late ulcers are higher than those of normal intestinal pixels. In order to increase the image contrast, it is necessary to make the grayscale values of outliers with lower grayscale values lower, and the grayscale values of outliers with higher grayscale values higher. Therefore, the grayscale adjustment range value is obtained based on the grayscale difference characteristics between the outliers in the region to be optimized and the nearest edge point neighborhood.
[0051] Preferably, in an embodiment of the present invention, the step of obtaining a grayscale adjustment range includes: using the minimum grayscale value of the outliers in the region to be optimized as a lower limit; using the maximum grayscale value of the outliers in the region to be optimized as an upper limit; if the upper limit is less than the minimum grayscale value of non-target points within a preset neighborhood of the nearest edge point, it means that the ulcer in the region to be optimized is in its early stages and has a low grayscale value, and the grayscale value needs to be further adjusted downward to highlight the ulcer; calculating the difference between the minimum grayscale value and the upper limit to obtain a first adjustment reference; the first adjustment reference is the difference between the maximum grayscale value of the outliers in the region to be optimized and the minimum grayscale value of the normal intestinal pixels, representing the grayscale difference between the ulcer and intestinal regions in a normal image. Calculating the difference between the lower limit and the first adjustment reference to obtain a minimum adjustment range; the minimum adjustment range represents the extent to which the outliers in the region to be optimized can be adjusted downward. Calculating the difference between the minimum adjustment range and the grayscale value of any outlier in the region to be optimized to obtain a grayscale adjustment range for that outlier; this grayscale adjustment range is a negative value.
[0052] Furthermore, if the lower limit is greater than the maximum grayscale value of a non-target point within a preset neighborhood of the nearest edge point, it means that the ulcer region in the region to be optimized is in the later stage and has a higher grayscale value. The difference between the lower limit and the maximum grayscale value is calculated to obtain a second adjustment benchmark. The second adjustment benchmark characterizes the grayscale difference between the ulcer region and the normal intestinal region in the region to be optimized. The difference between the upper limit and the second adjustment benchmark is calculated to obtain a maximum adjustment range. The maximum adjustment range is the degree to which an abnormal point in the region to be optimized can be adjusted upward. The difference between the maximum adjustment range and the grayscale value of any abnormal point in the region to be optimized is calculated to obtain a grayscale adjustment range value for the arbitrary abnormal point. This grayscale adjustment range value is a positive value.
[0053] After obtaining the grayscale adjustment range value of the outlier in the area to be optimized, in order to highlight the ulcer area while avoiding over-enhancement, the grayscale features in the area to be optimized need to be analyzed; therefore, the final grayscale value of the outlier is obtained based on the grayscale adjustment range value and the grayscale discrete features of the edge point neighborhood of the area to be optimized.
[0054] Preferably, in an embodiment of the present invention, the step of obtaining the final grayscale value includes: calculating the average grayscale value of non-outliers within a preset neighborhood range of the edge point to obtain the neighborhood grayscale average; calculating the average absolute value of the difference between the grayscale value of non-outliers within the preset neighborhood range of the edge point and the neighborhood grayscale average to obtain the grayscale discrete eigenvalue of the edge point; the grayscale discrete eigenvalue characterizes the grayscale distribution within the neighborhood of the edge point. If the grayscale discrete eigenvalue is larger, it means that the grayscale distribution is more uneven. Calculate the average grayscale discrete eigenvalue of all edge points in the area to be optimized and normalize them to obtain the average grayscale discrete eigenvalue; when the average grayscale discrete eigenvalue is larger, it means that the grayscale distribution of pixels in the area to be optimized is more uneven, and the grayscale value of the outliers needs to be adjusted to a higher degree; when the average grayscale discrete eigenvalue is smaller, it means that the grayscale distribution of pixels in the area to be optimized is more uniform, and it is less necessary to adjust the grayscale of the outliers to a large extent to obtain a significant contrast. The grayscale adjustment factor is calculated by multiplying the grayscale adjustment range by the average grayscale discrete eigenvalue. A larger absolute value of the grayscale adjustment factor indicates a greater grayscale adjustment. The grayscale value of the outlier point is calculated and rounded to the integer value to obtain the final grayscale value of the outlier point. The final grayscale value is adjusted based on the severity of the ulcer region where the outlier point is located, allowing subsequent image enhancement to highlight the characteristics of the ulcer region, thereby improving the reliability of endoscopic images in assisting doctors in diagnosis.
[0055] Step S4: Perform histogram equalization on the divided areas according to the grayscale values of the pixels and the final grayscale values of the outliers to obtain a local enhanced grayscale image; and splice all the local enhanced grayscale images to obtain an intestinal detection enhanced image.
[0056] After obtaining the final grayscale value of the outlier in the area to be optimized, the histogram equalization process can be performed on the block area according to the grayscale value of the pixel point and the final grayscale value of the outlier to obtain a local enhanced grayscale image. It should be noted that histogram equalization belongs to the existing technology and the specific steps will not be repeated. After obtaining the local enhanced grayscale image of each area, all the local enhanced grayscale images can be spliced to obtain the intestinal detection enhanced image; Figure 2 An example of an intestinal detection enhanced image is shown. Compared with the original grayscale image, the intestinal detection enhanced image can highlight the characteristics of the ulcer area, improve the accuracy of image enhancement and the reliability of assisting doctors in diagnosis.
[0057] In summary, the embodiments of the present invention provide a method for detecting intestinal lesion areas in children based on machine vision; threshold segmentation of grayscale images is performed to obtain reference points; the reference points are clustered and the grayscale image is partitioned according to the shape of the clusters; edge points and areas to be optimized are obtained according to the gradients of the pixel points in the block area; target points are obtained according to the grayscale difference characteristics between the pixel points and the edge points in the area to be optimized; outliers are obtained according to the grayscale difference characteristics between the target point and other target points in the neighborhood and the grayscale difference characteristics of the edge point neighborhood; grayscale adjustment range values are obtained according to the grayscale difference characteristics between the outliers in the area to be optimized and the edge point neighborhood. The present invention obtains the final grayscale value according to the grayscale adjustment range value and the grayscale discrete characteristics of the edge point neighborhood; histogram equalization is performed according to the final grayscale value to obtain an intestinal detection enhanced image, thereby improving the accuracy of image enhancement.
[0058] It should be noted that the order in which the embodiments of the present invention are described above is for illustrative purposes only and does not necessarily represent the superiority or inferiority of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0059] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments.
Claims
1. A method for detecting intestinal lesion areas in children based on machine vision, characterized in that: The method comprises the following steps: Acquire a grayscale image of the intestine through an endoscope; perform threshold segmentation on the grayscale image to obtain reference points; perform density clustering on the reference points to obtain different clusters; obtain partition side lengths based on shape features of the clusters; partition the grayscale image based on the partition side lengths to obtain different block areas; Obtain edge points and the area to be optimized based on the gradient distribution characteristics of the pixel points in the block area; obtain target points based on the grayscale difference characteristics between the pixel points in the area to be optimized and the edge points, and the grayscale difference characteristics between other pixel points in the neighborhood of the pixel points and the edge points; Obtain an outlier point based on the grayscale difference characteristics between the target point and other target points in the neighborhood and the grayscale difference characteristics of the edge point neighborhood closest to the target point; obtain a grayscale adjustment range value based on the grayscale difference characteristics between the outlier point in the area to be optimized and the nearest edge point neighborhood; obtain a final grayscale value of the outlier point based on the grayscale adjustment range value and the grayscale discrete characteristics of the edge point neighborhood in the area to be optimized; The block area is subjected to histogram equalization processing according to the grayscale value of the pixel point and the final grayscale value of the abnormal point to obtain a local enhanced grayscale image; all the local enhanced grayscale images are spliced to obtain an intestinal detection enhanced image.
2. The method for detecting intestinal lesion areas in children based on machine vision according to claim 1, characterized in that: The step of performing threshold segmentation on the grayscale image to obtain reference points comprises: Threshold segmentation is performed on the grayscale image according to a preset grayscale threshold, and pixel points in an area exceeding the preset grayscale threshold are used as the reference points.
3. The method for detecting intestinal lesion areas in children based on machine vision according to claim 1, characterized in that: The step of obtaining the partition side length according to the shape characteristics of the cluster comprises: Calculate the ratio of the width to the length of the minimum circumscribed rectangle of the cluster to obtain the shape feature value of the cluster; use the cluster whose shape feature value exceeds the preset shape threshold as the preliminary cluster; use the maximum value of the Euclidean distance between any reference point and the cluster center in any preliminary cluster as the partition reference; calculate the product of the partition reference and a preset multiple to obtain the partition side length; the preset multiple exceeds the constant 2.
4. The method for detecting intestinal lesion areas in children based on machine vision according to claim 1, characterized in that: The step of obtaining edge points and areas to be optimized based on the gradient distribution characteristics of the pixel points in the block area includes: Calculating the average of the gradient values of the first quartile and the second quartile in the block area according to the quartile method to obtain a gradient reference value; calculating the absolute value of the difference between the gradient value of any pixel point in the block area and the gradient reference value and normalizing the difference to obtain a gradient difference characteristic value of the any pixel point; and determining the pixel point whose gradient difference characteristic value exceeds a preset gradient threshold as the edge point; The average value of the gradient difference eigenvalues of all pixels in the block area and the sum of the maximum value of the gradient difference eigenvalues are calculated to obtain a probability eigenvalue; and the block area whose probability eigenvalue exceeds a preset probability threshold is used as the area to be optimized.
5. The method for detecting intestinal lesion areas in children based on machine vision according to claim 1, characterized in that: The step of obtaining the target point according to the grayscale difference characteristics between the pixel point and the edge point in the area to be optimized and the grayscale difference characteristics between other pixel points in the neighborhood of the pixel point and the edge point comprises: Calculate the absolute value of the grayscale difference between the pixel point and the nearest edge point in the area to be optimized and perform negative correlation mapping to obtain a grayscale similarity coefficient; calculate the average value of the absolute value of the grayscale difference between other pixel points that are not edge points in the preset neighborhood range of the pixel point and the nearest edge point and normalize them to obtain a neighborhood grayscale similarity coefficient; calculate the absolute value of the difference between the neighborhood grayscale similarity coefficient and the grayscale similarity coefficient to obtain a neighborhood difference eigenvalue; calculate the product of a preset first weight and the grayscale similarity coefficient to obtain a first factor; calculate the product of a preset second weight and the neighborhood difference eigenvalue to obtain a second factor; the preset first weight is greater than the preset second weight; calculate the sum of the first factor and the second factor to obtain a target index of the pixel point; and take the pixel point whose target index exceeds a preset target threshold as the target point.
6. The method for detecting intestinal lesion areas in children based on machine vision according to claim 1, characterized in that: The step of obtaining an outlier point based on the grayscale difference characteristics between the target point and other target points in the neighborhood and the grayscale difference characteristics of the neighborhood of the edge point closest to the target point comprises: Calculate the grayscale average of all target points and all edge points within a preset neighborhood range of the edge point closest to the target point to obtain a first average grayscale value; calculate the grayscale average of all non-target points and non-edge points within a preset neighborhood range of the edge point closest to the target point to obtain a second average grayscale value; calculate the reciprocal of the absolute value of the difference between the first average grayscale value and the second average grayscale value to obtain a first grayscale difference factor; calculate the variance of the grayscale values within the preset neighborhood range of the target point and normalize it to obtain a second grayscale difference factor; calculate the average of the first grayscale difference factor and the second grayscale difference factor to obtain a mutation probability value of the target point; and take the target point whose mutation probability value exceeds a preset mutation threshold as the abnormal point.
7. The method for detecting intestinal lesion areas in children based on machine vision according to claim 1, characterized in that: The step of obtaining the grayscale adjustment range value according to the grayscale difference characteristics between the abnormal point in the area to be optimized and the nearest edge point neighborhood includes: The minimum grayscale value of the outlier in the area to be optimized is used as the lower limit value; the maximum grayscale value of the outlier in the area to be optimized is used as the upper limit value; if the upper limit value is less than the minimum grayscale value of the non-target point within the preset neighborhood range of the nearest edge point, the difference between the minimum grayscale value and the upper limit value is calculated to obtain a first adjustment reference; the difference between the lower limit value and the first adjustment reference is calculated to obtain a minimum adjustment range; the difference between the minimum adjustment range and the grayscale value of any outlier in the area to be optimized is calculated to obtain a grayscale adjustment range value of any outlier; If the lower limit value is greater than the maximum grayscale value of the non-target point within the preset neighborhood range of the nearest edge point, calculate the difference between the lower limit value and the maximum grayscale value to obtain the second adjustment reference; calculate the difference between the upper limit value and the second adjustment reference to obtain the maximum adjustment range; calculate the difference between the maximum adjustment range and the grayscale value of any outlier in the area to be optimized to obtain the grayscale adjustment range value of the any outlier.
8. The method for detecting intestinal lesion areas in children based on machine vision according to claim 1, characterized in that: The step of obtaining the final grayscale value of the outlier point according to the grayscale adjustment range value and the grayscale discrete characteristics of the edge point neighborhood of the area to be optimized comprises: Calculate the average grayscale value of non-outlier points within the preset neighborhood range of the edge point to obtain the neighborhood grayscale average value; calculate the average absolute value of the difference between the grayscale value of non-outlier points within the preset neighborhood range of the edge point and the neighborhood grayscale average value to obtain the grayscale discrete eigenvalue of the edge point; calculate the average grayscale discrete eigenvalue of all edge points in the area to be optimized and normalize them to obtain the average grayscale discrete eigenvalue; calculate the product of the grayscale adjustment range value and the average grayscale discrete eigenvalue to obtain the grayscale adjustment factor; calculate the sum of the grayscale value of the outlier point and the grayscale adjustment factor and round them to obtain the final grayscale value of the outlier point.
Citation Information
Patent Citations
Radiopharmaceutical concentration measuring and calculating method and system
CN118781038A