Inorganic mineral casting detection method based on image processing

By performing grayscale mutation and connectivity analysis on the surface image sequence of inorganic mineral castings, combined with edge path and direction consistency processing, the problem of insufficient casting detection accuracy in the existing technology is solved, and higher-precision defect identification is achieved.

CN120431087BActive Publication Date: 2025-09-26SHANDONG CLAREMONT NEW MATERIAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510874432.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-09-26
Estimated Expiration
2045-06-27

AI Technical Summary

Technical Problem

Existing inorganic mineral casting detection methods based on grayscale threshold segmentation and edge detection operators have difficulty in accurately determining the presence or absence of defects when dealing with shallow textures or atypical defects on the casting surface. In addition, the boundary extraction results are prone to local fractures or closed-loop failures, resulting in insufficient detection accuracy.

Method used

By acquiring a sequence of casting surface images, structural areas with grayscale mutations and stable connectivity are extracted, the edge position change path is established, a direction analysis window is set to evaluate the pixel gradient direction, a direction-consistent mask layer is generated, and finally the defect type is determined.

Benefits of technology

It improves the integrity of target area screening and the consistency of area judgment in image sequences, accurately identifies directional discrete areas, refines abnormal edge expression, and improves the accuracy of defect recognition and the ability to suppress misjudgment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120431087B_ABST
    Figure CN120431087B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image detection technology, specifically to an inorganic mineral casting detection method based on image processing, comprising the following steps: acquiring an image sequence, performing grayscale scanning, extracting connected regions, screening closed blocks, and generating candidates; establishing edge paths, analyzing position changes, and correcting contours to generate trajectory images; evaluating directional distribution and annotation consistency to generate a mask layer; extracting features to determine categories and generate annotated images; and analyzing angle differences to identify interrupted calibration positions and generate annotated layers. In the present invention, grayscale mutations and connected path extraction in image sequences enhance the integrity of target region screening, eliminate spatial offset interference through boundary trajectory stability analysis, and improve regional judgment consistency. The standard deviation of pixel gradient directions is evaluated to accurately identify discrete directional regions, improving the accuracy of attribution judgments. Boundary disturbance analysis refines abnormal edge expression, and strengthens the ability to consistently utilize image sequence information and distinguish abnormal features.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image detection, and in particular to an inorganic mineral casting detection method based on image processing. Background Art

[0002] The field of image detection technology encompasses techniques for analyzing and identifying the appearance, structure, morphology, or surface defects of target objects through image acquisition and processing. The core of this technical field lies in capturing images of target objects using optical imaging devices and then extracting, identifying, and determining the features contained in these images through image analysis methods, thereby enabling the detection and analysis of the target's physical state or quality. Image detection is widely used in a variety of fields, including industrial quality control, automated inspection, materials characterization, and biomedical image analysis. It involves a systematic technical framework, including image acquisition equipment, image processing algorithms, image recognition logic, and related inspection procedures.

[0003] Among them, the inorganic mineral casting inspection method based on image processing refers to the use of optical imaging equipment to capture images of inorganic mineral products after casting. Based on the grayscale distribution, texture distribution, or edge contour information of the surface features in the image, abnormal areas on the casting surface are extracted through image enhancement and segmentation operations. Subsequently, pattern recognition rules are used to perform feature comparison and morphological analysis on these areas to determine the presence of casting defects such as pores, cracks, shrinkage holes, and slag inclusions. In this method, visible light cameras or industrial imaging equipment are used for image acquisition. The image analysis process includes threshold segmentation based on grayscale statistics, edge detection operators to extract defect contours, feature areas, or morphological measurements. The overall process constitutes a standard inspection process from image input to defect determination.

[0004] When analyzing a single-frame image using conventional image processing methods based on grayscale threshold segmentation and edge detection operators, there is a problem of insufficient utilization of spatial information continuity. Image analysis focuses on the extraction of grayscale and contour features within a single-frame image, and lacks the tracking and modeling of the target state's evolution over time or space in the image sequence, which can easily lead to misidentification of short-term interference or image acquisition errors. For example, when there are shallow textures or atypical defects on the surface of a casting, the grayscale changes are not significant. Traditional methods have difficulty in determining whether they are real defects in the absence of multi-frame correlation support. Moreover, since the defect boundaries are mostly irregular in shape, the contour results extracted based on static operators have problems of local breaks or closed-loop failures, and cannot effectively restore the true boundary structure, affecting the accuracy of subsequent judgments. In the feature analysis stage, the existing methods have a coarse granularity in processing boundary direction information, making it difficult to refine the disturbance features within the judgment area, resulting in ambiguous attribution judgments between similar defects. There is a lack of targeted feature characterization mechanisms, making it difficult to meet the needs of high-precision detection in complex defect environments. Summary of the Invention

[0005] The purpose of the present invention is to solve the shortcomings of the prior art and to propose an inorganic mineral casting detection method based on image processing.

[0006] In order to achieve the above object, the present invention adopts the following technical solution: an inorganic mineral casting detection method based on image processing, comprising the following steps:

[0007] S1: Obtain a sequence of casting surface images, perform grayscale change scanning on each frame, extract structural regions with grayscale mutations and stable connectivity, select image blocks with closed boundary properties as detection targets, and generate defect candidate connected region blocks;

[0008] S2: Based on the image boundary information in the defect candidate connected region blocks, establish the edge position change path in the image sequence, analyze the position association of the block contours in the continuous images, exclude the boundary segments with sudden shifts in the spatial position direction, correct the region contour connection state, and generate a stable growth trajectory boundary image;

[0009] S3: Based on the edge path in the stable growth trajectory boundary image, a direction analysis window is set for the periphery to evaluate the concentration of the direction distribution of local pixels in the image, classify and label areas with strong direction dispersion, and generate a direction consistency mask layer;

