Iron accessory defect detection method and system
By combining magnetic particle testing with wavelet denoising and a target random forest algorithm model, the problems of detection accuracy and reliability caused by uneven image quality in traditional iron accessory detection methods are solved, and efficient and accurate detection of iron accessory defects is achieved.
Patent Information
- Application Number
- CN202510262108.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-06
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-03-06
AI Technical Summary
Traditional iron accessory defect detection methods rely on basic image inspection. The lack of effective preprocessing leads to uneven image quality, affecting the accuracy and reliability of detection.
Magnetic particle inspection is used to obtain images of iron accessories. Wavelet denoising is used to remove noise, and a target random forest algorithm model is used for defect detection. Combined with the optimization of wavelet basis functions, decomposition levels, and thresholds, image clarity and detection accuracy are improved.
It improves the accuracy and reliability of iron accessory defect detection, highlights defect characteristics, and enhances the stability and precision of detection.
Smart Images

Figure CN120163792B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the field of image processing technology, and more specifically, relates to a method and system for detecting defects in iron accessories. Background Art
[0002] In modern industrial production, iron fittings are key components of various types of machinery, equipment, and building structures. Their quality and integrity are directly related to the safety and reliability of the entire system. For example, in power transmission systems, iron fittings support and secure transmission lines. Defects in these fittings can cause line failures and widespread power outages. In the construction sector, iron fittings are crucial components that connect building structures. Defects can compromise the stability of the structure, threatening life and property. Therefore, efficient and accurate defect detection of iron fittings is crucial.
[0003] Traditional methods for detecting defects in iron accessories rely primarily on basic image inspection. However, the lack of image preprocessing or the use of a single preprocessing method results in inconsistent image quality, which in turn reduces the accuracy and reliability of defect detection in iron accessories.
[0004] Therefore, an accurate and reliable method for detecting defects in iron accessories is urgently needed. Summary of the Invention
[0005] The purpose of the present disclosure is to provide a method and system for detecting defects in iron accessories, so as to improve the accuracy and reliability of the detection of defects in iron accessories.
[0006] A first aspect of the embodiments of the present disclosure provides a method for detecting defects in iron accessories, comprising:
[0007] Acquire a first iron accessory image, where the first iron accessory image is an image of the iron accessory after the target iron accessory is processed based on magnetic particle detection;
[0008] Performing denoising on the first iron attachment image based on a wavelet denoising method to obtain a target iron attachment image;
[0009] The target iron accessory image is input into the target random forest algorithm model to obtain the defect detection results of the target iron accessory.
[0010] A second aspect of the embodiments of the present disclosure provides an iron accessory defect detection system, comprising:
[0011] An image acquisition module is used to acquire a first iron accessory image, where the first iron accessory image is an image of the iron accessory after the target iron accessory is processed based on magnetic particle detection;
[0012] An image processing module is used to perform noise reduction processing on the first iron attachment image based on a wavelet noise reduction method to obtain a target iron attachment image;
[0013] The defect detection module is used to input the target iron accessory image into the target random forest algorithm model to obtain the defect detection result of the target iron accessory.
[0014] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the above-mentioned iron accessory defect detection method when executing the computer program.
[0015] According to a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned iron accessory defect detection method are implemented.
[0016] The beneficial effects of the iron accessory defect detection method and system provided by the embodiments of the present disclosure are:
[0017] This disclosure utilizes magnetic particle inspection technology to process target iron accessories, highlighting surface defects such as cracks and inclusions. It also uses noise reduction to remove noise introduced during image acquisition, thereby improving image clarity and making defects more visible, thereby enhancing the accuracy of iron accessory defect detection. This disclosure also utilizes a targeted random forest algorithm model to perform defect detection on processed images, building multiple decision trees and synthesizing their outputs to improve the accuracy and stability of iron accessory defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0019] Figure 1 A schematic flow chart of a method for detecting defects in iron accessories provided in one embodiment of the present disclosure;
[0020] Figure 2 This is a structural block diagram of an iron accessory defect detection system provided by an embodiment of the present disclosure;
[0021] Figure 3 A schematic block diagram of an electronic device provided in one embodiment of the present disclosure. DETAILED DESCRIPTION
[0022] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present disclosure. However, it will be apparent to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present disclosure with unnecessary detail.
[0023] In order to make the purpose, technical solutions and advantages of the present disclosure more clear, specific embodiments will be described below with reference to the accompanying drawings.
[0024] Please refer to Figure 1 , Figure 1 A schematic flow chart of a method for detecting defects in iron accessories provided in one embodiment of the present disclosure, the method comprising:
[0025] S101: Acquire a first iron accessory image, where the first iron accessory image is an image of the iron accessory after the target iron accessory is processed based on magnetic particle detection.
[0026] In this embodiment, a first iron accessory image may be acquired through a camera. The first iron accessory image is an image of the iron accessory after the target iron accessory is processed through magnetic particle testing.
[0027] Magnetic particle testing is a nondestructive testing method that uses the knowledge that after a ferromagnetic material is magnetized, if there are defects on or near the surface (such as cracks, pores, inclusions, etc.), the magnetic field lines at the defect will be distorted and leak to the surface, forming a leakage magnetic field. When magnetic powder is sprinkled on the material surface, it will aggregate under the influence of the leakage magnetic field, revealing information such as the location and shape of the defect.
[0028] Target iron accessories refer to iron components that need to be inspected for defects, such as iron connectors in power systems and iron components in building structures.
[0029] S102: performing noise reduction processing on the first iron accessory image based on a wavelet noise reduction method to obtain a target iron accessory image.
[0030] In this embodiment, the wavelet denoising method is a technique for image noise reduction that utilizes the characteristics of wavelet transforms. Wavelet transforms can decompose an image into different scales and frequencies. By processing the wavelet coefficients at different scales, the wavelet coefficients representing noise are removed while those representing useful image information are retained. The image is then reconstructed through an inverse transform, achieving the purpose of noise reduction.
[0031] This process involves the selection of wavelet basis functions, the determination of the number of decomposition layers, and the determination of the discrimination threshold. The above three parameters will affect the denoising effect of the wavelet denoising method.
[0032] The image after wavelet denoising is the target iron accessory image. The target iron accessory image contains various information on the surface or near the surface of the iron accessory, such as shape, texture, whether there are magnetic traces, etc., which is the basic data for subsequent defect detection.
[0033] S103: Inputting the target iron accessory image into the target random forest algorithm model to obtain a defect detection result of the target iron accessory.
[0034] In this embodiment, the target random forest algorithm model is obtained through training. For example, in one embodiment of the present disclosure, before inputting the target iron accessory image into the target random forest algorithm model to obtain the defect detection result of the target iron accessory, the following steps are further included:
[0035] Training a random forest algorithm model based on the first data set to obtain a target random forest algorithm model, where the number of decision trees in the target random forest algorithm model is the target number;
[0036] The first data set includes image data of iron accessories that have undergone magnetic particle inspection and corresponding defect type data.
[0037] In this embodiment, the first data set is a data set consisting of a large number of iron accessories that have undergone magnetic particle inspection and their corresponding defect types, and also includes defect-free iron accessory images that have undergone magnetic particle inspection and their corresponding defect types.
[0038] The random forest algorithm is an ensemble learning model composed of multiple decision trees. It synthesizes the predictions from a large number of decision trees to arrive at a final prediction. The predictions can include information such as the presence and type of defect. The output depends on the dataset annotations used during training.
[0039] From the above, it can be concluded that the present disclosure uses magnetic particle inspection technology to process target iron accessories, highlighting surface defects such as cracks and inclusions. The present disclosure uses noise reduction processing to remove noise that occurs during image acquisition, thereby improving image clarity, making defects more prominent, and thus improving the accuracy of iron accessory defect detection. The present disclosure uses a target random forest algorithm model to perform defect detection on the processed images, and improves the accuracy and stability of iron accessory defect detection by constructing multiple decision trees and integrating their output results.
[0040] In one embodiment of the present disclosure, performing noise reduction processing on the first iron accessory image based on a wavelet noise reduction method includes:
[0041] determining a wavelet basis function of a wavelet denoising method based on edge features of the first iron attachment image and image detail features of the first iron attachment image;
[0042] determining the number of decomposition layers of the wavelet denoising method based on the noise of the first iron accessory image and the characteristic scale of the first iron accessory image;
[0043] Determining a discrimination threshold of a wavelet denoising method based on the noise of the first iron attachment image and the required detection accuracy;
[0044] The first iron attachment image is denoised based on wavelet basis function, decomposition layer number and discrimination threshold.
[0045] In this embodiment, image edges refer to areas within an image where grayscale values change dramatically, and they contain the outline of objects within the image. For an image of an iron accessory, edge features can reveal important information such as the accessory's outline and internal structure. Edge detection methods, such as the Sobel operator and the Canny edge detection operator, can be used to extract edge information from an image.
[0046] Image detail refers to the richness of image detail. Fourier transforms can be used to convert an image from the spatial domain to the frequency domain, and the richness of image detail is determined based on the energy proportion of the high-frequency portion of the frequency domain image. A high proportion of high-frequency energy in the frequency domain image indicates rich image detail.
[0047] Considering that different iron attachment images have different edge features and image detail characteristics, and the wavelet basis function is the core of the wavelet transform, different wavelet basis functions have different characteristics. Choosing the appropriate wavelet basis function is very important for effectively separating the signal and noise in the image. The wavelet basis function is selected based on the edge characteristics and image detail characteristics of the first iron attachment image in order to enable the wavelet transform to better preserve the important features of the image while removing noise.
[0048] Image noise can interfere with the extraction of useful information. The noise level can be assessed by calculating the signal-to-noise ratio (SNR) or statistics such as the image noise variance and mean. Excessive noise can cause the image to exhibit multi-scale characteristics, with noise of different frequencies distributed at different scales. Therefore, image noise is related to the number of decomposition layers in the wavelet denoising method.
[0049] Feature scale refers to the scales corresponding to features of different sizes in an image. For example, an image of an iron attachment may contain large-scale overall contour features and small-scale local details. Features of different scales are distributed at different decomposition levels in the wavelet transform.
[0050] For example, magnetic particle inspection images contain both large macro defects, such as pores in castings, and micro defects, such as tiny cracks. If the number of decomposition levels is too low, it may be impossible to effectively distinguish the characteristics and noise of macro and micro defects during noise removal. This can lead to incomplete noise removal around macro defects, or micro defects may be over-smoothed during the noise reduction process, making them difficult to identify.
[0051] Therefore, this embodiment takes into account the influence of image noise and characteristic scale on the number of decomposition layers in the wavelet denoising method.
[0052] Secondly, noise and required detection accuracy also affect the discrimination threshold. When noise intensity increases, the threshold should be raised to better suppress noise; when noise intensity decreases, the threshold can be appropriately lowered to avoid excessive removal of useful signals in the image. Required detection accuracy refers to the strictness of noise removal. If the detection of very subtle defects requires high detection accuracy, the threshold setting should be more stringent to remove as much noise as possible.
[0053] From the above description, we can see that the edge features and image detail features of the image will affect the selection of the wavelet basis function, the noise and feature scale will affect the number of decomposition layers of the wavelet basis function, and the noise and required detection accuracy will affect the discrimination threshold.
[0054] In this embodiment, the wavelet basis function can be determined in the following manner:
[0055] In one embodiment of the present disclosure, determining a wavelet basis function of a wavelet denoising method based on edge features of the first iron accessory image and image detail features of the first iron accessory image includes:
[0056] Detecting edge features of the first iron accessory image based on an edge detection algorithm to obtain edge strength;
[0057] Perform frequency domain analysis on the image detail features of the first iron attachment image based on a frequency domain analysis algorithm to obtain the energy proportion of the high-frequency component;
[0058] The wavelet basis value is obtained by weighted calculation of the edge intensity and the energy proportion of the high-frequency component;
[0059] In response to the wavelet basis value being greater than the first wavelet basis threshold, using the first wavelet basis function as the wavelet basis function of the wavelet denoising method;
[0060] In response to the wavelet basis value being less than or equal to the first wavelet basis value, the second wavelet basis function is used as the wavelet basis function of the wavelet denoising method.
[0061] In this embodiment, the edge detection algorithm can be the Canny algorithm, which can determine the edge strength by calculating the gradient magnitude and direction of the image, performing non-maximum suppression and double threshold processing on the gradient magnitude. , calculate the energy proportion of high-frequency components based on frequency domain analysis algorithm .
[0062] For example, the first iron attachment image , the number of rows and columns is Perform discrete Fourier transform to obtain frequency domain image ,in , , firstly, the frequency domain image is centralized, that is , and then preset a cutoff frequency based on experience , the frequency domain image is divided into low-frequency and high-frequency parts. Calculate its frequency domain center distance .
[0063] The energy of high-frequency components , total energy , .
[0064] Before performing the weighted calculation, the energy proportion of the high-frequency energy can be preprocessed to obtain a numerical value, for example, multiplied by 100, or it can be calculated in the form of a ratio. However, it should be noted that the setting of the subsequent first wavelet basis threshold should also be adjusted according to whether preprocessing is performed. In this embodiment, no preprocessing is performed because the edge strength calculated by the Canny algorithm is a numerical value between 0 and 1, and the energy proportion of the high-frequency energy is also a numerical value between 0 and 1. The order of magnitude of the two data is the same. Therefore, no preprocessing is performed in this embodiment.
[0065] The weighted calculation formula for the two can be ,in, represents the wavelet basis value, represents the weight corresponding to the edge strength, Indicates the weight corresponding to the energy ratio.
[0066] The first wavelet basis threshold can be set based on experience or actual scenarios. When the wavelet basis value is greater than the first wavelet basis threshold, it indicates that the edge features and image details of the image have specific distributions and characteristics, and the image edges are relatively clear, the details are rich, and there is regularity. In this case, a wavelet basis function with good edge preservation characteristics and high-frequency detail capture capabilities can be selected. For example, the first wavelet basis function can be used as the wavelet basis function of the wavelet denoising method. The first wavelet basis function can be a certain wavelet basis function in the Dobesi wavelet family, such as db6. When the wavelet basis value is less than or equal to the first wavelet basis threshold, it indicates that the image edges are relatively blurred, the details are not obvious, or there is a lot of noise. In this case, a wavelet basis function that focuses more on denoising and smoothing can be selected. For example, the second wavelet basis function can be used as the wavelet basis function of the wavelet denoising method, such as the Symlets wavelet. This can suppress noise to a certain extent, while appropriately enhancing and extracting relatively weak edges and details, so that subsequent image analysis and processing can be accurate.
[0067] Secondly, the noise of the first iron attachment image can be obtained by calculating the signal-to-noise ratio. The characteristic scale of the first iron attachment image can be obtained by processing the image using multi-scale analysis tools such as wavelet transform, which is similar to the method of determining the wavelet basis function of the wavelet denoising method. For example:
[0068] performing weighted calculation on the signal-to-noise ratio of the first iron accessory image and the characteristic scale of the first iron accessory image to obtain a decomposition value;
[0069] In response to the decomposition value being less than a first decomposition threshold, using the first decomposition level as the decomposition level of the wavelet denoising method;
[0070] In response to the decomposition value being greater than or equal to the first decomposition threshold, the second decomposition level is used as the decomposition level of the wavelet denoising method; the first decomposition level is smaller than the second decomposition level.
[0071] In this embodiment, the first decomposition threshold may be obtained by fitting according to an experimental process, the first decomposition level may be 3, and the second decomposition level may be 5.
[0072] Finally, the discrimination threshold of the wavelet denoising method is determined based on the noise of the first iron accessory image and the required detection accuracy, which can be obtained through a preset mapping table, as shown in Table 1.
[0073]
[0074] After the wavelet basis function, the number of decomposition layers and the discrimination threshold are determined, the first iron attachment image can be subjected to denoising processing using a wavelet denoising method with predetermined parameters.
[0075] From the above, it can be concluded that the present disclosure can select the most suitable wavelet basis function based on the edge features and detail features of the iron accessory image, ensuring that the noise reduction processing can maximize the retention of useful information in the image while effectively removing noise, thereby improving the overall quality of the image and further improving the stability and reliability of iron accessory defect detection. The present disclosure considers the impact of the image noise level and feature scale on the number of decomposition layers, obtains the decomposition value through weighted calculation, and adjusts the number of decomposition layers, ensuring that the noise reduction processing can not only effectively remove noise but also fully retain the key features in the image, thereby improving the stability and reliability of iron accessory defect detection.
[0076] In one embodiment of the present disclosure, the method for detecting defects in iron accessories further includes:
[0077] In response to a resolution of the first iron accessory image being greater than a first resolution and a contrast of the first iron accessory image being less than or equal to the first contrast, increasing a weight corresponding to the energy proportion based on the first detail step size, and decreasing a weight corresponding to the edge strength based on the first detail step size;
[0078] In response to the image contrast of the first iron accessory being greater than the first contrast and the resolution of the first iron accessory image being less than or equal to the first resolution, the weight corresponding to the edge intensity is increased based on the first edge step, and the weight corresponding to the energy proportion is reduced based on the first edge step.
[0079] In this embodiment, the resolution of the first iron accessory image is basic information of an image, which can be directly obtained or obtained through image viewing software or tools, and the contrast can be obtained through the histogram of the first iron accessory image.
[0080] Considering that image resolution has a more significant effect on image detail, as details encompass more rich information within an image, high resolution can increase the amount of information in an image over a wider range, allowing for clearer visualization of various details. Edge features, on the other hand, primarily focus on object boundaries. While resolution increases can help with this, from the perspective of information richness, image detail is more prominently enhanced. Image contrast also significantly enhances edge features, as contrast primarily works by enhancing the differences between pixels. Edges are areas within an image where pixel values vary dramatically, so contrast has a more direct and noticeable effect on highlighting edges. While image details can also be made clearer through contrast enhancement, the effect is relatively limited for details with minimal contrast differences.
[0081] Therefore, this embodiment provides different adjustment methods for image resolution and contrast. When the resolution of the first iron accessory image is greater than the first resolution, and the contrast of the first iron accessory image is less than or equal to the first contrast, the image resolution has a greater impact on the image. Referring to the aforementioned logic and description, it can be seen that image resolution significantly improves image detail. Therefore, the weight of image detail features (represented by the energy percentage of high-frequency energy) should be appropriately increased in this case. This will increase the influence of image detail features on the wavelet basis values, thereby determining more accurate wavelet basis values and selecting appropriate wavelet basis functions. Therefore, the weight corresponding to the energy percentage can be increased based on the first detail step size, while the weight corresponding to the edge strength can be decreased based on the first detail step size. The first resolution and first contrast can be set empirically.
[0082] Conversely, when the image contrast of the first iron attachment is greater than the first contrast and the resolution of the first iron attachment image is less than or equal to the first resolution, the image contrast has a greater impact on the image. Referring to the aforementioned logic and description, we can see that image contrast has a more significant impact on edge features. Therefore, the weight of the edge feature (represented by edge strength) should also be increased in this case to make the edge feature wavelet basis value have a greater impact, thereby determining a more accurate wavelet basis value and selecting an appropriate wavelet basis function. Therefore, the weight corresponding to edge strength can be increased based on the first edge step size, while the weight corresponding to energy proportion can be reduced based on the first edge step size.
[0083] In one embodiment of the present disclosure, the method for detecting defects in iron accessories further includes:
[0084] determining a first detail step size based on a resolution of the first iron accessory image and a contrast of the first iron accessory image;
[0085] The first edge step size is determined based on a resolution of the first iron accessory image and a contrast of the first iron accessory image.
[0086] In this embodiment, it can be seen from the above description that the first detail step size and the first edge step size are used to adjust the weight distribution, and should also be related to the resolution and contrast of the first iron accessory image. Therefore, the first detail step size can be determined by the first formula:
[0087] .
[0088] The first edge step size can be determined by the second formula:
[0089] .
[0090] in, represents the first detail step, represents the first edge step, Indicates the resolution of the first iron attachment image, represents the contrast of the first iron attachment image, Indicates the first resolution, represents the first contrast, Represents the resolution exponent coefficient, which is used to adjust the impact of resolution changes on step size. Represents the contrast attenuation coefficient, which is used to control the attenuation effect of contrast on detail step size. Represents the contrast index coefficient, which is used to adjust the impact of contrast changes on step size. Represents the resolution attenuation coefficient, which is used to control the attenuation effect of resolution on edge step size. , , , It can be determined according to the fitting process.
[0091] The first formula numerator part, It reflects the change of resolution relative to the first resolution. Represents the attenuation effect of contrast on detail step size. The denominator of the first formula is This is to normalize the numerator.
[0092] The second formula numerator part, It reflects the change of contrast relative to the first contrast. Indicates the attenuation effect of resolution on edge step length, the denominator of the second formula Normalize the numerator.
[0093] In this embodiment, it is also considered that when the difference in resolution and contrast is large, only the determined , , , Unbalanced distribution will cause the formula to be unbalanced, so the parameters can be adjusted in the following ways:
[0094] In one embodiment of the present disclosure, in response to an absolute value of a resolution difference of the first iron accessory image being greater than a first difference, a resolution index coefficient is reduced based on a first difference step size, and a contrast index coefficient is reduced based on a third difference step size;
[0095] In response to the absolute value of the contrast difference of the first iron accessory image being greater than the second difference, the contrast attenuation coefficient is reduced based on the second difference step size, and the resolution attenuation coefficient is reduced based on the fourth difference step size.
[0096] In this embodiment, the resolution index coefficient and contrast attenuation coefficient are adjusted according to the degree of difference in resolution and contrast in order to make the formula adaptive to the characteristics of different images. The absolute value of the resolution difference is , absolute value of contrast difference When the absolute value of the resolution difference of the first iron attachment image is greater than the first difference, it means that the resolution of the current image is much different from the set first resolution. If the resolution index coefficient is not adjusted, it will result in This term is absolutely dominant in the formula, so the influence of other factors is ignored. Therefore, the resolution index coefficient can be reduced based on the first difference step. The first difference degree and the first difference step can be set based on experience. In order to avoid the resolution dominating, the resolution index coefficient should be reduced. The larger the difference step size, the smaller the contrast attenuation coefficient. However, since the resolution exponent coefficient is an exponential type, its influence on the formula result is more significant, especially when the resolution or contrast changes greatly. It will significantly change the relationship between detail step size and resolution or contrast. Therefore, the first difference step size is smaller than the second difference step size, and the third difference step size is smaller than the fourth difference step size.
[0097] Similarly, when the contrast difference is greater than the second difference, adjusting the contrast attenuation coefficient can make the contrast effect more reasonable, avoiding excessive or insufficient impact on the step size. The second difference and second difference step size can be set based on experience. The same principle applies to the reduction of the contrast index coefficient and the resolution attenuation coefficient. The third and fourth difference step sizes can be determined based on actual application scenarios or experience.
[0098] From the above, it can be concluded that the present disclosure adjusts the weights of image detail features and edge features through the resolution and contrast of the first iron accessory image, ensuring that the key features of the image can be captured more accurately under different image conditions, thereby improving the accuracy and reliability of iron accessory defect detection. In this embodiment, when the image resolution is high and the contrast is low, the weight of the edge features is reduced by increasing the weight of the image detail features, thereby focusing more on retaining the detail information in the image. Conversely, when the image contrast is high and the resolution is low, more emphasis is placed on extracting edge features to ensure the clarity and accuracy of the image contour. The present disclosure implements the adjustment of the first detail step and the first edge step through the first formula and the second formula. Furthermore, the present disclosure avoids the imbalance of the formula when the resolution and contrast differences are large or small by introducing the concepts of resolution difference and contrast difference, as well as the corresponding difference step adjustment mechanism, thereby improving the accuracy and reliability of iron accessory defect detection.
[0099] In one embodiment of the present disclosure, the number of decision trees in the target random forest algorithm model is a target number;
[0100] Input the target iron accessory image into the target random forest algorithm model to obtain the defect detection results of the target iron accessory, including:
[0101] In response to a dimension of the target iron accessory image being greater than or equal to the first dimension, calling a target number of decision trees in a target random forest algorithm model to process the target iron accessory image to obtain a defect detection result of the target iron accessory;
[0102] In response to a dimension of the target iron accessory image being smaller than the first dimension, calling a first number of decision trees in the target random forest algorithm model to process the target iron accessory image to obtain a defect detection result of the target iron accessory;
[0103] The first quantity is smaller than the target quantity.
[0104] In this embodiment, the dimension of the target iron attachment image is used to describe the number of elements contained in the vector representing the image features, or the number of independent variables used to represent the image features. It reflects the complexity of the image features and the amount of information contained, and can be calculated using a gray-level co-occurrence matrix or local binary pattern. When the dimension of the target iron attachment image is greater than or equal to the first dimension, it indicates that the image has high complexity and contains rich feature information. To fully utilize this information and accurately detect defects, it is necessary to call all the target number of decision trees in the target random forest algorithm model. Because more decision trees can analyze and judge image features from different perspectives, combining the results of multiple decision trees can improve detection accuracy and reliability, and address the complexities brought about by high-dimensional images. The first dimension can be obtained based on experimental data. For example, if it is found that the first number of decision trees no longer accurately evaluates the results at a dimension of 256×256, for example, some decision trees produce different results from other decision trees, and the number of different outputs exceeds a preset ratio of the total number of decision trees, the first dimension can be set to 256×256.
[0105] When the dimension of the target iron attachment image is smaller than the first dimension, it means that the image has relatively few features and contains little information. Excessive decision trees will increase computational cost and time. Therefore, the first number of decision trees, which are smaller in number, is selected to be used in the target random forest algorithm model. This allows for effective image analysis and defect detection to a certain extent, while also preventing overly complex models, improving detection efficiency, and reducing unnecessary computational resource consumption. The first number can be a reference to the number of decision trees used to solve related technical problems in this field, or it can be obtained through evaluation during the experimental process.
[0106] As can be seen from the above, this embodiment selects an appropriate number of decision trees within the target random forest algorithm model based on the dimensionality of the target iron accessory image. When the image dimension is high, all decision trees are invoked to fully utilize the rich feature information in the image, improving the accuracy and reliability of iron accessory defect detection and ensuring that the algorithm can optimally process images of varying complexity. This embodiment dynamically adjusts the number of decision trees based on image dimensionality, enhancing the flexibility and adaptability of the present disclosure.
[0107] Corresponding to the iron accessory defect detection method of the above embodiment, Figure 2 This is a structural block diagram of an iron accessory defect detection system provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 2 The iron accessory defect detection system 20 includes: an image acquisition module 21, an image processing module 22 and a defect detection module 23.
[0108] The image acquisition module 21 is used to obtain a first iron accessory image, where the first iron accessory image is an image of the iron accessory after the target iron accessory is processed based on magnetic particle detection;
[0109] An image processing module 22 is configured to perform noise reduction processing on the first iron attachment image based on a wavelet noise reduction method to obtain a target iron attachment image;
[0110] The defect detection module 23 is used to input the target iron accessory image into the target random forest algorithm model to obtain the defect detection result of the target iron accessory.
[0111] In one embodiment of the present disclosure, the image processing module 22 is specifically configured to determine a wavelet basis function of a wavelet denoising method based on edge features of the first iron accessory image and image detail features of the first iron accessory image;
[0112] determining the number of decomposition layers of the wavelet denoising method based on the noise of the first iron accessory image and the characteristic scale of the first iron accessory image;
[0113] Determining a discrimination threshold of a wavelet denoising method based on the noise of the first iron attachment image and the required detection accuracy;
[0114] The first iron attachment image is denoised based on wavelet basis function, decomposition layer number and discrimination threshold.
[0115] In one embodiment of the present disclosure, the image processing module 22 is further configured to detect edge features of the first iron accessory image based on an edge detection algorithm to obtain edge strength;
[0116] Perform frequency domain analysis on the image detail features of the first iron attachment image based on a frequency domain analysis algorithm to obtain the energy proportion of the high-frequency component;
[0117] The wavelet basis value is obtained by weighted calculation of the edge intensity and the energy proportion of the high-frequency component;
[0118] In response to the wavelet basis value being greater than the first wavelet basis threshold, using the first wavelet basis function as the wavelet basis function of the wavelet denoising method;
[0119] In response to the wavelet basis value being less than or equal to the first wavelet basis value, the second wavelet basis function is used as the wavelet basis function of the wavelet denoising method.
[0120] In one embodiment of the present disclosure, the iron accessory defect detection system 20 further includes: a weight adjustment module configured to, in response to a resolution of the first iron accessory image being greater than a first resolution and a contrast of the first iron accessory image being less than or equal to the first contrast, increase a weight corresponding to an energy proportion based on a first detail step size, and decrease a weight corresponding to an edge strength based on the first detail step size;
[0121] In response to the image contrast of the first iron accessory being greater than the first contrast and the resolution of the first iron accessory image being less than or equal to the first resolution, the weight corresponding to the edge intensity is increased based on the first edge step, and the weight corresponding to the energy proportion is reduced based on the first edge step.
[0122] In one embodiment of the present disclosure, the iron accessory defect detection system 20 further includes: a step size determination module for determining a first detail step size based on a resolution of the first iron accessory image and a contrast of the first iron accessory image;
[0123] The first edge step size is determined based on a resolution of the first iron accessory image and a contrast of the first iron accessory image.
[0124] In one embodiment of the present disclosure, the iron accessory defect detection system 20 further includes: a model training module for training a random forest algorithm model based on the first data set to obtain a target random forest algorithm model, wherein the number of decision trees in the target random forest algorithm model is a target number;
[0125] The first data set includes image data of iron accessories that have undergone magnetic particle inspection and corresponding defect type data.
[0126] In one embodiment of the present disclosure, the number of decision trees in the target random forest algorithm model is a target number;
[0127] a defect detection module 23 for, in response to a dimension of the target iron accessory image being greater than or equal to the first dimension, invoking a target number of decision trees in a target random forest algorithm model to process the target iron accessory image to obtain a defect detection result of the target iron accessory;
[0128] In response to a dimension of the target iron accessory image being smaller than the first dimension, calling a first number of decision trees in the target random forest algorithm model to process the target iron accessory image to obtain a defect detection result of the target iron accessory;
[0129] The first quantity is smaller than the target quantity.
[0130] See also Figure 3 , Figure 3 This is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure. Figure 3 The electronic device 300 in the embodiment shown may include: one or more processors 301, one or more input devices 302, one or more output devices 303, and one or more memories 304. The processors 301, input devices 302, output devices 303, and memories 304 communicate with each other via a communication bus 305. The memory 304 is used to store computer programs, which include program instructions. The processor 301 is used to execute the program instructions stored in the memory 304. The processor 301 is configured to call the program instructions to execute the functions of the modules / units in the above-mentioned system embodiments, such as Figure 2 The functions of modules 21 to 23 are shown.
[0131] It should be understood that in the embodiments of the present disclosure, the processor 301 may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0132] The input device 302 may include a touchpad, a fingerprint collection sensor (for collecting user fingerprint information and fingerprint direction information), a microphone, etc. The output device 303 may include a display (LCD, etc.), a speaker, etc.
[0133] The memory 304 may include a read-only memory and a random access memory, and provides instructions and data to the processor 301. A portion of the memory 304 may also include a non-volatile random access memory. For example, the memory 304 may also store device type information.
[0134] In a specific implementation, the processor 301, input device 302, and output device 303 described in the embodiments of the present disclosure can execute the implementation methods described in the first and second embodiments of the iron accessory defect detection method provided in the embodiments of the present disclosure, and can also execute the implementation methods of the electronic device described in the embodiments of the present disclosure, which will not be repeated here.
[0135] In another embodiment of the present disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, all or part of the process of the method in the above embodiment is implemented. The computer program can also be used to instruct related hardware to complete the process. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above method embodiments are implemented. The computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium.
[0136] The computer-readable storage medium can be an internal storage unit of the electronic device in any of the aforementioned embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium can also be an external storage device of the electronic device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. Furthermore, the computer-readable storage medium can include both an internal storage unit of the electronic device and an external storage device. The computer-readable storage medium is used to store computer programs and other programs and data required by the electronic device. The computer-readable storage medium can also be used to temporarily store data that has been output or is about to be output.
[0137] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.
[0138] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the electronic devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0139] In the several embodiments provided in this application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces or units, or can be an electrical, mechanical or other form of connection.
[0140] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, i.e., they may be located in one place or distributed across multiple network units. Some or all of these units may be selected based on actual needs to achieve the objectives of the embodiments of the present disclosure.
[0141] In addition, the functional units in the various embodiments of the present disclosure may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0142] The above are only specific embodiments of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or replacements within the technical scope disclosed in this disclosure, and such modifications or replacements should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure should be based on the scope of protection of the claims.
Claims
1. A method for detecting defects in iron accessories, characterized in that: include: Acquire a first iron accessory image, where the first iron accessory image is an image of the iron accessory after the target iron accessory is processed based on magnetic particle detection; Performing noise reduction processing on the first iron attachment image based on a wavelet noise reduction method to obtain a target iron attachment image; Inputting the target iron accessory image into a target random forest algorithm model to obtain a defect detection result of the target iron accessory; The performing denoising processing on the first iron attachment image based on the wavelet denoising method includes: determining a wavelet basis function of the wavelet denoising method based on edge features of the first iron attachment image and image detail features of the first iron attachment image; determining the number of decomposition layers of the wavelet denoising method based on the noise of the first iron attachment image and the characteristic scale of the first iron attachment image; Determining a discrimination threshold of the wavelet denoising method based on the noise of the first iron accessory image and the required detection accuracy; Performing noise reduction processing on the first iron attachment image based on the wavelet basis function, the number of decomposition layers, and the distinction threshold; The determining of the wavelet basis function of the wavelet denoising method based on the edge features of the first iron attachment image and the image detail features of the first iron attachment image includes: Detecting edge features of the first iron accessory image based on an edge detection algorithm to obtain edge strength; Performing frequency domain analysis on the image detail features of the first iron accessory image based on a frequency domain analysis algorithm to obtain an energy proportion of high-frequency components; Performing weighted calculation on the edge intensity and the energy proportion of the high-frequency component to obtain a wavelet basis value; In response to the wavelet basis value being greater than a first wavelet basis threshold, using the first wavelet basis function as the wavelet basis function of the wavelet denoising method; In response to the wavelet basis value being less than or equal to the first wavelet basis value, the second wavelet basis function is used as the wavelet basis function of the wavelet denoising method.
2. The iron accessory defect detection method according to claim 1, characterized in that: Also includes: In response to a resolution of the first iron accessory image being greater than a first resolution and a contrast of the first iron accessory image being less than or equal to a first contrast, increasing a weight corresponding to the energy proportion based on a first detail step, and decreasing a weight corresponding to the edge strength based on the first detail step; In response to the image contrast of the first iron accessory being greater than the first contrast and the resolution of the first iron accessory image being less than or equal to the first resolution, the weight corresponding to the edge intensity is increased based on the first edge step, and the weight corresponding to the energy proportion is reduced based on the first edge step.
3. The iron accessory defect detection method according to claim 2, characterized in that: Also includes: determining the first detail step size based on a resolution of the first iron accessory image and a contrast of the first iron accessory image; The first edge step size is determined based on a resolution of the first iron accessory image and a contrast of the first iron accessory image.
4. The iron accessory defect detection method according to claim 1, wherein: Before inputting the target iron accessory image into the target random forest algorithm model to obtain the defect detection result of the target iron accessory, the method further includes: Training a random forest algorithm model based on the first data set to obtain the target random forest algorithm model, wherein the number of decision trees in the target random forest algorithm model is the target number; The first data set includes image data of iron accessories that have undergone magnetic particle inspection and corresponding defect type data.
5. The iron accessory defect detection method according to claim 1, wherein: The number of decision trees in the target random forest algorithm model is the target number; The step of inputting the target iron accessory image into a target random forest algorithm model to obtain a defect detection result of the target iron accessory includes: In response to a dimension of the target iron accessory image being greater than or equal to a first dimension, calling a target number of decision trees in the target random forest algorithm model to process the target iron accessory image to obtain a defect detection result of the target iron accessory; In response to the dimension of the target iron accessory image being smaller than the first dimension, calling a first number of decision trees in the target random forest algorithm model to process the target iron accessory image to obtain a defect detection result of the target iron accessory; The first quantity is smaller than the target quantity.
6. An iron accessory defect detection system, characterized in that: include: An image acquisition module is used to acquire a first iron accessory image, where the first iron accessory image is an image of the iron accessory after the target iron accessory is processed based on magnetic particle detection; An image processing module, configured to perform noise reduction processing on the first iron attachment image based on a wavelet noise reduction method to obtain a target iron attachment image; a defect detection module, configured to input the target iron accessory image into a target random forest algorithm model to obtain a defect detection result of the target iron accessory; An image processing module, specifically configured to determine a wavelet basis function of a wavelet denoising method based on edge features of the first iron accessory image and image detail features of the first iron accessory image; determining the number of decomposition layers of the wavelet denoising method based on the noise of the first iron accessory image and the characteristic scale of the first iron accessory image; Determining a discrimination threshold of a wavelet denoising method based on the noise of the first iron attachment image and the required detection accuracy; Performing noise reduction processing on the first iron attachment image based on wavelet basis function, decomposition layer number and discrimination threshold; The image processing module is further configured to detect edge features of the first iron accessory image based on an edge detection algorithm to obtain edge strength; Perform frequency domain analysis on the image detail features of the first iron attachment image based on a frequency domain analysis algorithm to obtain the energy proportion of the high-frequency component; The wavelet basis value is obtained by weighted calculation of the edge intensity and the energy proportion of the high-frequency component; In response to the wavelet basis value being greater than the first wavelet basis threshold, using the first wavelet basis function as the wavelet basis function of the wavelet denoising method; In response to the wavelet basis value being less than or equal to the first wavelet basis value, the second wavelet basis function is used as the wavelet basis function of the wavelet denoising method.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Municipal road detection method and system
CN115272174A
Power grid fault detecting and positioning method and system for intelligent power grid system
CN119492958A