Mechanical casting detection method and system based on image data analysis processing
By analyzing and processing image data, employing grayscale classification and multi-layer grid density sequences, the problem of multi-angle identification deviation in the inspection of mechanical castings was solved, achieving improvements in stability and accuracy, and enhancing the reliability and visualization effect of defect detection.
Patent Information
- Application Number
- CN202510792889.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-06-13
AI Technical Summary
Existing technologies for inspecting mechanical castings are easily affected by factors such as lighting, shooting angle, and local stains, leading to identification errors. They are difficult to achieve stable defect detection in multi-angle and multi-scale scenarios, and lack multi-image analysis methods, which affects the accuracy and completeness of the inspection.
Image data analysis and processing are used to form a multi-layer structure by gray-level classification, extract the layer grid density sequence, generate a trend direction region index table, unify the boundary gradient abrupt change points in multi-view images, and screen the stable boundary pixel point set to achieve defect annotation.
It improves the accuracy and stability of mechanical casting inspection, enhances the reliability and interpretability of inspection results, and improves the intuitiveness of defect visualization.
Smart Images

Figure CN120635581B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image recognition, and particularly relates to a mechanical casting detection method and system based on image data analysis processing. BACKGROUND
[0002] The technical field of image recognition includes a technical system for automatically recognizing and classifying information in images using computer vision, image processing, and artificial intelligence methods. The core content of this technical field includes key technical links such as target detection, image segmentation, feature extraction, image classification, and image semantic understanding. Image recognition technology usually relies on numerical processing of low-level features such as image data grayscale, texture, and shape, and combines classification and discrimination models to recognize and analyze targets in images. This technology is widely used in medical image analysis, security monitoring, industrial quality inspection, autonomous driving, and remote sensing image interpretation, and has high automation and large-scale processing capabilities, enabling a complete technical process from image acquisition to information recognition.
[0003] Among them, the mechanical casting detection method based on image data analysis processing refers to using an image acquisition device to obtain the surface image of the mechanical casting, and identifying and processing the edge features, geometric shapes, and surface textures of the target region in the image, so as to realize the judgment of whether the mechanical casting has defects. This patent subject mainly focuses on data acquisition, image preprocessing, and feature extraction in casting surface defect detection, and obtains effective structural information of the target region through image enhancement denoising, edge contour extraction, and binarization processing, and then combines the recognition method based on feature vector matching to classify and recognize the defect type, thereby completing the detection of casting defects.
[0004] The processing mode of gray scale, texture and edge recognition based on low-level image features has strong dependence on single image, and it is difficult to avoid recognition deviation caused by factors such as surface illumination, shooting angle or local stain. In the absence of multi-layer image expression structure support, the gray scale information presents a single distribution state in the image, making the transition area and the normal area of part of the edge tend to be consistent in feature expression, resulting in an increase in misjudgment rate. Since the statistical trend of regional density change is not carried out, the existing technology does not have effective capture ability for small-scale but continuous texture abnormalities, and early defect signals are easily missed. At the same time, the method of extracting edges from a single view and directly classifying them cannot make a reasonable judgment on the boundary stability, making the boundary recognition susceptible to local noise and increasing the risk of false detection and missed detection. Lack of multi-image analysis means based on spatial coordinate cross confirmation and stable pixel point screening leads to insufficient stability of the recognition result under multiple angles, making it difficult to adapt to image changes in production scenes. For example, in industrial detection, the image edge performance of the same casting under different angles has obvious differences, and the conventional method is prone to boundary jitter and recognition misplacement, thereby affecting the accuracy and integrity of defect labeling. The existing technology fails to establish a coordinate mapping and verification mechanism between images, limiting the generalization ability of the recognition effect in multi-angle and multi-scale scenes. SUMMARY
[0005] The purpose of the present application is to solve the problems existing in the prior art, and to provide a mechanical casting detection method and system based on image data analysis processing.
[0006] In order to achieve the above purpose, the technical scheme adopted by the present application is as follows: a mechanical casting detection method based on image data analysis processing, comprising the following steps:
[0007] S1: acquiring image data of the surface area of the casting, extracting pixel gray scale values, attributing the pixels according to gray scale based on a preset gray scale interval standard, dividing the results to form a multi-layer image structure in order of layers, and generating a gray scale layered atlas data set;
[0008] S2: calling the gray scale layered atlas data set, setting equal area grid division in the layers, counting the number of pixels in each grid in each layer to form a multi-layer density sequence, extracting continuous trend areas according to the change relationship in the density sequence, and generating a trend area index table;
[0009] S3: according to the trend area index table, extracting the corresponding images of the indicated area under multiple shooting angles, extracting boundary point sequences composed of boundary gradient mutation pixels in the area in each image, matching the boundary points under multiple angles according to the position correspondence, and generating a boundary overlap intersection coordinate matrix;
[0010] S4: calling the boundary coincidence intersection coordinate matrix, performing statistics on the spatial coordinate changes of the intersection points under multiple images, performing stability judgment on the lateral and longitudinal offset amounts, screening the intersection point set with a change amplitude lower than a set standard, and generating a stable boundary pixel point set.
[0011] As a further scheme of the present application, the gray scale layered graph data set comprises a multi-layer image structure, a gray scale interval standard, and a pixel gray value, the trend direction area index table comprises a multi-layer density sequence at a grid position, a pixel number change in an area, and a continuous trend area, the boundary coincidence intersection coordinate matrix comprises a boundary point sequence, a matching result under multiple viewing angles, and an intersection point mapping in a unified coordinate system, and the stable boundary pixel point set comprises a stable intersection point set, an image area with coordinate coincidence, and an intersection point with a change amplitude lower than a set standard.
[0012] As a further scheme of the present application, the specific steps of S1 are as follows:
[0013] S101: acquiring image data of a casting surface area, calling a pixel array of an image gray channel, reading a gray value corresponding to each pixel, establishing a mapping relationship between a pixel position and a gray value, and generating an image pixel gray matrix value;
[0014] S102: based on the image pixel gray matrix value, judging the gray attribution of a pixel according to a preset gray scale interval standard, classifying the pixel to a corresponding gray scale label, arranging the pixel positions corresponding to the gray scales, acquiring a gray scale label division coordinate group, and the like.
[0015] S103: according to the gray scale label division coordinate group, sequentially labeling the gray scale values of corresponding positions in an image, organizing a layer structure in the order of gray scale labels, integrating image data to form a multi-layer image structure, and acquiring a gray scale layered graph data set.
[0016] As a further scheme of the present application, the specific steps of S2 are as follows:
[0017] S201: calling the gray scale layered graph data set, dividing each layer of the image into an equal-area grid, identifying the spatial distribution position of a pixel in the grid, establishing a corresponding relationship between the grid position and the pixel distribution in the layer, and generating a grid pixel distribution value.
[0018] S202: based on the grid pixel distribution value, constructing a pixel number sequence of the same grid position in the layer, judging the continuous direction feature of the value change in the sequence, extracting a layer section with a single direction change, and generating a density sequence trend section value.
[0019] S203: according to the density sequence trend section value, comparing the change direction identifiers of adjacent grid positions, classifying the area combinations with a consistent continuous direction, demarcating the trend extension range in the layer, and generating a trend direction area index table.
[0020] As a further scheme of the present application, the specific calculation formula of the continuous direction feature of the value change in the sequence is:
[0021]
[0022] Calculate the direction consistency feature value to generate the density sequence trend section value;
[0023] Wherein, H represents the direction consistency feature value, x f represents the pixel number sequence value of the grid position f, s represents the total length of the sequence, |x f+1 -x f | represents the absolute difference value of the number of adjacent grid pixels, (x f+1 -x f ) represents the change direction of the number of adjacent grid pixels, represents the sequence sum of squares, and ∈ represents the minimum value of the zero constant.
[0024] As a further scheme of the present application, the specific steps of S3 are:
[0025] S301: Obtain the multi-angle image corresponding to the number in the trend direction area index table, locate the corresponding area position in the image, extract the pixel gray scale change feature in the area, mark the boundary pixel points according to the gray scale value mutation, construct the boundary point set in order, and generate the boundary point position sequence value of the area;
[0026] S302: Call the boundary points under the angle in the boundary point position sequence value of the area, extract the coordinate corresponding points under the same area according to the position relationship in the image, construct the matching pair set between the views, and generate the boundary corresponding point coordinate pair value between the views;
[0027] S303: According to the boundary corresponding point coordinate pair value between the views and the image shooting parameters, uniform conversion to the same coordinate system, calculate the intersection position under multiple views, and integrate to generate the boundary coincidence intersection coordinate matrix.
[0028] As a further scheme of the present application, the specific calculation formula of the matching pair set between the views is:
[0029]
[0030] Calculate the view matching degree index to generate the boundary corresponding point coordinate pair value between the views;
[0031] Wherein, M ik represents the matching weight value of the i-th view and the k-th view, Δx ij represents the absolute difference value of the j-th boundary point of the i-th view and the reference x coordinate, Δy ijAn absolute difference value between the jth boundary point of the ith view and a reference y coordinate, θ jk An projection inclination radian value of the jth boundary point under the kth view, Δφ ik An optical axis angle change amount between the ith view and the kth view, Δψ jk A curvature change amount of the jth boundary point under the kth view, A three-dimensional unit direction vector of the ith view, R represents a preset field of view overlap radius threshold, and n represents a current region effective boundary point quantity.
[0032] As a further scheme of the present application, the specific steps of S4 are:
[0033] S401: Call the pixel position of the intersection point in the image sequence in the boundary coincidence intersection point coordinate matrix, extract the coordinate information in sequence, establish the sequence set of the image position corresponding to the intersection point, integrate the image position information of the intersection point, and generate the intersection point pixel displacement data set;
[0034] S402: According to the coordinate change in the intersection point pixel displacement data set, extract the horizontal and vertical displacement amplitudes of the intersection point in the image sequence, set the upper limit of the offset as the judgment reference, screen the intersection point set meeting the condition, and generate the coordinate stability screening matrix;
[0035] S403: Call the intersection point set in the coordinate stability screening matrix, integrate the horizontal and vertical position information under the image, generate the average position point set of the intersection point, construct the boundary distribution according to the original index, and generate the stable boundary pixel point set.
[0036] As a further scheme of the present application, the method further comprises:
[0037] S5: Based on the stable boundary pixel point set, find the corresponding position in the original image, compare the position coordinates in the trend area index table, extract the image area with the same coordinates, perform labeling processing on the area image, and generate a defect labeling visualization image result;
[0038] The defect labeling visualization image result comprises a detection image after labeling processing, an original image fusion output result, and visual defect information.
[0039] The specific steps of S5 are:
[0040] S501: Based on the stable boundary pixel point set, extract the position coordinate information in the original image, and compare the coordinates in the trend area index table point by point, screen the image positions with the same coordinate values, and generate a coordinate coincidence area index value set;
[0041] S502: Call the coordinate coincidence region index value set, extract the corresponding region image content from the original image, and generate a set of pixel position sets that can be labeled according to the edge feature distribution of the image channel and the position that meets the boundary definition condition.
[0042] S503: Call the set of pixel positions that can be labeled, complete pixel value replacement processing at the corresponding position in the original image, add a uniform boundary identifier, and perform image fusion to generate a defect labeling visualization image result.
[0043] The mechanical casting detection system based on image data analysis processing comprises:
[0044] The image layering module acquires mechanical casting surface region image data, collects the gray value of the pixels in the image, makes attribution judgment according to the preset gray scale interval standard, divides the pixels into corresponding layers, organizes the layers according to the gray scale order, and establishes a gray scale layering atlas data set.
[0045] The density extraction module calls the gray scale layering atlas data set, sets an equal-proportion grid in the image region, counts the number of pixels contained in each grid in the layer, organizes the pixel distribution sequence of the grid under the difference layer, extracts the trend region index according to the continuous change of the pixel distribution, and generates a trend region index table.
[0046] The trend construction module calls the trend region index table, extracts the image content of the corresponding region under multiple shooting angles, obtains the gray gradient mutation points in the boundary range, forms a boundary point sequence, matches the boundary points according to the correspondence between the image view angle and the position, maps the intersection position in the unified coordinate system, and establishes a boundary coincidence intersection coordinate matrix.
[0047] The boundary mapping module calls the boundary coincidence intersection coordinate matrix, counts the spatial position change of the intersection points under the difference image view angle, judges whether the horizontal and vertical offset amplitudes are lower than the stability benchmark, selects the intersection point set with a smaller position change range, and generates a stable boundary pixel point set.
[0048] The defect labeling module calls the stable boundary pixel point set, finds the corresponding coordinates in the original image region, compares the position with the trend region index table, extracts the coordinate coincidence region for image labeling processing, outputs the fused image, and generates a defect labeling visualization image result.
[0049] Compared with the prior art, the advantages and positive effects of the present application are:
[0050] In the present application, the multi-layer structure is formed by image gray scale attribution division, the hierarchical expression of texture difference is enhanced, the trend area is extracted by layer grid statistical density sequence, the precise positioning of abnormal distribution is realized, the boundary gradient mutation points in multi-view images are uniformly mapped to generate intersection coordinate matrix, the stable intersection points are selected according to the spatial offset, the consistency and robustness of boundary recognition are improved, finally the stable boundary and trend area position are compared and labeled, the intuitiveness and reliability of defect visualization expression are improved, the process runs through gray scale layering, trend extraction, spatial matching and precise labeling, and the detection accuracy, stability and interpretability are enhanced. BRIEF DESCRIPTION OF DRAWINGS
[0051] Figure 1 It is a step flowchart of the present application.
[0052] Figure 2 It is a system module diagram of the present application. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical scheme and advantages of the present application more clear, the present application will be further described in detail below in combination with the drawings and examples. It should be understood that the specific examples described herein are only used to explain the present application and do not limit the present application.
[0054] In the description of the present application, it should be understood that the terms "length", "width", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as limiting the present application. In addition, in the description of the present application, the meaning of "a plurality of" is two or more, unless otherwise specifically limited.
[0055] Please refer to Figure 1 , the mechanical casting detection method based on image data analysis processing, comprising the following steps:
[0056] S1: obtaining image data of the surface area of the casting, extracting pixel gray value, judging the pixels according to the preset gray scale interval standard according to gray scale, organizing the divided results in order of layers to form a multi-layer image structure, and generating a gray scale layering atlas data set;
[0057] S2: calling the gray scale layering atlas data set, setting the grid division of the same area in the layer, counting the number of pixels in each layer of the grid, constituting a multi-layer density sequence at the grid position, extracting the continuous trend area according to the change relationship in the density sequence, and generating a trend area index table;
[0058] S3: Call the trend area index table, extract the corresponding image of the region under multiple shooting angles, extract the boundary point sequence composed of boundary gradient mutation pixels in each image, match the boundary points under multiple perspectives according to the position correspondence, and complete the intersection mapping in the unified coordinate system to generate a boundary intersection coordinate matrix;
[0059] S4: Call the boundary intersection coordinate matrix, and statistically analyze the spatial coordinate changes of the intersection points under multiple images, perform stability judgment on the horizontal and vertical offset, filter the intersection point set with a change amplitude lower than the set standard, and generate a stable boundary pixel point set;
[0060] S5: Call the stable boundary pixel point set, find the corresponding position in the original image, compare it with the position coordinates in the trend area index table, extract the image region with coordinate coincidence, perform labeling processing on the region image, and fuse it with the original image to output a detection image, and generate a defect labeling visualization image result.
[0061] The gray scale layered atlas data set includes a multi-layer image structure, a gray scale interval standard, and a pixel gray value. The trend area index table includes a multi-layer density sequence on the grid position, a pixel number change in the region, and a continuous trend area. The boundary intersection coordinate matrix includes a boundary point sequence, a matching result under multiple perspectives, and an intersection mapping in the unified coordinate system. The stable boundary pixel point set includes a stable intersection point set, an image region with coordinate coincidence, and an intersection point with a change amplitude lower than the set standard. The defect labeling visualization image result includes a detection image after labeling processing, an original image fusion output result, and visualized defect information.
[0062] Please refer to Figure 1 , the specific steps of S1 are as follows:
[0063] S101: Obtain image data of the surface region of the casting, call the pixel array of the image gray channel, read the gray value corresponding to each pixel, establish a mapping relationship between the pixel position and the gray value, and generate an image pixel gray matrix value;
[0064] When acquiring the image data of the surface area of the casting, first, an industrial camera with a gray scale acquisition function is used for shooting. A commonly used device is a CCD type, the camera resolution is set to 1280x1024, the image is stored in a gray scale 8-bit format, and the pixel value range is 0 to 255. After the image acquisition is completed, the image is imported through an image processing system and converted into a gray scale pixel matrix, each pixel corresponds to a unique coordinate position and a gray scale value. The reading process uses a line-by-line scanning method to record the row and column coordinates and the corresponding gray scale value of each pixel point, such as the gray scale of the pixel point at coordinate position 120 rows and 240 columns is 187, and the gray scale value at coordinate position 500 rows and 300 columns is 72. The system sequentially extracts all pixel gray scale values and combines them into a complete two-dimensional gray scale matrix. The matrix size is consistent with the image resolution, forming a pixel gray scale mapping structure for the surface area of the casting. This matrix structure provides a basis for subsequent gray scale interval determination and layer decomposition.
[0065] S102: Based on the image pixel gray scale matrix value, according to the preset gray scale interval standard, the gray scale of the pixel is judged and classified into the corresponding gray scale label, the pixel position corresponding to the gray scale is arranged, and the gray scale label division coordinate group is obtained;
[0066] According to the gray scale matrix structure, the gray scale interval division standard is set, for example, it can be divided into five gray scale level labels, which cover the full range of gray scale values from 0 to 255, and the specific intervals are first level 0 to 50, second level 51 to 100, third level 101 to 150, fourth level 151 to 200, and fifth level 201 to 255. Traverse all positions in the pixel matrix to obtain each gray scale value and judge its corresponding gray scale attribution, for example, a pixel with a gray scale of 187 belongs to the fourth level, and a pixel with a gray scale value of 45 belongs to the first level. The system classifies all pixel coordinates under the same gray scale label into a coordinate group, such as all pixels with a gray scale between 101 and 150 are classified into the third level label, and the corresponding positions form a coordinate set, which is used for subsequent layer generation. The entire gray scale determination process compares the gray scale value interval through classification conditions one by one to realize the classification and mapping of pixel classification attribution, and finally obtains the coordinate group data structure under the five gray scale labels.
[0067] S103: According to the gray scale label division coordinate group, the gray scale value of the corresponding position in the image is labeled one by one, the layer structure is organized according to the gray scale label order, the image data is integrated to form a multi-layer image structure, and the gray scale layered graph data set is obtained;
[0068] According to the divided gray scale label and its corresponding coordinate set, a plurality of layers are constructed, and each layer represents a gray scale level. In the initial step, an empty layer consistent with the size of the original image is established, and only the pixel positions belonging to the gray scale range of the layer are filled with the gray scale value in the original image, and the remaining positions are kept as 0 value background. For example, in the third level layer, only the pixel positions with gray scale values in the range of 101 to 150 have gray scale values, and the rest are all 0. In this way, five layers of layers are constructed, and each layer represents five gray scale intervals. After the layer construction is completed, the layers are organized in order according to the gray scale level, and are combined into an image data set with a layered structure. The structure is used for subsequent image analysis tasks such as regional analysis, distribution identification or anomaly identification, and each layer of image can be loaded and reviewed layer by layer through an image viewer, and the layer data set can be exported as a multi-page image format for further processing and archiving.
[0069] Referring to Figure 1 , the specific steps of S2 are:
[0070] S201: calling the gray scale layered atlas data set, dividing each layer of image into equal area grid, identifying the spatial distribution position of the pixels in the grid, establishing the corresponding relationship between the grid position and the pixel distribution in the layer, and generating the grid pixel distribution value;
[0071] Firstly, each layer of image needs to be converted into a two-dimensional gray scale matrix representation, and each matrix element represents the gray scale value of a pixel point. The layer is divided into a plurality of equal area grids, for example, when the image size is 1024x1024, it can be divided into a 32x32 grid structure, and each grid contains 1024 pixels. Then the spatial distribution of the pixels in each grid is identified, which can be achieved by recording the relative position of the pixel to the center of the grid and clustering the pixel gray scale value, for example, by dividing into three categories to form a preliminary distribution feature model. Then the number of pixels in each category and the concentration degree of the spatial distribution are counted, which are used to measure the pixel distribution value of the grid. The pixel distribution value can be obtained by average gray scale, gray scale standard deviation or information entropy, for example, if the pixel gray scale in a certain grid is concentrated between 120 and 140, the average gray scale value is 130, and the standard deviation is less than 10, indicating that the gray scale distribution of this area is relatively concentrated. Based on this value, a mapping table of all grids is established to realize the corresponding process of the grid position and the pixel spatial distribution in the layer. This process is suitable for scenes such as remote sensing images and geological survey maps.
[0072] S202: based on the grid pixel distribution value, constructing the pixel number sequence of the same grid position in the layer, judging the continuous direction feature of the value change in the sequence, extracting the layer section with single direction change, and generating the density sequence trend section value;
[0073] The specific calculation formula for judging the continuous direction feature of the value change in the sequence is:
[0074]
[0075] The direction consistency eigenvalue is calculated, and a density sequence trend section value is generated.
[0076] Wherein, H represents the direction consistency eigenvalue, x f represents the pixel number sequence value of the grid position f, s represents the total length of the sequence, |x f+1 -x f | represents the absolute difference value of the number of pixels of adjacent grids, (x f+1 -x f ) represents the change direction of the number of pixels of adjacent grids, represents the sequence square sum, and ∈ represents the zero constant prevention constant.
[0077] Data acquisition and parameter setting:
[0078] The pixel number sequence value of the grid position f=1 to f=5 in the monitoring image layer grid area is collected:
[0079] x f =[12, 15, 18, 14, 20];
[0080] The total length of the sequence s=5 is directly obtained through grid division.
[0081] Adjacent difference calculation:
[0082] The absolute difference value of the number of pixels of adjacent grids:
[0083] |x f+1 -x f |=[3, 3, 4, 6];
[0084] The change direction (sign) of the number of pixels of adjacent grids:
[0085] (x f+1 -x f )=[3, 3, -4, 6];
[0086] Sequence square sum calculation:
[0087]
[0088] Zero constant prevention setting:
[0089] ∈=0.001 is set according to the IEEE floating point operation standard, which is used to avoid zero denominator.
[0090] Numerator calculation:
[0091]
[0092] Denominator calculation:
[0093]
[0094] Final result:
[0095]
[0096] Result analysis:
[0097] The direction consistency feature value H≈1.058 is greater than zero, indicating that the pixel number change trend is dominated by positive growth. When generating the density sequence trend segment value, the continuous increasing region should be extracted first.
[0098] S203: According to the density sequence trend segment value, compare the change direction identifier of adjacent grid positions, classify the continuous direction consistent region combination, delineate the trend extension range in the layer, and generate the trend direction region index table;
[0099] First, the trend direction of each grid needs to be quantitatively processed. The angle difference of adjacent position distribution value can be used to calculate the direction identifier to determine whether the trend direction of two adjacent grids is consistent. By setting the judgment threshold of direction consistency, for example, the direction is considered consistent when the direction change angle is less than 15 degrees. Then, the adjacent direction consistent grids are combined to form continuous regions, which are classified into the same trend group. Subsequently, numbering processing is performed and the position index of each region is recorded, including the coordinates of the upper left corner and the lower right corner, which are used to indicate the extension range of the region in the layer. Finally, the trend direction region index table is generated, which records the basic information of each trend region, such as number, range boundary, average direction, and area. For example, a trend region with number T01 extends from coordinates (0, 0) to (128, 256) with a direction of north by east 10 degrees, covering 128 grids. Such information can be used to identify regions with continuous structure extension in layer analysis, such as identifying consistent trend segments of rock layers in rock layer images.
[0100] Please refer to Figure 1 , the specific steps of S3 are as follows:
[0101] S301: Obtain the multi-angle image corresponding to the number in the trend direction region index table, locate the corresponding region position in the image, extract the pixel gray scale change feature in the region, mark the boundary pixel points according to the gray scale value mutation, construct the boundary point set in order, and generate the region boundary point sequence value;
[0102] When the image corresponding to the number is acquired, the number item is first extracted from the region index table, the multi-view image information associated with the number is parsed, for example, the number Z023 corresponds to 3 images, named A_1, A_2 and A_3 respectively, and the corresponding view angles are recorded through camera identification. After loading the image data, the position of the target region in the image is determined according to the pixel range defined in the index table, such as the rectangular boundary points being the upper left corner 124,210 and the lower right corner 242,305, then the region image can be generated by cropping the range. After the image is processed by grayscale, the color image is converted to a grayscale image, all pixel points in the region are traversed, the grayscale change amplitude between adjacent pixels is calculated, whether it constitutes an edge point is distinguished according to a preset threshold, the pixel points with a grayscale gradient exceeding 20 are regarded as boundary point candidates, the boundary pixel position coordinates are extracted from left to right in sequence using an edge tracking algorithm, the boundary points are organized in order to form a boundary point set, for example, 85 boundary pixel points are extracted in the A_1 image of the Z023 region, the two-dimensional coordinate positions are recorded, and the complete boundary point sequence value is arranged in order.
[0103] S302: The boundary points at the angle in the region boundary point position sequence value are called, the coordinate corresponding points in the same region are extracted according to the position relationship in the image, a matching pair set between views is constructed, and a boundary corresponding point coordinate pair value between views is generated;
[0104] The specific calculation formula for constructing the matching pair set between views is:
[0105]
[0106] The view matching degree index is calculated, and the boundary corresponding point coordinate pair value between views is generated.
[0107] Wherein, M ik represents the matching weight value of the i th view and the k th view, Δx ij represents the absolute difference value of the j th boundary point of the i th view and the reference x coordinate, Δy ij represents the absolute difference value of the j th boundary point of the i th view and the reference y coordinate, θ jk represents the projection inclination angle radian value of the j th boundary point in the k th view, Δφ ik represents the optical axis angle change amount of the i th view and the k th view, Δψ jk represents the curvature change amount of the j th boundary point in the k th view, represents the three-dimensional unit direction vector of the i th view, R represents the preset field of view overlap radius threshold, and n represents the number of effective boundary points of the current region.
[0108] Δx ijThe x coordinate of the jth boundary point in the ith view minus the x coordinate of the reference coordinate system. The reference coordinate system is determined by the center point coordinate of the calibration board (512, 384). The measured Δx 12 = 3.2 pixels, Δx 23 = 5.7 pixels.
[0109] Δy ij The measured Δy 12 = 2.1 pixels, Δy 23 = 4.3 pixels.
[0110] θ jk Calculated from the multi-view geometric projection model, the θ of the 2nd boundary point in the 3rd view 23 = 0.785 radian (45 degrees), with an error range of ± 0.05 radian.
[0111] Δφ ik Obtained by binocular vision system calibration, Δφ of the 1st and 3rd views 13 = 0.349 radian (20 degrees), which meets the lens field of view angle constraint condition.
[0112] Δψ jk Calculated by point cloud curvature analysis, Δψ of the 2nd boundary point in the 3rd view 23 = 0.062 radian. The curvature calculation uses the average method of the included angle of the normal vector of the adjacent 5 points.
[0113] Three-dimensional unit direction vector v i Calculated after collecting the view attitude angle by the inertial measurement unit, v1 = (0.707, 0.707, 0) in the 1st view, v3 = (0.866, 0.5, 0) in the 3rd view, after normalization processing.
[0114] The R value is preset to 120 mm according to the device parameters, corresponding to 1.2 times the diagonal length of the CMOS sensor.
[0115] n = 5 is determined by the number of effective boundary points output by the image segmentation algorithm.
[0116] Example calculation:
[0117] When j = 2, the numerator is calculated as:
[0118] (|3.2 * sin 0.785| + |2.1 * cos 0.785|) = (3.2 * 0.707 + 2.1 * 0.707) = 3.763;
[0119] The denominator is calculated as:
[0120]
[0121] The result of the former fraction is:
[0122] 3.763 / 0.501≈7.511;
[0123] Vector cross product:
[0124]
[0125] The result of the latter fraction is:
[0126] 0.707 / 120≈0.00589;
[0127] The single cycle term is:
[0128] 7.511×0.00589≈0.0443;
[0129] Accumulate the traversal n=5 boundary points, and the actual measurement j=1~5 terms are 0.0382, 0.0443, 0.0517, 0.0401, 0.0489, and the total sum M_13=0.0382+0.0443+0.0517+0.0401+0.0489=0.223.
[0130] The result shows that the matching weight value of the first and third perspectives is 0.223, and when M_ik exceeds the preset threshold value 0.5, an effective matching pair is generated, and the current result needs to continue to optimize the matching pair set.
[0131] S303: According to the value of the boundary corresponding point coordinates between the perspectives and the image shooting parameters, convert to the same coordinate system, calculate the intersection position under multiple perspectives, and integrate to generate a boundary coincidence intersection coordinate matrix;
[0132] Based on the image coordinate values and shooting parameter information of the matching point pairs, coordinate system conversion operation is needed. First, read the camera intrinsic parameters such as focal length, principal point position, and pixel density of each image, and obtain the spatial position and direction information of the camera for calculating the relative relationship. The two-dimensional points in the image are back-projected into three-dimensional rays, and then the intersection point is calculated with the back-projected rays of the matching points under another perspective to form a three-dimensional coordinate value. The intersection position is determined by the nearest distance principle. If the two rays are not coplanar, the midpoint between them is taken as the estimated position. For each group of matching points, such intersection calculation is performed. For example, 65 groups of boundary point pairs in region Z023 are calculated to obtain 65 three-dimensional space coordinate points. Each coordinate point is described by three real values, which constitutes a matrix set for describing the spatial boundary structure.
[0133] Please refer to Figure 1 , and the specific steps of S4 are:
[0134] S401: Call the pixel position of the intersection in the image sequence in the intersection coordinate matrix of the boundary overlap, extract the coordinate information in the order of the image, establish the sequence set of the image position corresponding to the intersection, integrate the image position information of the intersection, and generate the intersection pixel displacement data set;
[0135] First, the image sequence and the intersection coordinate matrix need to be read. The coordinate matrix records the corresponding pixel positions of each intersection in different frames of images. For example, the positions of the first intersection in the first to tenth frames of images are 100, 200 to 110, 210 two-dimensional coordinates, respectively. By sequentially analyzing the image frames, the position of each intersection in the image is extracted frame by frame, recorded as a horizontal and vertical coordinate pair, and arranged in order according to the image sequence frame number to form a coordinate sequence of each intersection. For example, the image is 1920x1080 pixels, and each frame of image may contain multiple intersections, each intersection corresponding to a two-dimensional coordinate in each frame. The frame number sequence is traversed and data is extracted for all intersections to construct their corresponding image position data into a coordinate sequence set. Then, the coordinate information of all intersections in the image sequence is summarized and arranged into a data set with sequence dimension, recording the image frame sequence pixel trajectory information of all intersections, and assigning an image order identification number to each intersection to form the image displacement analysis data base set.
[0136] S402: According to the coordinate change in the intersection pixel displacement data set, the horizontal and vertical displacement amplitudes of the intersection in the image sequence are extracted, the upper limit of the offset is set as the judgment reference, the intersection set that meets the condition is selected, and the coordinate stability screening matrix is generated;
[0137] Based on the image frame sequence pixel data obtained in the previous step, the amplitude of the horizontal and vertical coordinates of each intersection changing with the frame number is calculated. The pixel change amplitude between consecutive frames can be obtained by the frame difference value. For each intersection, first calculate the horizontal displacement amplitude between adjacent frames, for example, subtract the horizontal coordinates of the first and second frames, then perform difference operation frame by frame, and the vertical coordinates are the same. Then take the absolute value of all frame difference values to obtain the average displacement amplitude of each intersection in the image sequence. According to the set pixel displacement judgment reference, for example, if the average displacement of the horizontal and vertical directions is not more than 3 pixels, it is considered that the intersection is stable in the image sequence. For example, the horizontal coordinate of a certain intersection changes from 100 to 99 in 5 frames of images, and the horizontal difference value sequence is 1, 1, 2, 1. The average of these values is 1.25 pixels, which is lower than the judgment upper limit of 3 pixels, meeting the stability requirement. By judging whether the displacement of each intersection exceeds the offset limit value, a Boolean screening result is formed, recording whether each intersection belongs to the stable set, and a stability judgment matrix is generated as input for subsequent boundary reconstruction.
[0138] S403: Call the intersection set in the coordinate stability screening matrix, integrate the horizontal and vertical position information under the image, generate the average position point set of the intersection, construct the boundary distribution according to the original index, and generate the stable boundary pixel point set;
[0139] All intersection numbers marked as stable are extracted from the stability judgment matrix, and then the mean value of all coordinate values of these intersections in the image sequence is calculated to obtain the average values of the horizontal and vertical coordinates. The average value calculation adopts the method of sum divided by the number of frames, for example, the horizontal coordinate of a certain intersection is 100 to 109 in 10 frames of images, and the average horizontal coordinate is 104.5, and the vertical coordinate is processed in the same way. After sorting, the average position point set of the stable intersection is obtained. Next, the stable points are reordered in space according to their numbering order in the original data, and the connection relationship of the boundary contour is established, for example, the stable points numbered 2, 4 and 6 are connected to form a boundary segment according to the original order. Finally, the average position of all stable points and the reconstructed boundary relationship are combined to generate a boundary pixel point set composed of stable intersections, which is used for further image processing or boundary reconstruction.
[0140] Please refer to Figure 1 , the specific steps of S5 are:
[0141] S501: Based on the stable boundary pixel point set, the position coordinate information in the original image is extracted, and the coordinates are compared point by point with the coordinates in the trend area index table to screen the image positions with the same coordinate values, and generate the coordinate coincidence region index value set;
[0142] First, the edge points are extracted from the original image, and the conventional edge detection method is used, such as determining the edge attribute by gradient difference or local gray level change. The points with similar positions and consistent gradient changes in consecutive images are classified into the boundary stable set. Then, based on this set, the horizontal and vertical coordinates of each pixel point are extracted, and compared with the coordinate values of each region in the trend area index table point by point. The trend area index table divides the entire image into several logical regions in advance, and each region contains a fixed number of pixel coordinate values, such as 512x512 size of the entire image, which can be divided into 40 equal regions, each region contains about 200 pixel points. The matching process realizes fast comparison by establishing an index structure, such as using space division to speed up the positioning of whether the boundary point belongs to a certain region. When it is detected that the coordinate of a stable pixel point is completely consistent with the coordinate in a certain region, the index number of this region is recorded into the set. After the comparison of all stable boundary points, a set of region index numbers is obtained, which points to all image regions with boundary coordinate coincidence.
[0143] S502: Call the coordinate coincidence region index value set, extract the corresponding region image content from the original image, and generate a set of pixel position sets that can be labeled according to the edge feature distribution of the image channel.
[0144] According to the region index number set, the image content of all corresponding regions in the original image is extracted, which can be divided into image blocks. Then the pixel content in the image block is decomposed into channels, such as red, green and blue three basic channels. The edge change characteristics are analyzed on each channel. The continuity and mutation degree of the gray scale change in the channel can be used to determine whether the edge is clear. The average amplitude of the change value is calculated and compared with the set reference value. For example, if the average amplitude of the change value of any channel in an image block exceeds 30, it is determined that the boundary is clear and the effective region. All pixel positions of such image blocks are recorded and added to the set of labelable regions. Assuming that 5 of the 8 image blocks extracted in the previous step meet the conditions, each block is 64x64 pixels, and a total of about 20480 pixels are included in the labeling preparation queue. These pixel position sets form the basis index for subsequent image modification and fusion.
[0145] S503: Call the pixel position set of the labelable region, replace the pixel value at the corresponding position in the original image, add a uniform boundary identifier, and perform image fusion to generate a defect labeling visualization image result.
[0146] After obtaining the pixel coordinate set of the labeling region, the corresponding pixel position in the original image is located, and the color replacement operation is performed at the position. The original pixel value is replaced with a uniform boundary color, such as red. Each target pixel is directly replaced with a set color value, while the original image is retained for subsequent image fusion processing. The fusion process weights and superimposes the contents of the two images according to the set proportion, such as setting the weight to 70% for retaining the original image content and the remaining 30% for superimposing the identification image content. Different regions can automatically adjust the weight distribution according to the boundary stability. The region with clearer boundary corresponds to higher proportion of identification image superposition intensity to strengthen the visual performance. Finally, a fused image is generated, which contains all the pixel replacement and superimposed identification region content, forming an intuitive and visible defect position presentation.
[0147] Please refer to Figure 2 , a mechanical casting detection system based on image data analysis processing, comprising:
[0148] The image layering module acquires mechanical casting surface region image data, collects the gray scale values of the pixels in the image, makes attribution judgments according to the preset gray scale interval standard, divides the pixels into corresponding layers, organizes the layers according to the gray scale level order, and establishes a gray scale layering atlas data set.
[0149] The density extraction module calls the gray scale layered atlas dataset, sets an equal proportion grid in the image area, counts the number of pixels contained in each grid in the layer, sorts the pixel distribution sequence of the grid under the difference layer, extracts the trend area index according to the continuous change of the pixel distribution, and generates a trend direction area index table;
[0150] The trend construction module calls the trend direction area index table, extracts the image content of the corresponding area under multiple shooting angles, obtains the gray gradient mutation points in the boundary range, forms a boundary point sequence, matches the boundary points according to the corresponding relationship between the image view angle and the position, maps the intersection position in the unified coordinate system, and establishes a boundary coincidence intersection coordinate matrix;
[0151] The boundary mapping module calls the boundary coincidence intersection coordinate matrix, counts the spatial position change of the intersection points under the difference image view angle, judges whether the horizontal and vertical offset amplitudes are lower than the stability benchmark, selects the intersection point set with smaller position change range, and generates a stable boundary pixel point set;
[0152] The defect labeling module calls the stable boundary pixel point set, finds the corresponding coordinates in the original image area, compares the position with the trend direction area index table, extracts the coordinate coincidence area for image labeling processing, outputs the fused image, and generates a defect labeling visualization image result.
[0153] The above is only a preferred embodiment of the present application, and does not limit the form of the present application, any skilled person in the art can use the disclosed technical content to make changes or modifications as equivalent embodiments applied to other fields, but any simple modification, equivalent change and modification made according to the technical essence of the present application to the above embodiments without departing from the technical solution content of the present application still belongs to the protection scope of the present application technical solution.
Claims
1. A method for detecting a mechanical casting based on image data analysis processing, characterized in that, The method comprises the following steps: S1: acquiring image data of a casting surface area, extracting pixel gray values, attributing pixels according to a preset gray interval standard, dividing the results according to a layer order to form a multi-layer image structure, and generating a gray layered atlas data set; S2: calling the gray layered atlas data set, setting equal-area grid division in the layer, counting the number of pixels in the grid in each layer image to form a multi-layer density sequence, extracting a continuous trend area according to the change relationship in the density sequence, and generating a trend direction area index table; S3: according to the trend direction area index table, extracting the corresponding images of the indicated area under multiple shooting angles, extracting the boundary point sequence composed of boundary gradient mutation pixels in each image, matching the boundary points under multiple perspectives according to the position correspondence, and generating a boundary overlapping intersection coordinate matrix; S4: calling the boundary overlapping intersection coordinate matrix, counting the spatial coordinate changes of the intersection points under multiple images, performing stability judgment on the horizontal and vertical offsets, screening the intersection point set with a change amplitude lower than a set standard, and generating a stable boundary pixel point set; S5: based on the stable boundary pixel point set, finding the corresponding position in the original image, comparing the position coordinates in the trend direction area index table, extracting the image area with coordinate overlap, performing labeling processing on the area image, and generating a defect labeling visual image result.
2. The mechanical casting inspection method based on image data analysis processing according to claim 1, characterized in that, The gray layered atlas data set comprises a multi-layer image structure, a gray interval standard, and pixel gray values. The trend direction area index table comprises a multi-layer density sequence on the grid position, a change in the number of pixels in the area, and a continuous trend area. The boundary overlapping intersection coordinate matrix comprises a boundary point sequence, a matching result under multiple perspectives, and an intersection point mapping in a unified coordinate system. The stable boundary pixel point set comprises a stable intersection point set, an image area with coordinate overlap, and an intersection point with a change amplitude lower than a set standard.
3. The mechanical casting inspection method based on image data analysis processing according to claim 1, characterized by, The specific steps of S1 are as follows: S101: acquiring image data of a casting surface area, calling a pixel array of an image gray channel, reading the gray value corresponding to each pixel, establishing a mapping relationship between the pixel position and the gray value, and generating an image pixel gray matrix value; S102: based on the image pixel gray matrix value, judging the gray attribution of the pixel according to a preset gray interval standard, classifying the pixel to a corresponding gray label, arranging the pixel position corresponding to the gray label, and acquiring a gray label division coordinate group; S103: according to the gray label division coordinate group, sequentially labeling the gray value of the corresponding position in the image, organizing a layer structure according to the gray label order, integrating the image data to form a multi-layer image structure, and acquiring a gray layered atlas data set.
4. The mechanical casting inspection method based on image data analysis processing according to claim 3, characterized in that, The specific steps of S2 are as follows: S201: calling the gray layered atlas data set, dividing each layer image into equal-area grids, identifying the spatial distribution position of the pixels in the grid, establishing a corresponding relationship between the grid position and the pixel distribution in the layer, and generating a grid pixel distribution value; S202: based on the grid pixel distribution value, the number of pixels of the same grid position in the layer is constructed, the continuous direction feature of the value change in the sequence is judged, the layer section with single direction change is extracted, and the density sequence trend section value is generated; S203: according to the density sequence trend section value, the change direction mark of adjacent grid position is compared, the area combination with consistent continuous direction is classified, the trend extension range in the layer is demarcated, and the trend direction area index table is generated.
5. The mechanical casting inspection method based on image data analysis processing according to claim 4, characterized in that, The specific calculation formula of the judgment sequence value change continuous direction feature is: ; The direction consistency feature value is calculated, and the density sequence trend section value is generated; wherein, representing a direction consistency feature value, representing a grid position a pixel number sequence value, representing a sequence total length, representing an adjacent grid pixel number absolute difference value, representing an adjacent grid pixel number change direction, representing a sequence square sum, representing a minimum value prevention zero constant.
6. The mechanical casting inspection method based on image data analysis processing according to claim 4, characterized by, The specific steps of S3 are: S301: acquiring the multi-angle image corresponding to the number in the trend direction area index table, positioning the corresponding area position in the image, extracting the pixel gray value change feature in the area, marking the boundary pixel point according to the gray value mutation, constructing the boundary point set in sequence, and generating the area boundary point position sequence value; S302: calling the boundary point under the angle in the area boundary point position sequence value, extracting the coordinate corresponding point under the same area according to the position relationship in the image, constructing the matching pair set between the angles, and generating the coordinate pair value of the boundary corresponding point between the angles; S303: according to the coordinate pair value of the boundary corresponding point between the angles and the image shooting parameters, the same coordinate system is uniformly converted, the intersection position under multiple angles is calculated, and the boundary coincidence intersection coordinate matrix is integrated and generated.
7. The mechanical casting inspection method based on image data analysis processing according to claim 6, characterized in that, The specific calculation formula of the construction of the matching pair set between the angles is: ; The angle matching degree index is calculated, and the coordinate pair value of the boundary corresponding point between the angles is generated; wherein, represents a matching weight value of the i-th view and the k-th view, represents an absolute difference value of the j-th boundary point of the i-th view and the reference x-coordinate, represents an absolute difference value of the j-th boundary point of the i-th view and the reference y-coordinate, represents a projection inclination angle radian value of the j-th boundary point under the k-th view, represents a change amount of the optical axis included angle of the i-th view and the k-th view, represents a change amount of the curvature of the j-th boundary point under the k-th view, represents a three-dimensional unit direction vector of the i-th view, represents a preset field of view overlap radius threshold value, represents a current region effective boundary point number.
8. The mechanical casting inspection method based on image data analysis processing according to claim 6, characterized in that, The specific steps of S4 are: S401: calling the pixel position of the intersection point in the image sequence in the boundary coincidence intersection coordinate matrix, extracting the coordinate information in sequence, establishing the sequence set of the image position corresponding to the intersection point, integrating the image position information of the intersection point, and generating the intersection point pixel displacement data set; S402: according to the coordinate change in the intersection point pixel displacement data set, the horizontal and vertical displacement amplitudes of the intersection point in the image sequence are extracted, the upper limit of the offset is set as the judgment reference, the intersection point set meeting the condition is screened, and the coordinate stability screening matrix is generated; S403: calling the intersection point set in the coordinate stability screening matrix, integrating the horizontal and vertical position information under the image, generating the average position point set of the intersection point, constructing the boundary distribution according to the original index, and generating the stable boundary pixel point set.
9. The mechanical casting inspection method based on image data analysis processing according to claim 1, characterized by, The defect labeling visual image result includes a detection image after labeling processing, an original image fusion output result and visual defect information; The specific steps of S5 are: S501: based on the stable boundary pixel point set, the position coordinate information in the original image is extracted, and is compared with the coordinates in the trend direction area index table point by point, the image position with consistent coordinate value is screened, and the coordinate coincidence area index value set is generated; S502: calling the coordinate coincidence area index value set, extracting the corresponding area image content from the original image, screening the position meeting the boundary definition condition according to the edge feature distribution of the image channel, and generating the labelable area pixel position set; S503: Call the set of labelable region pixel positions, complete pixel value replacement processing in the corresponding position of the original image, add uniform boundary identification and perform image fusion to generate a defect label visualization image result.
10. A mechanical casting inspection system based on image data analysis processing, characterized by, The mechanical casting detection method based on image data analysis processing according to any one of claims 1-9, wherein the system comprises: The image layering module acquires mechanical casting surface area image data, collects the gray value of pixels in the image, makes attribution judgments according to a preset gray scale interval standard, divides the pixels into corresponding layers, organizes the layers according to the order of gray scale levels, and establishes a gray scale layering atlas data set; The density extraction module calls the gray scale layering atlas data set, sets an equal-proportion grid in the image area, counts the number of pixels contained in each grid in the layer, organizes the pixel distribution sequence of the grid under the difference layer, extracts the trend area index according to the continuous change of the pixel distribution, and generates a trend area index table; The trend construction module calls the trend area index table, extracts the image content of the corresponding area under multiple shooting angles, acquires the gray gradient mutation points in the boundary range, forms a boundary point sequence, matches the boundary points according to the correspondence between the image view angle and the position, maps the intersection position in a unified coordinate system, and establishes a boundary overlap intersection coordinate matrix; The boundary mapping module calls the boundary overlap intersection coordinate matrix, counts the spatial position change of the intersection points under the difference image view angle, judges whether the horizontal and vertical offset amplitudes are lower than the stability benchmark, screens the intersection point set with a smaller position change range, and generates a stable boundary pixel point set; The defect labeling module calls the stable boundary pixel point set, finds the corresponding coordinates in the original image area, compares the position with the trend area index table, extracts the coordinate overlap area for image labeling processing, outputs the fused image, and generates a defect label visualization image result.
Citation Information
Patent Citations
Systems and methods for fabricating variable digital optical images using generic optical matrices
CN107430380A
Building material welding surface defect detection method based on computer vision
CN115082467A