Friction stir welding seam defect image data set self-generating method based on parametric modeling
By generating a dataset of defect images of friction stir welding welds through parametric modeling, the problem of lack of defect sample data is solved, defect images that conform to actual process laws are efficiently generated, and the performance and robustness of the detection algorithm are improved.
Patent Information
- Application Number
- CN202510406515.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-09-12
AI Technical Summary
In the existing technology, stir friction welding weld defect detection has the problems of low detection efficiency and high risk of missed defects, mainly due to the lack of defect sample data and the large difference between traditional prefabricated defect methods and real metallurgical defects, which makes it impossible to optimize the neural network defect automatic recognition model.
A parametric modeling-based method is used to generate a dataset of friction stir welding weld defect images. The SAM model is used to divide the region, and the parametric defect generation model is combined to generate defect images such as incomplete penetration, tunnels, porosity, inclusions and cracks on the background image. Gaussian blurring and feature fusion are used to generate high-quality defect data.
A large amount of high-quality defect image data has been generated, covering a variety of typical defects, which conforms to the physical laws of actual welding processes and significantly improves the performance and robustness of the detection algorithm.
Smart Images

Figure CN120634941A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image data set generation, and in particular to a method for self-generating a friction stir welding weld defect image data set based on parameterized modeling. Background Art
[0002] With the development of lightweight aerospace equipment, large thin-walled rotating structural parts are widely using stir friction welding technology, such as launch vehicle fuel tanks. The joint performance directly affects the structural load-bearing reliability. Such components have large aspect ratios and high-precision curved surface features. Traditional manual radiographic inspection has two major technical bottlenecks: (1) low inspection efficiency: multiple exposure inspections are required, and the time required for single-piece film evaluation is over 40 hours; (2) high risk of defect omission: the accuracy of manual film evaluation fluctuates between 75% and 90%, and is significantly dependent on experience. Therefore, it is very necessary to explore a full-process automated inspection method based on micro-focus digital radiographic inspection.
[0003] Microfocus digital radiography can provide weld images with clarity comparable to film radiography. By establishing a neural network defect automatic recognition model, weld defects can be automatically identified and located. However, achieving fully automated inspection still faces a key constraint: an extreme lack of defect sample data, as shown in the following:
[0004] (1) Scarcity of natural defects: The welding qualification rate of this type of product exceeds 99.5%, and the annual accumulation of real defect samples is insufficient;
[0005] (2) Limitations of artificial prefabricated defects: Traditional prefabrication methods such as mechanical grooving / drilling destroy the material grain streamline topology, and there is a significant difference in the grayscale gradient distribution of real metallurgical defects in digital radiographic images, such as tunnel-type holes and microcracks in the thermoplastic zone.
[0006] Among the current mainstream solutions, the GAN-based data augmentation method has a failure rate of up to 62% in the field of welding defect generation. Data source: AWS 2023 Annual Report. The fundamental reason is the lack of physical constraints on the weld defect formation mechanism. Therefore, a self-generation method for stir friction welding weld defect image dataset based on parametric modeling is urgently needed to break the mutually exclusive dilemma of "physical authenticity and data scale". Summary of the Invention
[0007] The technical problem to be solved by the present invention is to solve the problem that the neural network defect automatic recognition model cannot be optimized due to the lack of sample data of this type of defect.
[0008] The technical solution adopted by the present invention to solve the technical problem is: a method for self-generating a friction stir welding weld defect image dataset based on parametric modeling, comprising the following steps:
[0009] S1: Acquire a defect-free friction stir welding image with the weld in the middle as an original image, copy a number of the original images to form an original image set, and prepare a number of completely black background images with the same size as the original image;
[0010] S2: Using the SAM model to divide the original image into regions, generating a plurality of candidate regions, traversing the plurality of candidate regions in turn, and determining the weld region in the plurality of candidate regions based on weld image features;
[0011] S3: generating a defect image on the background image according to a parameterized defect generation model, comparing the weld area, wherein the defect image includes an incomplete penetration defect image, a tunnel defect image, a porosity defect image, an inclusion defect image, and a crack defect image, wherein the parameterized defect generation model includes at least the following four parameters: a distance d between the weld area on the background image and the corresponding original image and the weld centerline, generating a rectangular area (l, w) along the weld direction based on the distance d between the weld area on the background image and the corresponding original image and the weld centerline, and assigning a random brightness value b to the brightness within the rectangular area;
[0012] S4: Gaussian blurring the background image used to generate the defect image;
[0013] S5: performing feature fusion on the Gaussian blurred background image and the original image to generate a corresponding defect image;
[0014] S6: Setting corresponding labels for the defect images and saving them;
[0015] S7: Repeat S2-S6 until a predetermined number of defect images corresponding to one type of defect are generated;
[0016] S8: Repeat S2-S7 until the number of defect images corresponding to the five types of defects reaches a predetermined number.
[0017] As a preferred technical solution of the present invention, S2 specifically includes the following steps:
[0018] S2.1: Using the SAM model to divide the original image into regions, generate a number of candidate regions, and traverse the candidate regions in sequence;
[0019] S2.2: Remove the candidate regions that are completely inside the original image, and obtain the bounding box of each remaining candidate region;
[0020] S2.3: Calculate the aspect ratio of the bounding box, and remove areas of the bounding box where the aspect ratio is less than k;
[0021] S2.4: Calculate the areas of the candidate regions and the areas of the corresponding bounding boxes, and remove candidate regions where the ratio of the candidate region area to the corresponding bounding box area is less than h;
[0022] S2.5: When the number of candidate areas remaining after removal is 1, the candidate area is the weld area. When the number of candidate areas remaining after removal is greater than 1, calculate the average value of the distances from all pixels in several candidate areas to the center point of the original image. The candidate area corresponding to the smallest average value is the weld area.
[0023] As a preferred technical solution of the present invention, the range of k is 3-4, and the range of h is 0.9-0.95.
[0024] As a preferred technical solution of the present invention, the parameterized defect generation model includes an incomplete penetration defect generation model corresponding to the incomplete penetration defect image, a tunnel defect generation model corresponding to the tunnel defect image, a loose defect generation model corresponding to the loose defect image, an inclusion defect generation model corresponding to the inclusion defect image, and a crack defect generation model corresponding to the crack defect image;
[0025] The process of modeling the incomplete penetration defect generation model includes: generating a rectangular area (l, w) along the weld direction at a position on the background image corresponding to the weld area on the original image at a distance d from the weld center axis, and assigning a random brightness value b to the brightness within the rectangular area;
[0026] The tunnel defect generation modeling process includes: generating a rectangular area (l, w) along the weld direction at a position on the background image corresponding to the weld area on the original image at a distance d from the weld center axis, and assigning a random brightness value b to the brightness within the rectangular area;
[0027] The modeling process of the porosity defect generation model includes: generating a rectangular area (l, w) along the weld direction at a position on the background image corresponding to the weld area on the original image at a distance d from the weld center axis, randomly generating n seed points within the rectangular area, taking each seed point as the center of a circle, randomly generating m points within a radius r as vertices of a polygonal area, connecting the m vertices in a clockwise direction to form a closed polygonal area, and assigning a random brightness value b to the brightness within the polygonal area;
[0028] The inclusion defect generation modeling process includes: randomly generating n seed points in the pixel area corresponding to the weld area on the background image, randomly generating m points as polygonal area vertices within a radius r with each seed point as the center of a circle, connecting the m vertices in a clockwise direction to form a closed polygonal area, and assigning the brightness within the polygonal area to a random brightness value b;
[0029] The crack defect generation modeling process includes: randomly generating starting point coordinates (x0, y0) on the background image and the weld area on the corresponding original image, and randomly generating crack propagation directions within the range of 0°-360° with the starting point coordinates (x0, y0) as the center of the circle. Extend the distance d1 along the crack propagation direction to the coordinate point (x1, y1), construct a rectangular crack segment with width w1 and random brightness value b1, and then take the coordinate point (x1, y1) as the center and rotate the crack propagation direction after the random rotation of θ degrees. Extend d2 to the next coordinate point (x2, y2), construct a new rectangular crack segment with width w2 and random brightness value b2, and repeat the construction of the rectangular crack segment g times to generate a crack path with multiple rectangular crack segments.
[0030] As a preferred technical solution of the present invention, the original image resolution is 1279×1542, one corner of the original image is used as the pixel origin (0,0), the starting pixel coordinates of the weld centerline are (80,1017), the ending pixel coordinates are (1279,1017), and the weld area width is 280 pixels.
[0031] As a preferred technical solution of the present invention, during the modeling process of the incomplete penetration defect generation model, the distance d from the center axis of the weld is in the range of 0-5 pixels, the width w of the rectangular area is in the range of 3-6 pixels, the length l of the rectangular area is in the range of 100-1200 pixels, and the random brightness value b of the rectangular area is in the range of 25-50 grayscale values.
[0032] As a preferred technical solution of the present invention, during the modeling process of the tunnel defect generation model, the distance d from the center axis of the weld is in the range of 80-100 pixels, the width w of the rectangular area is in the range of 3-6 pixels, the length l of the rectangular area is in the range of 100-1200 pixels, and the random brightness value b of the rectangular area is in the range of 25-50 grayscale values.
[0033] As a preferred technical solution of the present invention, during the modeling process of the porosity defect generation model, the distance d from the center axis of the weld is in the range of 20-100 pixels, the width w of the rectangular area is in the range of 10-50 pixels, the length l of the rectangular area is in the range of 3w-10w pixels, the number of seed points n is in the range of l×w÷100-l×w÷50, the radius r is in the range of 5-20 pixels, the number of vertices m is in the range of 3-5, and the brightness value b of the polygonal area is in the range of 25-50 grayscale values.
[0034] As a preferred technical solution of the present invention, in the modeling process of the inclusion defect generation model, the number of seed points n ranges from 1 to 20, the radius r ranges from 5 to 20 pixels, the number of vertices m ranges from 3 to 6, and the polygonal area brightness value b ranges from 25 to 50 grayscale values.
[0035] As a preferred technical solution of the present invention, during the modeling process of the crack defect generation model, the width w g The range of is 1-5 pixels, the range of θ is θ∈[-15°, 15°], the number of g ranges from 5-50, the brightness value b g The range is 10-35 grayscale values.
[0036] The beneficial effects of the present invention are embodied in:
[0037] 1. Through parametric modeling and random generation algorithms, it is possible to efficiently generate a large amount of high-quality defect image data, covering a variety of typical defects such as incomplete penetration, tunnels, looseness, inclusions, cracks, etc.
[0038] 2. Through the dynamic fusion algorithm based on pixel intensity distribution, defect features with large differences in morphology and distribution are automatically integrated into the original digital radiographic image of the weld, ensuring that the generated defect image conforms to the physical laws and distribution characteristics of the actual welding process.
[0039] 3. The generated high-value training samples can provide a large amount of real and effective data support for the welding intelligent detection neural network, significantly improving the performance and robustness of the detection algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a process diagram of generating defect images according to the present invention;
[0041] Figure 2 This is the algorithm flow for automatic identification of weld area in original image of the present invention;
[0042] Figure 3 This is an example of the present invention of automatically generating defects by arbitrarily selecting a digital radiographic image of a weld. DETAILED DESCRIPTION
[0043] The present invention will now be described in further detail with reference to the accompanying drawings.
[0044] Combined with attachment Figure 1-3 As shown, a method for self-generating a friction stir welding weld defect image dataset based on parametric modeling includes the following steps:
[0045] S1: Acquire a defect-free friction stir welding image with the weld in the middle as an original image, copy a number of the original images to form an original image set, and prepare a number of completely black background images with the same size as the original image;
[0046] Specifically, the original image is captured by a micro-focus digital radiographic detection system;
[0047] S2: Using the SAM model to divide the original image into regions, generating a plurality of candidate regions, traversing the plurality of candidate regions in turn, and determining the weld region in the plurality of candidate regions based on weld image features;
[0048] Specifically:
[0049] S2.1: Using the SAM model to perform region division on the original image to generate a number of candidate regions, and traversing the candidate regions in sequence. Preferably, the SAM model is used to perform full-pixel region division on the original image;
[0050] S2.2: Remove the candidate regions that are completely inside the original image, and obtain the bounding box of each remaining candidate region;
[0051] S2.3: Calculate the aspect ratio of the bounding box, and remove areas of the bounding box where the aspect ratio is less than k;
[0052] S2.4: Calculate the areas of the candidate regions and the areas of the corresponding bounding boxes, and remove candidate regions where the ratio of the candidate region area to the corresponding bounding box area is less than h;
[0053] S2.5: If the number of candidate regions remaining after removal is 1, the candidate region is a weld region. If the number of candidate regions remaining after removal is greater than 1, calculate the average distance from all pixels in the candidate regions to the center point of the original image. The candidate region with the smallest average value is the weld region.
[0054] The range of k is 3-4, and the range of h is 0.9-0.95. Preferably, k is 3 and h is 0.9, that is, the candidate areas completely inside the original image are removed, and the bounding boxes of each remaining candidate area are obtained. The areas with an aspect ratio of less than 3 of the bounding box are removed, and the candidate areas with an area ratio of less than 0.9 of the corresponding bounding box area are removed. Since the weld is usually a long strip structure and extends along the edge of the captured image, the candidate areas completely inside the original image (i.e., not touching the image boundary) are removed to narrow the selection range. Subsequently, due to the long strip structure of the weld, the areas with a small aspect ratio are removed to remove impurities or background areas. Furthermore, the areas with an area ratio of less than 0.9 are removed to remove scattered fragment areas.
[0055] S3: generating a defect image on the background image according to a parameterized defect generation model, comparing the weld area, wherein the defect image includes an incomplete penetration defect image, a tunnel defect image, a porosity defect image, an inclusion defect image, and a crack defect image, wherein the parameterized defect generation model includes at least the following four parameters: a distance d between the weld area on the background image and the corresponding original image and the weld centerline, generating a rectangular area (l, w) along the weld direction based on the distance d between the weld area on the background image and the corresponding original image and the weld centerline, and assigning a random brightness value b to the brightness within the rectangular area;
[0056] Specifically:
[0057] The parameterized defect generation model includes an incomplete penetration defect generation model corresponding to the incomplete penetration defect image, a tunnel defect generation model corresponding to the tunnel defect image, a loose defect generation model corresponding to the loose defect image, an inclusion defect generation model corresponding to the inclusion defect image, and a crack defect generation model corresponding to the crack defect image;
[0058] The incomplete penetration defect generation model modeling process includes: generating a rectangular area (l, w) along the weld direction at a position corresponding to the distance d from the weld area on the background image and the weld center axis on the original image, assigning a random brightness value b to the brightness within the rectangular area, specifically, the distance d from the weld center axis is close to 0;
[0059] The tunnel defect generation model modeling process includes: generating a rectangular area (l, w) along the weld direction at a position on the background image corresponding to the weld area on the original image at a distance d from the weld center axis, assigning a random brightness value b to the brightness within the rectangular area, specifically, the distance d from the weld center axis is related to the selected friction stir welding stirring head diameter, preferably, the distance d from the weld center axis is half the diameter of the corresponding friction stir welding stirring head;
[0060] The modeling process of the porosity defect generation model includes: generating a rectangular area (l, w) along the weld direction at a distance d from the weld area on the background image and the corresponding original image to the weld center axis, wherein l=3w-10w randomly generates n seed points within the rectangular area, and randomly generates m points within a radius r as vertices of a polygonal area with each seed point as the center of a circle, connecting the m vertices in a clockwise direction to form a closed polygonal area, and assigning the brightness within the polygonal area to a random brightness value b;
[0061] The inclusion defect generation modeling process includes: randomly generating n seed points in the pixel area corresponding to the weld area on the background image, randomly generating m points as polygonal area vertices within a radius r with each seed point as the center of a circle, connecting the m vertices in a clockwise direction to form a closed polygonal area, and assigning the brightness within the polygonal area to a random brightness value b;
[0062] Preferably, the number of vertices of the polygonal region of the loose defect image is smaller than the number of vertices of the polygonal region of the mixed defect image;
[0063] The crack defect generation modeling process includes: randomly generating starting point coordinates (x0, y0) on the background image and the weld area on the corresponding original image, and randomly generating crack propagation directions within the range of 0°-360° with the starting point coordinates (x0, y0) as the center of the circle. Extend the distance d1 along the crack propagation direction to the coordinate point (x1, y1), construct a rectangular crack segment with width w1 and random brightness value b1, and then take the coordinate point (x1, y1) as the center and rotate the crack propagation direction after the random rotation of θ degrees. Extend d2 to the next coordinate point (x2, y2), construct a new rectangular crack segment with width w2 and random brightness value b2, and repeat the construction of the rectangular crack segment g times to generate a crack path with multiple rectangular crack segments;
[0064] S4: Gaussian blurring the background image for generating the defect image, so as to make the boundary of the defect image smoothly transition. Preferably, the Gaussian blurring parameters are: Gaussian kernel 5*5, σ is set to 0;
[0065] S5: performing feature fusion on the Gaussian blurred background image and the original image to generate a corresponding defect image, wherein the feature fusion method is performed by subtracting or adding the pixel brightness value of the corresponding defect image from the pixel brightness in the original image. To further expand the data set, for the defect images generated from the same original image, 2 to 3 defect images of different defects can be randomly selected and superimposed and fused to generate a defect image containing multiple different defect types;
[0066] For incomplete penetration defect images, tunnel defect images, porosity defect images, and crack defect images, the pixel brightness in the original image is subtracted from the pixel brightness in the corresponding defect image. For inclusion defect images, the pixel brightness in the original image is subtracted from the pixel brightness in the corresponding defect image to generate a low-density inclusion defect image. The pixel brightness in the original image plus the pixel brightness in the corresponding defect image is used to generate a high-density inclusion defect image.
[0067] S6: Setting corresponding labels for the defect images and saving them. Specifically, the label setting method is to classify and label each defect image according to the generated defect type (for example, lack of penetration, tunnel, looseness, inclusion, crack). The labeled defect images can be saved in a standard format (such as JPEG, PNG, etc.) according to the category, and the corresponding parameter settings and feature information are recorded for subsequent use;
[0068] S7: Repeat S2-S6 until a predetermined number of defect images corresponding to one type of defect are generated;
[0069] S8: Repeat S2-S7 until the number of defect images corresponding to the five types of defects reaches a predetermined number.
[0070] Combined with attachment Figure 1-3 As shown, the original image resolution is selected, the original image resolution is 1279×1542, one corner of the original image is used as the pixel origin (0,0), preferably, one corner is the upper left corner, the starting pixel coordinates of the weld centerline are (80,1017), the ending pixel coordinates are (1279,1017), and the weld area width is 280 pixels;
[0071] In the process of modeling the incomplete penetration defect generation model, the distance d from the center axis of the weld is in the range of 0-5 pixels, the width w of the rectangular area is in the range of 3-6 pixels, the length l of the rectangular area is in the range of 100-1200 pixels, and the random brightness value b of the rectangular area is in the range of 25-50 grayscale values;
[0072] Specifically, a completely black background image with a pixel size of 1279×1542 is generated, and a rectangular area (l, w) along the weld direction is generated at a distance d from the center axis of the weld. The distance d ranges from 0 to 5 pixels, the width w of the rectangular area ranges from 3 to 6 pixels, and the length l ranges from 100 to 1200 pixels. The brightness within the square area is assigned a random brightness value b, and the brightness value b ranges from 25 to 50 grayscale values. Gaussian blur is applied to the above-obtained image to make the boundary of the defect image transition smoothly. The pixel brightness value in the original image is subtracted from the pixel brightness value of the corresponding defect image to obtain the incomplete weld defect image, as shown in FIG. Figure 3 (b)
[0073] During the modeling process of the tunnel defect generation model, the distance d from the central axis of the weld is in the range of 80-100 pixels, the width w of the rectangular area is in the range of 3-6 pixels, the length l of the rectangular area is in the range of 100-1200 pixels, and the random brightness value b of the rectangular area is in the range of 25-50 grayscale values;
[0074] Specifically, a completely black background image with a pixel size of 1279×1542 is generated, and a rectangular area (l, w) along the weld direction is generated at a distance d from the center axis of the weld. The distance d ranges from 80 to 100 pixels, the width w of the rectangular area ranges from 3 to 6 pixels, and the length l ranges from 100 to 1200 pixels. The brightness within the square area is assigned a random brightness value b, and the brightness value b ranges from 25 to 50 grayscale values. Gaussian blur is applied to the image obtained above to make the boundary of the defect image transition smoothly. The pixel brightness value in the original image is subtracted from the pixel brightness value of the corresponding defect image to obtain a tunnel defect image, as shown in FIG. Figure 3 (c)
[0075] In the modeling process of the porosity defect generation model, the distance d from the central axis of the weld is in the range of 20-100 pixels, the width w of the rectangular area is in the range of 10-50 pixels, the length l of the rectangular area is in the range of 3w-10w pixels, the number of seed points n is in the range of l×w÷100-l×w÷50, the radius r is in the range of 5-20 pixels, the number of vertices m is in the range of 3-5, and the brightness value b of the polygonal area is in the range of 25-50 grayscale values;
[0076] Specifically, a completely black background image with a pixel size of 1279×1542 is generated, and a rectangular area (l, w) along the weld direction is generated at a distance d from the weld centerline. The distance d ranges from 20 to 100 pixels, the width w of the rectangular area ranges from 10 to 50 pixels, and the length l ranges from 3w to 10w pixels. N seed points are randomly generated within the rectangular area, and the number of seed points n ranges from l×w÷100 to l×w÷50. At each seed point, within the range of radius r, Generate m points as polygonal area vertices, the radius r varies in the range of 5-20 pixels, the number of polygonal vertices m varies in the range of 3-5, and m vertices are connected in a clockwise direction to form a closed polygonal area. The brightness within the polygonal area is assigned a random brightness value b, and the brightness value varies in the range of 25-50 grayscale values. Gaussian blur is applied to the above-obtained image to make the boundary of the defect image transition smoothly. The pixel brightness value of the original image minus the pixel brightness value of the corresponding defect image can be used to obtain a loose defect image, as shown in the following example. Figure 3 (d)
[0077] In the process of modeling the inclusion defect generation model, the number of seed points n ranges from 1 to 20, the radius r ranges from 5 to 20 pixels, the number of vertices m ranges from 3 to 6, and the brightness value b of the polygonal area ranges from 25 to 50 grayscale values;
[0078] Specifically, a completely black background image with a pixel size of 1279×1542 is generated, and n seed point coordinates are randomly generated in the pixel area corresponding to the weld of the original image on the background image. The range of the number of seed points n is 1-20. M points are randomly generated as polygonal area vertices within the range of radius r with each seed point as the center of the circle. The range of the radius r is 5-20 pixels, and the range of the number of vertices m in the polygonal area is 3-6. The m vertices are connected clockwise to form a closed polygonal area. The brightness in the polygonal area is assigned to a random brightness value b, and the range of the brightness value is 25-50 grayscale values. Gaussian blur is applied to the above-obtained image to make the boundary of the defect image transition smoothly. The low-density inclusion defect image can be obtained by subtracting the pixel brightness value of the original image from the pixel brightness value of the corresponding defect image, and the high-density inclusion defect image can be obtained by adding them together, as shown in FIG. Figure 3 (e)
[0079] During the modeling process of the crack defect generation model, the width w g The range of is 1-5 pixels, the range of θ is θ∈[-15°, 15°], the number of g ranges from 5-50, the brightness value b g The range is 10-35 grayscale values;
[0080] Specifically, a black background image with a pixel size of 1279×1542 is generated, the defect starting point coordinates (x0, y0) are randomly generated in the weld area, and the crack propagation direction is randomly generated within the range of 0°-360° with the defect starting point coordinates (x0, y0) as the center. Along the crack propagation direction Generate the next coordinate point (x1, y1) at a distance of d1, and generate a rectangular crack segment with a random width w1 between the coordinate point (x1, y1) and the starting point coordinate (x0, y0). The range of the width w1 is 1-5 pixels. The brightness in the rectangular crack segment is assigned to a random brightness value b1. The range of the brightness value b1 is 10-35 grayscale values. The crack expansion direction is Randomly rotate θ degrees, the range of the rotation angle is θ∈[-15°, 15°], and take the coordinate point (x1, y1) as the starting point along the direction of the crack propagation after rotation Generate the next coordinate point (x2, y2) at a distance of d2, and generate a rectangular crack segment with a random width w2 between the coordinate point (x2, y2) and the coordinate point (x1, y1). The width w2 varies in the range of 1-5 pixels. Assign the brightness within the rectangular crack segment to a random brightness value b2. The brightness value b2 varies in the range of 10-35 grayscale values. Repeat the above steps g times to complete the drawing of the crack defect image. The range of g varies in the range of 5-50. Apply Gaussian blur to the above-obtained image to make the boundary of the defect image transition smoothly. Subtract the pixel brightness value of the corresponding defect image from the pixel brightness value in the original image to obtain the crack defect image, as shown in Figure 3 (f) shown.
[0081] To further expand the data set, we can arbitrarily select 2 to 3 defect images with different defects from the defect images generated by the same original image, and perform superposition and fusion to generate defect images containing multiple different defect types.
[0082] Each defect image is classified and labeled according to the generated defect type (for example: incomplete penetration, tunnel, looseness, inclusion, crack), and then the labeled defect images are saved in a standard format (such as JPEG, PNG, etc.) according to the category, and the corresponding parameter settings and feature information are recorded for subsequent use.
[0083] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions in the specification are only preferred examples of the present invention and are not intended to limit the present invention. Various changes and improvements may be made to the present invention without departing from the spirit and scope of the present invention. Such changes and improvements fall within the scope of the present invention as claimed. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for self-generating a friction stir welding weld defect image dataset based on parametric modeling, characterized by: The steps include: S1: Acquire a defect-free friction stir welding image with the weld in the middle as an original image, copy a number of the original images to form an original image set, and prepare a number of completely black background images with the same size as the original image; S2: Using the SAM model to divide the original image into regions, generating a plurality of candidate regions, traversing the plurality of candidate regions in turn, and determining the weld region in the plurality of candidate regions based on weld image features; S3: generating a defect image on the background image according to a parameterized defect generation model, comparing the weld area, wherein the defect image includes an incomplete penetration defect image, a tunnel defect image, a porosity defect image, an inclusion defect image, and a crack defect image, wherein the parameterized defect generation model includes at least the following four parameters: a distance d between the weld area on the background image and the corresponding original image and the weld centerline, generating a rectangular area (l, w) along the weld direction based on the distance d between the weld area on the background image and the corresponding original image and the weld centerline, and assigning a random brightness value b to the brightness within the rectangular area; S4: Gaussian blurring the background image used to generate the defect image; S5: performing feature fusion on the Gaussian blurred background image and the original image to generate a corresponding defect image; S6: Setting corresponding labels for the defect images and saving them; S7: Repeat S2-S6 until a predetermined number of defect images corresponding to one type of defect are generated; S8: Repeat S2-S7 until the number of defect images corresponding to the five types of defects reaches a predetermined number.
2. The method for self-generating a friction stir welding weld defect image dataset based on parametric modeling according to claim 1, characterized in that: The S2 specifically includes the following steps: S2.1: Using the SAM model to divide the original image into regions, generate a number of candidate regions, and traverse the candidate regions in sequence; S2.2: Remove the candidate regions that are completely inside the original image, and obtain the bounding box of each remaining candidate region; S2.3: Calculate the aspect ratio of the bounding box, and remove areas of the bounding box where the aspect ratio is less than k; S2.4: Calculate the areas of the candidate regions and the areas of the corresponding bounding boxes, and remove candidate regions where the ratio of the candidate region area to the corresponding bounding box area is less than h; S2.5: When the number of candidate areas remaining after removal is 1, the candidate area is the weld area. When the number of candidate areas remaining after removal is greater than 1, calculate the average value of the distances from all pixels in several candidate areas to the center point of the original image. The candidate area corresponding to the smallest average value is the weld area.
3. The method for self-generating a friction stir welding weld defect image dataset based on parametric modeling according to claim 2, characterized in that: The range of k is 3-4, and the range of h is 0.9-0.
95.
4. The method for self-generating a friction stir welding weld defect image dataset based on parametric modeling according to claim 1, characterized in that: The parameterized defect generation model includes an incomplete penetration defect generation model corresponding to the incomplete penetration defect image, a tunnel defect generation model corresponding to the tunnel defect image, a loose defect generation model corresponding to the loose defect image, an inclusion defect generation model corresponding to the inclusion defect image, and a crack defect generation model corresponding to the crack defect image; The process of modeling the incomplete penetration defect generation model includes: generating a rectangular area (l, w) along the weld direction at a position on the background image corresponding to the weld area on the original image at a distance d from the weld center axis, and assigning a random brightness value b to the brightness within the rectangular area; The tunnel defect generation modeling process includes: generating a rectangular area (l, w) along the weld direction at a position on the background image corresponding to the weld area on the original image at a distance d from the weld center axis, and assigning a random brightness value b to the brightness within the rectangular area; The modeling process of the porosity defect generation model includes: generating a rectangular area (l, w) along the weld direction at a position on the background image corresponding to the weld area on the original image at a distance d from the weld center axis, randomly generating n seed points within the rectangular area, taking each seed point as the center of a circle, randomly generating m points within a radius r as vertices of a polygonal area, connecting the m vertices in a clockwise direction to form a closed polygonal area, and assigning a random brightness value b to the brightness within the polygonal area; The inclusion defect generation modeling process includes: randomly generating n seed points in the pixel area corresponding to the weld area on the background image, randomly generating m points as polygonal area vertices within a radius r with each seed point as the center of a circle, connecting the m vertices in a clockwise direction to form a closed polygonal area, and assigning the brightness within the polygonal area to a random brightness value b; The crack defect generation modeling process includes: randomly generating starting point coordinates (x0, y0) on the background image and the weld area on the corresponding original image, and randomly generating crack propagation directions within the range of 0°-360° with the starting point coordinates (x0, y0) as the center of the circle. Extend the distance d1 along the crack propagation direction to the coordinate point (x1, y1), construct a rectangular crack segment with width w1 and random brightness value b1, and then take the coordinate point (x1, y1) as the center and rotate the crack propagation direction after the random rotation of θ degrees. Extend d2 to the next coordinate point (x2, y2), construct a new rectangular crack segment with width w2 and random brightness value b2, and repeat the construction of the rectangular crack segment g times to generate a crack path with multiple rectangular crack segments.
5. The method for self-generating a friction stir welding weld defect image dataset based on parametric modeling according to claim 4, characterized in that: The original image resolution is 1279×1542, with one corner of the original image as the pixel origin (0,0), the starting pixel coordinates of the weld centerline are (80,1017), the ending pixel coordinates are (1279,1017), and the weld area width is 280 pixels.
6. The method for self-generating a friction stir welding weld defect image dataset based on parametric modeling according to claim 5, characterized in that: During the modeling process of the incomplete penetration defect generation model, the distance d from the center axis of the weld is in the range of 0-5 pixels, the width w of the rectangular area is in the range of 3-6 pixels, the length l of the rectangular area is in the range of 100-1200 pixels, and the random brightness value b of the rectangular area is in the range of 25-50 grayscale values.
7. The method for self-generating a friction stir welding weld defect image dataset based on parametric modeling according to claim 5, characterized in that: During the modeling process of the tunnel defect generation model, the distance d from the center axis of the weld is in the range of 80-100 pixels, the width w of the rectangular area is in the range of 3-6 pixels, the length l of the rectangular area is in the range of 100-1200 pixels, and the random brightness value b of the rectangular area is in the range of 25-50 grayscale values.
8. The method for self-generating a friction stir welding weld defect image dataset based on parametric modeling according to claim 5, characterized in that: During the modeling process of the porosity defect generation model, the distance d from the center axis of the weld is in the range of 20-100 pixels, the width w of the rectangular area is in the range of 10-50 pixels, the length l of the rectangular area is in the range of 3w-10w pixels, the number of seed points n is in the range of l×w÷100-l×w÷50, the radius r is in the range of 5-20 pixels, the number of vertices m is in the range of 3-5, and the brightness value b of the polygonal area is in the range of 25-50 grayscale values.
9. The method for self-generating a friction stir welding weld defect image dataset based on parametric modeling according to claim 5, characterized in that: During the modeling process of the inclusion defect generation model, the number of seed points n ranges from 1 to 20, the radius r ranges from 5 to 20 pixels, the number of vertices m ranges from 3 to 6, and the polygonal area brightness value b ranges from 25 to 50 grayscale values.
10. The method for self-generating a friction stir welding weld defect image dataset based on parametric modeling according to claim 5, characterized in that: During the modeling process of the crack defect generation model, the width w g The range of is 1-5 pixels, the range of θ is θ∈[-15°, 15°], the number of g ranges from 5-50, the brightness value b g The range is 10-35 grayscale values.