Digital detection method for surface of high-strength aluminum alloy casting
The mean shift algorithm is used to cluster the grayscale images of the aluminum alloy casting surface, adjust the voting weight and drift speed, and identify crack defects. This solves the problems of low efficiency and insufficient accuracy in traditional detection methods, and achieves efficient crack identification and reliable detection results.
Patent Information
- Application Number
- CN202510686399.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-05-27
AI Technical Summary
Traditional surface inspection methods for aluminum alloy castings are inefficient and lack precision, making it difficult to accurately identify surface crack defects.
The mean shift algorithm is used to cluster the grayscale images of the aluminum alloy casting surface. By adjusting the change information of the window drift direction and distance, the voting weight and drift speed of the pixel points are adjusted in real time to identify the crack defect area.
The recognition accuracy of surface crack defects of aluminum alloy castings and the reliability of detection results are improved, overcoming the influence of texture features in traditional methods.
Smart Images

Figure CN120672667A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a surface digital detection method for a high-strength aluminum alloy casting. Background Art
[0002] High-strength aluminum alloy castings are made from high-strength aluminum alloys. These aluminum alloys are enhanced in strength and performance through alloying, heat treatment, and specialized casting processes. These castings are widely used in aerospace, automotive, industrial equipment, sports equipment, and building infrastructure. Surface testing of aluminum alloy castings can promptly identify surface defects that could affect structural strength or safety, ensuring the safety and reliability of the castings in practical applications.
[0003] Traditional surface inspection methods for aluminum alloy castings rely on professional inspectors, using visual inspection or other auxiliary instruments, resulting in low efficiency. Furthermore, the surface of aluminum alloy castings is not completely smooth and has certain texture characteristics, making it difficult for existing image processing methods to directly identify surface cracks, resulting in low accuracy in aluminum alloy casting surface inspection. Summary of the Invention
[0004] In order to solve the technical problem of low accuracy in surface detection of aluminum alloy castings, the purpose of the present invention is to provide a surface digital detection method for high-strength aluminum alloy castings. The technical solution adopted is as follows:
[0005] In a first aspect, the present invention provides a surface digital detection method for a high-strength aluminum alloy casting, the method comprising:
[0006] Acquiring a surface image of an aluminum alloy casting, and performing grayscale processing on the surface image to obtain a surface grayscale image of the aluminum alloy casting;
[0007] The casting pixels in the surface grayscale image are clustered using a mean shift algorithm. During the clustering process, the voting weight and drift speed of the casting pixel corresponding to each cluster position are adjusted in real time based on the change information of the window drift direction and the window drift distance until the drift stop condition is reached, thereby obtaining the final clustering result.
[0008] identifying crack defect areas in the surface grayscale image according to the clustering result;
[0009] Based on the distribution range information of the crack defect area, a qualified surface inspection result of the aluminum alloy casting is determined.
[0010] Optionally, clustering is performed on the casting pixels in the surface grayscale image using a mean shift algorithm. During the clustering process, based on the change information of the window drift direction and the window drift distance, the voting weight and drift speed of the casting pixel corresponding to each cluster position are adjusted in real time until the drift stop condition is reached, thereby obtaining the final clustering result, including:
[0011] generating a neighborhood window corresponding to the surface grayscale image, wherein the neighborhood window is used to move on the surface grayscale image, each time moving to a different cluster position;
[0012] Repeating the clustering process of the surface grayscale image using the neighborhood window until clustering is completed for each casting pixel in the surface grayscale image, and generating a clustering result of the surface grayscale image based on a voting weight of each casting pixel in the surface grayscale image;
[0013] The clustering process of the surface grayscale image includes:
[0014] Determine a center point and a plurality of casting pixel points included in the neighborhood window at a current cluster position;
[0015] Calculating a mean vector of the neighborhood window at the current cluster position based on the center point and the plurality of casting pixel points;
[0016] Determining change information of a window drift direction and a window drift distance according to mean vectors corresponding to the current cluster position and the previous cluster position respectively;
[0017] Based on the change information, adjusting the voting weights of the plurality of casting pixels included in the neighborhood window at the current cluster position corresponding to the crack category, and adjusting the drift speed of the neighborhood window at the current cluster position according to the voting weights;
[0018] Based on the mean vector at the current cluster position, the neighborhood window is controlled to move from the current cluster position to a next cluster position.
[0019] Optionally, generating a neighborhood window corresponding to the surface grayscale image includes:
[0020] Determining candidate casting pixel points that have not been clustered in the surface grayscale image;
[0021] Determine the candidate casting pixel point with the smallest grayscale value among the candidate casting pixel points as the starting point;
[0022] A spherical neighborhood window is generated with the starting point as the center and the first preset threshold as the neighborhood radius.
[0023] Optionally, the calculating, based on the center point and the plurality of casting pixel points, a mean vector of the neighborhood window at the current cluster position includes:
[0024] A cluster sample space is created with the lower left corner of the surface grayscale image as the origin, the rightward direction as the positive direction of the X axis, and the upward direction as the positive direction of the Y axis;
[0025] Determine a first coordinate value of the center point in the cluster sample space at the current cluster position, and second coordinate values of a plurality of the casting pixel points in the cluster sample space;
[0026] Calculating a vector of each of the casting pixel points at the current cluster position based on the first coordinate value and the second coordinate value;
[0027] According to the vectors of the plurality of casting pixel points, a mean vector of the neighborhood window at the current cluster position is calculated.
[0028] Optionally, controlling the movement of the neighborhood window from the current cluster position to a next cluster position based on the mean vector at the current cluster position includes:
[0029] Determining the direction and modulus of the mean vector at the current cluster position as the window drift direction and window drift distance when the neighborhood window moves from the current cluster position to the next cluster position, respectively;
[0030] According to the window drift direction and the window drift distance, the neighborhood window is controlled to move from the current cluster position to the next cluster position.
[0031] Optionally, adjusting the drift speed of the neighborhood window at the current cluster position according to the voting weight includes:
[0032] determining a second preset threshold for dividing a normal surface area and a crack defect area;
[0033] Based on the first preset threshold, the second preset threshold, the modulus of the mean vector at the current cluster position, and the voting weight, the drift speed of the neighborhood window at the current cluster position is calculated.
[0034] Optionally, the clustering result includes the number of votes cast by each cluster position at each pixel point of the casting and the voting weight corresponding to each vote;
[0035] The step of identifying crack defect areas in the surface grayscale image according to the clustering result includes:
[0036] Determining a classification result for each of the casting pixels based on the voting weights and the number of votes of the plurality of cluster positions on each of the casting pixels;
[0037] Dividing the surface grayscale image into a plurality of connected domains according to the classification result of each pixel point of the casting;
[0038] Crack defect regions are identified in the plurality of connected domains based on the connected domain size information.
[0039] Optionally, determining the classification result of each of the casting pixels based on the voting weights and the number of votes of the plurality of cluster positions on each of the casting pixels includes:
[0040] Determining the voting weight and number of votes for each of the casting pixels at the plurality of cluster positions;
[0041] Based on the voting weight and the number of votes, performing a cluster recognition process on each of the casting pixels;
[0042] The cluster identification process includes:
[0043] sequentially determining each of the casting pixel points as a target casting pixel point;
[0044] Obtaining a target number of votes and a target voting weight for the target casting pixel point;
[0045] When the target number of votes is 1, if the target voting weight is greater than or equal to a second preset threshold, the classification result of the target casting pixel point is determined to be a crack pixel point; if the target voting weight is less than the second preset threshold, the classification result of the target casting pixel point is determined to be a normal pixel point; or,
[0046] When the target number of votes is not 1, multiple target voting weights under the target number of votes are accumulated. If the accumulated voting weight is greater than or equal to the second preset threshold, the classification result of the target casting pixel point is determined to be a crack pixel point; if the accumulated voting weight is less than the second preset threshold, the classification result of the target casting pixel point is determined to be a normal pixel point.
[0047] Optionally, the connected domain size information includes a maximum length of the connected domain and a maximum width of the connected domain;
[0048] The surface grayscale image is divided into a plurality of connected domains according to the classification result of each pixel point of the casting, including:
[0049] Constructing a connected domain using connected casting pixel points that are classified into the same category in the surface grayscale image to obtain a plurality of connected domains contained in the surface grayscale image;
[0050] The identifying crack defect areas in the plurality of connected domains based on the connected domain size information includes:
[0051] Calculating a first evaluation value of a crack defect area corresponding to each connected domain based on the maximum length and the maximum width of each connected domain;
[0052] A connected domain among the multiple connected domains, the connected domain corresponding to the first evaluation value being greater than a third preset threshold, is determined as a crack defect region.
[0053] Optionally, the distribution range information includes the maximum crack length and maximum crack width of the crack defect area;
[0054] The determining of the surface qualified inspection result of the aluminum alloy casting based on the distribution range information of the crack defect area includes:
[0055] Calculating a second evaluation value for each crack defect region based on the maximum crack length and the maximum crack width of each crack defect region, wherein the second evaluation value is used to indicate the degree of damage caused by the crack in the crack defect region to the aluminum alloy casting;
[0056] Calculating a surface qualified inspection value of the aluminum alloy casting according to the number of regions containing the crack defect region in the surface grayscale image and the second evaluation value of each crack defect region;
[0057] When it is determined that the surface qualified inspection value is greater than or equal to a fourth preset threshold value, determining that the surface qualified inspection result of the aluminum alloy casting is qualified;
[0058] When it is determined that the surface qualified inspection value is less than the fourth preset threshold value, the surface qualified inspection result of the aluminum alloy casting is determined to be unqualified.
[0059] The present invention has the following beneficial effects: through the technical solution provided by the present invention, after collecting a surface image of an aluminum alloy casting and graying the surface image to obtain the surface grayscale image of the aluminum alloy casting, a mean shift algorithm can be used to cluster the casting pixels in the surface grayscale image. During the clustering process, based on the change information of the window drift direction and the window drift distance, the voting weight and drift speed of the casting pixel corresponding to each cluster position are adjusted in real time until the drift stop condition is reached, thereby obtaining the final clustering result; then, based on the clustering result, the crack defect area in the surface grayscale image can be identified; finally, based on the distribution range information of the crack defect area, the surface qualified inspection result of the aluminum alloy casting is determined. Given that when identifying crack defects on the surface of aluminum alloy castings, traditional image processing methods are often affected by the surface texture of the aluminum alloy, resulting in inaccurate crack defect identification. The present invention analyzes the characteristics of crack defects on the surface of aluminum alloy castings when clustering using the mean shift algorithm, and adjusts the voting weights during classification according to the drift process, which can effectively solve the above problems, improve the accuracy of crack defect identification, and improve the reliability of aluminum alloy casting surface inspection results.
[0060] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory and cannot limit the present invention. Other features and advantages of the present invention will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0062] Figure 1 A schematic flow chart of a surface digital detection method for a high-strength aluminum alloy casting provided by one embodiment of the present invention;
[0063] Figure 2 A schematic diagram of an aluminum alloy casting provided by one embodiment of the present invention;
[0064] Figure 3 A schematic flow chart of a surface digital detection method for a high-strength aluminum alloy casting provided in another embodiment of the present invention. DETAILED DESCRIPTION
[0065] To further illustrate the technical means and effectiveness of the present invention in achieving its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, describes in detail a surface digital inspection method for high-strength aluminum alloy castings, including its specific implementation, structure, features, and effectiveness. In the following description, references to different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
[0066] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0067] The specific scheme of the surface digital detection method of a high-strength aluminum alloy casting provided by the present invention is described in detail below with reference to the accompanying drawings.
[0068] See also Figure 1 , which shows a method flow chart of a surface digital detection method for a high-strength aluminum alloy casting provided by one embodiment of the present invention, the method comprising the following steps:
[0069] Step 110 : Acquire a surface image of the aluminum alloy casting, and perform grayscale processing on the surface image to obtain a surface grayscale image of the aluminum alloy casting.
[0070] Aluminum alloy castings are made from high-strength aluminum alloys. These aluminum alloys are enhanced through alloying, heat treatment, and specialized casting processes to enhance their strength and performance. These castings are widely used in aerospace, automotive, industrial equipment, sports equipment, and building infrastructure.
[0071] In the embodiment of the present disclosure, after the aluminum alloy casting is completed, when collecting the surface image of the aluminum alloy casting, the casting can be transferred to the detection position, and the surface image of the aluminum alloy casting can be captured using the camera above the detection position. The detection position bottom plate can be set to a color that is different from the color of the aluminum alloy casting, such as white. Because the color of the aluminum alloy casting is usually gray, the white area is removed from the captured image, and the remaining part is the aluminum alloy casting area, that is, the surface image of the aluminum alloy casting is obtained. Figure 2 As shown in the figure, which is a schematic diagram of an aluminum alloy casting. Furthermore, the surface image can be grayscaled to obtain a grayscale image of the aluminum alloy casting's surface. This grayscale image can extract texture features, avoiding interference and errors caused by color in image recognition, thereby improving the accuracy and speed of subsequent image processing.
[0072] Step 120: Cluster the casting pixels in the surface grayscale image using the mean shift algorithm. During the clustering process, the voting weight and drift speed of the casting pixel corresponding to each cluster position are adjusted in real time based on the change information of the window drift direction and the window drift distance until the drift stop condition is reached to obtain the final clustering result.
[0073] In the embodiment of the present disclosure, the mean shift algorithm can be used to cluster the pixels in the grayscale image of the casting, calculate the voting weight of each cluster position for the pixel, and adjust the drift speed during the clustering process.
[0074] In a specific application scenario, aluminum alloy castings typically have a rough surface, resulting in uneven grayscale in the surface grayscale image. The grayscale values of some normal areas may be similar to those of cracked areas, making them difficult to distinguish directly. However, the texture characteristics of the normal surface cause the window to drift randomly and over a relatively small distance when using mean-shift clustering. Cracked areas, on the other hand, have the opposite effect on window drift. Therefore, the changes in window movement direction and distance during clustering are used to adjust the voting weights for each pixel in each category during classification. Since normal surface areas lack effective defect information, a faster drift speed is required to improve clustering efficiency. In cracked defect areas, the drift speed can be appropriately reduced to ensure clustering effectiveness.
[0075] Step 130: Identify crack defect areas in the surface grayscale image based on the clustering result.
[0076] In specific application scenarios, cracks are typically long and narrow and extend in a generally fixed direction, so the aspect ratio of the cracks is generally large. The shape of the normal surface of a casting is related to the overall shape of the casting. Although it may be affected by cracks and have some irregularities, the overall aspect ratio is relatively small. In the disclosed embodiments, the distribution of clustering results in the casting image can be combined to effectively distinguish between normal areas and crack defect areas on the casting surface.
[0077] Step 140: Determine the surface qualified inspection result of the aluminum alloy casting based on the distribution range information of the crack defect area.
[0078] The distribution range information of the crack defect area may include the maximum crack length and the maximum crack width of the crack defect area.
[0079] In specific application scenarios, the distribution range of the crack defect area can be characterized based on the maximum crack length and maximum crack width of the crack defect area. The larger the distribution range of the crack defect area, that is, the larger the maximum crack length and maximum crack width, the more likely the crack will cause structural damage to the aluminum alloy casting during use, so the greater the harm.
[0080] In summary, according to the surface digital detection method of a high-strength aluminum alloy casting provided by the present invention, after collecting the surface image of the aluminum alloy casting and graying the surface image to obtain the surface grayscale image of the aluminum alloy casting, the mean shift algorithm can be used to cluster the casting pixels in the surface grayscale image. During the clustering process, based on the change information of the window drift direction and the window drift distance, the voting weight and drift speed of the casting pixel corresponding to each cluster position are adjusted in real time until the drift stop condition is reached to obtain the final clustering result; then, based on the clustering result, the crack defect area in the surface grayscale image can be identified; finally, based on the distribution range information of the crack defect area, the surface qualified detection result of the aluminum alloy casting is determined. Given that when identifying crack defects on the surface of aluminum alloy castings, traditional image processing methods are often affected by the surface texture of the aluminum alloy, resulting in inaccurate crack defect identification. The present invention analyzes the characteristics of crack defects on the surface of aluminum alloy castings when clustering using the mean shift algorithm, and adjusts the voting weights during classification according to the drift process, which can effectively solve the above problems, improve the accuracy of crack defect identification, and improve the reliability of aluminum alloy casting surface inspection results.
[0081] based on Figure 1 The embodiment shown is a refinement and expansion of the above embodiment. In order to fully illustrate the specific implementation process of the method of this embodiment, this embodiment provides the following Figure 3 The specific method shown. Figure 3 based on Figure 1 The embodiment shown. Figure 3 As shown, the method includes the following steps:
[0082] Step 310: Acquire a surface image of the aluminum alloy casting, and perform grayscale processing on the surface image to obtain a surface grayscale image of the aluminum alloy casting.
[0083] For the embodiments of the present disclosure, the embodiment steps can refer to the relevant description in embodiment step 210, and no specific limitation is given here.
[0084] Step 320: Generate a neighborhood window corresponding to the surface grayscale image. The neighborhood window is used to move on the surface grayscale image, each time moving to a different cluster position.
[0085] In a specific application scenario, when generating a neighborhood window corresponding to a surface grayscale image, the midpoint and neighborhood radius of the neighborhood window may be determined first, and then a spherical neighborhood window may be generated based on the midpoint and neighborhood radius.
[0086] As the clustering process proceeds, the candidate casting pixels that have not been clustered can be determined in real time, and the candidate casting pixel with the smallest grayscale value among the candidate casting pixels is determined as the center point of the corresponding cluster position. It should be noted that when there are multiple candidate casting pixels with the smallest grayscale value, any candidate casting pixel can be selected as the center point of the corresponding cluster position among the multiple candidate casting pixels with the smallest grayscale value. Exemplarily, at the beginning of the clustering process, because cracks usually appear as small grayscale values, all casting pixels in the surface grayscale image can be defined as candidate casting pixels, and then the candidate casting pixel with the smallest corresponding grayscale value is determined as the starting point a0 of the first cluster position. When determining the neighborhood radius R, because the grayscale value range of the pixel is between 0 and 255, in order to improve the accuracy of classification, the neighborhood radius should not be set too large; but if the neighborhood radius is set too small, the drift speed will be slow, affecting the efficiency of clustering. Therefore, the starting point is taken as the center, and 7 (empirical value) is used as the neighborhood radius R to generate a spherical neighborhood window.
[0087] Accordingly, for the embodiment of the present disclosure, the embodiment steps may include: determining candidate casting pixel points that have not been clustered in the surface grayscale image; determining the candidate casting pixel point with the smallest grayscale value among the candidate casting pixel points as the starting point; and generating a spherical neighborhood window with the starting point as the center and the first preset threshold as the neighborhood radius.
[0088] Step 330: Repeat the clustering process of the surface grayscale image using the neighborhood window until each casting pixel in the surface grayscale image is clustered, and generate a clustering result of the surface grayscale image based on the voting weight of each casting pixel in the surface grayscale image.
[0089] Among them, clustering is completed after determining each casting pixel point in the surface grayscale image, that is, the center point no longer changes, and the mean vector corresponding to the current cluster position is Length of mold When the new center point overlaps with the previous center point, the drifting stops, and based on the voting weight of each casting pixel in the surface grayscale image, the categories that finally converge to the same position are merged to obtain the clustering result of the surface grayscale image.
[0090] Accordingly, in the embodiment of the present disclosure, the clustering process of the surface grayscale image in step 330 may include the following steps:
[0091] Step 330 - 1 : Determine the center point and multiple casting pixel points included in the neighborhood window at the current cluster position.
[0092] In specific application scenarios, after determining the neighborhood window, the window can be controlled to move across the surface grayscale image, each time moving to a different cluster location. For each cluster location, the center point of the neighborhood window and the number of casting pixels contained within the spherical neighborhood window can be determined.
[0093] Step 330 - 2 : Based on the center point and multiple casting pixel points, calculate the mean vector of the neighborhood window at the current cluster position.
[0094] In a specific application scenario, we can first create a cluster sample space with the lower left corner of the image as the origin, the rightward direction as the positive X-axis, and the upward direction as the positive Y-axis. All casting pixels are placed in the cluster sample space according to their corresponding coordinates to obtain the corresponding coordinate values (x, y). The grayscale value is the Z-axis, and the grayscale value range is 0 to 255. Therefore, the coordinates of each pixel are (x, y, z). Then, based on the coordinate value of the center point in the cluster sample space and the coordinate values of multiple casting pixels in the cluster sample space, we can calculate the vector of each casting pixel at the current cluster position (pointing from the center point to each casting pixel):
[0095]
[0096] Where, represents the vector of the i-th casting pixel in the neighborhood window at the u-th cluster position; i represents the i-th casting pixel in the neighborhood window at the u-th cluster position; I(x u,i ,y u,i ,g u,i ) represents the coordinate value of the i-th casting pixel point in the neighborhood window at the u-th cluster position in the cluster sample space; x u,i represents the X-axis coordinate value of the i-th casting pixel point in the neighborhood window at the u-th cluster position in the cluster sample space; u,i represents the Y-axis coordinate value of the i-th casting pixel point in the neighborhood window at the u-th cluster position in the cluster sample space; g u,i represents the Z-axis coordinate value of the i-th casting pixel point in the neighborhood window at the u-th cluster position in the cluster sample space; I(x u,0 ,y u,0 ,g u,0 ) represents the coordinate value of the center point in the neighborhood window at the u-th cluster position in the cluster sample space; x u,0 represents the X-axis coordinate value of the center point in the neighborhood window at the u-th cluster position in the cluster sample space; y u,0 represents the Y-axis coordinate value of the center point in the neighborhood window at the u-th cluster position in the cluster sample space; g u,0 Represents the Z-axis coordinate value of the center point in the neighborhood window at the u-th cluster position in the cluster sample space.
[0097] Furthermore, based on the vector of each casting pixel at the current cluster position, the mean vector of the neighborhood window at the current cluster position can be calculated:
[0098]
[0099] Where, represents the mean vector of the neighborhood window at the u-th cluster position; n u represents the number of casting pixels contained in the neighborhood window at the u-th cluster position; i represents the i-th casting pixel in the neighborhood window at the u-th cluster position; The vector representing the pixel point of the i-th casting in the neighborhood window at the u-th cluster position.
[0100] Accordingly, for the embodiments of the present disclosure, the embodiment steps may include: creating a cluster sample space with the lower left corner of the surface grayscale image as the origin, the right as the positive direction of the X-axis, and the upward as the positive direction of the Y-axis; determining the first coordinate value of the center point in the cluster sample space at the current cluster position, and the second coordinate values of multiple casting pixel points in the cluster sample space respectively; calculating the vector of each casting pixel point at the current cluster position based on the first coordinate value and the second coordinate value; and calculating the mean vector of the neighborhood window at the current cluster position based on the vectors of multiple casting pixel points.
[0101] Step 330 - 3 : Determine the change information of the window drift direction and the window drift distance according to the mean vectors corresponding to the current cluster position and the previous cluster position respectively.
[0102] For the embodiment of the present disclosure, the mean vector corresponding to the current cluster position can be obtained And the mean vector of the current cluster position corresponding to the previous cluster position Mean vector of the previous cluster position The calculation method of the mean vector in step 330-2 of the embodiment can be referred to and will not be repeated here. The mean vector corresponding to the previous cluster position Calculate the change information of window drift direction and window drift distance:
[0103]
[0104] Where cosθ u Indicates the change information of window drift direction and window drift distance; Represents the mean vector corresponding to the current cluster position Length of the module; Represents the mean vector corresponding to the previous cluster position Length of the module; represents the mean vector With the mean vector The modulus of the product of ; u indicates that the current cluster position is the u-th cluster position.
[0105] Step 330 - 4 : Based on the change information, the voting weights of the plurality of casting pixels included in the neighborhood window at the current cluster position corresponding to the crack category are adjusted.
[0106] In specific application scenarios, although the surface of a normal aluminum alloy casting is not smooth, the texture distribution is relatively uniform, so the mean vector obtained in the normal surface area is usually long. Smaller and In the crack area on the surface of the aluminum alloy casting, since the crack is manifested as a relatively small gray value at each position, the modulus length of the mean vector obtained in the crack area is will be relatively large, and The direction of the crack will point to the direction of the crack growth. Because the aluminum alloy casting has a high hardness, the direction of the crack during the extension process changes little, so the crack area will be in the direction of the crack growth in two consecutive drifts. The direction will be closer.
[0107] So, according to and The changes in direction and modulus can reflect the possibility that the current neighborhood window is in the crack area: and The smaller the change in direction, and The bigger, The more likely the corresponding neighborhood window is to be in the crack area. In order to more accurately distinguish the crack area, the greater the possibility that the neighborhood window is in the crack area, the greater its corresponding voting weight:
[0108]
[0109] Where, φ u represents the voting weights of the multiple casting pixels contained in the neighborhood window at the u-th cluster position corresponding to the crack category; norm() represents the normalization function; Represents the mean vector corresponding to the current cluster position The modulus of cosθ u Indicates the change information of the window drift direction and window drift distance; u indicates that the current cluster position is the u-th cluster position.
[0110] Step 330 - 5 : Adjust the drift speed of the neighborhood window at the current cluster position according to the voting weight.
[0111] Since effective defect information cannot be provided in the normal surface area, in order to improve the clustering efficiency, it is necessary to increase the drift speed. Therefore, although the obtained is small, a larger drift distance is required during drifting. When the neighborhood window moves to the crack area, in order to obtain a relatively complete crack area, that is, in one clustering process, all pixel points in the same crack area should be covered as much as possible, so it is necessary to appropriately reduce the drift distance.
[0112] In step 330-4 of the embodiment, the voting weight φ u is calculated. Then, the second preset threshold k for dividing the normal surface area and the crack defect area can be determined. By comparing the voting weight with the second preset threshold k, it is determined whether to increase or decrease the drift distance. Among them, the drift distance is used to represent the drift speed. A large drift distance means a fast speed, and a small drift distance means a slow speed. Exemplarily, when u <k, it is considered that the area within the neighborhood window at the u-th clustering position is the normal surface area, so it is necessary to increase the drift distance; otherwise, it is necessary to reduce the drift distance. Adjust the drift speed of the neighborhood window at the current clustering position according to the voting weight as follows:
[0113]
[0114] In the formula, l u represents the drift distance that the neighborhood window needs to drift after adjustment at the u-th clustering position, that is, the corresponding drift speed; represents the modulus of the mean vector corresponding to the current clustering position ; u represents that the current clustering position is the u-th clustering position; k is the second preset threshold for dividing the normal surface area and the suspected crack area, where k = 0.5; R is the neighborhood radius of the neighborhood window, that is, the first preset threshold; φ u represents the voting weight corresponding to the multiple casting pixel points included in the neighborhood window at the u-th clustering position belonging to the crack category.
[0115] Correspondingly, for the embodiment of the present disclosure, the embodiment steps may include: determining the second preset threshold for dividing the normal surface area and the crack defect area; calculating the drift speed of the neighborhood window at the current clustering position based on the first preset threshold, the second preset threshold, the modulus of the mean vector at the current clustering position, and the voting weight.
[0116] Step 330-6: Based on the mean vector at the current clustering position, control the neighborhood window to move from the current clustering position to the next clustering position.
[0117] For the embodiment of the present disclosure, the direction of the mean vector at the current clustering position can be determined as the moving direction, with the mean vector The modulus length is the moving distance, and the center point is moved from the starting point to the new center point position. The corresponding neighborhood window also moves in the same way, that is, the size remains unchanged and is centered on the new center point.
[0118] Accordingly, for the embodiments of the present disclosure, the embodiment steps may include: determining the direction and modulus of the mean vector at the current cluster position as the window drift direction and window drift distance when the neighborhood window moves from the current cluster position to the next cluster position, respectively; and controlling the movement of the neighborhood window from the current cluster position to the next cluster position according to the window drift direction and window drift distance.
[0119] Step 340: Identify crack defect areas in the surface grayscale image based on the clustering results.
[0120] The clustering results include the number of votes for each cluster position at each casting pixel and the voting weight corresponding to each vote.
[0121] Accordingly, in the embodiment of the present disclosure, identifying crack defect areas in the surface grayscale image based on the clustering results in step 340 may include the following steps:
[0122] Step 340 - 1 : Determine a classification result for each pixel point of the casting based on the voting weights and the number of votes of multiple cluster positions on each pixel point of the casting.
[0123] Accordingly, for the embodiments of the present disclosure, the embodiment steps may include: determining the voting weight and number of votes for each casting pixel at multiple cluster positions; performing a cluster identification process on each casting pixel based on the voting weight and number of votes; the cluster identification process includes: determining each casting pixel as a target casting pixel in turn; obtaining the target number of votes and target voting weight of the target casting pixel; when the target number of votes is 1, if the target voting weight is greater than or equal to a second preset threshold, determining that the classification result of the target casting pixel is a crack pixel; if the target voting weight is less than the second preset threshold, determining that the classification result of the target casting pixel is a normal pixel; or, when the target number of votes is not 1, accumulating multiple target voting weights under the target number of votes, if the accumulated voting weight is greater than or equal to the second preset threshold, determining that the classification result of the target casting pixel is a crack pixel; if the accumulated voting weight is less than the second preset threshold, determining that the classification result of the target casting pixel is a normal pixel.
[0124] For example, during the first classification, the neighborhood window passes pixel a once from the start to the stop, and the voting weight calculated during the pass is p. Then the voting weight of pixel a is p. If p is greater than or equal to the second preset threshold, the classification result of pixel a is determined to be a crack pixel. Otherwise, the classification result of pixel a is determined to be a normal pixel. During the first classification, the neighborhood window passes pixel b five times from the start to the stop, and the voting weight calculated during each pass is p1, p2, p3, p4, and p5. Then the voting weight of pixel b is Q1 = p1 + p2 + p3 + p4 + p5. If Q1 is greater than or equal to the second preset threshold, the classification result of pixel b is determined to be a crack pixel. Otherwise, the classification result of pixel b is determined to be a normal pixel.
[0125] Step 340 - 2 : Divide the surface grayscale image into multiple connected domains based on the classification result of each casting pixel.
[0126] Accordingly, for the embodiment of the present disclosure, the embodiment steps may include: constructing a connected domain using the casting pixel points that are classified into the same category and connected in the surface grayscale image, to obtain multiple connected domains contained in the surface grayscale image.
[0127] Step 340 - 3 : Identify crack defect areas in multiple connected domains based on the connected domain size information.
[0128] The connected domain size information includes the maximum length and maximum width of the connected domain.
[0129] In specific application scenarios, cracks are usually slender and extend in a fixed direction, so the aspect ratio of the cracks is usually large. The shape of the normal surface of the casting is related to the overall shape of the casting. Although it may be affected by cracks and have some irregularities, the overall aspect ratio is relatively small. Therefore, for each connected domain, its maximum length and the maximum width in the vertical direction of the maximum length connecting the lines are determined, and the probability of each connected domain being a crack area is calculated, that is, the first evaluation value:
[0130]
[0131] Where q w represents the possibility that the wth connected domain is a crack area, i.e., the first evaluation value; norm( ) represents the normalization function; c w,max represents the maximum length of the connected domain of the wth connected domain; b w,max Indicates the maximum width of the connected component of the w-th connected component.
[0132] In q w>m, the connected domain is considered to be a crack defect area, wherein m is a third preset threshold, and its specific value can be set according to the actual application scenario, such as 0.3.
[0133] Accordingly, for the embodiment of the present disclosure, the embodiment steps may include: calculating the first evaluation value of each connected domain corresponding to a crack defect area based on the maximum length of the connected domain and the maximum width of the connected domain of each connected domain; and determining the connected domain among multiple connected domains whose corresponding first evaluation value is greater than a third preset threshold as a crack defect area.
[0134] Step 350: Determine the surface qualified inspection result of the aluminum alloy casting based on the distribution range information of the crack defect area.
[0135] The distribution range information includes the maximum crack length and maximum crack width of the crack defect area.
[0136] Accordingly, in the embodiment of the present disclosure, determining the surface qualified inspection result of the aluminum alloy casting based on the distribution range information of the crack defect area in step 350 may include the following steps:
[0137] Step 350 - 1 : Calculate a second evaluation value of each crack defect region based on the maximum crack length and maximum crack width of each crack defect region, where the second evaluation value is used to indicate the degree of damage caused by the cracks in the crack defect region to the aluminum alloy casting.
[0138] In specific application scenarios, the larger the crack area, that is, the larger the maximum length and maximum width of the crack, the more likely the crack will cause structural damage during the use of the casting, and therefore the greater the hazard. Therefore, the hazard level of each crack area, that is, the second evaluation value, is:
[0139] e w =c w,max ×b w,max
[0140] Where, e w represents the degree of damage of the w-th crack defect area, i.e., the second evaluation value; c w,max represents the maximum length of the crack in the w-th crack defect area; b w,max represents the maximum crack width of the w-th crack defect area.
[0141] Step 350 - 2 : Calculate the surface qualified inspection value of the aluminum alloy casting according to the number of regions containing crack defect regions in the surface grayscale image and the second evaluation value of each crack defect region.
[0142] The calculation method of the surface qualified test value of aluminum alloy castings is:
[0143]
[0144] Where H represents the surface qualified inspection value of aluminum alloy casting; norm() represents the normalization function; N represents the number of crack defect areas on the surface of aluminum alloy casting, e w It represents the degree of damage of the w-th crack defect area, that is, the second evaluation value; w represents the w-th crack defect area.
[0145] Step 350 - 3 : When it is determined that the surface qualified inspection value is greater than or equal to the fourth preset threshold, the surface qualified inspection result of the aluminum alloy casting is determined to be qualified.
[0146] The fourth preset threshold value may be set according to actual application scenarios, for example, it may be set to 0.7.
[0147] When the surface qualified inspection value H of the aluminum alloy casting is ≥0.7, it is determined that the surface qualified inspection result of the aluminum alloy casting is qualified.
[0148] Step 350 - 4 : When it is determined that the surface qualified inspection value is less than the fourth preset threshold value, the surface qualified inspection result of the aluminum alloy casting is determined to be unqualified.
[0149] When the surface qualified inspection value H of the aluminum alloy casting is less than 0.7, it is determined that the surface qualified inspection result of the aluminum alloy casting is unqualified.
[0150] In summary, the technical solution of the present application is to collect the surface image of the aluminum alloy casting and grayscale the surface image to obtain the surface grayscale image of the aluminum alloy casting. Then, the mean shift algorithm can be used to cluster the casting pixels in the surface grayscale image. During the clustering process, the voting weight and drift speed of the casting pixels corresponding to each cluster position are adjusted in real time based on the change information of the window drift direction and the window drift distance until the drift stop condition is reached to obtain the final clustering result. Then, the crack defect area in the surface grayscale image can be identified based on the clustering result. Finally, the surface qualified inspection result of the aluminum alloy casting is determined based on the distribution range information of the crack defect area. Given that when identifying crack defects on the surface of aluminum alloy castings, traditional image processing methods are often affected by the surface texture of the aluminum alloy, resulting in inaccurate crack defect identification. The present invention can effectively solve the above problems by analyzing the characteristics of the crack defect part of the aluminum alloy casting surface when clustering using the mean shift algorithm and adjusting the voting weight during classification according to the drift process, thereby improving the accuracy of crack defect identification and the reliability of the aluminum alloy casting surface inspection results.
[0151] It should be noted that the order in which the embodiments of the present invention are described above is for illustrative purposes only and does not necessarily represent the superiority or inferiority of the embodiments. Furthermore, the foregoing descriptions of specific embodiments of this specification are provided. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential sequence shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0152] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments.
[0153] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A surface digital detection method for high-strength aluminum alloy castings, characterized in that: The method comprises: Acquiring a surface image of an aluminum alloy casting, and performing grayscale processing on the surface image to obtain a surface grayscale image of the aluminum alloy casting; The casting pixels in the surface grayscale image are clustered using a mean shift algorithm. During the clustering process, the voting weight and drift speed of the casting pixel corresponding to each cluster position are adjusted in real time based on the change information of the window drift direction and the window drift distance until the drift stop condition is reached, thereby obtaining the final clustering result. identifying crack defect areas in the surface grayscale image according to the clustering result; Based on the distribution range information of the crack defect area, a qualified surface inspection result of the aluminum alloy casting is determined.
2. The surface digital detection method of high-strength aluminum alloy casting according to claim 1, characterized in that: The method utilizes the mean shift algorithm to cluster the casting pixels in the surface grayscale image. During the clustering process, based on the change information of the window drift direction and the window drift distance, the voting weight and drift speed of the casting pixel corresponding to each cluster position are adjusted in real time until the drift stop condition is reached, thereby obtaining the final clustering result, including: generating a neighborhood window corresponding to the surface grayscale image, wherein the neighborhood window is used to move on the surface grayscale image, each time moving to a different cluster position; Repeating the clustering process of the surface grayscale image using the neighborhood window until clustering is completed for each casting pixel in the surface grayscale image, and generating a clustering result of the surface grayscale image based on a voting weight of each casting pixel in the surface grayscale image; The clustering process of the surface grayscale image includes: Determine a center point and a plurality of casting pixel points included in the neighborhood window at a current cluster position; Calculating a mean vector of the neighborhood window at the current cluster position based on the center point and the plurality of casting pixel points; Determining change information of a window drift direction and a window drift distance according to mean vectors corresponding to the current cluster position and the previous cluster position respectively; Based on the change information, adjusting the voting weights of the plurality of casting pixels included in the neighborhood window at the current cluster position corresponding to the crack category, and adjusting the drift speed of the neighborhood window at the current cluster position according to the voting weights; Based on the mean vector at the current cluster position, the neighborhood window is controlled to move from the current cluster position to a next cluster position.
3. The surface digital detection method of high-strength aluminum alloy casting according to claim 2, characterized in that: Generating a neighborhood window corresponding to the surface grayscale image includes: Determining candidate casting pixel points that have not been clustered in the surface grayscale image; Determine the candidate casting pixel point with the smallest grayscale value among the candidate casting pixel points as the starting point; A spherical neighborhood window is generated with the starting point as the center and the first preset threshold as the neighborhood radius.
4. The surface digital detection method of high-strength aluminum alloy casting according to claim 2, characterized in that: The step of calculating the mean vector of the neighborhood window at the current cluster position based on the center point and the plurality of casting pixel points comprises: A cluster sample space is created with the lower left corner of the surface grayscale image as the origin, the rightward direction as the positive direction of the X axis, and the upward direction as the positive direction of the Y axis; Determine a first coordinate value of the center point in the cluster sample space at the current cluster position, and second coordinate values of a plurality of the casting pixel points in the cluster sample space; Calculating a vector of each of the casting pixel points at the current cluster position based on the first coordinate value and the second coordinate value; According to the vectors of the plurality of casting pixel points, a mean vector of the neighborhood window at the current cluster position is calculated.
5. The surface digital detection method of high-strength aluminum alloy casting according to claim 2, characterized in that: The controlling, based on the mean vector at the current cluster position, to move the neighborhood window from the current cluster position to the next cluster position includes: Determining the direction and modulus of the mean vector at the current cluster position as the window drift direction and window drift distance when the neighborhood window moves from the current cluster position to the next cluster position, respectively; According to the window drift direction and the window drift distance, the neighborhood window is controlled to move from the current cluster position to the next cluster position.
6. The surface digital detection method of high-strength aluminum alloy casting according to claim 3, characterized in that: The adjusting the drift speed of the neighborhood window at the current cluster position according to the voting weight includes: determining a second preset threshold for dividing a normal surface area and a crack defect area; Based on the first preset threshold, the second preset threshold, the modulus of the mean vector at the current cluster position, and the voting weight, the drift speed of the neighborhood window at the current cluster position is calculated.
7. The surface digital detection method of high-strength aluminum alloy casting according to claim 2, characterized in that: The clustering result includes the number of votes cast by each cluster position at each pixel point of the casting and the voting weight corresponding to each vote; The step of identifying crack defect areas in the surface grayscale image according to the clustering result includes: Determining a classification result for each of the casting pixels based on the voting weights and the number of votes of the plurality of cluster positions on each of the casting pixels; Dividing the surface grayscale image into a plurality of connected domains according to the classification result of each pixel point of the casting; Crack defect regions are identified in the plurality of connected domains based on the connected domain size information.
8. The surface digital detection method of high-strength aluminum alloy casting according to claim 7, characterized in that: Determining the classification result of each of the casting pixels based on the voting weights and the number of votes of the plurality of cluster positions on each of the casting pixels comprises: Determining the voting weight and number of votes for each of the casting pixels at the plurality of cluster positions; Based on the voting weight and the number of votes, performing a cluster recognition process on each of the casting pixels; The cluster identification process includes: sequentially determining each of the casting pixel points as a target casting pixel point; Obtaining a target number of votes and a target voting weight for the target casting pixel point; When the target number of votes is 1, if the target voting weight is greater than or equal to a second preset threshold, the classification result of the target casting pixel point is determined to be a crack pixel point; if the target voting weight is less than the second preset threshold, the classification result of the target casting pixel point is determined to be a normal pixel point; or, When the target number of votes is not 1, multiple target voting weights under the target number of votes are accumulated. If the accumulated voting weight is greater than or equal to the second preset threshold, the classification result of the target casting pixel point is determined to be a crack pixel point; if the accumulated voting weight is less than the second preset threshold, the classification result of the target casting pixel point is determined to be a normal pixel point.
9. The surface digital detection method of high-strength aluminum alloy casting according to claim 7, characterized in that: The connected domain size information includes the maximum length and the maximum width of the connected domain; The surface grayscale image is divided into a plurality of connected domains according to the classification result of each pixel point of the casting, including: Constructing a connected domain using connected casting pixel points that are classified into the same category in the surface grayscale image to obtain a plurality of connected domains contained in the surface grayscale image; The identifying crack defect areas in the plurality of connected domains based on the connected domain size information includes: Calculating a first evaluation value of a crack defect area corresponding to each connected domain based on the maximum length and the maximum width of each connected domain; A connected domain among the multiple connected domains, the connected domain corresponding to the first evaluation value being greater than a third preset threshold, is determined as a crack defect region.
10. The surface digital detection method of high-strength aluminum alloy casting according to claim 1, characterized in that: The distribution range information includes the maximum crack length and the maximum crack width of the crack defect area; The determining of the surface qualified inspection result of the aluminum alloy casting based on the distribution range information of the crack defect area includes: Calculating a second evaluation value for each crack defect region based on the maximum crack length and the maximum crack width of each crack defect region, wherein the second evaluation value is used to indicate the degree of damage caused by the crack in the crack defect region to the aluminum alloy casting; Calculating a surface qualified inspection value of the aluminum alloy casting according to the number of regions containing the crack defect region in the surface grayscale image and the second evaluation value of each crack defect region; When it is determined that the surface qualified inspection value is greater than or equal to a fourth preset threshold value, determining that the surface qualified inspection result of the aluminum alloy casting is qualified; When it is determined that the surface qualified inspection value is less than the fourth preset threshold value, the surface qualified inspection result of the aluminum alloy casting is determined to be unqualified.
Citation Information
Patent Citations
Part defect detection method and device and electronic equipment
CN111768381A
Automobile seat leather classification method, device and system based on computer vision
CN114913512A
Method for detecting traffic violation
US20160034778A1