Mold plate quality inspection method and system based on machine vision

Through the mold panel quality detection method based on condition generation adversarial network and Defect-ResNet network, combined with the fusion of attention mechanism and multi-scale features, the limitations of traditional detection methods are solved, and the mold panel with high precision and high robustness is achieved Part defect detection and positioning to adapt to complex industrial environments.

CN118587226BActive Publication Date: 2024-11-26NINGBO XINGBO MACHINERY
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411075912.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2024-11-26
Estimated Expiration
2044-08-07

AI Technical Summary

Technical Problem

Traditional mold panel quality inspection relies on manual visual inspection, which has problems such as low detection efficiency, poor accuracy, and susceptible to subjective factors. Early machine vision detection systems have limitations in dealing with complex backgrounds and multiple defect types.

Method used

The defect detection data set is constructed using a data enhancement method based on the conditional generation adversarial network, and the defect area of ​​the mold plate is detected through the Defect-ResNet network, and combined with attention mechanism, multi-scale feature fusion, pyramid pooling and feature pyramid network, Defect detection and segmentation, defect location is used using area growth segmentation algorithm and rotary shell algorithm.

Benefits of technology

Improve the defect detection accuracy and efficiency of the model in complex industrial scenarios, realize high-precision and high-rootability defect positioning, adapt to changes in different defect types and backgrounds, reduce dependence on a large number of real defect samples, and save labor Time and cost of labeling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118587226B_ABST
    Figure CN118587226B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for quality inspection of mold plates based on machine vision, which relates to the technical field of quality inspection, including constructing a defect detection data set based on a data enhancement method of a conditional generative adversarial network, detecting defective areas of mold plates through a Defect‑ResNet network; preprocessing the defective areas of the mold plates, taking defective pixels in the defective areas as seed points, setting a growth criterion, and continuously merging adjacent pixels that meet the growth criterion into the defective areas until no new pixels are added, thereby obtaining a segmented defective area; extracting contours from the segmented defective areas to obtain a contour matrix composed of contour point coordinates; searching for a minimum-area circumscribed rectangle in the contour matrix through a rotating caliper algorithm, and calculating the coordinates of four vertices of the circumscribed rectangle; and obtaining the center coordinates of the circumscribed rectangle as the position coordinates of the defective area through a diagonal intersection coordinate calculation formula.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to quality inspection technology, and in particular to a method and system for quality inspection of mold plates based on machine vision. Background Art

[0002] Molds are an indispensable key tool in industrial production, and their quality directly affects production efficiency and product quality. As the core component of the mold, the quality inspection of mold plates is crucial to ensure mold performance and extend its service life. Traditional mold plate quality inspection mainly relies on manual visual inspection, which has problems such as low inspection efficiency, poor accuracy, and susceptibility to subjective factors. It is difficult to meet the high quality and high efficiency requirements of modern industrial production.

[0003] In order to overcome the limitations of manual inspection, machine vision technology has been introduced into the field of mold plate quality inspection. Machine vision realizes the automatic detection of mold plate defects by combining computer vision algorithms with hardware equipment such as industrial cameras and light sources. Early machine vision inspection systems mainly used traditional image processing algorithms, such as threshold segmentation, edge detection, morphological operations, etc., to detect and identify defects on the surface of mold plates.

[0004] However, traditional machine vision inspection methods based on image processing have certain limitations when dealing with complex backgrounds, multiple defect types, and differences in defect size and shape. Summary of the invention

[0005] The embodiments of the present invention provide a method and system for detecting the quality of mold plates based on machine vision, which can solve the problems in the prior art.

[0006] According to a first aspect of the embodiments of the present invention,

[0007] Provides a machine vision-based mold plate quality inspection method, including:

[0008] A defect detection dataset is constructed based on the data enhancement method of conditional generative adversarial network, and the defect area of ​​the mold plate is detected through the Defect-ResNet network;

[0009] Preprocessing the defective area of ​​the mold plate, taking defective pixels in the defective area as seed points, setting a growth criterion, and continuously merging adjacent pixels that meet the growth criterion into the defective area until no new pixels are added, thereby obtaining a segmented defective area;

[0010] The contour of the segmented defective area is extracted to obtain a contour matrix composed of contour point coordinates; the circumscribed rectangle with the smallest area is found in the contour matrix through the rotating caliper algorithm, and the coordinates of the four vertices of the circumscribed rectangle are calculated; the center coordinates of the circumscribed rectangle are obtained as the position coordinates of the defective area through the diagonal intersection coordinate calculation formula.

[0011] In an optional embodiment,

[0012] The conditional generative adversarial network includes a generator and a discriminator.

[0013] The generator includes an encoder and a decoder, wherein the encoder extracts high-level semantic features of the image through convolution and downsampling operations, and the decoder maps the features back to the original image size through deconvolution and upsampling operations;

[0014] The discriminator adopts the PatchGAN architecture to divide the input image into multiple local areas, make a true or false judgment on each area, and finally average the judgment results of all areas to obtain the true or false probability of the entire image;

[0015] The generator and the discriminator are optimized alternately, the generator minimizes the difference between the generated image and the real image and maximizes the true probability of the discriminator for the generated image, and the discriminator maximizes the true probability of the real image and minimizes the true probability of the generated image.

[0016] In an optional embodiment,

[0017] An attention mechanism is introduced into the residual block of the Defect-ResNet network, and the attention mechanism includes two parts: channel attention and spatial attention;

[0018] The channel attention adaptively adjusts the weights of different channels, given the input feature map of the residual block of the Defect-ResNet network , channel descriptor is obtained by global average pooling ,in R Indicates the defect area, C Indicates the number of channels, H and W Represent the height and width of the feature map respectively, and generate the channel weight vector through several fully connected layers and Sigmoid activation functions. , the calculation formula of the weight vector s is:

[0019]

[0020] in, and is the weight matrix of the fully connected layer, represents the ReLU activation function, Represents the Sigmoid activation function, which obtains the channel attention weighted feature map by multiplying the channel weight vector with the input feature map ;

[0021] The spatial attention generates a weight matrix of spatial positions to highlight the spatial significance of the defect area; the input feature map Perform maximum pooling and average pooling on the channel dimension to obtain two spatial descriptors and , concatenate the two spatial descriptors and generate a spatial weight matrix through a convolutional layer and a Sigmoid activation function , the calculation formula of the spatial weight matrix is