[0010] S4: Based on the intact edge area retained in the directionally consistent mask layer, the structural and texture features of the corresponding image block are extracted, the category attribution judgment is completed according to the arrangement order of the feature attributes, the attribution results are layer-marked and managed, and a defect type attribution annotation image is generated.

[0011] As a further solution of the present invention, the defect candidate connected area block includes a closed-loop edge path, a grayscale mutation area, and a stable structure of a spatial coordinate set; the stable growth trajectory boundary image includes a contour continuous path, a boundary connection state, and a positional relationship between image frames; the direction consistency mask layer includes a directional gradient standard deviation distribution, a directional change discrete area, and a directional stable edge segment; the defect type attribution annotation image includes a structural feature label, a texture feature classification, and a layer attribution identifier.

[0012] As a further solution of the present invention, the specific steps of S1 are:

[0013] S101: After acquiring a sequence of casting surface images, scan each frame of the image for grayscale changes in sequence, extract pixels with prominent grayscale changes in the image, construct an initial structure region based on the pixel grayscale difference characteristics, extract pixel regions with continuous grayscale mutation characteristics, and generate grayscale mutation pixel distribution values;

[0014] S102: Based on the grayscale mutation pixel distribution value and the spatial adjacency relationship between pixels, a pixel set with connectivity characteristics is identified, and a pixel block group with coherent structure is retained to generate a number of pixels with stable connectivity structure;

[0015] S103: Extracting a set of pixel block edge coordinates based on the number of pixels in the stable connected structure, calculating a path distortion coefficient, determining whether the edge path forms a complete closed loop and has no jump breakpoints, retaining image blocks that meet the conditions as detection targets, and generating defect candidate connected area blocks.

[0016] As a further solution of the present invention, the specific calculation formula for calculating the path distortion coefficient is:

[0017] ;

[0018] in, represents the three-dimensional vector continuity index, Representative The direction vector of the segment edge path, Representative The normalized length of the segment path, represents the path smoothness adjustment factor, Representative The radian value of the vector angle at each corner, Represents the inverse of the radius of curvature at the corner, represents the geometric mean of the path lengths on both sides of the corner, Represents the number of corner feature points, Represents the total number of path segments.

[0019] As a further solution of the present invention, the specific steps of S2 are:

[0020] S201: Based on the image boundary information in the defect candidate connected region block, the coordinate values ​​of the block boundary points in the image frame are extracted, and the changes in the positions of the corresponding points between frames are sorted in sequence, and the change paths of the block edge positions along the frame sequence are collected to generate a sequence of edge position change path values;

[0021] S202: calling the edge position change path value sequence, analyzing the position changes of the starting and ending points of the boundary segments of the block outline in consecutive frames, identifying the boundary segments with sudden changes in the horizontal and vertical coordinates, and obtaining a boundary sequence after eliminating spatial sudden changes;

[0022] S203: Based on the boundary sequence after spatial mutation elimination, the trajectory relationship of the block outline connection points in the frame sequence is associated, the boundary connection state information between adjacent connection points is updated, the boundary trajectory of the block in the image sequence is established, and a growth trajectory boundary image is generated.

[0023] As a further solution of the present invention, the specific steps of S3 are:

[0024] S301: Based on the edge path position in the growth trajectory boundary image, a direction analysis window centered on the image pixel is set, grayscale change information of the pixel points in the window is extracted, the gradient direction of the pixel is determined according to the grayscale change trend, and a local pixel gradient direction angle value is generated;

[0025] S302: Arranging the direction angle sequence of pixels in the window according to the local pixel gradient direction angle value, extracting the amplitude characteristics of the direction change, and calculating the overall distribution of the angle fluctuation to generate a local direction change dispersion value;

[0026] S303: Based on the local directional variation discreteness value, determine whether the discreteness exceeds a set limit, mark the position of the corresponding area on the image, draw the area distribution in the binary layer, and generate a directional consistency mask layer.

[0027] As a further solution of the present invention, the specific steps of S4 are:

[0028] S401: extracting boundary contour pixels and grayscale distribution information based on the edge integrity area retained in the directionally consistent mask layer, screening regional blocks that meet pixel continuity requirements in combination with block indexes and spatial coordinates, and generating a number value of edge structure blocks;

[0029] S402: extracting grayscale features and texture gradient features within the block according to the corresponding positions of the edge structure block number values, constructing a feature vector based on grayscale differences in adjacent regions, calculating difference fusion parameters, arranging the blocks in order of grayscale mean values, and generating a block texture gradient arrangement sequence;

[0030] S403: Based on the block features in the block texture gradient arrangement sequence, determine the category to which the grayscale attribute belongs, record the block index and category number, mark the corresponding area in the mask layer, and generate a defect category layer annotation image.

[0031] As a further solution of the present invention, the specific calculation formula for calculating the difference fusion parameter is:

[0032] ;

[0033] in, Representative Tile and Grayscale-gradient fusion difference value of adjacent regions, Represents the grayscale value of the current tile Average grayscale value of adjacent blocks The absolute difference weight coefficient, Represents the grayscale value of the four adjacent direction blocks and its local mean The squared difference normalized coefficient, Represents the total number of adjacent tiles, Represents the current tile texture gradient amplitude, The fusion scaling factor representing the difference between gradient amplitude and grayscale.

[0034] As a further embodiment of the present invention, the method further comprises:

[0035] S5: Based on the defect type, the boundary area in the labeled image is set, a detection window is set for the extended neighborhood, the angle difference of the grayscale gradient direction of adjacent pixels is analyzed, the continuity interruption area of ​​the direction change is identified, the spatial position is calibrated, and a boundary disturbance concentrated labeling layer is generated;

[0036] The boundary disturbance concentrated annotation layer includes grayscale angle difference distribution, disturbance interruption area, and spatial position calibration information.

[0037] As a further solution of the present invention, the specific steps of S5 are:

[0038] S501: Based on the defect type classification, the boundary area in the labeled image is set, an extension neighborhood centered on the boundary pixel is set, the grayscale values ​​of adjacent pixels in the neighborhood are obtained, the distribution characteristics of the directional differences in the grayscale sequence are analyzed, the dense sections of directional changes are identified, and the grayscale directional difference change degree is generated;

[0039] S502: extracting pixel pairs with concentrated grayscale gradient direction changes in the neighborhood based on the grayscale direction difference change degree, analyzing the continuity state of the angle value, identifying the spatial position of the interruption, and generating the direction change interruption angle interval;

[0040] S503: Call the position coordinates in the direction change interruption angle interval, correspond them to the original image area, evaluate the local disturbance density level, identify the position set where the density value exceeds the critical range, and generate a boundary disturbance concentrated position distribution layer.

[0041] Compared with the prior art, the advantages and positive effects of the present invention are:

[0042] In this method, grayscale mutations and connected path extraction in image sequences enhance the integrity of target region screening. Boundary trajectory stability analysis eliminates spatial offset interference and improves the consistency of regional judgment. Standard deviation evaluation of pixel gradient directions accurately identifies discrete directional regions. Combined with masking, features are extracted from focused directional stable regions, improving the accuracy of attribution judgment. Boundary perturbation analysis refines the representation of abnormal edges, enhancing the ability to utilize consistent image sequence information and distinguish abnormal features, ultimately improving recognition accuracy and misjudgment suppression. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 It is a schematic diagram of the steps of the present invention. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0045] In the description of the present invention, it should be understood that the terms "length," "width," "up," "down," "front," "back," "left," "right," "vertical," "horizontal," "top," "bottom," "inside," "outside," and the like, indicating positions or relationships, are based on the positions or relationships shown in the accompanying drawings and are intended only to facilitate the description of the present invention and simplify the description. They do not indicate or imply that the devices or elements referred to must have a specific orientation, be constructed, or operate in a specific orientation. Therefore, they should not be construed as limiting the present invention. Furthermore, in the description of the present invention, "plurality" means two or more, unless otherwise expressly and specifically defined.

[0046] See also Figure 1 , an inorganic mineral casting detection method based on image processing, comprising the following steps:

[0047] S1: Obtain a sequence of casting surface images, perform grayscale change scanning on each frame, extract structural regions with grayscale mutations and stable connectivity, select image blocks whose edge pixels form a single closed-loop path in the spatial coordinate set and have no broken connections as detection targets, and generate defect candidate connected region blocks;

[0048] S2: Based on the image boundary information in the defect candidate connected region blocks, the edge position change path in the image sequence is established, the position association of the block contour in the continuous image is analyzed, the boundary segments with sudden shifts in the spatial position direction are excluded, the regional contour connection state is corrected, and a stable growth trajectory boundary image is generated;

[0049] S3: Based on the edge path in the stable growth trajectory boundary image, a directional analysis window is set for the periphery to evaluate the standard deviation of the local pixel gradient directional distribution in the image, identify areas where the degree of directional change dispersion exceeds the set limit, perform mask marking processing on the area, and generate a directional consistency mask layer;

[0050] S4: Based on the intact edge area retained in the directionally consistent mask layer, the structural and texture features of the corresponding image block are extracted, and the category attribution is determined according to the order of the feature attributes. The attribution results are marked and managed in layers to generate an image with defect type attribution annotations.

[0051] S5: Based on the defect type, the boundary area in the image is annotated, a detection window is set for the extended neighborhood, the angular difference in the grayscale gradient direction of adjacent pixels is analyzed, the continuity interruption area of ​​the direction change is identified, the spatial position calibration is performed, and the boundary disturbance concentrated annotation layer is generated.

[0052] The defect candidate connected area blocks include closed-loop edge paths, grayscale mutation areas, and stable structures of spatial coordinate sets. The stable growth trajectory boundary images include contour continuous paths, boundary connection states, and positional relationships between image frames. The direction consistency mask layers include direction gradient standard deviation distribution, direction change discrete areas, and direction stable edge segments. The defect type attribution annotation images include structural feature labels, texture feature classifications, and layer attribution identifiers. The boundary disturbance set annotation layers include grayscale angle difference distributions, disturbance interruption areas, and spatial position calibration information.

[0053] The specific steps of S1 are:

[0054] S101: After acquiring a sequence of casting surface images, scan each frame of the image for grayscale changes in sequence, extract pixels with prominent grayscale changes in the image, construct an initial structure region based on the pixel grayscale difference characteristics, extract pixel regions with continuous grayscale mutation characteristics, and generate grayscale mutation pixel distribution values;

[0055] After obtaining the casting surface image sequence, it is necessary to continuously shoot images at different angles through an industrial camera to form a complete image sequence, convert the images frame by frame into grayscale images, and use image processing tools to convert the color image into a single-channel image with a grayscale value range of 0 to 255. After the conversion is completed, the grayscale difference between each pixel and its adjacent pixels is scanned, and the grayscale mutation is analyzed point by point. A threshold value such as 30 is set as the judgment standard. When the grayscale difference between a certain point and its adjacent points exceeds the threshold, it is marked as a mutation pixel. For example, a grayscale increases rapidly from 120 to 190, and the difference is 70. It exceeds the threshold and can be identified as a grayscale mutation point. After traversing the entire image, the position information and corresponding difference of all mutation pixels are counted and recorded to generate a classification. The records are distributed, and cluster analysis is performed based on the grayscale difference. The grayscale values ​​can be divided into a low area of ​​0 to 85, a middle area of ​​86 to 170, and a high area of ​​171 to 255. The areas with obvious differences are defined as initial structural areas. For example, a group of grayscale points are located at the junction of middle and high grayscale, and are identified as potential structural anomalies. Then, it is determined whether it is a continuous mutation area. If the number of consecutive pixels reaches 5 or more and the grayscale difference is higher than the preset value, it is considered to constitute a continuous mutation structure. A set of weights can be set to perform weighted calculation on the pixel grayscale to highlight the edge direction. For example, multiple grayscale points on a boundary line are arranged in a manner that increases by more than 5 each time, and are marked as grayscale mutation areas. Finally, a data set containing the coordinates of all mutation areas and their mutation degrees is generated.

