Mold part quality detection and discrimination method based on image processing
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-06
- Publication Date
- 2026-08-11
AI Technical Summary
该类方案在一般灰度场景下可以完成缺陷提取,但在高亮金属模具表面,二维标量灰度容易同时叠加镜面高光、互反射、宏观圆角曲率和微观加工纹理,导致低频几何畸变与高频真实缺陷混杂,进而出现法向解算失真、正常刀纹区域误报以及不同曲率区域检测尺度不一致的问题
本发明先基于光度立体图像序列生成初始表面法向张量,再结合异常阻断与动态修复处理剔除由镜面高光、互反射和局部遮挡引起的伪法向数据,使进入后续分析链条的法向数据更稳定,降低异常数据在空间滤波和曲率计算中的传递干扰。
Smart Images

Figure CN122550475A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and more specifically, to a method for quality inspection and discrimination of mold parts based on image processing. Background Technology
[0002] In modern industrial manufacturing systems, the surface processing quality of precision metal molds directly affects the yield and physical properties of the molded products. Therefore, before the molds are rolled off the production line and put into mass production, it is usually necessary to inspect the abnormal topological structures on the cavity surface, such as cracks, pinholes, and scratches. Currently, the most common processing methods are still optical imaging combined with grayscale analysis, edge extraction, or saliency segmentation. The basic idea is to directly extract local grayscale change features from the two-dimensional image and then use this to locate the defect area.
[0003] In the prior art, the scheme disclosed in CN117893532A, entitled "Image Processing-Based Method for Crack Defect Detection in Dies for Forging Rigging," extracts grayscale features of connected regions and crack tortuosity features, and combines saliency detection and watershed segmentation to achieve crack detection. This type of scheme can complete defect extraction in general grayscale scenes, but on the surface of high-brightness metal molds, two-dimensional scalar grayscale is prone to simultaneously superimposed specular highlights, mutual reflection, macroscopic rounded corner curvature, and microscopic processing textures, resulting in the mixing of low-frequency geometric distortion and high-frequency real defects. This leads to problems such as normal calculation distortion, false alarms in normal tool mark areas, and inconsistent detection scales in areas with different curvatures.
[0004] To address the aforementioned problems, a technical solution is provided. Summary of the Invention
[0005] To overcome the aforementioned deficiencies of the prior art, embodiments of the present invention provide a method for quality inspection and discrimination of mold parts based on image processing. This method acquires a photometric stereo image sequence of the mold under multi-directional illumination conditions, calculates the initial surface normal tensor, and then performs anomaly blocking and dynamic repair on the initial surface normal tensor by combining optical fitting residuals and local normal divergence. A macroscopic topological tensor is extracted, and based on this, the principal curvature is calculated, generating a macroscopic expectation matrix and a macroscopic variance matrix. Subsequently, the repaired initial surface normal tensor is subjected to feature standardization and dimensionality reduction to form a scale-free topological tensor, which is used to output the final mold defect discrimination result, thereby solving the problems mentioned in the background art.
[0006] To achieve the above objectives, the present invention provides the following technical solution: S1. Obtain the photometric stereo image sequence of the mold under multi-directional illumination conditions, and generate the initial surface normal tensor corresponding to the same coordinate as the photometric stereo image sequence by solving the optical model. S2. Receive the initial surface normal tensor, perform local feature anomaly blocking and dynamic repair processing on the initial surface normal tensor, and filter out high-frequency signals in the initial surface normal tensor through spatial filtering, and output the repaired initial surface normal tensor and macroscopic topological tensor. S3. Receive the macroscopic topological tensor, calculate the principal curvature of the local topology based on the second-order partial derivative characteristics of the macroscopic topological tensor, and generate the macroscopic expectation matrix and macroscopic variance matrix corresponding to the original surface normal tensor after repair. S4. Simultaneously receive the repaired initial surface normal tensor, as well as the macroscopic expectation matrix and macroscopic variance matrix. Use the macroscopic expectation matrix and macroscopic variance matrix as a constraint base to perform feature standardization and dimensionality reduction on the initial surface normal tensor to obtain the scale-free topological tensor used to output the final mold defect discrimination result.
[0007] Further, step S2 includes: extracting the optical fitting residuals of each pixel coordinate based on the photometric stereo image sequence and the theoretical grayscale reconstruction results obtained from the optical model; calculating the local normal divergence of the corresponding coordinates based on the initial surface normal tensor; and jointly inputting the optical fitting residuals and the local normal divergence into the isolated forest model in the same pixel coordinate order to obtain the anomaly confidence score corresponding to each pixel coordinate.
[0008] Furthermore, the optical fitting residual is obtained by comparing the measured gray values of the same pixel coordinates in the photometric stereo image sequence with the theoretical gray values in the theoretical gray value reconstruction results. The measured gray values and theoretical gray values are aligned item by item according to the same light source number order and then the cumulative deviation is calculated. The pixel coordinate index is kept the same as the initial surface normal tensor to form the first input feature of the isolated forest model.
[0009] Furthermore, the local normal divergence is obtained by establishing a preset sliding window centered on the current pixel coordinates on the initial surface normal tensor, extracting the three-dimensional surface normal vectors of all adjacent pixels within the window and calculating the average normal vector of the window, and then obtaining the second input feature of the isolated forest model based on the degree of dispersion of the three-dimensional surface normal vectors of each adjacent pixel relative to the average normal vector of the window.
[0010] Furthermore, the anomaly blocking and dynamic repair processing includes: comparing the anomaly confidence score with a preset anomaly judgment threshold, blocking the abnormal normal data at the coordinates where the anomaly confidence score exceeds the preset anomaly judgment threshold, calling the effective features of the unblocked neighborhood around the corresponding anomaly coordinates to perform spatial interpolation repair, and writing the repair result back to the initial surface normal tensor in situ to obtain the repaired initial surface normal tensor.
[0011] Furthermore, the spatial filtering in step S2 includes: expanding the repaired initial surface normal tensor into multiple two-dimensional component matrices according to spatial components, performing spatial low-pass filtering on each two-dimensional component matrix, and recombining the filtered multiple low-frequency components according to the original pixel coordinates to obtain a macroscopic topological tensor that maintains the same coordinate layout as the repaired initial surface normal tensor.
[0012] Furthermore, step S3 includes: performing local quadratic surface fitting on the macroscopic topological tensor in the neighborhood of the current coordinates, constructing the Hessian matrix of the current coordinates based on the coefficients of the quadratic terms obtained from the fitting, performing eigenvalue decomposition on the Hessian matrix, determining the principal curvature of the current coordinates according to the absolute values of the two eigenvalues obtained from the eigenvalue decomposition, and maintaining the same pixel coordinate correspondence between the principal curvature and the macroscopic topological tensor.
[0013] Furthermore, the macroscopic expectation matrix and macroscopic variance matrix are generated in the following way: a dynamic kernel space covering the physical cycle of the standard milling tool marks of the mold is established with the current pixel coordinates as the center. The principal curvature of each coordinate is collected in the dynamic kernel space. The average result of the principal curvature at the current position is statistically obtained as the corresponding value of the macroscopic expectation matrix. The fluctuation scale of the principal curvature at the current position is statistically obtained as the corresponding value of the macroscopic variance matrix.
[0014] Further, step S4 includes: on the repaired initial surface normal tensor, constructing a high-frequency normal change based on the difference between the normal component of the current pixel coordinate and the average normal component of its four neighbors, then subtracting the macroscopic expectation matrix value of the corresponding coordinate from the high-frequency normal change pixel by pixel, and dividing by the macroscopic variance matrix value of the corresponding coordinate to obtain the standardized deviation result.
[0015] Furthermore, the scale-free topological tensor is obtained by writing the standardized deviation results of each pixel coordinate back to the three-dimensional tensor position in the order of the original pixel coordinates and spatial components. After the scale-free topological tensor is generated, the Euclidean norm of the standardized deviation results of each pixel coordinate is calculated. The Euclidean norm is compared with the defect discrimination threshold. Then, the eight-neighbor connected domain merging is performed on the pixel coordinates that meet the comparison conditions to output the final mold defect discrimination result.
[0016] The technical effects and advantages of the image processing-based mold part quality inspection and discrimination method of this invention are as follows: This invention first generates an initial surface normal tensor based on a photometric stereo image sequence, and then combines anomaly blocking and dynamic repair processing to remove pseudo normal data caused by specular highlights, mutual reflection and local occlusion, making the normal data entering the subsequent analysis chain more stable and reducing the transmission interference of anomalous data in spatial filtering and curvature calculation.
[0017] This invention separates the macroscopic geometric curvature of the mold surface from the microscopic abnormal topological changes by extracting the macroscopic topological tensor, calculating the principal curvature, and generating the macroscopic expectation matrix and macroscopic variance matrix. This prevents the low-frequency structures corresponding to complex fillets, curved surface transitions, and standard milling marks from being mixed with anomalies such as local scratches and holes.
[0018] This invention uses the macroscopic expectation matrix and macroscopic variance matrix as a constraint base to perform feature standardization and dimensionality reduction on the repaired initial surface normal tensor to obtain a scale-free topological tensor. This enables local anomalies in different curvature regions to be distinguished at a unified scale, and the final output mold defect discrimination result has a clearer coordinate correspondence and region boundary. Attached Figure Description
[0019] Figure 1 This is an overall flowchart of the image processing-based mold part quality inspection and discrimination method of the present invention; Figure 2 This is a schematic diagram of the multi-directional illumination acquisition and initial surface normal tensor generation of the present invention; Figure 3 This is a schematic diagram of the abnormal blocking and dynamic repair processing of the present invention; Figure 4 This is a schematic diagram illustrating the macroscopic topological tensor extraction and curvature benchmark generation of the present invention; Figure 5 This is a schematic diagram of the output of the scale-free topological tensor construction and defect discrimination results of the present invention. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Please see Figure 1 - Figure 5 This invention provides a method for quality detection and discrimination of mold parts based on image processing, including: S1. Obtain the photometric stereo image sequence of the mold under multi-directional illumination conditions, and generate the initial surface normal tensor corresponding to the same coordinate as the photometric stereo image sequence by solving the optical model. S2. Receive the initial surface normal tensor, perform local feature anomaly blocking and dynamic repair processing on the initial surface normal tensor, and filter out high-frequency signals in the initial surface normal tensor through spatial filtering, and output the repaired initial surface normal tensor and macroscopic topological tensor. S3. Receive the macroscopic topological tensor, calculate the principal curvature of the local topology based on the second-order partial derivative characteristics of the macroscopic topological tensor, and generate the macroscopic expectation matrix and macroscopic variance matrix corresponding to the original surface normal tensor after repair. S4. Simultaneously receive the repaired initial surface normal tensor, as well as the macroscopic expectation matrix and macroscopic variance matrix. Use the macroscopic expectation matrix and macroscopic variance matrix as a constraint base to perform feature standardization and dimensionality reduction on the initial surface normal tensor to obtain the scale-free topological tensor used to output the final mold defect discrimination result.
[0022] The core idea of this solution is to first reconstruct the three-dimensional normal information from the reflection image of the mold surface obtained under multi-directional lighting conditions. Then, it identifies and removes pseudo-anomalies caused by specular highlights, mutual reflections, and complex rounded corners. Subsequently, it extracts the large-scale curvature reference of the mold body and, based on this, performs unified-scale discrimination of genuine minute defects. The technical problem addressed by this solution is that metal mold surfaces typically possess characteristics such as high reflectivity, curved surface transitions, and machining textures. When using conventional two-dimensional grayscale detection methods, normal rounded corner areas and tool-cut areas are easily misjudged as cracks or scratches. Compared to existing processing methods that directly analyze based on two-dimensional grayscale features, this solution first performs normal calculation, then uses isolated forests to block and repair pseudo-normal anomalies, and further combines macroscopic curvature references to standardize local anomalies. This allows minute defects in different curvature regions to be identified on a unified scale.
[0023] Step S1: Obtain a sequence of photometric stereo images of the mold under multi-directional illumination conditions, and generate the initial surface normal tensor in three-dimensional space by solving the optical model.
[0024] In this embodiment, step S1 serves as the data starting point of the entire technology chain. The image processing device completes multi-directional illumination acquisition, illumination parameter calibration, optical model calculation, and tensor organization processing within the mold inspection station. The direct outputs of step S1 include a photometric stereo image sequence, an initial surface normal tensor, theoretical grayscale reconstruction results, and multi-directional illumination calibration parameters. The photometric stereo image sequence serves as the measured input for subsequent optical fitting residual calculation, and the initial surface normal tensor serves as the direct input for anomaly blocking and dynamic repair processing in step S2. The theoretical grayscale reconstruction results and the multi-directional illumination calibration parameters jointly participate in the anomaly feature construction in step S2.
[0025] S101: Acquire multi-directional illumination observations and form a photometric stereo image sequence.
[0026] The image processing device first fixes the camera's position, orientation, focal length, and exposure reference relative to the mold under test, and then controls multiple numbered light sources to illuminate one by one in a predetermined order, so that the surface of the mold cavity within the same detection field of view is continuously sampled under different illumination directions. The camera's imaging coordinate system remains unchanged during each sampling process, ensuring that the coordinates of any pixel always correspond to the same position on the mold surface throughout all sampling frames.
[0027] Before formal data acquisition, the image processing device first obtains multi-directional illumination calibration parameters. These parameters refer to the incident direction and illuminance compensation coefficient of each light source, corresponding one-to-one with its number. Specifically, during acquisition, a diffuse reflection standard plate and a standard sphere are placed sequentially within the camera's field of view. Each light source is illuminated according to its number, and the incident direction of each light source is deduced using the line connecting the highlight center and center of the standard sphere. The illuminance of each light source is then normalized using the average grayscale of the diffuse reflection standard plate under various illumination conditions, yielding the incident direction and illuminance compensation coefficient corresponding one-to-one with the light source number. These multi-directional illumination calibration parameters remain fixed during the testing of the same batch of molds and serve as the basis for constructing the illumination direction matrix in step S1.
[0028] After calibration, the image processing device continuously acquires multiple grayscale images under sequential illumination from various light sources and writes them into a unified sequence according to the light source number, forming a photometric stereo image sequence. Each image in the photometric stereo image sequence maintains the same resolution, row and column coordinates, and indexing method, so that grayscale values can be extracted frame by frame for the same pixel coordinates in subsequent processing. Taking the rounded corner transition area of an injection mold cavity as an example, when multiple obliquely incident light sources illuminate this area sequentially, although the brightness of the top of the rounded corner, the sidewall, and the flat area changes in different frames, their corresponding pixel coordinates remain unchanged. Subsequently, a cross-illumination observation vector can be constructed at the same coordinates.
[0029] S102: Calculate pixel-level surface normal vectors based on optical models.
[0030] After forming the photometric stereo image sequence in step S101, the image processing device extracts the grayscale values from each illumination frame point by point according to pixel coordinates and organizes them into an observation grayscale vector for that coordinate. For any pixel coordinate... The gray values of this coordinate in all lighting frames are arranged in order of light source number to form the observed gray value vector. Simultaneously, the incident direction and illuminance compensation coefficient of each light source in the multi-directional lighting calibration parameters are organized into a lighting direction matrix in the same order. Among them, pixel coordinates Indicates the current position to be solved. This represents the set of measured gray levels at that location under all lighting directions. This represents a matrix representation of the calibrated lighting conditions.
[0031] The image processing device uses a least-squares optical model of photometric stereo vision to solve for the surface response vector at this coordinate. The solution relationship is written as: , in, pixel coordinates The surface response vector at that location is used to simultaneously characterize the local reflection coefficient and the surface normal direction; This is the fitting deviation term for the current coordinates under the optical model, used to record the deviation of the measured gray level from the theoretical gray level. Preferably, the optical model adopts the Lambertian reflection equation; when there is specular highlight or mutual reflection on the surface of the metal mold, the resulting non-ideal components are not directly written into the surface normal vector, but are retained in the fitting deviation term for subsequent step S2 to calculate the optical fitting residual.
[0032] When the illumination direction matrix When the full-rank condition is met, the image processing device uses the least squares method to obtain the surface response vector estimate; when local occlusion causes the matrix condition number to increase, the Moore-Penrose generalized inverse is used to maintain the continuity of the solution, and the solution relation is written as: , in, This is the estimated value of the surface response vector. Lighting direction matrix Moore-Penrose generalized inverse.
[0033] get Then, the image processing device performs L2 norm normalization on it to obtain the pixel coordinates. Unit surface normal vector at the location : , in, The unit surface normal vector, This is the L2 norm of the surface response vector estimate. Meanwhile, the image processing device will... Substitute the optical model back into the model to obtain the theoretical grayscale reconstruction results of the coordinates under various light source conditions, so that the subsequent step S2 can compare the grayscale with the measured grayscale at the same pixel coordinates.
[0034] S103: Assemble the initial surface normal tensor and output the object called in step S2.
[0035] After obtaining the unit surface normal vector for all pixel coordinates, the image processing device, according to the original row and column coordinate order of the photometric stereo image sequence, processes the corresponding pixel coordinates... The process is repeated point-by-point, writing back to the three-dimensional space to form an initial surface normal tensor. The first and second dimensions of the initial surface normal tensor correspond to the row and column coordinates of the image, while the third dimension corresponds to the three spatial components of the unit surface normal vector. Thus, each tensor element at any coordinate position maintains a one-to-one correspondence with the corresponding pixel coordinates in the photometric stereo image sequence.
[0036] During the output stage, the image processing device simultaneously saves the photometric stereo image sequence, the initial surface normal tensor, the theoretical grayscale reconstruction results, and the multi-directional illumination calibration parameters, ensuring that all four use a unified pixel coordinate index and a unified light source numbering order. Step S2 then allows direct extraction of the measured grayscale, theoretical grayscale, and surface normal data at the same coordinates, calculating the optical fitting residual and local normal divergence, without requiring re-performing coordinate registration or renumbering of the light sources.
[0037] Through steps S101 to S103, the mold under test is converted into a calculable photometric stereo image sequence and an initial surface normal tensor under a unified field of view, unified coordinates, and calibrated multi-directional illumination conditions, forming theoretical grayscale reconstruction results and multi-directional illumination calibration parameters, providing a complete input basis for subsequent abnormal blocking and dynamic repair processing.
[0038] Step S2: Receive the initial surface normal tensor, perform local feature anomaly blocking and dynamic repair processing on the initial surface normal tensor, and then filter out high-frequency signals in the initial surface normal tensor through spatial filtering to extract the macroscopic topological tensor reflecting the geometric bending morphology of the mold entity.
[0039] In this embodiment, step S2 is performed by the image processing device based on the output object of step S1, including anomaly feature construction, isolated forest model discrimination, anomaly normal blocking, neighborhood effective feature interpolation repair, and macroscopic topology extraction. The direct inputs of step S2 are the initial surface normal tensor, the photometric stereo image sequence, the theoretical grayscale reconstruction result, and the multi-directional illumination calibration parameters. The direct outputs are the repaired initial surface normal tensor and the macroscopic topology tensor, where the former is used by step S4 and the latter is used by step S3.
[0040] S201: Construct anomaly detection feature sequence.
[0041] The image processing device first uses the initial surface normal tensor as the primary indexing object, and simultaneously calls the photometric stereo image sequence and the theoretical grayscale reconstruction results to construct anomaly discrimination features at the same pixel coordinates. For any pixel coordinate... The image processing device sequentially reads the measured grayscale value of the coordinate under all light source conditions from the photometric stereo image sequence. And read the theoretical grayscale values under the same coordinates and the same light source number from the theoretical grayscale reconstruction results. ,in, Indicates the light source number. This represents the measured grayscale value. This represents the theoretical grayscale value. The image processing device compares the two values one by one and calculates the optical fitting residual for this coordinate. : , in, The total number of light sources involved in the solution. This represents the cumulative least-squares residual value of the current pixel coordinates under the optical model fitting. The larger the value, the more significantly the coordinates are affected by specular highlights, mutual reflections, or occlusions.
[0042] After obtaining the optical fitting residual, the image processing device applies pixel coordinates to the initial surface normal tensor. Create a preset sliding window at the center The image processing device first extracts the 3D surface normal vectors of all adjacent pixels within the window. The side length of the preset sliding window is determined by converting 1 to 2 texture cycles of a standard milling tool mark at the current detection resolution, preferably 3×3 to 7×7 pixels. Then, calculate the degree of dispersion of the cosine distance between each adjacent normal vector within the current window and the average normal vector to obtain the local normal divergence. : , in, This is the preset number of pixels to be included in the calculation within the sliding window. The coordinates of adjacent pixels within the window. The three-dimensional surface normal vectors of adjacent pixels. The window average normal vector, This represents the local normal divergence of the current pixel coordinates.
[0043] Because the optical fitting residual and the local normal divergence have different dimensions, the image processing device performs normalization mapping on both separately. The normalization mapping employs a linear compression method based on reference sample quantiles, mapping the optical fitting residual and the local normal divergence to the 0-1 interval according to the 5th and 95th quantiles of the historical defect-free reference samples, respectively. Values exceeding the upper bound are truncated to 1, and values below the lower bound are truncated to 0. Then, a two-dimensional feature vector is constructed according to the same pixel coordinate order. : , in, The normalized optical fitting residuals, The normalized local normal divergence, Input the two-dimensional feature vector of the isolated forest model for the current pixel coordinates. Taking the corner region of the deep cavity of a die-casting mold as an example, when a pixel coordinate is simultaneously affected by highlight overflow and local normal disorder, its... and It will rise synchronously, thus deviating from the normal sample distribution in the feature space.
[0044] S202: Generate anomaly confidence scores and perform anomaly blocking.
[0045] After the two-dimensional feature vectors are constructed, the image processing device inputs the two-dimensional feature vectors corresponding to each pixel coordinate into the pre-trained isolated forest model. In this embodiment, the pre-trained isolated forest model consists of 200 isolated trees, with each isolated tree having a training subsample size of 256, a maximum tree depth of 8, and a minimum node sample size of 1. Each internal node randomly selects only one input feature as the current splitting feature and randomly generates a splitting value within the current sample value range of that feature; splitting stops when a sample is assigned to a single sample leaf node, the sample values are completely identical, or the tree depth reaches 8. The model input is a two-dimensional feature vector, where the first dimension is the normalized optical fitting residual, and the second dimension is the normalized local normal divergence, both of which correspond one-to-one with the pixel coordinates of the initial surface normal tensor. The training dataset consists of historically calibrated samples, with a total of 120,000 coordinate points. 80,000 of these are from stable normal regions of a defect-free reference mold under normal imaging conditions, and 40,000 are from pseudo-normal regions with specular highlights, mutual reflections, or local occlusion. Before training, the optical fitting residuals and local normal divergence are linearly normalized to the 5th and 95th percentiles of the reference samples, respectively, and truncated to the 0-1 interval. Offline unsupervised training is employed. The pre-training process essentially involves repeatedly performing random partitioning of the two-dimensional feature space to statistically analyze the path length traversed by a sample to a leaf node in each isolated tree. During model inference, the path length of the test coordinates in 200 isolated trees is averaged, and then mapped to an anomaly confidence score between 0 and 1 using a standard normalization method corresponding to the path length and sample size. Shorter paths result in higher anomaly confidence scores. Model parameters can be obtained by adjusting the pseudo-normal sample recognition results on the validation set. It is preferable to keep the number of trees at 200, the subsampling size at 256, and the maximum tree depth at 8. When invoked, the image processing device feeds the two-dimensional feature vectors of the current detection batch point by point into the trained isolated forest model. The model internally performs recursive segmentation of the two-dimensional feature space through multiple random decision trees and calculates the average path length required for the current sample to be isolated to a leaf node.
[0046] When a pixel coordinate exhibits both a large optical fit residual and a large local normal divergence, the sample is typically isolated with a shorter path in an isolated forest model. The image processing device outputs an anomaly confidence score between 0 and 1 based on an inverse relationship with the average path length. and compare it with the preset anomaly detection threshold. Point-by-point comparison. Preset anomaly detection threshold. For different mold surface finish levels, the 95th percentile value was used to adjust the score distribution of the anomaly confidence level of the corresponding defect-free reference mold, and the score was limited to the range of 0.75 to 0.85. At that time, the image processing device writes an abnormal blocking marker at the corresponding coordinates. ;when When, write .in, This represents the anomaly confidence score. This indicates the preset anomaly detection threshold. This indicates an anomaly blocking marker. After completing all coordinate comparisons, the image processing device divides the initial surface normal tensor into two sets of coordinates: anomaly normal data and valid neighborhood features.
[0047] S203: Call the effective features of the neighborhood to perform spatial interpolation repair.
[0048] After the abnormal blocking marker is formed, the image processing device processes all the signals that meet the requirements. Spatial interpolation repair is performed on the anomaly coordinates. Valid neighborhood features refer to the set of three-dimensional surface normal vectors around the current anomaly coordinates that have anomaly confidence scores not exceeding a preset anomaly detection threshold and have not been written into anomaly blocking markers. The image processing device uses each anomaly coordinate... Establish a local interpolation window centered on And extract all valid feature coordinates of the neighborhood from this window. and its corresponding normal vector .
[0049] Spatial interpolation repair preferably employs inverse distance weighted interpolation, where the reciprocal of the Euclidean distance between the anomalous coordinates and the effective neighboring feature coordinates is used as the weight and then normalized. When the number of effective neighboring features within the local interpolation window is less than 3, the image processing device expands the window boundary outward in 1-pixel steps until the minimum number of effective coordinates is reached or the effective detection boundary of the current mold is reached. The repaired normal vector of the current anomalous coordinates... The following formula can be used to obtain: , in, This is the repair normal vector for the current abnormal coordinates. abnormal coordinates effective feature coordinates of the neighborhood Inverse distance weights between them Let be the Euclidean distance between the two. After the repair is complete, the image processing device will... The anomalous coordinates in the initial surface normal tensor are written back in situ to form the repaired initial surface normal tensor. Taking the edge of a narrow groove at the bottom of a mold as an example, when local bright reflection causes small patches of pseudo-normal data, the image processing device extracts the effective features of the neighborhood from the unblocked normal vectors on both sides of the groove edge, and obtains a new repaired normal vector by inverse distance weighted interpolation, which then covers the original anomalous values.
[0050] S204: Extract macroscopic topological tensors through spatial filtering.
[0051] Once the repaired initial surface normal tensor is formed, the image processing device uses it as the sole input for the current sub-step, performing spatial low-pass filtering to remove high-frequency normal fluctuations corresponding to local tool marks, scratches, and hole edges, while retaining low-frequency variation trends reflecting the geometric curvature of the mold entity. The image processing device first processes the repaired initial surface normal tensor according to... , , The three spatial components are each expanded into two-dimensional component matrices, and then spatial low-pass filtering is performed on each two-dimensional component matrix.
[0052] Spatial filtering preferably employs a Gaussian low-pass filter. The filter kernel size is determined based on the pixel span of the standard milling tool mark physical cycle at the current detection resolution. It is an odd-numbered window that covers at least one complete tool mark cycle and is smaller than the projected span of the macroscopic fillet radius. The Gaussian standard deviation is taken as 1 / 3 to 1 / 2 of the corresponding kernel size. Let the repaired initial surface normal tensor be... Each component is Its low-frequency output Written as: , in, Indicates the spatial component number, Indicates the current row and column coordinates. This represents the discrete window covered by the Gaussian filter kernel. The standard deviation is expressed as Discrete Gaussian kernel coefficients, This represents the low-frequency output components. The image processing device recombines the three low-frequency output components according to their original coordinates to obtain a macroscopic topological tensor. The macroscopic topological tensor maintains the same coordinate layout as the repaired initial surface normal tensor, but only retains the macroscopic geometric curvature trend. The macroscopic topological tensor is then passed to step S3 for principal curvature calculation, while the repaired initial surface normal tensor remains until step S4.
[0053] Through steps S201 to S204, the image processing device completes optical fitting residual extraction, local normal divergence calculation, anomaly confidence score discrimination, anomaly normal data blocking, neighborhood effective feature space interpolation repair, and macroscopic topology extraction based on the unified coordinates formed in step S1. Finally, it outputs the repaired initial surface normal tensor and macroscopic topology tensor, providing direct input for subsequent curvature benchmark construction and scale-free topology standardization.
[0054] Step S3: Receive the macroscopic topological tensor, calculate the principal curvature of the local topology based on the second-order partial derivative characteristics of the macroscopic topological tensor, and then generate the macroscopic expectation matrix and macroscopic variance matrix containing structural bending reference information.
[0055] In this embodiment, step S3 involves the image processing device performing second-order partial derivative extraction, local principal curvature calculation, and dynamic statistical benchmark construction based on the macroscopic topological tensor output in step S2. The direct input to step S3 is the macroscopic topological tensor, and the direct output is the macroscopic expectation matrix and the macroscopic variance matrix. Both of these correspond to the mold detection coordinates pixel by pixel and serve as the constraint base for feature standardization and dimensionality reduction in step S4.
[0056] S301: Constructing a second-order partial derivative Hessian matrix based on macroscopic topological tensors.
[0057] The image processing device first scans point-by-point along the row and column coordinates of the macroscopic topological tensor, and extracts the low-frequency normal variations of the macroscopic topological tensor within each coordinate neighborhood. Since the macroscopic topological tensor has already filtered out high-frequency tool marks and micro-defect undulations, its local variations can be regarded as a smooth approximation of the geometric curvature of the mold entity. To obtain stable second-order partial derivative features, the image processing device performs local quadratic surface fitting on the macroscopic topological tensor within the current coordinate neighborhood. Within the current coordinate neighborhood, the image processing device first calculates the window-averaged normal vector, and uses the projection of the low-frequency normal variations at each sampling coordinate along the window-averaged normal vector as the scalar sample value of the local quadratic surface fitting. The scalar sample value, varying with the coordinate position, constitutes the height term in the local surface approximation equation. A local surface approximation equation centered at the current coordinate is established: , in, and This is the local coordinate increment relative to the current coordinate. , , , , , The surface coefficients are obtained by least-squares fitting of neighborhood sampling points. This represents the surface approximation of the macroscopic topological tensor within the current local neighborhood.
[0058] The image processing device constructs the Hessian matrix of the current coordinates from the coefficients of the quadratic terms: , in, The current row and column coordinates The Hessian matrix at a given location, with its elements corresponding to the second-order partial derivatives of the local surface approximation equation in two orthogonal directions, is constructed as follows: Through this construction, the second-order partial derivative characteristics of the macroscopic topological tensor in the spatial domain are uniformly incorporated into the standard two-dimensional curvature operator, providing a stable input for subsequent principal curvature calculations.
[0059] S302: Solve for the principal curvature of the local topology based on the Hessian matrix.
[0060] After the Hessian matrices for each coordinate are constructed, the image processing device performs eigenvalue decomposition on each Hessian matrix to obtain two eigenvalues. and ,satisfy: , in, For the eigenvalues to be found, It is a 2-order identity matrix. and These represent the bending intensity of the current coordinate in the two principal directions, respectively.
[0061] The image processing device determines the principal curvature of the current coordinates according to the magnitude of the absolute values, that is, it selects the eigenvalue with the larger absolute value as the principal curvature of the current coordinates. The original sign of the feature value is retained to distinguish between concave and convex curvature. To ensure that the standardized object and the normal change in subsequent step S4 maintain the same dimension, the image processing device further incorporates the sampling interval corresponding to the current detection resolution. The principal curvature is converted into a normal variation scale per unit sampling step. : , in, This represents the physical length of the mold surface corresponding to a single pixel in the current detection field of view, which is obtained from the imaging resolution calibration. This represents the scale of normal change per unit sampling step, used to characterize the fundamental contribution of macroscopic curvature at the current location to the normal change. Taking the deep cavity sidewall and bottom corner region as an example, the corner position... The absolute value is large, and the result is more significant after conversion by sampling interval. This leads to a higher macroscopic curvature benchmark in subsequent statistics.
[0062] S303: Statistically generate the macroscopic expectation matrix and macroscopic variance matrix within the dynamic kernel space.
[0063] When the unit sampling step size of all coordinates changes scale After obtaining the result, the image processing device uses it as input for the current sub-step, constructs a dynamic kernel space at each pixel coordinate, and performs local statistics. The physical period of the standard milling cutter marks on the mold is primarily determined by the tool feed pitch in the process parameter table; when the process parameter table does not directly provide this, the image processing device extracts a one-dimensional normal sampling sequence along the cutter mark direction in a defect-free reference area, and inversely calculates the physical period of the cutter mark using the adjacent peak spacing of the autocorrelation function. This is then converted into a pixel span based on the current imaging resolution, serving as the window scale for the dynamic kernel space. The dynamic kernel space is denoted as... , indicating the current coordinates A local statistical window centered on and covering the pixel span corresponding to a complete standard milling tool mark physical cycle.
[0064] Image processing devices in dynamic kernel space The system collects the normal variation scale of all valid coordinates at a unit sampling step size and calculates the macroscopic expectation matrix value of the current coordinates. Numerical values of macroscopic variance matrix : , , in, This represents the number of valid coordinates participating in the statistics within the dynamic kernel space. The value of the macroscopic expectation matrix representing the current coordinates is used to characterize the average bending reference of the mold base at the current position. This represents the macroscopic variance matrix value of the current coordinates, used to characterize the curvature fluctuation scale near the reference. Although the object name follows the macroscopic variance matrix, its matrix elements are the scale values obtained by taking the square root of the corresponding local variance, so that they can be directly used as standardized divisors in step S4. Taking the sidewall milling area of an automotive body panel forming mold as an example, after the periodic fluctuations of the normal tool marks fall completely into the dynamic kernel space, the average result of the principal curvature conversion within the window is formed. The fluctuation scale around this average result forms The macroscopic expectation matrix and macroscopic variance matrix are then passed to step S4 in a one-to-one correspondence with the repaired initial surface normal tensor along the same coordinates.
[0065] Through steps S301 to S303, the image processing device completes the local quadratic surface fitting of the macroscopic topological tensor, the construction of the Hessian matrix, the solution of the principal curvature, and the dynamic kernel space statistics, and finally generates the macroscopic expectation matrix and macroscopic variance matrix corresponding to the detection coordinates pixel by pixel. The macroscopic expectation matrix is used to characterize the macroscopic curvature reference at the current position, and the macroscopic variance matrix is used to characterize the fluctuation scale near the curvature reference at the current position. Together, they constitute the constraint base for feature standardization and dimensionality reduction in step S4.
[0066] Step S4: Simultaneously receive the repaired initial surface normal tensor, as well as the macroscopic expectation matrix and macroscopic variance matrix. Use the macroscopic expectation matrix and macroscopic variance matrix as a constraint base to perform feature standardization and dimensionality reduction on the initial surface normal tensor to obtain the scale-free topological tensor used to output the final mold defect discrimination result.
[0067] In this embodiment, in step S4, the image processing device simultaneously receives the repaired initial surface normal tensor output in step S2 and the macroscopic expectation matrix and macroscopic variance matrix output in step S3 within a unified detection coordinate system. It performs standardization and dimensionality reduction on the high-frequency changes of the normal to eliminate the scale differences caused by different macroscopic curvature regions, and further outputs the scale-free topological tensor and the final mold defect discrimination result.
[0068] S401: Construct a pixel-by-pixel constrained base.
[0069] The image processing device first uses the restored initial surface normal tensor as the primary indexing object, scans it point by point according to its row and column coordinates, and simultaneously reads the three spatial components of the current coordinate at each coordinate. , , And the macroscopic expectation matrix value at the same coordinate. and macroscopic variance matrix numerical values .in, , and These represent the three spatial components of the repaired initial surface normal tensor in the current coordinates. The baseline representing the expected macroscopic curvature at the current location. This indicates the scale of macroeconomic fluctuations at the current location.
[0070] The image processing device writes the above five types of quantities into the standardized input unit in a one-to-one correspondence with the same coordinates, so that the normal features at the same coordinates maintain a strict binding relationship with their respective macroscopic references. When When the curvature fluctuation scale within the current dynamic kernel space is zero, the image processing device retrieves the nearest non-zero macroscopic variance matrix value within the current coordinate neighborhood and performs... Perform in-situ replacement; if no non-zero value is found within the current effective detection boundary of the mold, then... Set to the preset minimum positive number .in, This represents the minimum positive number set to ensure that the division operation can be performed, preferably 1% of the mean of all non-zero macroscopic variance matrix values in the current batch. Through this process, the denominator in the subsequent standardized mapping in step S4 remains valid.
[0071] S402: Perform feature standardization and dimensionality reduction.
[0072] After the pixel-by-pixel constrained base is constructed, the image processing device does not directly participate in the normalization with the original normal components. Instead, it first constructs a unit sampling step normal variation vector on the repaired initial surface normal tensor. For any coordinate... The image processing device calculates the differences between the three spatial components of the current coordinates and the average value of their four neighborhoods, forming a high-frequency normal variation vector. Among them, the 4-neighborhood is denoted as This represents the four pixel coordinates directly adjacent to the current coordinate in the top, bottom, left, and right directions. High-frequency normal variation of each spatial component Written as: , in, Indicates the spatial component number, Indicates the current coordinates are at position 1. The change in normal direction of a unit sampling step on each spatial component.
[0073] Due to the macroscopic expectation matrix in step S3 and macroscopic variance matrix The normal variation scale has already been converted from the principal curvature to a unit sampling step size. For the high-frequency normal variation vector formed at the same coordinate, the macroscopic expectation matrix value serves as the macroscopic variation benchmark shared by the three spatial components, and the macroscopic variance matrix value serves as the fluctuation scale shared by the three spatial components. Based on this, the image processing device performs co-coordinate normalization mapping on the three spatial components respectively. The image processing device can perform normalization mapping pixel-by-pixel on each component of the high-frequency normal variation vector to obtain the normalized deviation vector. : , in, Indicates the current coordinates are at position 1. The standardized deviation values on each spatial component. The image processing device will , and Organized into standardized deviation vectors according to the original spatial component order. After this mapping, the differences in normal scale caused by the original macroscopic fillets and complex curved surfaces of the mold are eliminated, while the high-frequency deviations corresponding to abnormal scratches, pinholes, and holes are still retained. Taking the same fine scratch that spans both the fillet area and the planar area as an example, although the original normal undulation amplitudes of the two locations are different, after the above standardization, both locations are mapped to dimensionless deviations relative to their respective macroscopic references, thus achieving comparability at a unified scale.
[0074] S403: Generate scale-free topological tensors and output the final mold defect discrimination results.
[0075] After obtaining the standardized deviation vectors for all coordinates, the image processing device will... The original row coordinates, column coordinates, and spatial components are written back point by point in sequence to form a scale-free topological tensor. The first and second dimensions of the scale-free topological tensor correspond to the row and column coordinates of the detected image, and the third dimension corresponds to the three spatial components of the normalized deviation vector. The closer the value at any coordinate is to 0, the higher the consistency between the normal change at that point and the macroscopic bending reference of the mold substrate; the larger the absolute value of the value at any coordinate, the more significant the local topological anomaly.
[0076] After the scale-free topological tensor is generated, the image processing device further calculates the Euclidean norm of the normalized deviation vector for each coordinate. : , in, This represents the overall strength of the scale-free topological anomaly at the current coordinates. The image processing device will... Defect discrimination threshold Pixel-by-pixel comparison; when At that time, write the defect candidate marker at the corresponding coordinates. Otherwise, write Defect detection threshold The model is tuned using the 99th percentile of the Euclidean norm distribution of the scale-free topological tensor of a defect-free reference mold of the same model. After completing all coordinate discrimination, the image processing device performs 8-neighborhood connected component merging on all defect candidate labels to obtain continuous defect candidate regions, and outputs the coordinate boundaries, area range, and position markers of each defect candidate region as the final mold defect discrimination result. Taking the deep cavity corner and planar transition region of a precision die-casting mold as an example, if a fine scratch spans different macroscopic curvature regions, the image processing device obtains a continuous high-response trajectory in the same dimensionless space in the scale-free topological tensor. After Euclidean norm discrimination and connected component merging, it can be output as a single defect region.
[0077] Through steps S401 to S403, the image processing device, under the same coordinate constraint of the repaired initial surface normal tensor, macroscopic expectation matrix, and macroscopic variance matrix, completes the construction of high-frequency normal changes, pixel-by-pixel normalization dimensionality reduction, scale-free topological tensor generation, and final defect candidate region extraction. Therefore, the final mold defect discrimination result is based on a topological expression where abnormal data has been removed, macroscopic curvature has been decoupled, and the scale of each region has been unified, directly reflecting the true defect distribution on the mold surface.
[0078] The above embodiments are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A mold part quality detection and discrimination method based on image processing, characterized by, Including the following steps: S1. Obtain the photometric stereo image sequence of the mold under multi-directional illumination conditions, and generate the initial surface normal tensor corresponding to the same coordinate as the photometric stereo image sequence by solving the optical model. S2. Receive the initial surface normal tensor, perform local feature anomaly blocking and dynamic repair processing on the initial surface normal tensor, and filter out high-frequency signals in the initial surface normal tensor through spatial filtering, and output the repaired initial surface normal tensor and macroscopic topological tensor. S3. Receive the macroscopic topological tensor, calculate the principal curvature of the local topology based on the second-order partial derivative characteristics of the macroscopic topological tensor, and generate the macroscopic expectation matrix and macroscopic variance matrix corresponding to the original surface normal tensor after repair. S4. Simultaneously receive the repaired initial surface normal tensor, as well as the macroscopic expectation matrix and macroscopic variance matrix. Use the macroscopic expectation matrix and macroscopic variance matrix as a constraint base to perform feature standardization and dimensionality reduction on the initial surface normal tensor to obtain the scale-free topological tensor used to output the final mold defect discrimination result.
2. The image processing-based mold part quality detection and discrimination method according to claim 1, characterized by, Step S2 includes: extracting the optical fitting residuals of each pixel coordinate based on the photometric stereo image sequence and the theoretical grayscale reconstruction results obtained from the optical model; calculating the local normal divergence of the corresponding coordinates based on the initial surface normal tensor; and jointly inputting the optical fitting residuals and the local normal divergence into the isolated forest model in the same pixel coordinate order to obtain the anomaly confidence score corresponding to each pixel coordinate.
3. The image processing-based mold part quality detection and discrimination method according to claim 2, characterized by, The optical fitting residual is obtained by comparing the measured gray value of the same pixel coordinate in the photometric stereo image sequence with the theoretical gray value in the theoretical gray value reconstruction result. The measured gray value and the theoretical gray value are aligned item by item according to the same light source number order and then the cumulative deviation is calculated. The pixel coordinate index is kept the same as the initial surface normal tensor to form the first input feature of the isolated forest model.
4. The image processing-based mold part quality detection and discrimination method according to claim 3, characterized by, Local normal divergence is obtained by establishing a preset sliding window centered on the current pixel coordinates on the initial surface normal tensor, extracting the three-dimensional surface normal vectors of all adjacent pixels within the window and calculating the average normal vector of the window, and then obtaining the second input feature of the isolated forest model based on the degree of dispersion of the three-dimensional surface normal vectors of each adjacent pixel relative to the average normal vector of the window.
5. The image processing-based method for quality inspection and discrimination of mold parts according to claim 4, characterized in that, The anomaly blocking and dynamic repair process includes: comparing the anomaly confidence score with a preset anomaly judgment threshold, blocking the abnormal normal data at the coordinates where the anomaly confidence score exceeds the preset anomaly judgment threshold, calling the effective features of the unblocked neighborhood around the corresponding anomaly coordinates to perform spatial interpolation repair, and writing the repair result back to the initial surface normal tensor in situ to obtain the repaired initial surface normal tensor.
6. The image processing-based mold part quality detection and discrimination method according to claim 5, characterized by, The spatial filtering in step S2 includes: expanding the repaired initial surface normal tensor into multiple two-dimensional component matrices according to spatial components, performing spatial low-pass filtering on each two-dimensional component matrix, and recombining the filtered multiple low-frequency components according to the original pixel coordinates to obtain a macroscopic topological tensor that maintains the same coordinate layout as the repaired initial surface normal tensor.
7. The image processing-based mold part quality detection and discrimination method according to claim 6, characterized by, Step S3 includes: performing local quadratic surface fitting on the macroscopic topological tensor in the neighborhood of the current coordinates, constructing the Hessian matrix of the current coordinates based on the coefficients of the quadratic terms obtained from the fitting, performing eigenvalue decomposition on the Hessian matrix, determining the principal curvature of the current coordinates according to the absolute values of the two eigenvalues obtained from the eigenvalue decomposition, and maintaining the same pixel coordinate correspondence between the principal curvature and the macroscopic topological tensor.
8. The image processing-based mold part quality detection and discrimination method according to claim 7, characterized by, The macroscopic expectation matrix and macroscopic variance matrix are generated as follows: a dynamic kernel space covering the physical cycle of the standard milling tool marks of the mold is established with the current pixel coordinates as the center. The principal curvature of each coordinate is collected in the dynamic kernel space. The average result of the principal curvature at the current position is statistically obtained as the corresponding value of the macroscopic expectation matrix. The fluctuation scale of the principal curvature at the current position is statistically obtained as the corresponding value of the macroscopic variance matrix.
9. The image processing-based mold part quality detection and discrimination method according to claim 8, characterized by, Step S4 includes: on the repaired initial surface normal tensor, constructing a high-frequency normal change based on the difference between the normal component of the current pixel coordinate and the average normal component of its four neighbors, then subtracting the macroscopic expectation matrix value of the corresponding coordinate from the high-frequency normal change pixel by pixel, and dividing by the macroscopic variance matrix value of the corresponding coordinate to obtain the standardized deviation result.
10. The image processing-based method for quality inspection and discrimination of mold parts according to claim 9, characterized in that, The scale-free topological tensor is obtained by writing the standardized deviation results of each pixel coordinate back to the three-dimensional tensor position in the order of the original pixel coordinates and spatial components. After the scale-free topological tensor is generated, the Euclidean norm of the standardized deviation results of each pixel coordinate is calculated. The Euclidean norm is compared with the defect discrimination threshold. Then, the eight-neighbor connected domain merging is performed on the pixel coordinates that meet the comparison conditions to output the final mold defect discrimination result.
Citation Information
Patent Citations
Die forging rigging die crack defect detection method based on image processing
CN117893532A