A valve body crack detection method and system for visual image detection and a storage medium
Patent Information
- Application Number
- CN202611217056.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-12
- Publication Date
- 2026-10-30
AI Technical Summary
现阶段主流的裂纹检测方法多依赖全局阈值分割、单一边缘梯度检测或轮廓拟合方式完成缺陷识别,在实际工业检测场景中存在明显局限性;工业现场采集的阀体图像普遍存在表面纹理复杂、局部灰度差异大、成像噪声较多等问题,传统局部灰度变化分析,易出现边缘轮廓残缺、前景背景分割混淆、细小裂纹边缘漏提取等问题,导致后续缺陷定位精度下降
[0044]分析本发明提供的上述一种视觉图像检测的阀体龟裂检测方法、系统及存储介质可知,在具体应用时本发明通过样本阀体图像采集与预处理得到标准化待检测图像,消除原始图像噪声、亮度不均带来的干扰,保证后续轮廓提取与缺陷分析的输入图像质量稳定;方案通过均匀分块分割方式对图像区域进行精细化前景、背景区分,有效适配阀体表面灰度不均匀、纹理复杂的场景,精准提取阀体轮廓边界像素,避免全局阈值分割造成的轮廓缺失与边缘失真问题;
Smart Images

Figure CN123015479A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of valve body fracture, and more particularly to a method, system, and storage medium for detecting valve body cracks using visual image detection. Background Technology
[0002] In the field of precision valve body surface defect detection, crack fracture is a key defect type affecting the structural strength and reliability of valve bodies. Accurate and stable identification of crack fracture locations is of significant engineering importance for product quality inspection and yield selection. Currently, mainstream crack detection methods mostly rely on global threshold segmentation, single edge gradient detection, or contour fitting to complete defect identification, which has obvious limitations in actual industrial inspection scenarios. Valve body images acquired in industrial settings generally suffer from complex surface textures, large local grayscale differences, and significant imaging noise. Traditional local grayscale variation analysis is prone to problems such as incomplete edge contours, confusion between foreground and background segmentation, and failure to extract small crack edges, leading to a decrease in subsequent defect localization accuracy.
[0003] Meanwhile, most existing edge detection technologies only perform contour analysis based on pixel-level edge coordinates, without fine-tuning the edge pixel positions. This results in limited edge positioning accuracy and difficulty in identifying minute contour deformations caused by minor crack fractures. Conventional contour defect discrimination methods typically rely solely on single features of contour corner points for anomaly detection, failing to distinguish between the bending of the valve body's arc or concave surfaces (referring to meandering cracks, which are difficult to identify as part of the overall contour), surface texture wrinkles, and contour interruptions caused by actual crack fractures. This easily leads to false positives and false negatives. Traditional detection mechanisms lack angular deflection feature analysis of the continuous contour direction, failing to capture latent defect features such as continuous contour deviation and localized continuous fractures. They also have insufficient ability to identify weak deformations and small-sized fracture cracks, resulting in poor detection stability and robustness. Summary of the Invention
[0004] The purpose of this invention is to provide a method, system, and storage medium for detecting valve body cracks using visual image detection, which solves the aforementioned technical problems pointed out in the prior art.
[0005] This invention provides a method for detecting valve body cracks using visual image detection, the specific operation method including:
[0006] The original image of the sample valve body is acquired, and the original image is preprocessed to obtain the image to be detected;
[0007] The image to be detected is uniformly segmented to form multiple local small regions; grayscale analysis is performed on the local small regions to identify boundary pixels; gradient analysis is performed on the boundary pixels to correct their coordinate positions and identify boundary corners; boundary corner windows are extracted according to a preset pixel window; directional deflection values are obtained based on the gradient identification of adjacent pixels within the boundary corner window; abnormal directional deviation regions of consecutive boundary corners are identified based on the directional deflection values; boundary corners with starting index positions are selected from the abnormal directional deviation regions; suspected breakage positions are identified based on the left and right adjacent boundary corners of the boundary corners with starting index positions; and breakage positions are identified based on the suspected breakage positions and the abnormal directional deviation regions.
[0008] The location of the fracture is taken as the final identification result of the sample valve body.
[0009] Preferably, the image to be detected is uniformly segmented to form multiple local small regions; grayscale analysis is performed on the local small regions to identify boundary pixels. The specific operation steps are as follows:
[0010] The image to be detected is converted to grayscale, and the grayscale image is uniformly segmented to form multiple local small regions. The average grayscale value of the pixels within each local small region is calculated. If the grayscale value of a pixel within a local small region is greater than the average value, the pixel is designated as a foreground pixel. If the grayscale value of a pixel within a local small region is less than the average value, the pixel is designated as a background pixel. The foreground pixels and the background pixels are then combined to form a binary image to be detected.
[0011] The binary image to be detected is traversed through each foreground pixel using an eight-connected neighborhood search algorithm, and the coordinate position of each foreground pixel is determined. Based on the coordinate position of each foreground pixel, adjacent foreground pixels are connected to form a foreground connected region. The coordinate position of the foreground pixel in the foreground connected region is determined, and it is determined whether the adjacent pixels of the foreground pixel are background pixels or other foreground connected regions.
[0012] If any of the criteria is met, then the foreground pixel is taken as the boundary pixel.
[0013] Preferably, the boundary pixels are corrected by gradient analysis to identify boundary corners; a boundary corner window is extracted according to a preset pixel window; and the direction deflection value is obtained based on the gradient identification of adjacent pixels within the boundary corner window. The specific operation steps are as follows:
[0014] A local analysis window is established by expanding a preset pixel range centered on the boundary pixel. Within this window, the grayscale gradient magnitude and direction of each pixel are calculated. The gradient magnitudes of neighboring pixels are interpolated and fitted along the gradient direction to obtain a grayscale change curve. The coordinates of the boundary pixels between the maximum and minimum gradient magnitudes of the grayscale change curve are determined. The deviation between the boundary pixel and the boundary pixels between the maximum and minimum gradient magnitudes is calculated and used as a two-dimensional offset vector. The two-dimensional offset vector of the boundary pixel is then compared with its coordinate position to obtain the corrected sub-pixel precision coordinates.
[0015] Obtain the starting coordinates of all boundary pixels and slide a local window. Calculate the curvature response intensity of the window center point for this sliding local window. If the curvature response intensity is greater than a preset boundary corner discrimination threshold, then the window center point is recorded as a boundary corner point. Select any boundary corner point and trace it along the contour of all boundary pixels. Record the sub-pixel precision coordinates of all boundary corner points in sequence to form a boundary corner point coordinate sequence with an index identifier of the sub-pixel precision coordinate order.
[0016] The sub-pixel row coordinates and sub-pixel column coordinates of the boundary corner points are extracted based on the boundary corner point coordinate sequence. The coordinate position in the image to be detected is located using the sub-pixel precision coordinates of the boundary corner points as the center, and a boundary corner point window is extracted according to a preset pixel window. The difference in grayscale values of the left and right adjacent pixels in the sub-pixel row coordinates of this boundary corner point window is calculated, and the set of differences in all sub-pixel row coordinates is used as the first gradient component. The difference in grayscale values of the upper and lower adjacent pixels in the sub-pixel column coordinates of this boundary corner point window is calculated, and the set of differences in all sub-pixel column coordinates is used as the second gradient component. A preset angle value range is established. The ratio of the first gradient component to the second gradient component is calculated, and this ratio is mapped to the angle value range to extract the gradient direction angle value.
[0017] Based on the sequential index of the boundary corner point coordinate sequence, the difference between the gradient direction angle values of adjacent boundary corner points is calculated sequentially and used as the direction deflection value.
[0018] Preferably, the abnormal directional deviation regions of continuous boundary corner points are identified based on the directional deflection value; boundary corner points with starting index positions are filtered within the abnormal directional deviation regions; suspected fracture locations are identified based on the left and right adjacent boundary corner points of the boundary corner points with starting index positions; and fracture locations are identified based on the suspected fracture locations and the abnormal directional deviation regions. The specific operation steps are as follows:
[0019] For each directional deflection value, the absolute difference is calculated to identify directional deviation anomaly regions at consecutive boundary corners; the geometric center point of the directional deviation anomaly region is identified as the directional deviation anomaly coordinate; the boundary corner point with the starting index position in the directional deviation anomaly region is selected as the starting corner point, and the boundary corner point preceding and following the starting corner point is selected to obtain three side length parameters; the curvature value of the boundary corner point is obtained based on the three side length parameters; the suspected fracture location is identified based on the curvature value of the boundary corner point; the fracture location is obtained by coinciding the suspected fracture location with the directional deviation anomaly coordinate.
[0020] Preferably, the absolute difference of each directional deflection value is calculated to identify abnormal directional deviation regions at consecutive boundary corner points; the geometric center point of the abnormal directional deviation region is identified as the directional deviation anomaly coordinate. The specific operation steps are as follows:
[0021] For each directional deflection value, calculate the absolute difference. If the absolute difference is greater than the preset directional threshold, mark the adjacent boundary corner point pair corresponding to the absolute difference as the initial screening boundary corner point pair; filter continuous initial screening boundary corner point pairs to form an independent continuous initial screening boundary corner point pair sequence.
[0022] The absolute values of all directional deflection values in the sequence of independent and continuous initial screening boundary corner points are calculated, and all absolute values are summed to obtain the cumulative deviation value. If the cumulative deviation value is greater than a preset cumulative threshold, the sequence of independent and continuous initial screening boundary corner points is determined to be a directional deviation abnormal region. The average value of the sub-pixel row coordinates and the average value of the sub-pixel column coordinates of the boundary corner points in the directional deviation abnormal region are calculated to form the geometric center point, which is used as the directional deviation abnormal coordinate.
[0023] Preferably, the boundary corner points in the abnormal region whose directions deviate from the starting index position are selected as the starting corner points, and the boundary corner points preceding and following the starting corner points are selected to obtain three side length parameters. The specific operation steps are as follows:
[0024] Select the boundary corner points in the abnormal region whose direction deviates from the starting index position as the starting corner points, and select the sub-pixel precision coordinates of the boundary corner points located before the starting corner points in the sequential index and the boundary corner points located after the starting corner points in the sequential index to form a continuous three-point spatial coordinate group.
[0025] Extract the sub-pixel row coordinates of the starting corner point and the previous boundary corner point to calculate the first difference; extract the sub-pixel column coordinates of the starting corner point and the previous boundary corner point to calculate the second difference; determine the first side length of the spatial coordinate group of three consecutive points based on the first difference and the second difference;
[0026] Extract the sub-pixel row coordinates of the starting corner point and the next boundary corner point to calculate the third difference; extract the sub-pixel column coordinates of the starting corner point and the next boundary corner point to calculate the fourth difference; determine the second side length of the spatial coordinate group of the three consecutive points based on the third difference and the fourth difference;
[0027] Extract the sub-pixel row coordinates of the previous boundary corner point and the next boundary corner point to calculate the fifth difference; extract the sub-pixel column coordinates of the previous boundary corner point and the next boundary corner point to calculate the sixth difference; determine the length of the third side of the three consecutive point spatial coordinate group based on the fifth difference and the sixth difference;
[0028] The first side length, the second side length, and the third side length form the three side length parameters of a continuous three-point spatial coordinate system;
[0029] The longest and shortest side lengths are selected from the three side length parameters to establish a side length relationship; the circumcircle radius is extracted from the three side length parameters according to the side length relationship; the curvature value of the starting corner point is calculated using the circumcircle radius; and the curvature values of all boundary corner points are formed into a curvature value sequence.
[0030] Preferably, the suspected fracture location is identified based on the curvature value of the boundary corner point; the fracture location is obtained by aligning the suspected fracture location with the abnormal coordinates of the directional deviation. The specific operation steps are as follows:
[0031] Effective curvature abrupt change locations are identified based on the curvature values of adjacent boundary corner points indexed in the curvature numerical sequence; suspected fracture locations are identified along the sequential indexing direction of the sub-pixel precision coordinates of all boundary corner points, using the effective curvature abrupt change location as the center point; a distance mapping matrix is generated based on the directional deviation anomaly coordinates of the abnormal region and the sub-pixel precision coordinates of the suspected fracture location; and the fracture location is generated based on the overlap of the directional deviation anomaly coordinates and the sub-pixel precision coordinates using the distance mapping matrix.
[0032] Preferably, the effective curvature abrupt change location is identified based on the curvature values of adjacent boundary corner points indexed in the curvature numerical sequence; and the suspected break location is identified along the sequential indexing direction of the sub-pixel precision coordinates of all boundary corner points, using the effective curvature abrupt change location as the center point. The specific operation steps are as follows:
[0033] Based on the difference between the curvature values of adjacent boundary corner points indexed in the curvature value sequence, and further calculating the absolute value of the difference as the change amplitude value, a curvature change amplitude sequence is formed; if the change amplitude value is greater than a preset curvature threshold, the sub-pixel precision coordinates of the adjacent boundary corner points of the index corresponding to the change amplitude value are determined as candidate positions for curvature abrupt change.
[0034] Using the candidate curvature abrupt change position as the center point, the corner index range is expanded by a preset number of corner points in the forward and backward directions of the boundary corner point coordinate sequence. The local variance and local range of the curvature values of each boundary corner point within the corner index range are calculated. If the local variance is greater than a preset variance threshold and the local range is greater than a preset range threshold, the candidate curvature abrupt change position is determined to be an effective curvature abrupt change position. Using the effective curvature abrupt change position as the center point, the curvature value of the first search along the sequential index direction of the sub-pixel precision coordinates of all boundary corner points is determined along the forward and backward directions. The first curvature value is then used as a preset stable fluctuation range, which is taken as the boundary continuity characteristic interruption region. Based on the sub-pixel precision coordinates of all boundary corner points within the continuity characteristic interruption region, the cumulative path length between adjacent boundary corner points along the sequential index direction within the continuity characteristic interruption region is calculated, which is taken as the interruption region length.
[0035] The suspected fracture location is formed by combining the length of the interrupted region with the sub-pixel precision coordinates of the effective curvature abrupt change position.
[0036] Preferably, a distance mapping matrix is generated based on the directional deviation anomaly coordinates of the directional deviation anomaly region and the sub-pixel precision coordinates of the suspected fracture location. The specific operation steps are as follows:
[0037] The first coordinate set is formed by taking the coordinates of all directions deviating from the abnormal area; the second coordinate set is formed by taking the sub-pixel precision coordinates of all suspected fracture locations; the first coordinate set is used as the row identifier and the second coordinate set is used as the column identifier to construct a corresponding relationship matrix; the first coordinate point in the first coordinate set is paired with the sub-pixel precision coordinate in the second coordinate set in turn to obtain row and column coordinate pairs, and the row direction difference and column direction difference are calculated.
[0038] The straight-line distance between the row direction difference and the column direction difference is filled into the corresponding relationship matrix to obtain the distance mapping matrix.
[0039] Preferably, the fracture location is generated based on the overlap between the directional deviation anomaly coordinates and the sub-pixel precision coordinates according to the distance mapping matrix. The specific operation steps are as follows:
[0040] A preset neighborhood overlap threshold is set. If the straight-line distance between each unit element in the distance mapping matrix is less than the neighborhood overlap threshold, the row and column coordinate pairs of the corresponding unit element are taken as spatial overlap position pairs. Suspected break positions are extracted from the spatial overlap position pairs as candidate real break positions, and the number of candidate real break positions in the same connected domain is counted.
[0041] If the number of candidate true fracture locations is greater than a preset threshold, the number of boundary corner indexes between adjacent candidate true fracture locations is calculated based on the sequential index of each candidate true fracture location along the contour direction; if the number of boundary corner indexes is less than a preset merging threshold, the adjacent candidate true fracture locations are merged into the final fracture location.
[0042] The coordinates of the fracture location are used as the sub-pixel precision coordinates of the true fracture location of the foreground connected region.
[0043] Compared with the prior art, the embodiments of the present invention have at least the following technical advantages:
[0044] Analysis of the valve body crack detection method, system, and storage medium provided by the present invention reveals that, in specific applications, the present invention obtains a standardized image to be detected through sample valve body image acquisition and preprocessing, eliminating interference caused by noise and uneven brightness in the original image, and ensuring stable input image quality for subsequent contour extraction and defect analysis. The scheme uses a uniform block segmentation method to finely distinguish the foreground and background of the image region, effectively adapting to scenes with uneven grayscale and complex textures on the valve body surface, accurately extracting the valve body contour boundary pixels, and avoiding contour loss and edge distortion problems caused by global threshold segmentation.
[0045] Furthermore, this method achieves sub-pixel coordinate correction of boundary pixels through gradient interpolation fitting, improving the contour positioning accuracy. Then, based on the window curvature response stability, boundary corner points are extracted to obtain a continuous and ordered sub-pixel contour corner point sequence. The scheme calculates the gradient direction deflection value of adjacent corner points to screen out abnormal regions with continuous directional changes, effectively separating the normal contour of the valve body from the contour distortion caused by the bending and defects of the valve body's arc or concave surface. The scheme solves the curvature value of each corner point by solving the three-point geometric relationship of the abnormal region, quantifies the degree of local curvature change of the contour, and accurately screens the real curvature change interval through multiple constraints of curvature change amplitude, local variance and local range, locking the suspected break area where the contour continuity is interrupted.
[0046] Furthermore, this invention constructs a distance mapping matrix to achieve spatial matching between directional deviation anomaly regions and curvature anomaly fracture regions, verifying the authenticity of defects through spatial overlap. It also removes false defect interference by combining connected component statistics and neighbor point merging, ultimately outputting a high-precision valve body fracture location. The overall method combines contour direction change features and curvature change features as dual criteria, constraining defect judgment conditions in multiple dimensions. This effectively suppresses false detection and missed detection problems caused by image noise, surface texture, and slight contour wrinkles, enabling stable and accurate identification of minor fracture defects on the valve body surface. It significantly improves the detection accuracy and stability of valve body fracture defects and is suitable for automated detection scenarios of surface defects in various precision valve bodies. Attached Figure Description
[0047] Figure 1 This is a flowchart of the main process of a visual image detection method for detecting cracks in a valve body, as described in Example 1.
[0048] Figure 2 This is a schematic diagram of valve body fracture and bending, which is a valve body crack detection method based on visual image detection according to Embodiment 1.
[0049] Figure 3 This is an enlarged schematic diagram of the fracture and bending of a valve body crack detection method based on visual image detection, as described in Embodiment 1.
[0050] Figure 4 The direction deflection value is the valve body crack detection method of visual image detection in Embodiment 1;
[0051] Figure 5 The curvature flowchart is shown for a visual image detection method for valve body crack detection in Embodiment 1.
[0052] Figure 6 This is a schematic diagram of continuous boundary corner points of a valve body crack detection method based on visual image detection, as described in Embodiment 1.
[0053] Figure 7 This is a flowchart illustrating the fracture location of a valve body crack detection method based on visual image detection, as described in Embodiment 1.
[0054] Figure 8 This is a flowchart of a valve body crack detection system based on visual image detection, as described in Embodiment 2.
[0055] Figure 9 This is a schematic diagram of the structure of a storage medium for applying the above-mentioned visual image detection method for valve body crack detection.
[0056] Labels: Acquisition module 10; Analysis module 20; Identification module 30; Processor 1110; Communication interface 1120; Memory 1130; Computer storage medium 1140. Detailed Implementation
[0057] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0058] The present invention will now be described in further detail with reference to specific embodiments and accompanying drawings.
[0059] Example 1
[0060] like Figure 1As shown, this invention provides a method for detecting valve body cracks using visual image detection, the specific operation method including:
[0061] S10: Acquire the original image of the sample valve body, and preprocess the original image to obtain the image to be detected;
[0062] It should be noted that the above steps optimize image quality through image preprocessing, remove adverse factors such as shooting noise, uneven lighting, and noise interference, and output standardized images to be detected. This provides a stable and reliable image input basis for subsequent contour segmentation, boundary extraction, and defect identification, ensuring that the detection accuracy of the entire process is not affected by the quality of the original image.
[0063] S20: The image to be detected is uniformly segmented to form multiple local small regions; grayscale analysis is performed on the local small regions to identify boundary pixels; gradient analysis is performed on the boundary pixels to correct their coordinate positions and identify boundary corners; boundary corner windows are extracted according to a preset pixel window; direction deflection values are obtained based on the gradient identification of adjacent pixels within the boundary corner window; abnormal direction deviation regions of consecutive boundary corners are identified based on the direction deflection values; boundary corners with starting index positions are selected from the abnormal direction deviation regions; suspected breakage positions are identified based on the left and right adjacent boundary corners of the boundary corners with starting index positions; and breakage positions are identified based on the suspected breakage positions and the abnormal direction deviation regions.
[0064] It should be noted that in the above steps, the image to be detected is uniformly segmented into multiple local small regions. Local grayscale features are combined to distinguish the foreground from the background, accurately extracting the boundary pixels corresponding to the valve body contour. This solves the problems of edge incompleteness and segmentation failure that easily occur in traditional global segmentation methods in scenarios with uneven grayscale distribution and complex surface textures on the valve body. The above steps also perform sub-pixel correction of the boundary pixel coordinates through gradient analysis and interpolation fitting, effectively improving the problem of rough pixel-level edge positioning and enhancing the accuracy of contour boundary positioning. Simultaneously, a method based on sliding window curvature feature extraction is used to stabilize the image. The method for determining boundary corner points involves calculating the contour direction deflection value through the neighborhood gradient of the corner point. It then uses the deflection characteristics of continuous corner points to filter out abnormal directional deviation areas, accurately capturing abnormal deformation intervals in the valve body contour. Next, it utilizes the neighborhood geometric relationships and curvature change characteristics of the corner points in the abnormal areas to identify suspected fracture locations where contour continuity is interrupted. This is combined with abnormal directional deviation characteristics for double verification, accurately identifying the true fracture area and effectively distinguishing between the normal valve body contour and the bending of the valve body's arc or concave surfaces (bending cracks are represented by a winding crack, a complex curved contour, and numerous corner points during bending). Figure 2 As shown Figure 3 As shown, where Figure 2 The cracks are caused by bending of the valve body. Figure 3 This is a magnified view of the bending crack;
[0065] S30: Take the fracture location as the final identification result of the sample valve body.
[0066] It should be noted that in the above steps, the verified precise fracture location is used as the final identification result of the sample valve body defect. The present invention combines local grayscale features, contour gradient direction features and curvature change features throughout the process to achieve multi-level defect judgment, avoiding the disadvantages of single feature detection being easily affected by image noise and slight texture wrinkles on the valve body surface, greatly reducing the probability of false detection and missed detection of defects, and can accurately identify minor fracture defects in the valve body.
[0067] like Figure 4 As shown, specifically, in step S20, the image to be detected is uniformly segmented to form multiple local small regions; grayscale analysis is performed on the local small regions to identify boundary pixels; gradient analysis is performed on the boundary pixels to correct their coordinate positions and identify boundary corners; boundary corner windows are extracted according to a preset pixel window; direction deflection values are obtained based on the gradient identification of adjacent pixels within the boundary corner window; abnormal direction deviation regions of consecutive boundary corners are identified based on the direction deflection values; boundary corners with starting index positions are selected from the abnormal direction deviation regions; suspected breakage positions are identified based on the left and right adjacent boundary corners of the boundary corners with starting index positions; and breakage positions are identified based on the suspected breakage positions and the abnormal direction deviation regions. The specific operation steps are as follows:
[0068] S21: Convert the image to be detected to grayscale, and uniformly segment the grayscale image to be detected to form multiple local small regions;
[0069] Calculate the average grayscale value of the internal pixels for each local small block region;
[0070] If the gray value of a pixel within the local small area is greater than the average value, then that pixel is considered a foreground pixel (i.e., it may be a crack area).
[0071] If the gray value of a pixel within the local small region is less than the average value, then that pixel is taken as a background pixel (which may be a non-cracked region); the foreground pixel and the background pixel are combined to form a binary image to be detected.
[0072] The binary image to be detected is traversed through each foreground pixel using an eight-connected neighborhood search algorithm, and the coordinate position of each foreground pixel is determined. Based on the coordinate position of each foreground pixel, adjacent foreground pixels are connected to form a foreground connected region.
[0073] Determine the coordinate position of the foreground pixel in the foreground connected region, and determine whether the neighboring pixels of the foreground pixel are background pixels or other foreground connected regions (indicated by whether the neighboring pixels are foreground pixels of other foreground connected regions; if so, it means that the foreground pixel is the boundary position).
[0074] If any of the criteria are met, the foreground pixel is taken as the boundary pixel (i.e., the pixel-level coordinate point located at the edge of the foreground connected region).
[0075] It should be noted that the above steps complete image grayscale conversion and uniform region segmentation, and generate a binary image by distinguishing foreground pixels from background pixels through the mean grayscale value of local regions; the steps use 8-connected neighborhood search to connect the foreground region and extract boundary pixels by judging the attributes of neighboring pixels; this method uniformly divides the region by local grayscale features, avoids the segmentation distortion problem caused by uneven illumination in global fixed threshold segmentation, accurately locks the potential foreground region of the crack, and completely extracts the contour boundary pixels, providing a basic contour data source for subsequent fine correction of boundary coordinates and reducing the invalid calculations caused by irrelevant background pixels;
[0076] S22: Expand the preset pixel range with the boundary pixel as the center to establish a local analysis window; calculate the gray-level gradient magnitude and gradient direction of each pixel within the local analysis window (i.e., determine the direction (i.e., gradient direction) and magnitude (i.e., gradient magnitude) of the most drastic gray-level change at that point).
[0077] Interpolate and fit the gradient magnitude of neighboring pixels along the gradient direction to obtain a grayscale change curve (a broken line with up and down fluctuations).
[0078] Determine the coordinates of the boundary pixels between the maximum and minimum gradient magnitudes of the grayscale change curve (i.e., the peak position where the grayscale change is most dramatic).
[0079] Calculate the deviation of the boundary pixel (the boundary pixel at the center position) from the gradient magnitude of the maximum and minimum values of the boundary pixel, and use this as a two-dimensional offset vector (i.e., compare the deviation between the maximum and minimum peak positions and the current boundary pixel center position; if the peak position is biased to the right, it means the real edge is on the right, and the coordinates need to be offset to the right by the coordinates of one boundary pixel or a small number of two or three boundary pixels (i.e., the number of boundary pixels to be offset is small, such as less than 5 boundary pixels); if the peak position is biased to the top, it means the real edge is at the top, and the coordinates need to be offset upwards by a small amount; combine the horizontal and vertical offsets to form a two-dimensional offset vector (including row offset and column offset)).
[0080] The two-dimensional offset vector of the boundary pixel is reduced by the coordinate position (i.e., the original coordinates of the boundary pixel) to obtain the corrected sub-pixel precision coordinates (the two-dimensional offset vector is added to the row and column coordinates of the original boundary pixel respectively; for example, if the original coordinates are (row = 100, column = 200) and the two-dimensional offset vector is (row direction +0.35, column direction -0.22), then the corrected coordinates are (100.35, 199.78)).
[0081] A sliding local window is created by obtaining the starting coordinates of all boundary pixels. The curvature response intensity of the window's center point (i.e., the boundary pixel) is calculated within this sliding local window (i.e., the window is gradually slid forward along the boundary direction (moving one point at a time). At each sliding window position, the distribution of all boundary points within the window is observed. If these points are approximately aligned in a straight line, the curvature response intensity of the window's center point is very low; if these points experience significant bending (such as a turn) at this point, the curvature response intensity of the window's center point is very high. The curvature response intensity reflects the degree of bending at that point. Specifically, the current sliding window contains N boundary pixels, whose coordinates are... For points i=1,2,...,N; first, perform least-squares line fitting on these N points to obtain the fitted line equation y= +b; then, calculate the perpendicular distance from each point to the fitted line. The calculation formula is: = |k· - + b| / √(k² + 1); where k is the slope of the fitted line and b is the intercept of the fitted line; then the curvature response intensity R at the center point of the window is defined as the reciprocal of the average distance from all points to the fitted line, i.e. The larger the value, the greater the deviation of each point within the window from the fitted straight line, meaning the higher the curvature of the contour at that point; conversely, the smaller the value, the closer each point within the window is to a straight line, meaning the contour at that point tends to be straight. If the curvature response intensity R is greater than the preset boundary corner discrimination threshold, then the center point of the window is recorded as a boundary corner; if it does not exceed the threshold, then the point is determined not to be a boundary corner, and the window continues to slide until all boundary pixels on the entire boundary contour trajectory have been detected.
[0082] If the curvature response intensity is greater than the preset boundary corner discrimination threshold (i.e., the curvature response intensity threshold used to determine whether a boundary point is a corner; this threshold is related to the image resolution and contour smoothness; preferably, the value range is [0.5, 5.0] (pixel⁻¹), more preferably 2.0 (pixel⁻¹); if the curvature response intensity is greater than this value, then the point is considered to be a boundary corner), then the center point of the window is recorded as a boundary corner (i.e., a contour key point with significant curvature features selected from the boundary pixels, represented by sub-pixel precision coordinates; if it does not exceed the threshold, then the point is determined not to be a boundary corner, and the window continues to slide until all boundary pixels on the entire boundary contour trajectory have been detected).
[0083] Select any boundary corner point and trace along the contour of all boundary pixels. Record the sub-pixel precision coordinates of all boundary corner points in sequence to form a boundary corner point coordinate sequence with index identification of sub-pixel precision coordinate order.
[0084] It should be noted that in the above steps, a local analysis window is constructed to solve for the pixel gradient magnitude and gradient direction. Interpolation is used to fit the grayscale change curve, and then a two-dimensional offset vector is calculated through the peak position to complete the sub-pixel coordinate correction of the boundary pixels. Then, a sliding window is used to obtain the contour curvature response intensity to identify the boundary corners, and the sub-pixel coordinates of the corners are recorded in an orderly manner to form a coordinate sequence. This step corrects the positioning deviation of the original pixel-level boundary and improves the accuracy of the contour coordinates. The curvature features are used to distinguish the bending corner positions of straight contour segments and the arc or concave surface of the valve body, and the boundary corner position information is organized in an orderly manner to ensure the continuous calculation of subsequent gradient direction and deflection features.
[0085] S23: Extract the sub-pixel row coordinates and sub-pixel column coordinates of the boundary corner points based on the boundary corner point coordinate sequence;
[0086] The coordinate position in the image to be detected is located based on the sub-pixel precision coordinates of the boundary corner points as the center, and the boundary corner point window is extracted according to the preset pixel point window.
[0087] The difference in grayscale values of the left and right adjacent pixels in the sub-pixel row coordinates of the boundary corner window is calculated (i.e., if the brightness difference between the left and right adjacent pixels is large, it indicates that there is a significant grayscale change in the horizontal direction). The set of all sub-pixel row coordinate differences is used as the first gradient component (i.e., the overall intensity and direction of the change along the row direction at the corner point; a positive value indicates that the grayscale increases from the left to the right, and a negative value indicates that the grayscale decreases from the left to the right).
[0088] The difference in grayscale values of adjacent pixels in the sub-pixel column coordinates of the boundary corner window is calculated (i.e., if the brightness difference between adjacent pixels is large, it indicates that there is a significant grayscale change in the vertical direction). The set of all sub-pixel column coordinate differences is used as the second gradient component (i.e., the overall intensity and direction of the change along the column direction at the corner point; a positive value indicates that the grayscale increases from top to bottom, and a negative value indicates that the grayscale decreases from top to bottom).
[0089] A preset angle range (e.g., -180 degrees to 180 degrees) is defined. The ratio of the first gradient component to the second gradient component is calculated, and this ratio is mapped to the angle range. The gradient direction angle value is extracted (i.e., determining which gradient component is larger, whether the grayscale change at that point is horizontal or vertical, and which quadrant it points to). Based on the ratio of the first gradient component to the second gradient component, the corresponding angle value is found within the preset angle range. The larger the ratio (horizontal component dominates), the closer the angle is to 0 degrees or 180 degrees (horizontal direction); the smaller the ratio (vertical component dominates), the closer the angle is to 90 degrees or 270 degrees (vertical direction). The sign determines whether the angle is in the upper or lower semicircle. The mapped angle value is used as the gradient direction angle of the current target corner point. Specifically, the ratio of the first gradient component Gx to the second gradient component Gy is calculated, and the gradient direction angle value θ = atan2(Gy, Gx) is obtained by using the arctangent function atan2(Gy, Gx). Gx), where the range of the atan2 function is (-180°, 180°), that is, (-180°, 180°) is the range of angle values.
[0090] Based on the sequential index of the boundary corner point coordinate sequence, the difference between the gradient direction angle values of adjacent boundary corner points is calculated sequentially as the direction deflection value (i.e., the difference between the gradient direction angle values of adjacent boundary corner points, which quantifies the degree of change in the contour direction; this difference indicates how much the direction of the boundary has deflected from the previous corner point to the current corner point, and can show abnormal direction deviation).
[0091] It should be noted that in the above steps, a local window is constructed with the sub-pixel coordinates of the boundary corner points as the center. The gray-level difference in the horizontal and vertical directions is solved to obtain two sets of gradient components, which are then converted to obtain the gradient direction angle. The gradient angle difference between adjacent corner points is obtained sequentially along the contour sequence to obtain the direction deflection value. The above method comprehensively represents the local gray-level change trend of the corner points by relying on the gray-level difference of multiple pixels within the window, quantifies the degree of angle change of the contour direction, intuitively reflects the contour direction deflection feature, realizes the numericalization of the contour shape change feature, and supports the screening and judgment of abnormal areas.
[0092] S24: Calculate the absolute difference for each directional deflection value to identify directional deviation anomaly regions at continuous boundary corners (the aforementioned directional deviation anomaly regions are of great significance for determining the fracture location); identify the geometric center point of the directional deviation anomaly region as the directional deviation anomaly coordinate; select the boundary corner point at the starting index position in the directional deviation anomaly region as the starting corner point, and select the boundary corner point one position before and one position after the starting corner point to obtain three side length parameters; obtain the curvature value of the boundary corner point based on the three side length parameters; identify the suspected fracture location based on the curvature value of the boundary corner point; identify the fracture location by coinciding with the directional deviation anomaly coordinates;
[0093] It should be noted that in the above steps, the abnormal directional deviation region formed by continuous corner points is filtered by directional deflection value, and the starting corner point of the region is extracted (that is, the geometric center point in the abnormal directional deviation region is the center position of the entire region; while the boundary corner point of the starting index position is the boundary corner point in the abnormal directional deviation region, the boundary corner point is filtered according to the boundary pixel point sequence, and the starting corner point is the first boundary corner point after the position coordinate is arranged). The side length parameter is calculated by combining the adjacent corner points to solve the curvature value, and the suspected fracture position is identified. The suspected fracture position is superimposed with the coordinate matching result of the abnormal directional deviation, and the crack fracture position is finally determined. Then, the contour direction change feature and local curvature feature are used for joint judgment to distinguish the bending of the normal contour valve body arc surface or concave surface from the actual crack fracture defect, reduce the misjudgment caused by relying solely on the angle change judgment, and accurately locate the fracture point of the crack contour interruption and defect.
[0094] The above scheme extracts contour features in a layered manner, first segmenting to obtain the foreground boundary, then correcting the boundary coordinates to achieve sub-pixel positioning, quantifying the contour direction deflection and curvature features, and using dual features to jointly identify the crack fracture location, effectively suppressing detection interference caused by image noise and illumination fluctuations, and improving the accuracy of crack fracture location identification.
[0095] like Figure 5 As shown, specifically, in step S24, the absolute difference of each directional deflection value is calculated to identify directional deviation anomaly regions of continuous boundary corner points; the geometric center point of the directional deviation anomaly region is identified as the directional deviation anomaly coordinate; the boundary corner point with the starting index position in the directional deviation anomaly region is selected as the starting corner point, and the boundary corner point before and after the starting corner point is selected to obtain three side length parameters; the curvature value of the boundary corner point is obtained based on the three side length parameters; the suspected fracture location is identified based on the curvature value of the boundary corner point; the fracture location is obtained by overlapping the suspected fracture location with the directional deviation anomaly coordinate. The specific operation steps are as follows:
[0096] S241: Calculate the absolute difference for each directional deflection value (i.e., check if the directional deflection value is negative; if it is negative, convert it to a positive number (take its absolute value); if it is already positive, leave it unchanged; the absolute value reflects the severity of the directional deflection and is independent of the deflection direction (clockwise or counterclockwise)). If the absolute difference is greater than a preset directional threshold (i.e., a threshold used to determine whether the directional deflection between adjacent corner points is a significant abrupt change; its unit is angle (degrees); the preferred value range is [15°, 45°], more preferably 30°; if the absolute value of the directional deflection value is greater than this threshold, then mark the adjacent corner point pair as a preliminary screening boundary corner point pair), then mark the adjacent boundary corner point pair corresponding to the absolute difference as a preliminary screening boundary corner point pair (i.e., it indicates that there is a large directional abrupt change between the adjacent corner point pairs, and the corner point pair is determined to have passed the preliminary screening due to directional deviation).
[0097] Filter consecutive initial screening boundary corner point pairs to form an independent consecutive initial screening boundary corner point pair sequence (that is, the 5th, 6th, 7th and 8th pairs of adjacent corner points in the sequence are all marked as passed, and they constitute a consecutive initial screening mark set).
[0098] The absolute values of all directional deflection values in the sequence of independent and continuous initial screening boundary corner point pairs are calculated, and all absolute values are summed to obtain the cumulative deviation value (which reflects the degree of continuous deviation of the boundary direction in this area: the larger the cumulative deviation value, the more continuously the direction deflects in this area, rather than a brief fluctuation; at the same time, the core purpose of the cumulative deviation value is to filter out isolated noise points; if a corner point pair exceeds the standard individually, but the areas before and after it are normal, the cumulative deviation value is usually small and will be excluded in subsequent steps; if multiple consecutive corner point pairs exceed the standard and the deflection direction is consistent, the cumulative deviation value will increase significantly, indicating that there is indeed an anomaly in this area; the cumulative deviation value is also used to characterize the total magnitude of continuous deflection of the contour direction in this area).
[0099] If the cumulative deviation value is greater than the preset cumulative threshold (i.e., the threshold used to determine whether a region composed of consecutive initial screening corner point pairs is a region with abnormal directional deviation; its unit is angle (degrees); this threshold is used to filter isolated angle jitter caused by noise; the preferred value range is [60°, [180°], more preferably 120°; if the sum of the absolute values of all directional deflections within the region is greater than this threshold, it is determined to be a directional deviation abnormal region), then the independent continuous initial screening boundary corner point pair sequence is determined to be a directional deviation abnormal region (i.e., continuous corner point pairs can form a contour region, a local contour interval composed of multiple consecutive initial screening boundary corner point pairs, where the cumulative directional deflection exceeds a preset threshold; a directional deviation abnormal region refers to a local contour interval composed of three or more consecutive initial screening boundary corner point pairs in the boundary corner point coordinate sequence; within this interval, the gradient direction angle value of each boundary corner point has undergone a continuous deflection relative to the normal contour direction, and the cumulative amplitude exceeds a preset cumulative threshold, which is essentially an abnormal turn of the contour direction that is not designed within this interval; the starting position of this region is determined by the first boundary corner point pair in the independent continuous initial screening boundary corner point pair sequence, and the ending position is determined by the last boundary corner point pair in the sequence, such as Figure 6 As shown; this area reflects the spatial range of a continuous abnormal turn in the profile direction; the bends of the valve body's arc or concave surfaces in a normal valve body profile (such as fillets or chamfers in the design) are usually smooth transitions, with small and evenly distributed directional deflection values; while the profile distortion caused by fracture defects is characterized by a concentration of directional deflection values in a short period of time.
[0100] For the boundary corner points in the directional deviation anomaly region, calculate the average value of the sub-pixel row coordinates and the average value of the sub-pixel column coordinates to form the geometric center point, which is used as the directional deviation anomaly coordinate (i.e., this point is the geometric center coordinate of the directional deviation anomaly region).
[0101] It should be noted that in the above steps, the absolute value of the direction deflection is calculated, and the boundary corner point pairs are initially screened based on the preset direction threshold. The continuously marked corner point pairs are aggregated to form an independent sequence. The cumulative deviation value of the sequence is statistically analyzed to screen abnormal direction deviation areas. The geometric center of the abnormal area is solved simultaneously to obtain the abnormal direction deviation coordinates. The above continuous feature aggregation process filters out the instantaneous angle disturbance caused by isolated single-point noise, distinguishes between small local jitter of the contour and continuous direction deflection, avoids misidentification caused by single corner point pair judgment, and accurately locks the continuous turning area of the contour and obtains the reference coordinates of the center of the area, providing a positioning basis for subsequent break point matching.
[0102] S242: Select the boundary corner points at the starting index position in the direction deviation abnormal region as the starting corner points, and select the sub-pixel precision coordinates of the boundary corner points located before and after the starting corner points in the sequential index to form a continuous three-point spatial coordinate group (i.e., starting from the starting position of the sequence of direction deviation abnormal region, select a corner point as the current corner point; take the corner point in the sequence that is one position before the current corner point as the previous corner point; take the corner point in the sequence that is one position after the current corner point as the next corner point; if the current corner point is the first corner point of the sequence, then its previous corner point is the last corner point of the sequence (head and tail connected, closed boundary); if the current corner point is the last corner point of the sequence, then its next corner point is the first corner point of the sequence; the three corner points are combined into a spatial coordinate group in the order of previous corner point, current corner point, and next corner point, and connected to form a triangle (or an approximate triangle shape), with the current corner point located in the middle position).
[0103] Extract the sub-pixel row coordinates of the starting corner point and the previous boundary corner point to calculate the first difference (i.e., the row direction difference).
[0104] The sub-pixel column coordinates of the starting corner point and the previous boundary corner point are extracted to calculate the second difference (i.e., the column direction difference).
[0105] The length of the first side of the spatial coordinate group of three consecutive points is determined based on the first difference and the second difference (that is, the straight-line distance between the two points is determined by combining the row direction difference and the column direction difference; the larger the difference, the farther the distance; the smaller the difference, the closer the distance; this side corresponds to the first side of the triangle, that is, the side length from the previous corner point to the current corner point).
[0106] The sub-pixel row coordinates of the starting corner point and the next boundary corner point are extracted to calculate the third difference (i.e., the row direction difference).
[0107] The sub-pixel column coordinates of the starting corner point and the next boundary corner point are extracted to calculate the fourth difference (i.e., the column direction difference).
[0108] The second side length of the spatial coordinate group of three consecutive points is determined based on the third and fourth differences (that is, the second side of the triangle corresponding to this side, i.e., the side length from the current corner point to the next corner point).
[0109] The sub-pixel row coordinates of the previous and next boundary corner points are extracted to calculate the fifth difference (i.e., the row direction difference).
[0110] The sub-pixel column coordinates of the previous and next boundary corner points are extracted to calculate the sixth difference (i.e., the column direction difference).
[0111] The length of the third side of the three consecutive spatial coordinate group is determined based on the fifth and sixth differences (that is, the third side of the triangle corresponding to this side, which is the length of the side from the previous corner point to the next corner point (crossing the current corner point)).
[0112] The three side length parameters (i.e., the relative size relationship of the three side lengths) form a continuous three-point spatial coordinate system (i.e., the shape of the triangle is determined by the relative size relationship of the three side lengths, whether it is slender, flat, or close to an equilateral triangle).
[0113] It should be noted that in the above steps, the starting corner point of the abnormal area and its adjacent corner points are selected to form a three-point coordinate group. The straight-line distance between the three sets of points is solved sequentially by using the difference between the row and column coordinates to obtain the complete three side length parameters. The step calculates the point spacing through sub-pixel coordinates, quantifies the spatial distribution of the three adjacent boundary corner points, forms stable geometric calculation basis parameters, and relies on the three side dimensions to reflect the arrangement of the three points, supporting the subsequent quantitative solution of the local curvature.
[0114] S243: Select the longest and shortest side lengths from the three side length parameters to construct the side length relationship (i.e., which of the three side lengths is the longest and which is the shortest, and the proportional relationship between them; if the three side lengths are relatively close, it means that the three corner points are evenly distributed and the triangle formed is full; if one side is particularly long and the other two sides are relatively short, it means that the three corner points tend to be aligned in a straight line, forming a relative relationship of side lengths; check whether the longest side length is close to the sum of the other two side lengths; if the longest side is close to the sum of the other two side lengths, it means that the three corner points are almost on the same straight line (i.e., the boundary is relatively straight at this point), in which case the circumscribed circle will be very large (tending to infinity); if the longest side is significantly smaller than the sum of the other two side lengths, it means that the three corner points form obvious bends in the valve body arc or concave surface, the radius of the circumscribed circle will be relatively small, forming an approximately collinear relationship).
[0115] The circumscribed circle radius is extracted from the three side length parameters based on the aforementioned side length relationship (i.e., the radius of a circle that can pass through the three corner points is determined based on the relationship between the three side lengths; the closer the three points are to a straight line (the smaller the degree of curvature of the valve body's arc or concave surface), the larger the circumscribed circle radius; the more severe the curvature of the three points on the valve body's arc or concave surface (the sharper the triangle formed), the smaller the circumscribed circle radius; in extreme cases, if the three points are completely on a straight line, the circumscribed circle radius tends to infinity; the circumscribed circle radius describes the degree of local curvature of the boundary at the current corner point: the larger the radius, the gentler the curvature; the smaller the radius, the more severe the curvature).
[0116] The curvature value of the starting corner point is calculated using the circumcircle radius (specifically, by comparing the lengths of the three sides a (first side length), b (second side length), and c (third side length) to determine the longest and shortest sides, and calculating the difference between the longest side and the sum of the other two side lengths). If this difference is less than a preset collinearity threshold, the three points are considered to be close to collinear, at which point the circumcircle radius approaches infinity and the curvature value approaches 0. If the difference is large, it indicates that the triangle formed by the three points is relatively full, and the circumcircle radius is finite. The circumcircle radius is extracted from the three side length parameters based on the side length relationship. First, the area Δ of the triangle formed by the spatial coordinates of the three consecutive points is calculated using Heron's formula. Where s is the semi-perimeter of the triangle, and a, b, and c are the lengths of the first, second, and third sides, respectively; then, the radius of the circumcircle is calculated using the formula for the radius of the circumcircle of a triangle. The curvature value C of the starting corner point is calculated using the radius of the circumscribed circle, with the formula C = 1 / R. When the three points tend to be collinear, Δ approaches 0, R approaches infinity, and the curvature value C approaches 0, indicating that the boundary at that point tends to be straight. The more severe the bending of the three points on the valve body's arc or concave surface, the larger Δ becomes, the smaller R becomes, and the larger the curvature value C becomes, indicating that the boundary bends more severely at that point. The curvature values of all boundary corner points are arranged according to their index order in the boundary corner point coordinate sequence to form a curvature value sequence. (where n is the total number of boundary corner points).
[0117] Form a curvature value sequence from the curvature values of all boundary corner points;
[0118] It should be noted that in the above steps, the relative relationship of side lengths is established based on the three side parameters, the radius of the circumcircle of the three points is solved, and then the curvature value of the corresponding boundary corner point is calculated and summarized to generate a complete curvature value sequence. The circumcircle radius of the three points can intuitively characterize the degree of bending of the local valve body arc surface or concave surface. The curvature value transforms the geometric shape into a quantitative indicator. The curvature value is smaller in straight positions and larger in the bending positions of the valve body arc surface or concave surface. This realizes the standardized quantitative expression of the local bending characteristics of the contour, which makes it easier to distinguish the bending of the normal contour valve body arc surface or concave surface from the morphological change caused by crack fracture.
[0119] S244: Identify effective curvature abrupt change locations based on the curvature values of adjacent boundary corner points indexed in the curvature numerical sequence; identify suspected fracture locations using the effective curvature abrupt change locations as the center point and along the sequential indexing direction of all boundary corner point sub-pixel precision coordinates; generate a distance mapping matrix based on the directional deviation anomaly coordinates of the abnormal region and the sub-pixel precision coordinates of the suspected fracture locations; generate fracture locations based on the overlap of the directional deviation anomaly coordinates and the sub-pixel precision coordinates using the distance mapping matrix.
[0120] It should be noted that in the above steps, the curvature sequence is traversed to identify curvature abrupt change points, and the suspected fracture location is initially locked. A distance mapping matrix is constructed to compare the coordinates of the suspected fracture location with the abnormal coordinates of the direction deviation. The crack fracture location is finally determined by the coordinate coincidence matching method. Then, the contour direction deflection feature and the local curvature abrupt change feature are used for dual condition joint verification to distinguish between normal curves of the coating contour and crack fracture gaps. This weakens the interference caused by image noise and small contour wrinkles, reduces the probability of false defect detection, and accurately locates the actual point where the crack breaks.
[0121] The above scheme continuously filters abnormal intervals by angle deflection, combines three-point geometric solution of curvature features, and identifies fracture points by mutual verification of bidirectional features. The entire process is based on sub-pixel coordinates to carry out geometric calculations, ensuring positioning accuracy and effectively improving the reliability of crack fracture location identification.
[0122] like Figure 7 As shown, specifically, in step S244, effective curvature abrupt change locations are identified based on the curvature values of adjacent boundary corner points indexed in the curvature value sequence; suspected fracture locations are identified along the sequential indexing direction of the sub-pixel precision coordinates of all boundary corner points, using the effective curvature abrupt change location as the center point; a distance mapping matrix is generated based on the directional deviation anomaly coordinates of the abnormal region and the sub-pixel precision coordinates of the suspected fracture location; and the fracture location is generated based on the overlap of the directional deviation anomaly coordinates and the sub-pixel precision coordinates using the distance mapping matrix. The specific operation steps are as follows:
[0123] S2441: Based on the difference between the curvature values of adjacent boundary corner points indexed in the curvature value sequence, and further calculate the absolute value of the difference as the change amplitude value, a curvature change amplitude sequence is formed (that is, for each pair of adjacent curvature values, the previous curvature value is subtracted from the next curvature value to obtain a difference value. A positive value indicates that the curvature has increased (the boundary has become more curved), and a negative value indicates that the curvature has decreased (the boundary has become smoother). The absolute value of each calculated difference is taken, and the negative number is converted into a positive number. The absolute value reflects the degree of curvature change and is independent of the direction of change (whether it increases or decreases). All absolute values are arranged in order to generate a curvature change amplitude sequence. The larger the value in the sequence, the more drastic the curvature change at the corresponding position).
[0124] If the change amplitude value is greater than the preset curvature threshold (i.e., the threshold used to screen candidate locations for curvature abrupt changes; its dimension is the same as the curvature value (1 / pixel); this value is used to identify the starting point where the curvature value changes significantly; preferably the value range is [1.0, 10.0] (1 / pixel), more preferably 5.0 (1 / pixel)), then the sub-pixel precision coordinates of the adjacent boundary corner points of the index corresponding to the change amplitude value are determined as candidate locations for curvature abrupt changes;
[0125] Taking the candidate curvature change position as the center point, the corner index range of a preset number of corner points is expanded in the forward and backward directions of the boundary corner point coordinate sequence (that is, the forward and backward directions are the expansion range of a preset number of corner points along the forward and backward paths of the boundary pixel contour (candidate curvature change position); for example, if the preset expansion number is 5 corner points, then the neighborhood range of a candidate position (the Nth corner point) covers corner points from the N-5th to the N+5th). The statistical values of each boundary corner point within the corner index range are calculated. Local variance of curvature values (i.e., the dispersion of all curvature values in the neighborhood relative to their mean; if the curvature values are all close to the mean, it indicates that the curvature fluctuation in the neighborhood is small and the variance is small; if the curvature values differ greatly, it indicates that the curvature fluctuation in the neighborhood is drastic and the variance is large; local variance reflects the overall dispersion of curvature in the neighborhood) and local range (i.e., finding the maximum and minimum values among all curvature values in the neighborhood; subtracting the minimum value from the maximum value yields the local range (i.e., the range of curvature value fluctuations; local range reflects the range of curvature changes in the neighborhood)
[0126] If the local variance is greater than a preset variance threshold and the local range is greater than a preset range threshold, then the candidate curvature change location is determined to be a valid curvature change location (i.e., if the local variance exceeds the variance threshold, it indicates that there is indeed significant fluctuation in curvature within the neighborhood; if the local range exceeds the range threshold, it indicates that the fluctuation amplitude of curvature within the neighborhood is sufficiently large; when both conditions are met simultaneously, the candidate curvature change location is confirmed as a valid curvature change location; if either condition is not met, it indicates that the change at this location may be caused by local noise or small fluctuations, and the candidate location is discarded; the aforementioned variance threshold and range threshold are used as thresholds to verify whether the candidate curvature change location is valid; the local variance is used to measure the dispersion of curvature values within the neighborhood, and its dimension is (1 / pixel)²; the local range is used to measure the maximum fluctuation amplitude of curvature values within the neighborhood, and its dimension is (1 / pixel); preferably, the variance threshold range is [0.5, 5.0] (1 / pixel)², more preferably 2.0). (1 / pixel)²; the range threshold is [2.0, 15.0] (1 / pixel), more preferably 8.0 (1 / pixel));
[0127] It should be noted that in the above steps, the curvature difference between adjacent boundary corner points is calculated and the absolute value is used to construct a curvature change amplitude sequence. At the same time, a curvature threshold is used to screen candidate locations for curvature abrupt changes. A local index interval is formed by expanding outward from the candidate point as the center. The local variance and local range of the curvature values within the interval are statistically analyzed. Only when both threshold conditions are met can a valid curvature abrupt change location be determined. This method does not rely on the curvature value of a single point for direct determination. Instead, it combines the overall fluctuation range and dispersion of curvature in the neighborhood for joint discrimination, effectively filtering out instantaneous curvature fluctuations caused by random noise at a single point, eliminating false abrupt change points, and accurately locating areas where the contour curvature changes continuously and drastically.
[0128] S2442: Taking the effective curvature abrupt change position as the center point, along the sequential indexing direction of the sub-pixel precision coordinates of all boundary corner points, search for the first curvature value in the forward and backward directions respectively. The initial curvature value is within the preset stable fluctuation range (i.e., the parameter used to define the normal contour curvature value fluctuation range; this range is defined as the average value μ of the entire contour curvature value sequence plus or minus two standard deviations σ, i.e., [μ-2σ, μ+2σ]; corner points whose curvature values fall within this range are considered to be in a normal contour curvature state). The pixel point connecting the two boundary corner points (i.e., the pixel point is the boundary pixel point and the boundary corner point; because it is the middle area of the two boundary corner points, the area formed along the contour includes the boundary pixel point and the boundary corner point) is regarded as the boundary continuity interruption area (i.e., the local interval of the contour where the curvature value continuously deviates from the normal fluctuation range centered on the effective curvature abrupt change position; at the confirmed effective abrupt change position, find the entire interval from the start of the abrupt change to the restoration of the boundary curvature to normal, this interval reflects the disruption of the boundary continuity). The range; the curvature values of all corner points within the boundary continuity interruption area are in an abnormal state (deviating from the stable fluctuation range), indicating that the boundary continuity is disrupted in this area; specifically, starting from the corner point index of the effective mutation position, move point by point in the forward direction of the sequence (the direction of decreasing index), and check the curvature value of each corner point to see if the curvature value has returned to the preset stable fluctuation range (i.e., the normal fluctuation range of curvature value); continue searching forward until the first corner point whose curvature value has returned to the stable fluctuation range is found, and record the index position of this corner point as the forward boundary index of the interruption area. If no recovery point is found before reaching the start of the sequence, the start of the sequence is used as the forward boundary index. Starting from the corner index of the effective mutation position, the sequence moves point by point in the backward direction (the direction of increasing index). At each corner, the curvature value of that point is checked to see if it returns to the preset stable fluctuation range. This search continues until the first corner with a curvature value restored to the stable fluctuation range is found. The index position of this corner is recorded as the backward boundary index of the interrupted region. If no recovery point is found before reaching the end of the sequence, the end of the sequence is used as the backward boundary index. Boundary continuity characteristic. The interruption region refers to the continuous contour interval defined between two recovered points, centered on the effective curvature abrupt change location and expanded along the forward and backward directions of the boundary corner point coordinate sequence until the boundary corner point where the curvature value recovers to the stable fluctuation range is found. The curvature values of all boundary corner points within this region continuously deviate from the normal level, reflecting a discontinuity interruption (i.e., fracture) in the valve body contour at that location. Essentially, this is an irreversible abrupt change in the contour's geometry in space. The boundary continuity interruption region and the aforementioned directional deviation anomaly region constitute a fracture candidate interval, complementary in description from the two dimensions of directional anomaly and curvature anomaly.
[0129] Based on the sub-pixel precision coordinates of all boundary corner points within the continuous characteristic interruption region, calculate the cumulative path length between adjacent boundary corner points along the sequential index direction within the continuous characteristic interruption region (i.e., starting from the first corner point within the interruption region, calculate the straight-line distance between it and the next corner point, continue calculating the distance between the second and third corner points; and so on, until the distance between the second-to-last corner point and the last corner point is calculated; sum all these distances to obtain the cumulative path length of the interruption region along the boundary direction), as the length of the interruption region;
[0130] The sub-pixel precision coordinates of the length of the interrupted region and the effective curvature abrupt change position are used to form the suspected fracture position (that is, the sub-pixel precision coordinates are used as the positioning reference of the suspected fracture region, and the length of the interrupted region is used as the scale parameter of the suspected fracture region).
[0131] It should be noted that in the above steps, the effective curvature abrupt change location is used as the center, and a bidirectional search is performed along the contour index to find the boundary corner points where the curvature recovers to the stable fluctuation range, thus defining the boundary continuity interruption area; at the same time, the path distance between adjacent corner points within the interruption area is accumulated to obtain the length of the interruption area, and the suspected fracture location is generated by combining the coordinates of the abrupt change location; then, the bidirectional search is used to completely capture the curvature abnormal range, obtain the contour discontinuity range corresponding to the fracture defect, distinguish between large-scale contour deformation and local small fluctuations, completely preserve the spatial scale information of the fracture area, and form a dataset of suspected points that can be matched later;
[0132] S2443: Use all directional deviations from the abnormal region as the first coordinate set (that is, each directional deviation coordinate (geometric center point) in the set represents the position of a directional deviation from the abnormal region).
[0133] The subpixel precision coordinates of all suspected fracture locations are used as the second coordinate set (each coordinate point in the set represents a suspected fracture location).
[0134] The first set of coordinates is used as the row identifier, and the second set of coordinates is used as the column identifier (that is, they are arranged according to the order of coordinate positions, numbered according to the order of arrangement, and the numbers are used as row identifiers and column identifiers), and a corresponding relationship matrix is constructed (that is, the number of rows is equal to the number of elements in the first set of coordinates, and the number of columns is equal to the number of elements in the second set of coordinates).
[0135] The first coordinate point in the first coordinate set (i.e. the coordinate with abnormal direction deviation) is paired with the sub-pixel precision coordinate in the second coordinate set in turn to obtain row and column coordinate pairs, and the row direction difference and column direction difference are calculated.
[0136] The straight-line distance between the row direction difference and the column direction difference is filled into the corresponding relationship matrix to obtain the distance mapping matrix. (For each pair (A1 and B1, A1 and B2, A1 and B3...): compare the difference between the row coordinates of the two points (row direction difference), compare the difference between the column coordinates of the two points (column direction difference), combine the row direction difference and the column direction difference to determine the straight-line distance between the two points, and fill the calculated distance value into the corresponding position in the corresponding relationship matrix (row A1, column B1); after A1 and all B points in the first coordinate set have been calculated, take A2 and repeat the above process until all points in the first coordinate set have completed the distance calculation with all points in the second coordinate set. The final table is the distance mapping matrix, and each value in the matrix represents the spatial distance between the corresponding two points.)
[0137] It should be noted that the above-mentioned abnormal coordinates of directional deviation constitute the first coordinate set, and the coordinates of suspected fractures constitute the second coordinate set. The two sets of coordinates are used as row and column identifiers to build a corresponding relationship matrix. The straight-line distance between the coordinate points is calculated for each group and the matrix cells are filled to generate a distance mapping matrix. The matrix fully records the spatial distance relationship between all abnormal points of directional deviation and suspected fracture points, quantifies the spatial proximity relationship between the two sets of feature points, establishes a standardized comparison carrier, and facilitates the screening of spatial overlap.
[0138] S2444: Preset neighborhood overlap threshold (i.e., this threshold defines how close is considered spatially overlapping; if the distance between two points is less than this threshold, they are considered to overlap spatially; a distance threshold used to determine whether two coordinate points overlap spatially; its unit is pixels; preferably, the value range is [1.0, 5.0] pixels, more preferably 2.0 pixels).
[0139] If the straight-line distance between any unit element in the distance mapping matrix is less than the neighborhood overlap threshold, then the row and column coordinate pairs of the corresponding unit element are considered as spatially overlapping position pairs (i.e., if the current distance value is less than the neighborhood overlap threshold, it means that the two coordinate points corresponding to the distance value are very close in space and meet the overlap condition; for each selected distance value, find its position in the matrix (which row, which column); determine the corresponding directional deviation anomaly coordinate point (from the first coordinate set) according to the row number; determine the corresponding suspected fracture position coordinate point (from the second coordinate set) according to the column number; pair these two coordinate points to form a spatially overlapping position pair; for example, the 3rd row in the matrix). If the distance value in column 5 is less than the threshold, then the 3rd point in the first coordinate set is paired with the 5th point in the second coordinate set. Each pairing result contains a directional deviation anomaly coordinate and a suspected fracture coordinate. Spatial coincidence pair refers to a pair of coordinate points that match each other in spatial location after constructing a distance mapping matrix and performing neighborhood coincidence determination. One of them comes from the representative coordinate of the directional deviation anomaly region (macroscopic anomaly location), and the other comes from the center point coordinate of the suspected fracture region (microscopic anomaly location). The establishment of this pairing relationship means that the contour direction anomaly and the curvature change anomaly mutually confirm each other in space, thus confirming that the location is the real fracture point.
[0140] For the spatially overlapping position pairs, extract the suspected fracture positions inside as candidate real fracture positions, and count the number of candidate real fracture positions within the same connected domain (within the same foreground connected region).
[0141] If the number of candidate true fracture locations is greater than a preset threshold (i.e., the threshold used to determine whether an abnormal region contains enough candidate fracture points to confirm it as a true fracture; the unit is "number"; the preferred value range is [2, 5], and more preferably 3), then the number of boundary corner point indices between adjacent candidate true fracture locations (i.e., how many boundary corner points are between adjacent candidate true fracture locations) is calculated according to the sequential index of each candidate true fracture location along the contour direction (i.e., the contour direction of the boundary pixels).
[0142] If the number of boundary corner point indices is less than the preset merging threshold (i.e., the threshold for the number of corner point intervals used to determine whether two adjacent candidate fracture points in the same abnormal area should be merged into one fracture point; its unit is "corner points"; the preferred value range is [3, 10], and more preferably 5), then the adjacent candidate true fracture positions are merged into the final fracture position.
[0143] The coordinates of the fracture location are used as the subpixel precision coordinates of the true fracture location of the foreground connected region (i.e., the subpixel precision coordinates here are the true fracture location).
[0144] It should be noted that in the above steps, the distance mapping matrix is traversed by a preset neighborhood overlap threshold to filter out spatially overlapping position pairs and extract the corresponding suspected fracture points as candidate real fracture locations. At the same time, the method counts the number of candidate points in the same foreground connected region. When the number of corner points between adjacent candidate points meets the merging condition, point merging is performed, and finally, the real fracture coordinates with sub-pixel accuracy are output. The above method uses dual spatial matching verification of contour deflection features and curvature change features to distinguish between bending and crack fracture defects on the normal contour valve body arc surface or concave surface. At the same time, it completes the aggregation of adjacent fracture points, reduces duplicate marking, and finally obtains crack fracture points with stable accuracy and reliable location.
[0145] Meanwhile, by limiting the merging to areas deviating from the abnormal region in the same direction, this step effectively prevents multiple independent defects at the bends of different valve body arc or concave surfaces from being mistaken for a single defect. At the same time, by uniformly upgrading candidate points to candidate regions for management, the merging operation is logically a fusion of multiple spatially connected abnormal regions, rather than simply aggregating isolated points, and the result is more consistent with the physical morphology of fracture defects.
[0146] In the above steps, abnormal regions are identified from curvature fluctuation features, a two-way feature matching mechanism is constructed, and the identification of true and false defects is completed by relying on spatial overlap constraints. Geometric operations are performed based on sub-pixel coordinates throughout the process to suppress false detections caused by image noise and contour wrinkles, thereby improving the accuracy of crack fracture location identification and the regularity of the results.
[0147] Example 2
[0148] like Figure 8 As shown, the present invention also provides a valve body crack detection system for visual image detection, including: acquisition module 10, analysis module 20, and recognition module 30;
[0149] The acquisition module 10 is used to acquire the original image of the sample valve body, and preprocess the original image to obtain the image to be detected;
[0150] The analysis module 20 is used to uniformly segment the image to be detected into multiple local small regions; perform grayscale analysis on the local small regions to identify boundary pixels; perform gradient analysis on the boundary pixels to correct their coordinate positions and identify boundary corners; extract boundary corner windows according to a preset pixel window; obtain direction deflection values based on gradient identification of adjacent pixels within the boundary corner window; identify abnormal direction deviation regions of consecutive boundary corners based on the direction deflection values; filter boundary corners with starting index positions from the abnormal direction deviation regions; identify suspected breakage positions based on the left and right adjacent boundary corners of the boundary corners with starting index positions; and identify breakage positions based on the suspected breakage positions and the abnormal direction deviation regions.
[0151] The identification module 30 is used to take the fracture location as the final identification result of the sample valve body.
[0152] Example 3
[0153] On the other hand, this third embodiment, based on the visual image detection method for valve body crack detection provided in the first embodiment, also provides a computer storage medium 1140 (hereinafter referred to as the storage medium). For example... Figure 9 The diagram shown is a schematic of a computer storage medium structure framework provided in Embodiment 3 of the present invention, which includes:
[0154] Memory 1130 is used to store computer programs;
[0155] The communication interface 1120 is used to connect the memory 1130 to the processor 1110;
[0156] Processor 1110 is configured to execute a computer program to implement an embodiment of a visual image detection method for valve body crack detection, as disclosed in any combination of the above embodiments.
[0157] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; those skilled in the art can modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting valve body cracks using visual image detection, characterized in that, Specific operating methods include: The original image of the sample valve body is acquired, and the original image is preprocessed to obtain the image to be detected; The image to be detected is uniformly segmented to form multiple local small regions; grayscale analysis is performed on the local small regions to identify boundary pixels; gradient analysis is performed on the boundary pixels to correct their coordinate positions and identify boundary corners; boundary corner windows are extracted according to a preset pixel window; and the direction deflection value is obtained based on the gradient identification of adjacent pixels within the boundary corner window. Based on the direction deflection value, identify the abnormal direction deviation region of continuous boundary corner points; filter the boundary corner points with the starting index position in the abnormal direction deviation region; identify the suspected fracture position based on the left and right adjacent boundary corner points of the boundary corner point with the starting index position; identify the fracture position based on the suspected fracture position and the abnormal direction deviation region; The location of the fracture is taken as the final identification result of the sample valve body.
2. The method for detecting valve body cracks using visual image detection according to claim 1, characterized in that, The image to be detected is uniformly segmented to form multiple local small regions; grayscale analysis is performed on the local small regions to identify boundary pixels. The specific operation steps are as follows: The image to be detected is converted to grayscale, and the grayscale image is uniformly segmented to form multiple local small regions. The average grayscale value of the pixels within each local small region is calculated. If the grayscale value of a pixel within a local small region is greater than the average value, the pixel is designated as a foreground pixel. If the grayscale value of a pixel within a local small region is less than the average value, the pixel is designated as a background pixel. The foreground pixels and the background pixels are then combined to form a binary image to be detected. The binary image to be detected is traversed through each foreground pixel using an eight-connected neighborhood search algorithm, and the coordinate position of each foreground pixel is determined. Based on the coordinate position of each foreground pixel, adjacent foreground pixels are connected to form a foreground connected region. The coordinate position of the foreground pixel in the foreground connected region is determined, and it is determined whether the adjacent pixels of the foreground pixel are background pixels or other foreground connected regions. If any of the criteria is met, then the foreground pixel is taken as the boundary pixel.
3. The method for detecting valve body cracks using visual image detection according to claim 2, characterized in that, The boundary pixels are corrected by gradient analysis to identify boundary corners; boundary corner windows are extracted according to a preset pixel window; and the direction deflection value is obtained based on the gradient identification of adjacent pixels within the boundary corner window. The specific operation steps are as follows: A local analysis window is established by expanding a preset range of pixels centered on the boundary pixel; the grayscale gradient magnitude and gradient direction of each pixel are calculated within the local analysis window; the gradient magnitude of neighboring pixels is interpolated and fitted along the gradient direction to obtain a grayscale change curve; the coordinates of the boundary pixel between the maximum and minimum gradient magnitudes of the grayscale change curve are determined. Calculate the deviation of the boundary pixel's coordinate position from the gradient magnitude of the maximum value and the gradient magnitude of the minimum value, and use it as a two-dimensional offset vector; then, subtract the offset vector from the two-dimensional offset vector of the boundary pixel's coordinate position to obtain the corrected sub-pixel precision coordinates. Obtain the starting coordinates of all boundary pixels and slide a local window. Calculate the curvature response intensity of the window center point for this sliding local window. If the curvature response intensity is greater than a preset boundary corner discrimination threshold, then the window center point is recorded as a boundary corner point. Select any boundary corner point and trace it along the contour of all boundary pixels. Record the sub-pixel precision coordinates of all boundary corner points in sequence to form a boundary corner point coordinate sequence with an index identifier of the sub-pixel precision coordinate order. The sub-pixel row coordinates and sub-pixel column coordinates of the boundary corner points are extracted based on the boundary corner point coordinate sequence. The coordinate position in the image to be detected is located using the sub-pixel precision coordinates of the boundary corner points as the center, and a boundary corner point window is extracted according to a preset pixel window. The difference in grayscale values of the left and right adjacent pixels in the sub-pixel row coordinates of this boundary corner point window is calculated, and the set of all sub-pixel row coordinate differences is used as the first gradient component. The difference in grayscale values of the upper and lower adjacent pixels in the sub-pixel column coordinates of this boundary corner point window is calculated, and the set of all sub-pixel column coordinate differences is used as the second gradient component. Preset angle range; Calculate the ratio of the first gradient component to the second gradient component, map the ratio to the angle range, and extract the gradient direction angle value; Based on the sequential index of the boundary corner point coordinate sequence, the difference between the gradient direction angle values of adjacent boundary corner points is calculated sequentially and used as the direction deflection value.
4. The method for detecting valve body cracks using visual image detection according to claim 3, characterized in that, The following steps are taken: Identify abnormal directional deviation regions of continuous boundary corner points based on the directional deflection value; filter boundary corner points with starting index positions within the abnormal directional deviation regions; identify suspected fracture locations based on the left and right adjacent boundary corner points of the boundary corner points with starting index positions; and identify the fracture location based on the suspected fracture location and the abnormal directional deviation regions. For each directional deflection value, calculate the absolute difference to identify directional deviation anomaly regions at consecutive boundary corner points; identify the geometric center point of the directional deviation anomaly region as the directional deviation anomaly coordinate; filter the boundary corner point at the starting index position in the directional deviation anomaly region as the starting corner point, and filter the boundary corner point one position before and one position after the starting corner point to obtain three side length parameters; obtain the curvature value of the boundary corner point based on the three side length parameters; The suspected fracture location is identified based on the curvature value of the boundary corner point; the fracture location is obtained by coinciding with the coordinates of the suspected fracture location and the abnormal deviation in direction.
5. The method for detecting valve body cracks using visual image detection according to claim 4, characterized in that, For each directional deflection value, the absolute difference is calculated to identify abnormal directional deviation regions at consecutive boundary corner points; the geometric center point of the abnormal directional deviation region is identified as the coordinate of the directional deviation anomaly. The specific operation steps are as follows: For each directional deflection value, calculate the absolute difference. If the absolute difference is greater than the preset directional threshold, mark the adjacent boundary corner point pair corresponding to the absolute difference as the initial screening boundary corner point pair; filter continuous initial screening boundary corner point pairs to form an independent continuous initial screening boundary corner point pair sequence. The absolute value of all directional deflection values in the sequence of independent continuous initial screening boundary corner points is calculated, and all absolute values are summed to obtain the cumulative deviation value. If the cumulative deviation value is greater than the preset cumulative threshold, the independent continuous initial screening boundary corner point pair sequence is determined to be a direction deviation abnormal region; The average value of the subpixel row coordinates and the average value of the subpixel column coordinates are calculated for the boundary corner points in the directional deviation anomaly region to form the geometric center point, which is used as the directional deviation anomaly coordinate.
6. The method for detecting valve body cracks using visual image detection according to claim 5, characterized in that, The following steps are taken to select the boundary corner points in the abnormal region whose directions deviate from the starting index position as the starting corner points, and to obtain the three side length parameters by selecting the boundary corner points one position before and one position after the starting corner points: Select the boundary corner points in the abnormal region whose direction deviates from the starting index position as the starting corner points, and select the sub-pixel precision coordinates of the boundary corner points located before the starting corner points in the sequential index and the boundary corner points located after the starting corner points in the sequential index to form a continuous three-point spatial coordinate group. Extract the sub-pixel row coordinates of the starting corner point and the previous boundary corner point to calculate the first difference; extract the sub-pixel column coordinates of the starting corner point and the previous boundary corner point to calculate the second difference; determine the first side length of the spatial coordinate group of three consecutive points based on the first difference and the second difference; Extract the sub-pixel row coordinates of the starting corner point and the next boundary corner point to calculate the third difference; extract the sub-pixel column coordinates of the starting corner point and the next boundary corner point to calculate the fourth difference; determine the second side length of the spatial coordinate group of the three consecutive points based on the third difference and the fourth difference; Extract the sub-pixel row coordinates of the previous boundary corner point and the next boundary corner point to calculate the fifth difference; extract the sub-pixel column coordinates of the previous boundary corner point and the next boundary corner point to calculate the sixth difference; determine the length of the third side of the three consecutive point spatial coordinate group based on the fifth difference and the sixth difference; The first side length, the second side length, and the third side length form the three side length parameters of a continuous three-point spatial coordinate group; The longest and shortest side lengths are selected from the three side length parameters to establish a side length relationship; the circumcircle radius is extracted from the three side length parameters based on the side length relationship; the curvature value of the starting corner point is calculated using the circumcircle radius; Form a curvature value sequence from the curvature values of all boundary corner points.
7. The method for detecting valve body cracks using visual image detection according to claim 6, characterized in that, The suspected fracture location is identified based on the curvature value of the boundary corner point; the fracture location is then determined by aligning the suspected fracture location with the abnormal coordinates of the directional deviation. The specific operation steps are as follows: Effective curvature abrupt change locations are identified based on the curvature values of adjacent boundary corner points indexed in the curvature numerical sequence; suspected fracture locations are identified along the sequential indexing direction of the sub-pixel precision coordinates of all boundary corner points, using the effective curvature abrupt change location as the center point; a distance mapping matrix is generated based on the directional deviation anomaly coordinates of the abnormal region and the sub-pixel precision coordinates of the suspected fracture location; and the fracture location is generated based on the overlap of the directional deviation anomaly coordinates and the sub-pixel precision coordinates using the distance mapping matrix.
8. The method for detecting valve body cracks using visual image detection according to claim 7, characterized in that, The effective curvature abrupt change locations are identified based on the curvature values of adjacent boundary corner points indexed in the curvature numerical sequence. Suspected break locations are then identified along the sequential indexing direction of all boundary corner point sub-pixel precision coordinates, using the effective curvature abrupt change location as the center point. The specific operation steps are as follows: Based on the difference between the curvature values of adjacent boundary corner points indexed in the curvature value sequence, and further calculating the absolute value of the difference as the change amplitude value, a curvature change amplitude sequence is formed; if the change amplitude value is greater than a preset curvature threshold, the sub-pixel precision coordinates of the adjacent boundary corner points of the index corresponding to the change amplitude value are determined as candidate positions for curvature abrupt change. Using the candidate curvature abrupt change position as the center point, the corner index range is expanded by a preset number of corner points in the forward and backward directions of the boundary corner point coordinate sequence. The local variance and local range of the curvature values of each boundary corner point within the corner index range are calculated. If the local variance is greater than a preset variance threshold and the local range is greater than a preset range threshold, the candidate curvature abrupt change position is determined to be an effective curvature abrupt change position. Using the effective curvature abrupt change position as the center point, the curvature value of the first search along the sequential index direction of the sub-pixel precision coordinates of all boundary corner points is determined along the forward and backward directions. The first curvature value is then used as a preset stable fluctuation range, which is taken as the boundary continuity characteristic interruption region. Based on the sub-pixel precision coordinates of all boundary corner points within the continuity characteristic interruption region, the cumulative path length between adjacent boundary corner points along the sequential index direction within the continuity characteristic interruption region is calculated, which is taken as the interruption region length. The suspected fracture location is formed by combining the length of the interrupted region with the sub-pixel precision coordinates of the effective curvature abrupt change position.
9. The method for detecting valve body cracks using visual image detection according to claim 8, characterized in that, A distance mapping matrix is generated based on the directional deviation anomaly coordinates of the abnormal region and the sub-pixel precision coordinates of the suspected fracture location. The specific operation steps are as follows: The first coordinate set is formed by taking the coordinates of all directions deviating from the abnormal area; the second coordinate set is formed by taking the sub-pixel precision coordinates of all suspected fracture locations; the first coordinate set is used as the row identifier and the second coordinate set is used as the column identifier to construct a corresponding relationship matrix; the first coordinate point in the first coordinate set is paired with the sub-pixel precision coordinate in the second coordinate set in turn to obtain row and column coordinate pairs, and the row direction difference and column direction difference are calculated. The straight-line distance between the row direction difference and the column direction difference is filled into the corresponding relationship matrix to obtain the distance mapping matrix.
10. The method for detecting valve body cracks using visual image detection according to claim 9, characterized in that, The fracture location is generated based on the overlap between the directional deviation anomaly coordinates and the sub-pixel precision coordinates according to the distance mapping matrix. The specific operation steps are as follows: A preset neighborhood overlap threshold is set. If the straight-line distance between each unit element in the distance mapping matrix is less than the neighborhood overlap threshold, the row and column coordinate pairs of the corresponding unit element are taken as spatial overlap position pairs. Suspected break positions are extracted from the spatial overlap position pairs as candidate real break positions, and the number of candidate real break positions in the same connected domain is counted. If the number of candidate true fracture locations is greater than a preset threshold, the number of boundary corner indexes between adjacent candidate true fracture locations is calculated based on the sequential index of each candidate true fracture location along the contour direction; if the number of boundary corner indexes is less than a preset merging threshold, the adjacent candidate true fracture locations are merged into the final fracture location. The coordinates of the fracture location are used as the sub-pixel precision coordinates of the true fracture location of the foreground connected region.
