A defect location method and system for nonferrous metal parts
By sliding the window on the image of non-ferrous metal parts to obtain and reduce the characteristic change rate of the window, screening and iteratively enlarging suspected defect areas solves the problem of blurred defect features caused by the large amount of calculation of Gaussian filtering, and achieves efficient defect location and detection.
Patent Information
- Application Number
- CN202410842817.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-06-27
AI Technical Summary
In the existing technology, in the image processing of non-ferrous metal parts, Gaussian filtering requires a large amount of calculation, resulting in the indiscriminate smoothness of the entire image, which may cause the defect features to be blurred or lost, making it difficult to accurately locate the defect area.
By sliding the window on the image of non-ferrous metal parts, the uniformity of the grayscale distribution of the initial window is obtained, the window to be analyzed is divided, and the window is reduced to obtain the characteristic change rate, and the first target window is selected for iterative amplification and filtering to reduce calculations amount to improve the filtering effect.
Efficient filtering of images of non-ferrous metal parts is achieved to ensure that defect features are not blurred or lost, the defect area can be accurately located, and the accuracy of defect detection is improved.
Smart Images

Figure CN118397003B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a defect locating method and system for nonferrous metal parts. Background Art
[0002] In the production process of non-ferrous metal parts, quality control is the key to ensure product performance, reliability and safety. The presence of defects will seriously affect the performance and service life of the parts, and may even lead to safety accidents. Therefore, accurate defect detection of non-ferrous metal parts is an indispensable part of the production process. With the continuous development of computer vision and image processing technology, image filtering technology provides a new solution for defect detection of non-ferrous metal parts. By introducing image filtering technology, the image of non-ferrous metal parts can be pre-processed to remove noise and enhance defect features, thereby improving the accuracy of defect detection, reducing the missed detection rate and false detection rate, and ensuring product quality.
[0003] The patent application document with the publication number CN116342439A discloses a vascular image enhancement method based on multi-scale Gaussian filtering. By inputting an endoscopic vascular image, the input vascular image is separated into three RGB channel planes, and the G component is filtered using a multi-scale Gaussian filter and a bilateral filter to obtain a detail layer and a base layer. The detail layer is multiplied by a gain coefficient and then merged with the base layer to obtain two enhancement results. The two enhancement results are converted to the HIS space, and the I component is decomposed by 4 layers of wavelets to obtain 1 low-frequency and 12 high-frequency components. The enhanced I component is fused using the rule of high-frequency weighted averaging and low-frequency modulus maximum value, and then merged with the HS and converted to the RGB space to obtain the final enhancement result.
[0004] In the process of acquiring images of non-ferrous metal parts, due to the influence of CCD sensors and external environment, the acquired images of non-ferrous metal parts often contain noise, such as salt and pepper noise and Gaussian noise. These noises will not only blur the details of the images of non-ferrous metal parts and reduce the image quality, but also bring a certain degree of difficulty to the detection of defects in the images of non-ferrous metal parts. Therefore, it is necessary to denoise the acquired images of non-ferrous metal parts. The above method is to perform weighted averaging on the entire image of non-ferrous metal parts to remove noise. While global filtering requires a large amount of calculation, it will also perform indiscriminate smoothing on the entire image of non-ferrous metal parts, which may cause the defect features in the image of non-ferrous metal parts to be blurred or lost, and it is impossible to locate the accurate defect area. Summary of the invention
[0005] In order to solve the problem that Gaussian filtering requires a large amount of calculation and indiscriminately smoothes the entire non-ferrous metal component image, which may cause the defect features in the non-ferrous metal component image to be blurred or lost, the present invention provides a defect location method and system for non-ferrous metal components.
[0006] In a first aspect, the present invention provides a defect location method for nonferrous metal parts, which adopts the following technical solution:
[0007] A method for locating defects of nonferrous metal parts, comprising the steps of:
[0008] Collect images of non-ferrous metal parts;
[0009] A preset sliding window slides on the image of the non-ferrous metal part to obtain each initial window; the grayscale distribution uniformity of each initial window is obtained, and the grayscale distribution uniformity represents the complexity of the grayscale value distribution in the initial window; based on the grayscale distribution uniformity, each window to be analyzed is obtained; each window to be analyzed is reduced to obtain a reduced window of each window to be analyzed; and the characteristic change rate of each reduced window of each window to be analyzed is obtained , where represents the characteristic change rate of the vth reduced window of the mth window to be analyzed; Represents the uniformity of the grayscale distribution of the vth reduced window of the mth window to be analyzed; Represents the uniformity of the grayscale distribution of the v-1th reduced window of the mth window to be analyzed; represents the uniformity of the grayscale distribution of the v+1th reduced window of the mth window to be analyzed; || represents the absolute value symbol; based on the characteristic change rate, a plurality of first target windows are obtained;
[0010] According to each first target window, each suspected defect area is obtained; after filtering each suspected defect area, defect detection is performed.
[0011] The innovation of the present invention lies in obtaining each suspected defect area, filtering each suspected defect area and then detecting defects, which reduces the amount of calculation and can improve the filtering effect of the non-ferrous metal component image, so that the defect features in the non-ferrous metal component image are not blurred or lost, and the accurate defect area can be located. Furthermore, the present invention divides the non-ferrous metal component image into various initial windows, and obtains the window to be analyzed according to the uniformity of the grayscale distribution of each initial window. The window to be analyzed may contain a defect area, and the area where defects may exist can be distinguished from the normal area. Furthermore, the window to be analyzed is reduced, and the characteristic change rate of each reduced window of each window to be analyzed is obtained. Based on the characteristic change rate, a first target window is obtained, and the first target window is closer to the defect area, which is convenient for subsequent reduction of the filtering calculation amount; further, the first target window is iteratively enlarged, and based on the change of the edge information in the first target window during the iteration process, the iteration of the first target window is stopped to obtain the suspected defect area, so that the defect area in the obtained suspected defect area is more complete.
[0012] Preferably, the preset sliding window slides on the non-ferrous metal component image to obtain each initial window, including the steps of:
[0013] Preset sliding window size , the sliding step length is , place the sliding window at the upper left corner of the non-ferrous metal part image, slide the sliding window in the non-ferrous metal part image according to the direction from left to right and from top to bottom and the sliding step size, and use each sliding window with data as each initial window.
[0014] Preferably, the grayscale distribution uniformity of each initial window is obtained by calculating the formula:
[0015] ;
[0016] In the formula, Represents the uniformity of the grayscale distribution of the i-th initial window; Represents the mean gray value of all pixels in the i-th initial window; Represents the number of pixels in the i-th initial window; Represents the grayscale value of the j-th pixel in the i-th initial window; || represents the absolute value symbol.
[0017] The uniformity of grayscale distribution represents the complexity of grayscale value distribution in the initial window. Based on the uniformity of grayscale distribution, the area where defects may exist can be distinguished from the normal area.
[0018] Preferably, the calculation formula for obtaining each window to be analyzed is:
[0019] A uniformity threshold T is preset. When the uniformity of the grayscale distribution in the initial window is less than the uniformity threshold T, the initial window is recorded as a window to be analyzed, and a plurality of windows to be analyzed are obtained.
[0020] The preset threshold distinguishes the area with possible defects from the normal area, and only the analysis window is analyzed subsequently to reduce the amount of calculation.
[0021] Preferably, the step of reducing each window to be analyzed to obtain a reduced window of each window to be analyzed includes:
[0022] The preset reduction step size is D, and the final window size is b. For any window to be analyzed, the window to be analyzed is reduced each time according to the reduction step size D until the window to be analyzed is reduced to b. b, and then the analysis stops and a number of reduced windows of the window to be analyzed are obtained.
[0023] The window to be analyzed is continuously reduced to obtain a number of reduced windows, so as to facilitate subsequent analysis of the several reduced windows and obtain a reduced window that is closest to the suspected defect area.
[0024] Preferably, the obtaining of a plurality of first target windows is calculated by the following formula:
[0025] The maximum value of the characteristic change rates of all reduced windows of the mth window to be analyzed is obtained, and the reduced window corresponding to the maximum value is recorded as the first target window, so as to obtain a plurality of first target windows.
[0026] Preferably, acquiring each suspected defect area according to each first target window includes:
[0027] The first target window is iteratively enlarged with a preset enlargement step size until the oth target window is enlarged and the iteration is stopped. When the absolute value of the difference between the number of edge pixels in the oth target window and the number of edge pixels in the o+1th target window is less than or equal to the difference threshold T1, the o+1th target window is recorded as a suspected defect area.
[0028] The first target window is iteratively enlarged, and based on the change of edge information in the first target window during the iteration process, the iteration of the first target window is stopped to obtain a suspected defect area, so that the defect area in the obtained suspected defect area is more complete.
[0029] In a second aspect, the present invention provides a defect location system for nonferrous metal parts, which adopts the following technical solution:
[0030] A defect location system for non-ferrous metal parts comprises: a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the defect location method for non-ferrous metal parts is implemented.
[0031] By adopting the above technical solution, the above-mentioned defect positioning method of a non-ferrous metal component is generated into a computer program and stored in a memory so as to be loaded and executed by a processor, thereby making a terminal device based on the memory and the processor for easy use.
[0032] The present invention has the following technical effects: the present invention obtains each suspected defect area, filters each suspected defect area and then detects the defect, which reduces the amount of calculation and can improve the filtering effect of the non-ferrous metal component image, so that the defect features in the non-ferrous metal component image are not blurred or lost. Further, the present invention divides the non-ferrous metal component image into each initial window, obtains the window to be analyzed according to the uniformity of the grayscale distribution of each initial window, and the window to be analyzed may contain a defect area, which can distinguish the area where defects may exist from the normal area. Further, the window to be analyzed is reduced, and the characteristic change rate of each reduced window of each window to be analyzed is obtained. Based on the characteristic change rate, a first target window is obtained, and the first target window is closer to the defect area, which is convenient for subsequent reduction of the filtering calculation amount; further, the first target window is iteratively enlarged, and based on the change of the edge information in the first target window during the iteration process, the iteration of the first target window is stopped to obtain the suspected defect area, so that the defect area in the obtained suspected defect area is more complete. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-restrictive manner, and the same or corresponding reference numerals represent the same or corresponding parts.
[0034] Figure 1 It is a method flow chart of a defect location method of a nonferrous metal component according to an embodiment of the present invention;
[0035] Figure 2 A zoomed-out diagram representing the window to be analyzed. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0037] It should be understood that when the terms "first", "second", etc. are used in the claims, descriptions, and drawings of the present invention, they are only used to distinguish different objects, rather than to describe a specific order. The terms "include" and "comprise" used in the description and claims of the present invention indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their collections.
[0038] The embodiment of the present invention discloses a defect location method for nonferrous metal parts, referring to Figure 1 , comprising steps S1 to S3:
[0039] S1: Collect images of non-ferrous metal parts.
[0040] In the embodiment of the present invention, a CCD camera is used to photograph a titanium plate to obtain an RGB image of a non-ferrous metal component, and the RGB image of the non-ferrous metal component is gray-scaled to obtain an image of the non-ferrous metal component.
[0041] S2: A preset sliding window slides on the image of the non-ferrous metal part to obtain each initial window, and a number of windows to be analyzed are obtained through the uniformity of the grayscale distribution of each initial window. Each window to be analyzed is reduced to obtain a reduced window of each window to be analyzed, and a feature change rate of each reduced window of each window to be analyzed is obtained. Based on the feature change rate, a number of first target windows are obtained.
[0042] It should be noted that, in the process of acquiring images of non-ferrous metal parts, due to the influence of CCD sensors and external environment, the acquired images of non-ferrous metal parts often contain noise, such as salt and pepper noise and Gaussian noise, etc. These noises will not only cause the details of the images of non-ferrous metal parts to be blurred, but also reduce the image quality. Therefore, it brings a certain degree of difficulty to the detection of defects in the images of non-ferrous metal parts. Therefore, it is necessary to denoise the acquired images of non-ferrous metal parts, and Gaussian filtering is a linear smoothing filter, which removes noise by weighted averaging the entire image of non-ferrous metal parts. Compared with other filtering methods, Gaussian filtering can more completely retain the information of defect edges while eliminating noise, which is crucial for defect detection. However, global filtering requires a large amount of calculation, and the entire image of non-ferrous metal parts will also be smoothed indiscriminately, which may cause the defect features in the image of non-ferrous metal parts to be blurred or lost. Local filtering can reduce part of the amount of calculation, and can also improve the contrast between the filtered area and the unfiltered area, which is more conducive to the location and expression of defects. Therefore, as long as the purpose of the present invention is to locate the defect area, only the defect area is filtered.
[0043] Step S2 includes steps S20-S21, which are specifically as follows:
[0044] S20: A preset sliding window slides on the image of the nonferrous metal component to obtain each initial window, and a plurality of windows to be analyzed are obtained according to the uniformity of the grayscale distribution of each initial window.
[0045] It should be noted that the known standard titanium plate has a smooth surface, that is, the grayscale distribution of the non-ferrous metal part image collected by the defect-free titanium plate is relatively uniform. When there are defects on the titanium plate surface (such as pits), this grayscale distribution uniformity will be destroyed, and the defects on the titanium plate are generally small in area, and the location of the defects is unknown. Therefore, a sliding window can be slid on the non-ferrous metal part image to obtain each initial window, and the window to be analyzed is obtained by the uniformity of the grayscale distribution of each initial window, that is, the window to be analyzed may contain a defective area, and then the suspected defective area is approached by continuously shrinking the window to be analyzed, and finally the suspected defective area is filtered, and then defect detection is performed to further determine whether the suspected defective area is a real defective area.
[0046] In the embodiment of the present invention, the sliding window size is preset , the sliding step length is , place the sliding window at the upper left corner of the non-ferrous metal component image, slide the sliding window in the non-ferrous metal component image from left to right and from top to bottom, and use each sliding window with data as each initial window. It should be noted that when the sliding window slides to the edge of the non-ferrous metal component image, it is padded with 0, and the sliding step size is smaller than the sliding window size to ensure that even if the defect is located at the edge of the window, it will not be missed due to the large step size. Specifically, the preset sliding window size , sliding step length In other embodiments, the implementer may preset the sliding window size according to other implementations. as well as .
[0047] In this embodiment of the present invention, the grayscale distribution uniformity of each initial window is obtained:
[0048] ;
[0049] In the formula, Represents the uniformity of the grayscale distribution of the i-th initial window; Represents the mean gray value of all pixels in the i-th initial window; Represents the number of pixels in the i-th initial window; Represents the gray value of the jth pixel in the i-th initial window; Represents the cumulative difference between the grayscale value of each pixel in the i-th initial window and the mean grayscale value of all pixels. The larger the cumulative difference, the lower the uniformity of the grayscale distribution.
[0050] A uniformity threshold T is preset. When the uniformity of the grayscale distribution in the initial window is less than the uniformity threshold T, the initial window is recorded as a window to be analyzed, and a plurality of windows to be analyzed are obtained.
[0051] S21: shrinking each window to be analyzed, obtaining each shrunken window of each window to be analyzed, obtaining a feature change rate of each shrunken window of each window to be analyzed, and obtaining a plurality of first target windows based on the feature change rate.
[0052] It should be noted that there may be a defective area in the window to be analyzed obtained above, so it is necessary to reduce the window to be analyzed to approach the suspected defective area. If there is a suspected defective area in the window to be analyzed, the grayscale uniformity will continue to change during the process of reducing the window to be analyzed until the window can be covered by the suspected defective area, that is, the window to be analyzed is reduced and the suspected defective area is in the window to be analyzed (see Figure 2 , Figure 2 The shaded area in the figure is the suspected defect area. Figure 2The window to be analyzed is reduced from Window 1 to Window 2 and the suspected defect area is in Window 1 and Window 2). At this time, the uniformity of the grayscale distribution before and after the window to be analyzed is gradually increasing. When the window to be analyzed is reduced and the suspected defect area completely covers the window to be analyzed ( Figure 2 The window 2 to be analyzed in the analysis is reduced to the window 3 to be analyzed and the suspected defect area covers the window 3 to be analyzed). At this time, the uniformity of the grayscale distribution before and after the window to be analyzed is increasing and the change in the uniformity of the grayscale distribution at this time is the largest. Therefore, if there is a suspected defect area in the window to be analyzed, the uniformity of the grayscale distribution before and after the window to be analyzed will change as the window to be analyzed is reduced and approaches the suspected defect area. Therefore, a window closest to the suspected defect area can be obtained through the change in the uniformity of the grayscale distribution when the window to be analyzed is reduced.
[0053] It should be further explained that the window to be analyzed must be first reduced to obtain various reduced windows. In the process of reducing the window to be analyzed, there will be a reduced window that can contain the suspected defect area before reduction and can cover the suspected defect area after reduction. Therefore, this reduced window is closest to the suspected defect area, and the change in the uniformity of the grayscale distribution in the window before and after the reduction of the reduced window is also the most obvious. Therefore, the characteristic change rate of the reduced window can be reflected according to the change in the uniformity of the grayscale distribution before and after the reduction of the reduced window.
[0054] In the embodiment of the present invention, the preset reduction step size is D, the preset final window size is b, and for any window to be analyzed, the window to be analyzed is reduced each time according to the reduction step size D until the window to be analyzed is reduced to b. b, and then the number of reduced windows of the window to be analyzed is obtained. In the embodiment of the present invention, the preset reduction step size is D=2, b=3. In other embodiments, the implementer can preset the values of D and b according to the specific implementation situation.
[0055] According to the method for obtaining the uniformity of grayscale distribution of each initial window, obtaining the uniformity of grayscale distribution of the reduced window of each window to be analyzed;
[0056] Get the characteristic change rate of the vth reduced window of the mth window to be analyzed:
[0057] ;
[0058] In the formula, represents the characteristic change rate of the vth reduced window of the mth window to be analyzed; Represents the uniformity of the grayscale distribution of the vth reduced window of the mth window to be analyzed; Represents the uniformity of the grayscale distribution of the v-1th reduced window of the mth window to be analyzed; represents the grayscale distribution uniformity of the v+1th reduced window of the mth window to be analyzed; || represents the absolute value symbol; it should be noted that the grayscale distribution uniformity of the previous reduced window of the 1st reduced window of the mth window to be analyzed is the grayscale distribution uniformity of the mth window to be analyzed; The larger the value of , the more drastic the change in the uniformity of the grayscale distribution of the previous and next reduced windows of the v-th reduced window of the m-th window to be analyzed is, and the v-th reduced window of the m-th window to be analyzed is closest to the suspected defect area.
[0059] The maximum value of the characteristic change rates of all reduced windows of the mth window to be analyzed is obtained, and the reduced window corresponding to the maximum value is recorded as the first target window, so as to obtain a plurality of first target windows.
[0060] S3: After magnifying each first target window, analyze the change in the number of front and rear edge pixels, thereby obtaining each suspected defect area, and after filtering each suspected target area, perform defect detection.
[0061] Step S3 includes steps S30 and S31, which are specifically as follows:
[0062] S30: After magnifying each first target window, analyze the change in the number of front and rear edge pixels thereof, so as to obtain each suspected defect area.
[0063] It should be noted that the first target window is selected based on the logic that "the reduced window can contain the suspected defect area before reduction and can cover the suspected defect area after reduction", so the suspected defect area included in the first target window is incomplete (for example, Figure 2 The suspected defect area contained in window 3 in the figure is incomplete), and the first target window needs to be enlarged. Since the suspected defect area has an edge, the integrity of the suspected defect area can be judged by the change in the number of edge pixels during the enlargement of the first target window, and the suspected defect area is obtained.
[0064] In the embodiment of the present invention, a magnification step length k is preset, and for any first target window, an edge detection algorithm is used to obtain edge pixels of the first target window, the first target window is magnified according to the magnification step length to obtain a second target window, and the edge pixels of the second target window are obtained by using the edge detection algorithm. If the absolute value of the difference between the number of edge pixels of the first target window and the number of edge pixels of the second target window is less than or equal to the difference threshold T1, the first target window is stopped from being magnified, and the second target window is a suspected target area. If the absolute value of the difference between the number of edge pixels of the first target window and the number of edge pixels of the second target window is greater than the difference threshold T1, the second target window is magnified according to the magnification step length to obtain edge pixels of a third target window, and the absolute value of the difference between the number of edge pixels of the third target window and the number of edge pixels of the second target window is compared with the difference threshold T1, and so on, until the absolute value of the difference between the number of edge pixels of the oth target window and the number of edge pixels of the o+1th target window is less than or equal to the difference threshold T1, the oth target window is stopped from being magnified, and the o+1th target window is a suspected target area.
[0065] The above operation is performed on each first target window to obtain several suspected target areas.
[0066] In the embodiment of the present invention, the preset difference threshold value T1=0.2, the preset amplification step length k=2, and in other embodiments, implementers may preset the values of T1 and k according to specific implementation conditions.
[0067] S31: After filtering each suspected target area, defect detection is performed.
[0068] In an embodiment of the present invention, Gaussian filtering is performed on each suspected defect area to obtain each filtered suspected defect area, and an edge detection algorithm is used to perform edge detection on each filtered suspected defect area, thereby realizing the positioning of defects in the image of non-ferrous metal parts.
[0069] The present invention obtains each suspected defect area, filters each suspected defect area and then detects defects, which reduces the amount of calculation and can improve the filtering effect of the non-ferrous metal component image, so that the defect features in the non-ferrous metal component image are not blurred or lost. Furthermore, the present invention divides the non-ferrous metal component image into each initial window, obtains the window to be analyzed according to the uniformity of the grayscale distribution of each initial window, and the window to be analyzed may contain a defect area, which can distinguish the area where defects may exist from the normal area. Furthermore, the window to be analyzed is reduced, and the feature change rate of each reduced window of each window to be analyzed is obtained. Based on the feature change rate, a first target window is obtained, and the first target window is closer to the defect area, which is convenient for subsequent reduction of filtering calculation amount; further, the first target window is iteratively enlarged, and based on the change of edge information in the first target window during the iteration process, the first target window is stopped from iterating to obtain a suspected defect area, so that the defect area in the obtained suspected defect area is more complete.
[0070] The above system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface, and their configuration and functions are known in the art, so they will not be described in detail here.
[0071] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium may be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory, a dynamic random access memory, a static random access memory, an enhanced dynamic random access memory, a high bandwidth memory, a hybrid storage cube, etc., or any other medium that can be used to store the required information and can be accessed by an application, a module, or both. Any such computer storage medium may be part of the device or accessible or connectable to the device.
[0072] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
[0073] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A defect location method for nonferrous metal parts, It is characterized in that Includes steps: Collect images of non-ferrous metal parts; The preset sliding window slides on the non-ferrous metal component image to obtain each initial window, including the steps of: the preset sliding window size is , the sliding step length is , place the sliding window at the upper left corner of the non-ferrous metal component image, slide the sliding window in the non-ferrous metal component image in the direction from left to right and from top to bottom and the sliding step length, and use each sliding window with data as each initial window; Get the uniformity of grayscale distribution of each initial window. The calculation formula is: ; In the formula, Represents the uniformity of the grayscale distribution of the i-th initial window; Represents the mean gray value of all pixels in the i-th initial window; Represents the number of pixels in the i-th initial window; represents the gray value of the jth pixel in the ith initial window; |*| represents the absolute value symbol, and the uniformity of the gray distribution characterizes the complexity of the gray value distribution in the initial window; based on the uniformity of the gray distribution, each window to be analyzed is obtained; each window to be analyzed is reduced to obtain a reduced window of each window to be analyzed; the characteristic change rate of each reduced window of each window to be analyzed is obtained , where represents the characteristic change rate of the vth reduced window of the mth window to be analyzed; Represents the uniformity of the grayscale distribution of the vth reduced window of the mth window to be analyzed; Represents the uniformity of the grayscale distribution of the v-1th reduced window of the mth window to be analyzed; represents the uniformity of grayscale distribution of the v+1th reduced window of the mth window to be analyzed; |*| represents the absolute value symbol; based on the characteristic change rate, a number of first target windows are obtained, and the calculation formula is: obtain the maximum value of the characteristic change rate of all reduced windows of the mth window to be analyzed, record the reduced window corresponding to the maximum value as the first target window, and obtain a number of first target windows; According to each first target window, each suspected defect area is obtained; after filtering each suspected defect area, defect detection is performed.
2. A defect location method for nonferrous metal parts according to claim 1, It is characterized in that The calculation formula for obtaining each window to be analyzed is: A uniformity threshold T is preset. When the uniformity of the grayscale distribution in the initial window is less than the uniformity threshold T, the initial window is recorded as a window to be analyzed, and a plurality of windows to be analyzed are obtained.
3. A defect location method for nonferrous metal parts according to claim 1, It is characterized in that The step of reducing each window to be analyzed to obtain a reduced window of each window to be analyzed includes: The preset reduction step size is D, and the final window size is b. For any window to be analyzed, the window to be analyzed is reduced each time according to the reduction step size D until the window to be analyzed is reduced to b. b, and then the analysis stops and a number of reduced windows of the window to be analyzed are obtained.
4. A defect location method for nonferrous metal parts according to claim 1, It is characterized in that The step of obtaining each suspected defect area according to each first target window includes: The first target window is iteratively enlarged with a preset enlargement step size until the oth target window is enlarged and the iteration is stopped. When the absolute value of the difference between the number of edge pixels in the oth target window and the number of edge pixels in the o+1th target window is less than or equal to the difference threshold T1, the o+1th target window is recorded as a suspected defect area.
5. A defect location system for nonferrous metal parts, It is characterized in that include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a defect location method for a non-ferrous metal component according to any one of claims 1 to 4 is implemented.