[0022]

[0023] in, Represents a 3x3 convolution operation, which multiplies the spatial weight matrix M by the input feature map X to obtain the spatial attention weighted feature map ;

[0024] By combining channel attention and spatial attention, the final attention-weighted feature map is obtained , the calculation formula of the attention weighted feature map is:

[0025] .

[0026] In an optional embodiment,

[0027] On the output feature maps of the second, third and fourth residual block groups of the Defect-ResNet network, the number of channels is adjusted by 1x1 convolution to obtain feature maps of three different scales. , and ,in , and are the number of output channels of the corresponding residual block groups, and and The size is enlarged to Same, get and ; The feature maps of the three scales are spliced ​​in the channel dimension, and feature fusion is performed through a 3x3 convolution to obtain the final multi-scale fusion feature map .

[0028] In an optional embodiment,

[0029] A pyramid pooling module is introduced at the end of the Defect-ResNet network. The pyramid pooling module processes the input feature map through four parallel pooling branches. The first branch uses global average pooling to obtain a feature map of size 1x1. , used to represent global information; the second, third, and fourth branches use adaptive average pooling of sizes 2x2, 3x3, and 6x6, respectively, to obtain feature maps of different scales , and , used to represent the local information of different receptive fields; through upsampling operation , , , The size of is restored to the same as the input feature map, and concatenated in the channel dimension to obtain the feature map after pyramid pooling ;

[0030] A feature pyramid network is introduced into the Defect-ResNet network, and a multi-scale feature pyramid is constructed through top-down feature propagation and lateral connection.

[0031] In an optional embodiment,

[0032] According to the scale characteristics of the defect area, the size and shape of the structural element are adaptively selected. Through the connected region analysis, the preliminary defect area is extracted and the equivalent diameter of each area is calculated. According to the size of the equivalent diameter, the defect area is divided into three scale levels: small, medium and large.

[0033] Selecting corresponding structural elements according to the scale level of the defect area, and performing morphological opening and closing operations respectively;

[0034] Taking the defect area as the center, extracting a local neighborhood window of the defect area; in each local window, calculating a normalized histogram of the image grayscale, and calculating a local entropy value according to the histogram;

[0035] According to the size of the local entropy value, the grayscale contrast of the pixels in the local window is adaptively adjusted; for a given local neighborhood window W(i,j) ,in (i,j) Represents the coordinates of the center pixel of the window. The calculation formula of local entropy is as follows:

[0036]

[0037] in, H(i, j) In pixels (i, j) The entropy value of the local neighborhood window centered at is, L represents the grayscale level of the image, Indicates in the local window W(i,j) The probability of a pixel with gray level k appearing in ;

[0038] For the local neighborhood window W(i,j) , its contrast enhancement factor The calculation formula is:

[0039]

[0040] in, and Respectively represent the maximum and minimum values ​​of local entropy in the entire image; and Represents the preset maximum and minimum contrast enhancement coefficients respectively; for each pixel in the window, the enhanced gray value The calculation formula is:

[0041]

[0042] in, Represents the original grayscale value of the pixel, Represents the average grayscale value of pixels in the local window.

[0043] In an optional embodiment,

[0044] Perform edge detection on the pre-processed defect area, extract the boundary pixels of the defect area, and select the pixel with the largest gray value from the boundary pixels as the initial seed point ; The initial seed point The selection formula is:

[0045]

[0046] Among them, the boundary pixel set is B, Represents the grayscale value of pixel (x, y);

[0047] Dynamically adjust the growth criterion threshold to adapt to the change of grayscale in the defect area; the initial threshold is calculated based on the grayscale statistical characteristics of the pixels in the neighborhood of the seed point. The calculation formula is:

[0048]

[0049] in, Indicates the seed point The average grayscale value of pixels in the neighborhood. Represents the standard deviation of the grayscale value of pixels in the neighborhood of the seed point; k is a preset constant parameter used to adjust the threshold value;

[0050] During the growth process, for the candidate growth pixel (x, y), its gray value g(x, y) is equal to the average gray value of the current growth area G. When the absolute value of the difference is less than or equal to the current threshold T, it is incorporated into the growth area, that is, the following conditions are met:

[0051]

[0052] The update formula of threshold T is:

[0053]

[0054] in Indicates the standard deviation of the pixel grayscale value in the current growth area;

[0055] If a pixel (x, y) belongs to a boundary pixel, the following conditions must be met to incorporate it into the growing region:

[0056] in, represents the dot product of the gradient vector and the growth direction, and denote the magnitude of the gradient vector and the growth direction vector, respectively. is a preset angle threshold used to determine the consistency between the gradient direction and the growth direction;

[0057] Performing local contrast enhancement and region growing segmentation on the defect image at multiple scales to obtain a set of segmentation results, wherein the segmentation results at different scales can reflect the shape and boundary features of the defect region at different levels;

[0058] For the segmentation results at each scale, calculate its confidence score;

[0059] According to the confidence score, weighted voting is performed on the multi-scale segmentation results to obtain the final defect area.

[0060] In an optional embodiment,

[0061] The method for extracting the contour of the segmented defective area includes:

[0062] The Moore-Neighbor tracking algorithm is used, based on the 8-neighborhood, starting from the upper left corner pixel of the defect area, and performing neighborhood search in a clockwise direction to extract a complete set of defect contour points, which is recorded as , where N is the number of contour points;

[0063] The rotating caliper algorithm includes:

[0064] Defect contour point set Perform Graham scan to obtain the convex hull point set of the defect area , where M is the number of convex hull points;

[0065] In the convex hull point set, select the point with the smallest y coordinate as the starting point, denoted as If there are multiple points with the smallest y coordinates, select the point with the smallest x coordinate;

[0066] by As the starting point, sort the convex hull points in a clockwise direction to get the sorted convex hull point set ;

[0067] Initialize the current edge for arrive Vector, initialize the minimum enclosing rectangle area ;

[0068] Loop through the convex hull point set, for each point :

[0069] Calculate the current edge Angle with x-axis ;

[0070] Calculate is the area of ​​the circumscribed rectangle of one side , where the other side of the rectangle is A vertical straight line;