[0056] S102: Based on the grayscale mutation pixel distribution value and the spatial adjacency relationship between pixels, a pixel set with connectivity characteristics is identified, and a group of pixel blocks with coherent structure is retained to generate a number of pixels with stable connectivity structure;

[0057] After the grayscale mutation data set is formed, it is necessary to determine whether they are connected to each other based on the positional relationship between the mutation pixels. The four-way or eight-way adjacency principle is used for identification. For each mutation point, find out whether there are pixels around it that are also mutation points. If so, they are considered adjacent. All adjacent points are summarized into a connected group. All connected groups are constructed by traversing the image. Each group constitutes an independent pixel block. The number of pixels in each group is counted. For example, a group contains 12 mutation pixels, which is recorded as a stable pixel block. At the same time, it is judged whether it meets the minimum number standard. If it is greater than 10 points, it is valid. If it is less than 10 points, it is discarded. The position parameters of each retained pixel block are further extracted, including the center position of each group. The average coordinates of all points are calculated as the block marker point. The entire process retains all areas that meet the connectivity and have sufficient pixel number, and the pixel block number and quantity information are recorded separately to provide a basis for subsequent screening and processing.

[0058] S103: Extracting a pixel block edge coordinate set based on the number of pixels in the stable connected structure, calculating a path distortion coefficient, determining whether the edge path forms a complete closed loop and has no jump breakpoints, retaining image blocks that meet the conditions as detection targets, and generating defect candidate connected region blocks;

[0059] The specific calculation formula for calculating the path distortion coefficient is:

[0060] ;

[0061] in, represents the three-dimensional vector continuity index, Representative The direction vector of the segment edge path, Representative The normalized length of the segment path, represents the path smoothness adjustment factor, Representative The radian value of the vector angle at each corner, Represents the inverse of the radius of curvature at the corner, represents the geometric mean of the path lengths on both sides of the corner, Represents the number of corner feature points, Represents the total number of path segments;

[0062] Parameter definition and data acquisition

[0063] Path direction vector ;

[0064] How to obtain: Extract Segment path start point and end point The pixel coordinates of

[0065] Calculation formula: ;

[0066] Normalized length ;

[0067] Acquisition method: Calculate the vector modulus and divide it by the image resolution ;

[0068] Calculation formula: ;

[0069] Path smoothness adjustment factor ;

[0070] Value setting: 0.15 (according to ISO9276-6:2008 industrial testing standard);

[0071] Fluctuation range: 0.1-0.2 (varies with image noise level);

[0072] Corner angle radian value ;

[0073] Acquisition method: Calculate the dot product of adjacent path vectors and the modulus length ratio

[0074] Calculation formula: ;

[0075] Inverse of curvature radius ;

[0076] Acquisition method: Three-point method to measure the 5-pixel coordinates before and after the corner point and fit the arc radius ;

[0077] Calculation formula: ;

[0078] Geometric mean ;

[0079] Acquisition method: Calculate the path length on both sides of the corner and The geometric mean

[0080] Calculation formula: ;

[0081] Actual example

[0082] Input Data

[0083] Number of path segments , number of corners ;

[0084] Coordinates of the third path: starting point ,end ;

[0085] Second corner vector: , ;

[0086] Parameter calculation

[0087] calculate: ;

[0088] calculate: ;

[0089] calculate: radian;

[0090] Measurements: 42.43 pixels → ;

[0091] calculate: ;

[0092] Formula calculation

[0093] Numerator: ;

[0094] Denominator: ;

[0095] Final result: ;

[0096] Result interpretation

[0097] The value 150.6 exceeds the preset threshold of 100, and it is determined that there is a jump breakpoint in the path;

[0098] Execution result: The candidate area is eliminated and no defective connected area block is generated.

[0099] The specific steps of S2 are:

[0100] S201: Based on the image boundary information in the defect candidate connected region block, the coordinate values ​​of the block boundary points in the image frame are extracted, and the changes in the positions of the corresponding points between frames are sorted in sequence. The change paths of the block edge positions along the frame sequence are collected to generate a sequence of edge position change path values;

[0101] First, each frame in the image sequence is divided into multiple tiles. Common edge detection methods, such as the Sobel or Canny operators, are then used to extract the coordinates of each tile's boundary points. These boundary points are recorded as two-dimensional coordinates, and the boundary information for each tile within each frame is sequentially extracted and labeled. During this processing, the positions of the tile boundary points in successive frames are paired in chronological order, and their positional changes are recorded point by point. Distance calculations are used to determine the extent of these changes. The displacements of each pair of boundary points are extracted and sorted, forming a trajectory of the tile edge's path across the image frame sequence. Taking a traffic surveillance image as an example, if the movement distance of the boundary point of the same block in 10 consecutive frames is 1.2, 1.5, 1.8, 2.1, 2.2, 2.0, 2.3, 2.1, and 1.9 pixels, respectively, then the change trajectory of the point in the entire frame sequence can be classified and organized. The boundary path changes of all blocks are merged to form a two-dimensional data table, where each row represents a boundary point of a block and the columns represent the position change values ​​between frames. This process is applied to the dynamic tracking of block boundaries in video detection to complete the sequence collection of edge paths.

[0102] S202: Calling the edge position change path value sequence, analyzing the position changes of the starting and ending points of the boundary segments of the block outline in consecutive frames, identifying the boundary segments with sudden changes in the horizontal and vertical coordinates, and obtaining the boundary sequence after eliminating spatial sudden changes;