[0071] if , then update the minimum enclosing rectangle area , and record the coordinates of the four vertices of the current rectangle;

[0072] Set the current edge Rotate to the next edge ,Right now arrive A vector of

[0073] After the loop ends, the coordinates of the four vertices of the minimum bounding rectangle are obtained, recorded as:

[0074] ;

[0075] The method for calculating the defect position coordinates includes:

[0076] According to the coordinates of the four vertices of the minimum circumscribed rectangle, the center coordinates of the rectangle are calculated as the position coordinates of the defect.

[0077] In the second aspect of the embodiments of the present application,

[0078] Provides a machine vision-based mold plate quality inspection system, including:

[0079] The first unit is used to construct a defect detection dataset based on the data enhancement method of conditional generative adversarial network, and detect the defect area of ​​the mold plate through the Defect-ResNet network;

[0080] The second unit is used to pre-process the defective area of ​​the mold plate, take the defective pixels in the defective area as seed points, set a growth criterion, and continuously merge adjacent pixels that meet the growth criterion into the defective area until no new pixels are added, thereby obtaining a segmented defective area;

[0081] The third unit is used to extract the contour of the segmented defective area to obtain a contour matrix composed of contour point coordinates; through the rotating caliper algorithm, find the circumscribed rectangle with the smallest area in the contour matrix, and calculate the coordinates of the four vertices of the circumscribed rectangle; through the diagonal intersection coordinate calculation formula, obtain the center coordinates of the circumscribed rectangle as the position coordinates of the defective area.

[0082] According to a third aspect of the embodiments of the present invention,

[0083] An electronic device is provided, comprising:

[0084] processor;

[0085] a memory for storing processor-executable instructions;

[0086] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.

[0087] This application uses a data enhancement method based on conditional generative adversarial networks to construct a defect detection dataset, which effectively solves the problem of insufficient defect samples. By generating realistic synthetic defect samples, the defect types and quantities are enriched, the generalization ability and robustness of the model are improved, the dependence on a large number of real defect samples is reduced, and the time and cost of manual annotation are saved.

[0088] The Defect-ResNet network is used to detect defective areas of mold plates. Feature enhancement strategies such as attention mechanism, multi-scale feature fusion, pyramid pooling and feature pyramid network are introduced, which greatly improves the defect detection accuracy and efficiency of the model in complex industrial scenarios. This method can effectively cope with challenges such as complex surface textures and diverse defect types of mold plates, and achieves high-precision and high-robust defect localization.

[0089] The detected defective area is preprocessed, and a segmentation algorithm based on region growing is used. The defective pixels are used as seed points, and the adjacent pixels are adaptively merged through the growth criterion to obtain accurate defective area segmentation results. This method overcomes the limitations of the traditional threshold segmentation method, can adapt to different defect types and background changes, and improves the accuracy of defect area extraction.

[0090] The contour of the segmented defect area is extracted to obtain a contour matrix composed of contour point coordinates. The rotating caliper algorithm is used to find the smallest circumscribed rectangle in the contour matrix and calculate the coordinates of the four vertices of the circumscribed rectangle. This method can accurately locate the position and range of the defect area, providing an important basis for subsequent defect classification, measurement and statistics.

[0091] Through the calculation formula of the diagonal intersection coordinates, the center coordinates of the circumscribed rectangle are obtained as the position coordinates of the defect area. This method is simple and efficient, can quickly determine the exact location of the defect, facilitates the visualization and positioning of the defect area, and provides strong support for quality traceability and problem diagnosis in industrial production. BRIEF DESCRIPTION OF THE DRAWINGS

[0092] Figure 1 It is a flow chart of a method for detecting quality of mold plate parts based on machine vision according to an embodiment of the present invention;

[0093] Figure 2 It is a structural schematic diagram of a mold plate quality inspection system based on machine vision according to an embodiment of the present invention. DETAILED DESCRIPTION

[0094] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0095] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0096] Figure 1 FIG. 1 is a flow chart of a method for detecting quality of mold plate parts based on machine vision according to an embodiment of the present invention. Figure 1 As shown, the method includes:

[0097] S101. Construct a defect detection dataset based on the data enhancement method of conditional generative adversarial network, and detect defective areas of mold plates through Defect-ResNet network;

[0098] S102. Preprocessing the defective region of the mold plate, using defective pixels in the defective region as seed points, setting growth criteria, and continuously merging adjacent pixels that meet the growth criteria into the defective region until no new pixels are added, thereby obtaining a segmented defective region;

[0099] S103. Extract the contour of the segmented defective area to obtain a contour matrix composed of contour point coordinates; use the rotating caliper algorithm to find the smallest circumscribed rectangle in the contour matrix, and calculate the coordinates of the four vertices of the circumscribed rectangle; use the diagonal intersection coordinate calculation formula to obtain the center coordinates of the circumscribed rectangle as the position coordinates of the defective area.

[0100] The machine vision-based mold plate quality detection method proposed in the present invention uses conditional generative adversarial networks for data enhancement, uses Defect-ResNet networks for defect detection, and combines regional growth segmentation and rotating chuck algorithms for defect location, which greatly improves the accuracy, efficiency and robustness of mold plate defect detection. This method can effectively solve the limitations of traditional manual detection and machine vision detection methods based on image processing, adapt to the needs of defect detection in complex industrial environments, and provide important technical support for improving mold quality, ensuring production safety, and improving production efficiency. It has broad application prospects and economic value.

[0101] In an optional embodiment,

[0102] The conditional generative adversarial network includes a generator and a discriminator.

[0103] The generator includes an encoder and a decoder, wherein the encoder extracts high-level semantic features of the image through convolution and downsampling operations, and the decoder maps the features back to the original image size through deconvolution and upsampling operations;

[0104] The discriminator adopts the PatchGAN architecture to divide the input image into multiple local areas, make a true or false judgment on each area, and finally average the judgment results of all areas to obtain the true or false probability of the entire image;

[0105] The generator and the discriminator are optimized alternately, the generator minimizes the difference between the generated image and the real image and maximizes the true probability of the discriminator for the generated image, and the discriminator maximizes the true probability of the real image and minimizes the true probability of the generated image.

[0106] In an optional embodiment,

[0107] An attention mechanism is introduced into the residual block of the Defect-ResNet network, and the attention mechanism includes two parts: channel attention and spatial attention;

[0108] The channel attention adaptively adjusts the weights of different channels, given the input feature map of the residual block of the Defect-ResNet network , channel descriptor is obtained by global average pooling ,in R Indicates the defect area, C Indicates the number of channels, H and W Represent the height and width of the feature map respectively, and generate the channel weight vector through several fully connected layers and Sigmoid activation functions. , the calculation formula of the weight vector s is:

[0109]

[0110] in, and is the weight matrix of the fully connected layer, represents the ReLU activation function, Represents the Sigmoid activation function, which obtains the channel attention weighted feature map by multiplying the channel weight vector with the input feature map ;

[0111] The spatial attention generates a weight matrix of spatial positions to highlight the spatial significance of the defect area; the input feature map Perform maximum pooling and average pooling on the channel dimension to obtain two spatial descriptors and , concatenate the two spatial descriptors and generate a spatial weight matrix through a convolutional layer and a Sigmoid activation function , the calculation formula of the spatial weight matrix is:

[0112]

[0113] in, Represents a 3x3 convolution operation, which multiplies the spatial weight matrix M by the input feature map X to obtain the spatial attention weighted feature map ;

[0114] By combining channel attention and spatial attention, the final attention-weighted feature map is obtained , the calculation formula of the attention weighted feature map is:

[0115] .

[0116] In an optional embodiment,

[0117] On the output feature maps of the second, third and fourth residual block groups of the Defect-ResNet network, the number of channels is adjusted by 1x1 convolution to obtain feature maps of three different scales. , and ,in , and are the number of output channels of the corresponding residual block groups, and and The size is enlarged to Same, get and ; The feature maps of the three scales are spliced ​​in the channel dimension, and feature fusion is performed through a 3x3 convolution to obtain the final multi-scale fusion feature map .

[0118] In an optional embodiment,

[0119] A pyramid pooling module is introduced at the end of the Defect-ResNet network. The pyramid pooling module processes the input feature map through four parallel pooling branches. The first branch uses global average pooling to obtain a feature map of size 1x1. , used to represent global information; the second, third, and fourth branches use adaptive average pooling of sizes 2x2, 3x3, and 6x6, respectively, to obtain feature maps of different scales , and , used to represent the local information of different receptive fields; through upsampling operation , , , The size of is restored to the same as the input feature map, and concatenated in the channel dimension to obtain the feature map after pyramid pooling ;

[0120] A feature pyramid network is introduced into the Defect-ResNet network, and a multi-scale feature pyramid is constructed through top-down feature propagation and lateral connection.

[0121] For example, in the task of defect detection of mold plate parts, building a high-quality defect detection dataset is the basis for training high-performance deep learning models. This paper adopts a data enhancement method based on Generative Adversarial Network (GAN) to synthesize a large number of realistic defect samples and expand the original defect dataset.

[0122] Specifically, this paper designs a conditional generative adversarial network (CGAN), which uses the defect type as conditional information to control the generation of specific types of defect samples. CGAN consists of two parts: the generator and the discriminator. The generator aims to generate realistic defect images, and the discriminator aims to determine whether the input image is a real sample or a generated sample. The two play adversarial games during the training process, and ultimately enable the generator to generate images that are almost indistinguishable from real defect samples.

[0123] The generator of CGAN adopts the U-Net architecture, which consists of two parts: encoder and decoder. The encoder extracts high-level semantic features of the image through convolution and downsampling operations, and the decoder maps the features back to the original image size through deconvolution and upsampling operations. A jump connection is introduced between the encoder and decoder to retain the detailed information of the image. At the same time, the defect type is used as conditional information and spliced ​​with the encoder's features, so that the generator can generate corresponding defect images according to different defect types.

[0124] The discriminator of CGAN adopts the PatchGAN architecture, which divides the input image into multiple local areas, makes a true or false judgment for each area, and finally averages the judgment results of all areas to obtain the true or false probability of the entire image. Compared with global discrimination, PatchGAN can pay more attention to the local details of the image, improving the performance of the discriminator.

[0125] During the training process, the generator and the discriminator are optimized alternately. The goal of the generator is to minimize the difference between the generated image and the real image, and to maximize the true probability of the discriminator for the generated image; the goal of the discriminator is to maximize the true probability for the real image and minimize the true probability for the generated image. Through continuous adversarial training, the generator can eventually generate realistic defect images.

[0126] Based on the original defect dataset, this paper uses the trained CGAN model to generate a large number of different types of defect samples, including scratches, bubbles, deformations, etc. The generated defect samples are mixed with the original dataset to form an enhanced defect detection dataset. Experimental results show that the enhanced dataset can effectively improve the generalization performance of the defect detection model, especially in small sample scenarios.

[0127] In the task of mold plate defect detection, selecting a suitable deep learning model and performing targeted optimization are crucial to improving detection performance. Based on the comparative analysis of various classic convolutional neural networks (CNN), this paper proposes an improved ResNet model named Defect-ResNet.

[0128] In deep convolutional neural networks, different feature channels and spatial positions contribute differently to the target detection task. In order to enable the model to adaptively focus on features that are more important for defect detection, this paper introduces an attention mechanism in the residual block of Defect-ResNet, including channel attention and spatial attention.

[0129] The introduction of the attention mechanism enables Defect-ResNet to adaptively adjust the importance of different channels and spatial positions, pay more attention to the features that play a key role in defect detection, and improve the representation ability and detection accuracy of the model. The experimental results on the mold plate defect detection dataset show that after the introduction of the attention mechanism, the defect detection performance of Defect-ResNet has been significantly improved, especially in complex backgrounds and small-size defect scenarios.

[0130] As a general feature enhancement method, the attention mechanism can not only be applied to ResNet, but also can be integrated into other mainstream convolutional neural networks, such as VGGNet, Inception and DenseNet, providing new ideas and directions for improving the performance of deep learning models in defect detection tasks.

[0131] The defects of mold plates are of various sizes and shapes. It is difficult for a single-scale feature representation to take into account defects of different sizes and shapes. In order to improve the detection capability of Defect-ResNet for multi-scale defects, this paper designs a multi-scale feature fusion module to obtain a more comprehensive and robust defect representation by fusing shallow and deep feature information.