[0103] First, the start and end positions of contour segments in adjacent frames are obtained. The displacement of the start and end points in adjacent frames is calculated and compared with a set change threshold to determine whether there is a significant change. Using a threshold of 2 pixels as the standard, if a contour segment moves 1.2 pixels at its start point and 1.4 pixels at its end point between frame 1 and frame 2, it is considered a non-mutation segment. If the start and end points of another segment move 3.5 and 3.8 pixels, respectively, it is considered a mutation segment. All boundary segments identified as mutations are eliminated, resulting in a boundary contour sequence that eliminates abnormal movement. During data screening, contour segment changes are classified into three levels: low (less than 1 pixel), medium (1 to 2 pixels), and sudden (≥2 pixels). In video frames with an image resolution of 640 × 480 pixels, a change of less than 1 pixel is considered micro-motion, while a change of more than 2 pixels is considered significant. The entire processing process analyzes boundary segments segment by segment in a loop, updating the contour boundary segment set and retaining only those with stable changes in consecutive frames as the basis for subsequent trajectory construction.

[0104] S203: performing association processing on the trajectory relationship of the block outline connection points in the frame sequence according to the boundary sequence after spatial mutation elimination, updating the boundary connection state information between adjacent connection points, establishing the boundary trajectory of the block in the image sequence, and generating a growth trajectory boundary image;

[0105] Based on the sequence of contour boundary segments after mutation elimination, a trajectory is constructed for the boundary connection points of each tile in the image sequence. This process involves identifying adjacent contour connection points within the image frames and comparing their positional relationships across consecutive frames. A connection point pair whose displacement change within three frames is less than 1.5 pixels is considered continuous; those exceeding this value are considered discontinuous. A three-frame sliding window is used to traverse each connection point pair, updating the connection status flag, marking it as "continuous" or "discontinuous." For example, in a traffic scene, a tile boundary point pair with a displacement of 1.1, 1.3, and 1.2 pixels in consecutive frames is considered continuous; if it reaches 2.5 pixels in one frame, it is considered discontinuous. The resulting status flags are recorded in a connection state array. The corresponding connection relationships within the image frames are plotted point by point, and all boundary line segments marked as continuous are constructed in each frame. By visually plotting the contour line segments, a boundary growth trajectory map for the tile across the entire frame sequence is generated. This process can be implemented using image processing tools, such as using a drawing function to batch output continuously connected line segments to a blank image to generate a complete boundary trajectory map.

[0106] The specific steps of S3 are:

[0107] S301: Based on the edge path position in the growth trajectory boundary image, a direction analysis window centered on the image pixel is set, grayscale change information of the pixel points within the window is extracted, the gradient direction of the pixel is determined according to the grayscale change trend, and the local pixel gradient direction angle value is generated;

[0108] First, a pixel on the edge path is identified and set as the analysis center. A 5×5 pixel directional analysis window is constructed around this point, encompassing a total of 25 pixels. The grayscale values ​​of all pixels within this window are extracted one by one to form a grayscale matrix. Using the grayscale of the central pixel as a reference, the grayscale differences between the surrounding pixels and the central pixel are calculated. The distribution of these differences in eight principal directions is statistically analyzed: horizontal, vertical, two sets of diagonal directions, and each pair of angular directions. A sequence of grayscale values ​​is extracted along each direction and a difference-by-difference analysis is performed to identify the trend and determine the direction with the most dramatic grayscale change. Specifically, the direction with the largest sum of differences across all directions is identified as the primary gradient direction for the central pixel, and its corresponding angle is recorded. For example, in a plant edge image, if the grayscale differences around a pixel in the northeast direction are continuously large, the northeast direction is considered the primary gradient direction, and the corresponding angle is recorded as 45 degrees. This process is applied to every edge path pixel in the image, ultimately resulting in an angle value image of the same size as the original image, representing the local gradient direction of each edge pixel.

[0109] S302: Arranging the direction angle sequence of pixels in the window based on the local pixel gradient direction angle value, extracting the amplitude characteristics of the direction change, and calculating the overall distribution of the angle fluctuation to generate a local direction change dispersion value;

[0110] Based on the gradient direction angle value for each pixel obtained in the previous processing, the angle sequence of all pixels within each analysis window is extracted. The direction angle differences between adjacent pixels are compared pairwise, and the absolute value of the angle difference is recorded. When the angle difference crosses the boundary between 0 and 360 degrees, periodic adjustments are performed to maintain the angle difference between 0 and 180 degrees. All angle differences are then counted, and the standard deviation of this angle sequence is calculated to reflect the degree of dispersion of direction changes within the window. Large angle fluctuations and frequent jumps in angle direction result in a large standard deviation, indicating significant direction differences. For example, if the direction angles of pixels within the window are 45, 50, 47, 53, and 49 degrees, respectively, the adjacent differences are 5, 3, 6, and 4 degrees, respectively. The overall fluctuation is small, resulting in a low standard deviation. However, if the angles are 45, 70, 120, 180, and 240 degrees, the differences are 25, 50, 60, and 60 degrees, respectively, indicating a significantly higher standard deviation. The above process is applied to all pixels in the entire image to generate a directional change dispersion layer to indicate the degree of directional fluctuation of each pixel in the image.

[0111] S303: Based on the local directional variation dispersion value, determine whether the dispersion exceeds a set limit, mark the position of the corresponding area on the image, draw the area distribution in the binary layer, and generate a directional consistency mask layer;