[0132] For example, multi-scale feature fusion is a commonly used feature enhancement technology. In addition to the upsampling and splicing methods used in this paper, it can also be achieved through pyramid pooling, dilated convolution, feature pyramid network and other methods. These methods have achieved wide success in tasks such as image classification, target detection, and semantic segmentation, and provide effective solutions to the problems of scale change and small target detection. This paper applies multi-scale feature fusion to the field of industrial defect detection, further expanding its application scope and providing new ideas for improving the performance of defect detection algorithms.

[0133] Furthermore, in order to further enhance the adaptability of Defect-ResNet to defects of different scales, this paper introduces a pyramid pooling module at the end of the network. Pyramid pooling obtains feature representations of different receptive fields by multi-scale downsampling and global average pooling of feature maps, enabling the model to simultaneously utilize global and local contextual information, thereby improving the ability to detect defects in complex backgrounds. The pyramid pooling module enables Defect-ResNet to simultaneously capture the global and local features of defects by fusing features of different scales and receptive fields, thereby enhancing the ability to detect defects in complex environments. Experiments on the mold plate defect detection dataset show that after the introduction of pyramid pooling, the detection accuracy and robustness of Defect-ResNet on complex backgrounds and defects of different sizes have been significantly improved, proving the effectiveness of the pyramid pooling strategy.

[0134] In summary, this paper greatly improves the performance of the model in the mold plate defect detection task by introducing multiple feature enhancement strategies such as attention mechanism, multi-scale feature fusion, pyramid pooling and FPN in Defect-ResNet. These strategies enhance the feature representation ability of the model from different angles, enabling it to better adapt to the diversity of defect size, morphology and background, and achieve significant improvement in detection accuracy and robustness. At the same time, the work of this paper also provides useful reference and reference for other industrial defect detection tasks, demonstrating the broad application prospects of feature enhancement technology in improving defect detection performance.

[0135] In an optional embodiment,

[0136] According to the scale characteristics of the defect area, the size and shape of the structural element are adaptively selected. Through the connected region analysis, the preliminary defect area is extracted and the equivalent diameter of each area is calculated. According to the size of the equivalent diameter, the defect area is divided into three scale levels: small, medium and large.

[0137] Selecting corresponding structural elements according to the scale level of the defect area, and performing morphological opening and closing operations respectively;

[0138] Taking the defect area as the center, extracting a local neighborhood window of the defect area; in each local window, calculating a normalized histogram of the image grayscale, and calculating a local entropy value according to the histogram;

[0139] According to the size of the local entropy value, the grayscale contrast of the pixels in the local window is adaptively adjusted; for a given local neighborhood window W(i,j) ,in (i,j) Represents the coordinates of the center pixel of the window. The calculation formula of local entropy is as follows:

[0140]

[0141] in, H(i, j) In pixels (i, j) The entropy value of the local neighborhood window centered at is, L represents the grayscale level of the image, Indicates in the local window W(i,j) The probability of a pixel with gray level k appearing in ;

[0142] For the local neighborhood window W(i,j) , its contrast enhancement factor The calculation formula is:

[0143]

[0144] in, and Respectively represent the maximum and minimum values ​​of local entropy in the entire image; and Represents the preset maximum and minimum contrast enhancement coefficients respectively; for each pixel in the window, the enhanced gray value The calculation formula is:

[0145]

[0146] in, Represents the original grayscale value of the pixel, Represents the average grayscale value of pixels in the local window.

[0147] In an optional embodiment,

[0148] Perform edge detection on the pre-processed defect area, extract the boundary pixels of the defect area, and select the pixel with the largest gray value from the boundary pixels as the initial seed point ; The initial seed point The selection formula is:

[0149]

[0150] Among them, the boundary pixel set is B, Represents the grayscale value of pixel (x, y);

[0151] Dynamically adjust the growth criterion threshold to adapt to the change of grayscale in the defect area; the initial threshold is calculated based on the grayscale statistical characteristics of the pixels in the neighborhood of the seed point. The calculation formula is:

[0152]

[0153] in, Indicates the seed point The average grayscale value of pixels in the neighborhood. Represents the standard deviation of the grayscale value of pixels in the neighborhood of the seed point; k is a preset constant parameter used to adjust the threshold value;

[0154] During the growth process, for the candidate growth pixel (x, y), its gray value g(x, y) is equal to the average gray value of the current growth area G. When the absolute value of the difference is less than or equal to the current threshold T, it is incorporated into the growth area, that is, the following conditions are met:

[0155]

[0156] The update formula of threshold T is:

[0157]

[0158] in Indicates the standard deviation of the pixel grayscale value in the current growth area;

[0159] If a pixel (x, y) belongs to a boundary pixel, the following conditions must be met to incorporate it into the growing region:

[0160] in, represents the dot product of the gradient vector and the growth direction, and denote the magnitude of the gradient vector and the growth direction vector, respectively. is a preset angle threshold used to determine the consistency between the gradient direction and the growth direction;

[0161] Performing local contrast enhancement and region growing segmentation on the defect image at multiple scales to obtain a set of segmentation results, wherein the segmentation results at different scales can reflect the shape and boundary features of the defect region at different levels;

[0162] For the segmentation results at each scale, calculate its confidence score;

[0163] According to the confidence score, weighted voting is performed on the multi-scale segmentation results to obtain the final defect area.

[0164] For example, in the process of defect detection of mold plate parts, the detected defect area usually contains certain background pixels. In order to accurately locate the defects, the defect area needs to be further segmented. Based on the segmentation algorithm based on region growing, this paper has introduced a variety of optimization measures. The algorithm uses the defect pixels in the defect detection results as seed points, and by setting the growth criteria, it continuously merges adjacent pixels that meet the criteria into the defect area until no new pixels are added.

[0165] Based on the above defect area segmentation algorithm, in order to further improve the segmentation accuracy and algorithm innovation, this paper proposes a defect area segmentation algorithm based on adaptive morphology and local contrast enhancement. The algorithm achieves accurate segmentation of the defect area of ​​the mold plate through adaptive morphological preprocessing, local contrast enhancement, improved region growing segmentation, multi-scale fusion and post-processing. The following will elaborate on the various steps of the algorithm and its technical implementation.