[0112] For the discreteness value of each pixel in the direction change discreteness layer, a fixed judgment threshold is set, such as 10 degrees as the judgment benchmark, and the discreteness value of each pixel is compared. If its value exceeds this threshold, it is considered that there is a significant direction change in the area to which the pixel belongs. Mark the pixel positions that meet the conditions, and construct a binary layer on a new image layer. In the initial state, all pixels are 0, indicating no significant change. When it is found that the discreteness of a certain pixel is higher than the threshold, the corresponding position value is modified to 1, indicating an inconsistent direction area. In practical applications, if the discreteness of a pixel position in the image is 12.7 degrees, which exceeds the preset threshold, it will be recorded as 1 in the mask layer; if the discreteness of a pixel is 7.2 degrees, which is lower than the threshold, the corresponding mask value remains 0. The final mask layer clearly marks the area where the direction change is concentrated in the entire image, and is suitable for identifying texture mutations, complex edge areas or abnormal target contours.

[0113] The specific steps of S4 are:

[0114] S401: Based on the edge integrity area retained in the directionally consistent mask layer, extract the boundary contour pixels and grayscale distribution information, combine the tile index and spatial coordinates, screen the area tiles that meet the pixel continuity requirements, and generate the edge structure tile quantity value;

[0115] First, edge detection methods such as the Sobel or Canny algorithm are used to identify the gradient direction and intensity information in the image. After calculating the gradient direction at each pixel, continuous edge regions are screened based on the directional consistency between pixels. Regions with complete closed boundary characteristics are designated as retained regions. Next, boundary contour pixels within these regions are extracted. Contour tracing can be used to traverse point by point from the edge pixels, recording the spatial coordinates and grayscale value of each contour point. At the same time, the image is divided into equally spaced blocks based on the image size, such as 64×64 pixels per block. Block indexes and their spatial coordinate information are established one by one. The edge density within the block is calculated by counting the number of contour pixels contained in each block. If a block contains 850 edge pixels and the total number of pixels is 4096, the edge density of the block is 20.7%. If the screening criterion is set to 20%, the block is considered to meet the pixel continuity requirement, retained, and its number is added to the edge structure block set. All blocks of the image are traversed again, and the number of blocks that meet the density condition is accumulated as the final edge structure block number value.

[0116] S402: extracting grayscale features and texture gradient features within the block based on the corresponding positions of the edge structure block number values, constructing a feature vector based on the grayscale differences of adjacent regions, calculating the difference fusion parameters, arranging the blocks in order of grayscale mean values, and generating a block texture gradient arrangement sequence;

[0117] The specific calculation formula for calculating the difference fusion parameters is:

[0118] ;

[0119] in, Representative Tile and Grayscale-gradient fusion difference value of adjacent regions, Represents the grayscale value of the current tile Average grayscale value of adjacent blocks The absolute difference weight coefficient, Represents the grayscale value of the four adjacent direction blocks and its local mean The squared difference normalized coefficient, Represents the total number of adjacent tiles, Represents the current tile texture gradient amplitude, The fusion scale factor representing the difference between gradient amplitude and grayscale;

[0120] Current tile grayscale value The average grayscale value of 8 adjacent blocks is collected by infrared thermal imager Calculated from the regional grayscale histogram.

[0121] Absolute difference weight coefficient According to the gray standard deviation pass Dynamic adjustment, the coefficient increases linearly with the increase of grayscale distribution dispersion.

[0122] Grayscale values ​​of adjacent four direction blocks 、 、 、 Obtained by regional block scanning, local mean Calculated by the arithmetic average of the grayscale of the four neighborhoods.

[0123] Normalized squared difference coefficient According to the local contrast pass Confirmed, the contrast increases by a factor of 0.15 for every 1 unit increase.

[0124] Texture gradient amplitude After the Sobel operator convolution calculation, the modulus value is taken and the scale factor is integrated Based on the gradient standard deviation pass Dynamic settings.

[0125] The formula calculation process is carried out step by step:

[0126] Numerator calculation:

[0127] ;

[0128] Denominator calculation:

[0129] ;

[0130] ;

[0131] Gradient term calculation:

[0132] ;

[0133] Final result synthesis:

[0134] ;

[0135] The result shows that the fusion difference between the current block and the adjacent area reaches 5.981, which is directly involved in the construction of the feature vector. The larger the value, the more significant the grayscale difference and texture gradient comprehensive features between regions. The values, when arranged in ascending order, form a texture gradient arrangement sequence.

[0136] S403: Based on the block features in the block texture gradient arrangement sequence, determine the category to which the grayscale attribute belongs, record the block index and category number, mark the corresponding area in the mask layer, and generate a defect category layer annotation image;

[0137] According to the feature information of each block recorded in the tile texture gradient arrangement sequence, the block category is determined by the grayscale mean, and the grayscale range is divided into three segments: 0 to 85 is low grayscale, 86 to 170 is medium grayscale, and 171 to 255 is high grayscale. According to this division standard, each block is determined according to its grayscale mean and assigned a corresponding number. For example, the block with a grayscale mean of 132 is classified into the medium grayscale category and is numbered 2. The index position and corresponding category number of each block are recorded one by one, and then the block position is marked with the category number in the mask layer. For example, numbers 1, 2, and 3 represent low, medium, and high categories, respectively. The corresponding block area is filled with specific grayscale values, for example, low grayscale is marked as 50, medium grayscale is 128, and high grayscale is 200. After the processing is completed, a defect category layer annotation image containing all block category marks is generated.

[0138] The specific steps of S5 are:

[0139] S501: Annotate the boundary area in the image based on the defect type, set an extension neighborhood centered on the boundary pixel, obtain the grayscale values ​​of adjacent pixels in the neighborhood, analyze the distribution characteristics of the directional difference in the grayscale sequence, identify the dense segments of directional change, and generate the grayscale directional difference change degree;