[0166] Morphological operation is a commonly used region processing method in image processing, which can effectively eliminate image noise and fill regional holes. Traditional morphological operations usually use fixed structural elements, which are difficult to adapt to defect areas of different scales and shapes. To solve this problem, this paper proposes an adaptive morphological preprocessing method.

[0167] According to the scale characteristics of the defect area, the size and shape of the structural element are adaptively selected. First, the preliminary defect area is extracted through connected region analysis, and the equivalent diameter of each area is calculated. Then, according to the size of the equivalent diameter, the defect area is divided into three scale levels: small, medium, and large. For defect areas of different scales, circular or rectangular structural elements of different sizes are selected to adapt to the shape characteristics of the defect area.

[0168] For each defective area, the corresponding structural element is selected according to its scale level, and morphological opening and closing operations are performed respectively. The opening operation can eliminate small noise points and burrs by corroding and dilating the image; the closing operation can fill small holes in the area by dilating first and then corroding. Through adaptive morphological operations, noise interference can be effectively suppressed while retaining the shape characteristics of the defective area.

[0169] The surface texture of mold plates is complex, and the contrast between the defect area and the background is often low, which brings challenges to the accurate segmentation of the defect area. In order to enhance the contrast of the defect area, this paper proposes a contrast enhancement method based on local entropy.

[0170] The local neighborhood window is extracted with the defect area segmented initially as the center. In each local window, the normalized histogram of the image grayscale is calculated, and the local entropy value is calculated based on the histogram. The local entropy reflects the uniformity of the grayscale distribution in the local area of ​​the image. The larger the entropy value, the lower the local contrast.

[0171] According to the size of the local entropy value, the grayscale contrast of the pixels in the local window is adaptively adjusted. For areas with larger entropy values, a larger contrast enhancement coefficient is used to stretch the pixel grayscale in the local window to increase the contrast difference between the defect area and the background. For areas with smaller entropy values, a smaller contrast enhancement coefficient is used to avoid detail loss caused by over-enhancement.

[0172] Through adaptive local contrast enhancement, the visual significance of the defect area can be effectively improved, providing more reliable boundary information for subsequent region growing segmentation.

[0173] Exemplarily, based on the traditional region growing segmentation algorithm, this paper introduces boundary constraints and adaptive growing strategies to improve segmentation accuracy and robustness.

[0174] Traditional region growing algorithms usually select seed points randomly, which are easily affected by noise and background interference. In order to improve the reliability of seed points, this paper adopts a seed point selection strategy based on boundaries. First, edge detection is performed on the preprocessed defect area to extract the boundary pixels of the defect area. Then, the pixel with the largest grayscale value is selected from the boundary pixels as the initial seed point to ensure that the seed point is located inside the defect area.

[0175] During the region growing process, the threshold of the growth criterion is dynamically adjusted to adapt to the change of the grayscale of the defective area. The initial threshold is calculated based on the grayscale statistical characteristics of the pixels in the neighborhood of the seed point. During the growing process, the threshold of the growth criterion is adaptively updated according to the average grayscale value and standard deviation of the current growing area. Through the adaptive threshold strategy, background interference can be effectively suppressed and the accuracy and adaptability of growth can be improved.

[0176] In order to prevent the boundary generalization problem caused by excessive regional growth, boundary constraints are introduced in the growth process. For each candidate growth pixel, it is determined whether it is located on the boundary of the defect region. If the pixel belongs to the boundary pixel, its gradient direction is further checked for consistency with the current growth direction. Only when the gradient direction is consistent with the growth direction, the pixel is incorporated into the growth region to ensure that the growth process proceeds along the defect boundary direction.

[0177] Through the improved region growing strategy, background interference can be effectively suppressed, segmentation accuracy can be improved, and the integrity and accuracy of the defect boundary can be ensured.

[0178] In an optional embodiment,

[0179] The method for extracting the contour of the segmented defective area includes:

[0180] The Moore-Neighbor tracking algorithm is used, based on the 8-neighborhood, starting from the upper left corner pixel of the defect area, and performing neighborhood search in a clockwise direction to extract a complete set of defect contour points, which is recorded as , where N is the number of contour points;

[0181] The rotating caliper algorithm includes:

[0182] Defect contour point set Perform Graham scan to obtain the convex hull point set of the defect area , where M is the number of convex hull points;

[0183] In the convex hull point set, select the point with the smallest y coordinate as the starting point, denoted as If there are multiple points with the smallest y coordinates, select the point with the smallest x coordinate;

[0184] by As the starting point, sort the convex hull points in a clockwise direction to get the sorted convex hull point set ;

[0185] Initialize the current edge for arrive Vector, initialize the minimum enclosing rectangle area ;

[0186] Loop through the convex hull point set, for each point :

[0187] Calculate the current edge Angle with x-axis ;

[0188] Calculate is the area of ​​the circumscribed rectangle of one side , where the other side of the rectangle is A vertical straight line;

[0189] if , then update the minimum enclosing rectangle area , and record the coordinates of the four vertices of the current rectangle;

[0190] Set the current edge Rotate to the next edge ,Right now arrive A vector of

[0191] After the loop ends, the coordinates of the four vertices of the minimum bounding rectangle are obtained, recorded as:

[0192] ;

[0193] The method for calculating the defect position coordinates includes:

[0194] According to the coordinates of the four vertices of the minimum circumscribed rectangle, the center coordinates of the rectangle are calculated as the position coordinates of the defect.

[0195] For example, after obtaining the segmented defect area, it is necessary to further extract its position coordinate information so as to calibrate the defect position in the CAD model or physical image of the mold plate. This paper proposes a defect position coordinate extraction algorithm based on rectangle fitting, which obtains its center coordinates as the defect position coordinates by fitting the minimum circumscribed rectangle of the segmented defect area.

[0196] First, the contour of the segmented defect area is extracted to obtain a contour matrix composed of contour point coordinates. Then, the rotating caliper algorithm is used to find the smallest circumscribed rectangle in the contour matrix and calculate the coordinates of its four vertices. Finally, the center coordinates of the circumscribed rectangle are obtained through the diagonal intersection coordinate calculation formula as the location coordinates of the defect.

[0197] Specifically:

[0198] In industrial product quality inspection, accurate defect location is a key step to achieve defect annotation and subsequent defect analysis. Traditional defect location extraction methods, such as regional geometric center method and edge fitting method, have low accuracy and robustness when dealing with complex backgrounds and irregular defect shapes. In order to overcome these problems, this paper proposes a defect location coordinate extraction algorithm based on rectangle fitting. By fitting the minimum circumscribed rectangle of the segmented defect area, its center coordinates are obtained as the defect location coordinates, achieving high-precision and high-robust defect location.

[0199] This application uses a rotating caliper algorithm to search for the minimum circumscribed rectangle, which can efficiently and accurately fit irregularly shaped defect areas, overcoming the limitations of traditional methods on defect shapes. Through Graham scanning preprocessing of the convex hull point set, the search range of the rotating caliper algorithm is reduced, and the efficiency of the algorithm is improved. The center coordinates of the minimum circumscribed rectangle are used as the defect position coordinates, which not only considers the overall geometric characteristics of the defect area, but also avoids the interference of edge noise and local shape changes, thereby improving positioning accuracy and robustness. The algorithm is suitable for defect areas of various shapes and sizes, has strong versatility and adaptability, and can be promoted and used in different application scenarios of industrial defect detection.

[0200] The defect location coordinate extraction algorithm based on rectangle fitting proposed in this paper makes comprehensive use of the contour features and geometric features of the defect area, and realizes efficient, accurate and robust defect location through the rotating caliper algorithm and convex hull preprocessing. Compared with traditional methods, this algorithm shows better performance in complex backgrounds and provides a reliable defect location solution for industrial product defect detection and quality control.

[0201] Figure 2 FIG. 1 is a schematic diagram of the structure of a mold plate quality inspection system based on machine vision according to an embodiment of the present invention. Figure 2 As shown, the system comprises:

[0202] The first unit is used to construct a defect detection dataset based on the data enhancement method of conditional generative adversarial network, and detect the defect area of ​​the mold plate through the Defect-ResNet network;

[0203] The second unit is used to pre-process the defective area of ​​the mold plate, take the defective pixels in the defective area as seed points, set a growth criterion, and continuously merge adjacent pixels that meet the growth criterion into the defective area until no new pixels are added, thereby obtaining a segmented defective area;

[0204] The third unit is used to extract the contour of the segmented defective area to obtain a contour matrix composed of contour point coordinates; through the rotating caliper algorithm, find the circumscribed rectangle with the smallest area in the contour matrix, and calculate the coordinates of the four vertices of the circumscribed rectangle; through the diagonal intersection coordinate calculation formula, obtain the center coordinates of the circumscribed rectangle as the position coordinates of the defective area.

[0205] According to a third aspect of the embodiments of the present invention,

[0206] An electronic device is provided, comprising:

[0207] processor;

[0208] a memory for storing processor-executable instructions;

[0209] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.

[0210] The present invention may be a method, an apparatus, a system and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present invention.

[0211] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting mold plate quality based on machine vision, characterized in that: include: A defect detection dataset is constructed based on the data enhancement method of conditional generative adversarial network, and the defect area of ​​the mold plate is detected through the Defect-ResNet network; Preprocessing the defective area of ​​the mold plate, taking defective pixels in the defective area as seed points, setting a growth criterion, and continuously merging adjacent pixels that meet the growth criterion into the defective area until no new pixels are added, thereby obtaining a segmented defective area; Extract the contour of the segmented defective area to obtain a contour matrix composed of contour point coordinates; search for the smallest circumscribed rectangle in the contour matrix by using a rotating caliper algorithm, and calculate the coordinates of the four vertices of the circumscribed rectangle; obtain the center coordinates of the circumscribed rectangle as the position coordinates of the defective area by using a diagonal intersection coordinate calculation formula; An attention mechanism is introduced into the residual block of the Defect-ResNet network, and the attention mechanism includes two parts: channel attention and spatial attention; The channel attention adaptively adjusts the weights of different channels, given the input feature map of the residual block of the Defect-ResNet network , channel descriptor is obtained by global average pooling ,in R Indicates the defect area, C Indicates the number of channels, H and W Represent the height and width of the feature map respectively, and generate the channel weight vector through several fully connected layers and Sigmoid activation functions. , the calculation formula of the weight vector s is: in, and is the weight matrix of the fully connected layer, represents the ReLU activation function, Represents the Sigmoid activation function, which obtains the channel attention weighted feature map by multiplying the channel weight vector with the input feature map ; The spatial attention generates a weight matrix of spatial positions to highlight the spatial significance of the defect area; the input feature map Perform maximum pooling and average pooling on the channel dimension to obtain two spatial descriptors and , concatenate the two spatial descriptors and generate a spatial weight matrix through a convolutional layer and a Sigmoid activation function , the calculation formula of the spatial weight matrix is: in, Represents a 3x3 convolution operation, which multiplies the spatial weight matrix M by the input feature map X to obtain the spatial attention weighted feature map ; By combining channel attention and spatial attention, the final attention-weighted feature map is obtained , the calculation formula of the attention weighted feature map is: ; On the output feature maps of the second, third and fourth residual block groups of the Defect-ResNet network, the number of channels is adjusted by 1x1 convolution to obtain feature maps of three different scales. , and ,in , and are the number of output channels of the corresponding residual block groups, and and The size is enlarged to Same, get and ; The feature maps of the three scales are spliced ​​in the channel dimension, and feature fusion is performed through a 3x3 convolution to obtain the final multi-scale fusion feature map ; A pyramid pooling module is introduced at the end of the Defect-ResNet network. The pyramid pooling module processes the input feature map through four parallel pooling branches. The first branch uses global average pooling to obtain a feature map of size 1x1. , used to represent global information; the second, third, and fourth branches use adaptive average pooling of sizes 2x2, 3x3, and 6x6, respectively, to obtain feature maps of different scales , and , used to represent the local information of different receptive fields; through upsampling operation , , , The size of is restored to the same as the input feature map, and concatenated in the channel dimension to obtain the feature map after pyramid pooling ; A feature pyramid network is introduced into the Defect-ResNet network, and a multi-scale feature pyramid is constructed through top-down feature propagation and lateral connection.