[0140] First, the image is processed by the edge detection method. The common method is to use grayscale gradient operators such as Canny or Sobel to extract boundary pixels, and then construct a neighborhood area of ​​fixed size with these pixels as the center. Usually the neighborhood size can be set to 5×5 or 7×7, and obtain the grayscale values ​​of all pixels in the neighborhood. The grayscale values ​​are sampled in multiple directions radiating from the center to form a directional grayscale sequence. Typical directions include horizontal, vertical and two groups of diagonal directions, a total of 8 main directions. The grayscale difference between the neighborhood pixels and the central pixel in each direction is calculated, and the sum of the grayscale differences between multiple consecutive pixels in the same direction is counted. The sum reflects the degree of grayscale change in that direction. , then the grayscale change values ​​in the eight directions are sorted and normalized to identify the direction set with the most obvious grayscale direction change. Further first-order difference processing is performed on these directions to find the direction segments with drastic grayscale difference changes. For example, in the image area containing crack defects, if the boundary pixel is located at coordinates 120, 80, a 5×5 neighborhood is selected, and the grayscale sequence is 130, 133, 136, 140, 142, etc. After calculating the grayscale difference in multiple directions, it can be found that the change amplitude of the 45-degree and 90-degree directions is significant. Further detection of the local difference density concentration area in this direction is summarized as the direction band with prominent direction change, which is the concentrated segment identifier of the grayscale direction difference change.

[0141] S502: extracting pixel pairs with concentrated grayscale gradient direction changes in the neighborhood based on the grayscale direction difference change degree, analyzing the continuity state of the angle value, identifying the spatial position of the interruption, and generating the direction change interruption angle interval;

[0142] Based on the grayscale directional difference change, pixel pairs with significant grayscale gradient directional changes are extracted from the neighborhood. Filtering is performed based on whether the directional change value exceeds a set threshold. The threshold is set based on the average value and fluctuation range of the overall image grayscale difference change, which can be set to the average value plus twice the standard deviation. The filtered pixel pairs have directional mutation characteristics. Then, the directional angle value is calculated for the direction of the line connecting each pair of pixels. Each directional angle is obtained by geometric calculation based on the pixel coordinate position. The angle sequence is arranged and the continuity of adjacent angles in the sequence is tested using a sliding window. If the difference between two adjacent angles exceeds 15 degrees, it is judged as a discontinuity point. All position intervals where angle jumps occur are counted and classified into the directional discontinuity angle range. The corresponding image coordinate positions are recorded. For example, if the angles in a sequence are 10 degrees, 13 degrees, 15 degrees, 18 degrees, 55 degrees, and 60 degrees, the directional change discontinuity segment is from 18 degrees to 55 degrees. A list of these positions is generated for the next stage of analysis.

[0143] S503: Recall the position coordinates in the direction change interruption angle interval, map them to the original image area, evaluate the local disturbance density level, identify the location set where the density value exceeds the critical range, and generate a boundary disturbance concentrated location distribution layer;

[0144] All position coordinates in the directional interruption angle interval are mapped to the original image area. A fixed neighborhood window of, for example, 7×7 pixels is set for each coordinate point. The number of directional interruption angle points in the neighborhood is counted and the disturbance density is calculated by comparing it with the total number of pixels in the neighborhood. The total number of neighborhood pixels is 49. If the number of interruption points exceeds the set threshold, the neighborhood is considered to be a disturbance-intensive area. This threshold can be calculated based on the global disturbance density level of the image. For example, if the average disturbance density is 12% and the standard deviation is 5%, the threshold can be set to 12% plus 1.5 times the standard deviation, that is, 19.5%. All neighborhoods with disturbance density exceeding this threshold are classified as disturbance-intensive areas. The coordinates of each neighborhood center point that meets the conditions are boundary disturbance high-density points. For example, if multiple dense point coordinates such as 85, 115, 86, 116, 87, 117 appear in a certain area, it can be classified as a disturbance-intensive area. These coordinates are organized to form a boundary disturbance concentrated location distribution layer, which is output as a two-dimensional location layer.

[0145] The above are merely preferred embodiments of the present invention and do not limit the present invention in any other form. Any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall still fall within the scope of protection of the technical solution of the present invention.

Claims

1. An inorganic mineral casting detection method based on image processing, characterized in that: The following steps are involved: S1: Obtain a sequence of casting surface images, perform grayscale change scanning on each frame, extract structural regions with grayscale mutations and stable connectivity, select image blocks with closed boundary properties as detection targets, and generate defect candidate connected region blocks; S2: Based on the image boundary information in the defect candidate connected region blocks, establish the edge position change path in the image sequence, analyze the position association of the block contours in the continuous images, exclude the boundary segments with sudden shifts in the spatial position direction, correct the region contour connection state, and generate a stable growth trajectory boundary image; S3: Based on the edge path in the stable growth trajectory boundary image, a direction analysis window is set for the periphery to evaluate the concentration of the direction distribution of local pixels in the image, classify and label areas with strong direction dispersion, and generate a direction consistency mask layer; The specific steps of S3 are: S301: Based on the edge path position in the growth trajectory boundary image, a direction analysis window centered on the image pixel is set, grayscale change information of the pixel points in the window is extracted, the gradient direction of the pixel is determined according to the grayscale change trend, and a local pixel gradient direction angle value is generated; S302: Arranging the direction angle sequence of pixels in the window according to the local pixel gradient direction angle value, extracting the amplitude characteristics of the direction change, and calculating the overall distribution of the angle fluctuation to generate a local direction change dispersion value; S303: determining whether the degree of dispersion exceeds a set limit based on the local direction variation dispersion value, marking the position of the corresponding area on the image, drawing the area distribution in the binary layer, and generating a direction consistency mask layer; S4: Based on the intact edge area retained in the directionally consistent mask layer, the structural and texture features of the corresponding image block are extracted, the category attribution judgment is completed according to the arrangement order of the feature attributes, the attribution results are layer-marked and managed, and a defect type attribution annotation image is generated.

2. The inorganic mineral casting detection method based on image processing according to claim 1, characterized in that: The defect candidate connected area block includes a closed-loop edge path, a grayscale mutation area, and a stable structure of a spatial coordinate set. The stable growth trajectory boundary image includes a contour continuous path, a boundary connection state, and a positional relationship between image frames. The direction consistency mask layer includes a direction gradient standard deviation distribution, a direction change discrete area, and a direction stable edge segment. The defect type attribution annotation image includes a structural feature label, a texture feature classification, and a layer attribution identifier.

3. The inorganic mineral casting detection method based on image processing according to claim 1 is characterized in that: The specific steps of S1 are: S101: After acquiring a sequence of casting surface images, scan each frame of the image for grayscale changes in sequence, extract pixels with prominent grayscale changes in the image, construct an initial structure region based on the pixel grayscale difference characteristics, extract pixel regions with continuous grayscale mutation characteristics, and generate grayscale mutation pixel distribution values; S102: Based on the grayscale mutation pixel distribution value and the spatial adjacency relationship between pixels, a pixel set with connectivity characteristics is identified, and a pixel block group with coherent structure is retained to generate a number of pixels with stable connectivity structure; S103: Extracting a set of pixel block edge coordinates based on the number of pixels in the stable connected structure, calculating a path distortion coefficient, determining whether the edge path forms a complete closed loop and has no jump breakpoints, retaining image blocks that meet the conditions as detection targets, and generating defect candidate connected area blocks.

4. The inorganic mineral casting detection method based on image processing according to claim 3 is characterized in that: The specific calculation formula for calculating the path distortion coefficient is: ; in, represents the three-dimensional vector continuity index, Representative The direction vector of the segment edge path, Representative The normalized length of the segment path, represents the path smoothness adjustment factor, Representative The radian value of the vector angle at each corner, Represents the inverse of the radius of curvature at the corner, represents the geometric mean of the path lengths on both sides of the corner, Represents the number of corner feature points, Represents the total number of path segments.

5. The inorganic mineral casting detection method based on image processing according to claim 3 is characterized in that: The specific steps of S2 are: S201: Based on the image boundary information in the defect candidate connected region block, the coordinate values ​​of the block boundary points in the image frame are extracted, and the changes in the positions of the corresponding points between frames are sorted in sequence, and the change paths of the block edge positions along the frame sequence are collected to generate a sequence of edge position change path values; S202: calling the edge position change path value sequence, analyzing the position changes of the starting and ending points of the boundary segments of the block outline in consecutive frames, identifying the boundary segments with sudden changes in the horizontal and vertical coordinates, and obtaining a boundary sequence after eliminating spatial sudden changes; S203: Based on the boundary sequence after spatial mutation elimination, the trajectory relationship of the block outline connection points in the frame sequence is associated, the boundary connection state information between adjacent connection points is updated, the boundary trajectory of the block in the image sequence is established, and a growth trajectory boundary image is generated.

6. The inorganic mineral casting detection method based on image processing according to claim 5 is characterized in that: The specific steps of S4 are: S401: extracting boundary contour pixels and grayscale distribution information based on the edge integrity area retained in the directionally consistent mask layer, screening regional blocks that meet pixel continuity requirements in combination with block indexes and spatial coordinates, and generating a number value of edge structure blocks; S402: extracting grayscale features and texture gradient features within the block according to the corresponding positions of the edge structure block number values, constructing a feature vector based on grayscale differences in adjacent regions, calculating difference fusion parameters, arranging the blocks in order of grayscale mean values, and generating a block texture gradient arrangement sequence; S403: Based on the block features in the block texture gradient arrangement sequence, determine the category to which the grayscale attribute belongs, record the block index and category number, mark the corresponding area in the mask layer, and generate a defect category layer annotation image.

7. The inorganic mineral casting detection method based on image processing according to claim 6 is characterized in that: The specific calculation formula for calculating the difference fusion parameter is: ; in, Represents the grayscale-gradient fusion difference between the i-th block and the j-th adjacent area, Represents the grayscale value of the current tile Average grayscale value of adjacent blocks The absolute difference weight coefficient, Represents the grayscale value of the four adjacent direction blocks and its local mean The squared difference normalized coefficient, Represents the total number of adjacent tiles, Represents the current tile texture gradient amplitude, The fusion scaling factor representing the difference between gradient amplitude and grayscale.

8. The inorganic mineral casting detection method based on image processing according to claim 1 is characterized in that: The method further comprises: S5: Based on the defect type, the boundary area in the labeled image is set, a detection window is set for the extended neighborhood, the angle difference of the grayscale gradient direction of adjacent pixels is analyzed, the continuity interruption area of ​​the direction change is identified, the spatial position is calibrated, and a boundary disturbance concentrated labeling layer is generated; The boundary disturbance concentrated annotation layer includes grayscale angle difference distribution, disturbance interruption area, and spatial position calibration information.

9. The inorganic mineral casting detection method based on image processing according to claim 8, characterized in that: The specific steps of S5 are: S501: Based on the defect type classification, the boundary area in the labeled image is set, an extension neighborhood centered on the boundary pixel is set, the grayscale values ​​of adjacent pixels in the neighborhood are obtained, the distribution characteristics of the directional differences in the grayscale sequence are analyzed, the dense sections of directional changes are identified, and the grayscale directional difference change degree is generated; S502: extracting pixel pairs with concentrated grayscale gradient direction changes in the neighborhood based on the grayscale direction difference change degree, analyzing the continuity state of the angle value, identifying the spatial position of the interruption, and generating the direction change interruption angle interval; S503: Call the position coordinates in the direction change interruption angle interval, correspond them to the original image area, evaluate the local disturbance density level, identify the position set where the density value exceeds the critical range, and generate a boundary disturbance concentrated position distribution layer.

Citation Information

Patent Citations

  • Tool setting method of mechanical arm feeding type laser etching system

    CN111604598A

  • Industrial part defect detection method

    CN119515770A