2. The method according to claim 1, characterized in that The conditional generative adversarial network includes a generator and a discriminator. The generator includes an encoder and a decoder, wherein the encoder extracts high-level semantic features of the image through convolution and downsampling operations, and the decoder maps the features back to the original image size through deconvolution and upsampling operations; The discriminator adopts the PatchGAN architecture to divide the input image into multiple local areas, make a true or false judgment on each area, and finally average the judgment results of all areas to obtain the true or false probability of the entire image; The generator and the discriminator are optimized alternately, the generator minimizes the difference between the generated image and the real image and maximizes the true probability of the discriminator for the generated image, and the discriminator maximizes the true probability of the real image and minimizes the true probability of the generated image.

3. The method according to claim 1, characterized in that According to the scale characteristics of the defect area, the size and shape of the structural element are adaptively selected. Through the connected region analysis, the preliminary defect area is extracted and the equivalent diameter of each area is calculated. According to the size of the equivalent diameter, the defect area is divided into three scale levels: small, medium and large. Selecting corresponding structural elements according to the scale level of the defect area, and performing morphological opening and closing operations respectively; Taking the defect area as the center, extracting a local neighborhood window of the defect area; in each local window, calculating a normalized histogram of the image grayscale, and calculating a local entropy value according to the histogram; According to the size of the local entropy value, the grayscale contrast of the pixels in the local window is adaptively adjusted; for a given local neighborhood window W(i,j) ,in (i,j) Represents the coordinates of the center pixel of the window. The calculation formula of local entropy is as follows: in, H(i, j) In pixels (i, j) The entropy value of the local neighborhood window centered at is, L represents the grayscale level of the image, Indicates in the local window W(i,j) The probability of a pixel with gray level k appearing in ; For the local neighborhood window W(i,j) , its contrast enhancement factor The calculation formula is: in, and Respectively represent the maximum and minimum values ​​of local entropy in the entire image; and Represents the preset maximum and minimum contrast enhancement coefficients respectively; for each pixel in the window, the enhanced gray value The calculation formula is: in, Represents the original grayscale value of the pixel, Represents the average grayscale value of pixels in the local window.

4. The method according to claim 1, characterized in that Perform edge detection on the pre-processed defect area, extract the boundary pixels of the defect area, and select the pixel with the largest gray value from the boundary pixels as the initial seed point ; The initial seed point The selection formula is: Among them, the boundary pixel set is B, Represents the grayscale value of pixel (x, y); Dynamically adjust the growth criterion threshold to adapt to the change of grayscale in the defect area; the initial threshold is calculated based on the grayscale statistical characteristics of the pixels in the neighborhood of the seed point. The calculation formula is: in, Indicates the seed point The average gray value of pixels in the neighborhood. Represents the standard deviation of the grayscale value of pixels in the neighborhood of the seed point; k is a preset constant parameter used to adjust the size of the threshold; During the growth process, for the candidate growth pixel (x, y), its gray value g(x, y) is equal to the average gray value of the current growth area G. When the absolute value of the difference is less than or equal to the current threshold T, it is incorporated into the growth area, that is, the following conditions are met: The update formula of threshold T is: in Indicates the standard deviation of the pixel grayscale value in the current growth area; If a pixel (x, y) belongs to a boundary pixel, the following conditions must be met to merge it into the growing region: in, represents the dot product of the gradient vector and the growth direction, and denote the magnitude of the gradient vector and the growth direction vector, respectively. is a preset angle threshold used to determine the consistency between the gradient direction and the growth direction; Perform local contrast enhancement and region growing segmentation on the defect image at multiple scales to obtain a set of segmentation results. The segmentation results at different scales can reflect the shape and boundary characteristics of the defect area at different levels. For the segmentation results at each scale, calculate its confidence score; According to the confidence score, weighted voting is performed on the multi-scale segmentation results to obtain the final defect area.

5. The method according to claim 1, characterized in that The method for extracting the contour of the segmented defective area includes: The Moore-Neighbor tracking algorithm is used, based on the 8-neighborhood, starting from the upper left corner pixel of the defect area, and performing neighborhood search in a clockwise direction to extract a complete set of defect contour points, which is recorded as , where N is the number of contour points; The rotating caliper algorithm includes: Defect contour point set Perform Graham scan to obtain the convex hull point set of the defect area , where M is the number of convex hull points; In the convex hull point set, select the point with the smallest y coordinate as the starting point, denoted as , if there are multiple points with the smallest y coordinates, select the point with the smallest x coordinate; by As the starting point, sort the convex hull points in a clockwise direction to get the sorted convex hull point set ; Initialize the current edge for arrive Vector, initialize the minimum enclosing rectangle area ; Loop through the convex hull point set, for each point : Calculate the current edge Angle with x-axis ; Calculate is the area of ​​the circumscribed rectangle of one side , where the other side of the rectangle is A vertical straight line; if , then update the minimum enclosing rectangle area , and record the coordinates of the four vertices of the current rectangle; Set the current edge Rotate to the next edge ,Right now arrive A vector of After the loop ends, the coordinates of the four vertices of the minimum bounding rectangle are obtained, recorded as: ; The calculation method of defect location coordinates includes: According to the coordinates of the four vertices of the minimum circumscribed rectangle, the center coordinates of the rectangle are calculated as the position coordinates of the defect.

6. A mold plate quality inspection system based on machine vision, used to implement the method described in any one of claims 1 to 5, characterized in that: include: The first unit is used to construct a defect detection dataset based on the data enhancement method of conditional generative adversarial network, and detect the defect area of ​​the mold plate through the Defect-ResNet network; The second unit is used to pre-process the defective area of ​​the mold plate, take the defective pixels in the defective area as seed points, set a growth criterion, and continuously merge adjacent pixels that meet the growth criterion into the defective area until no new pixels are added, thereby obtaining a segmented defective area; The third unit is used to extract the contour of the segmented defective area to obtain a contour matrix composed of contour point coordinates; through the rotating caliper algorithm, find the circumscribed rectangle with the smallest area in the contour matrix, and calculate the coordinates of the four vertices of the circumscribed rectangle; through the diagonal intersection coordinate calculation formula, obtain the center coordinates of the circumscribed rectangle as the position coordinates of the defective area.

7. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method described in any one of claims 1 to 5.

Citation Information

Cited By

  • Tungsten steel die defect detection method and system based on visual inspection

    CN121582192A

  • Tungsten steel mold defect detection method and system based on visual detection

    CN121582192B