Image fusion method, system and device for product defect sample and storage medium

By generating high-quality and diverse product defect samples through image fusion technology, the problem of scarce defect samples in existing technologies is solved, and the generalization ability and robustness of deep learning models are improved, making them suitable for automatic detection of various industrial products.

CN122243772APending Publication Date: 2026-06-19SHANGHAI WESTWELL INFORMATION & TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI WESTWELL INFORMATION & TECH CO LTD
Filing Date
2026-03-05
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing technologies struggle to generate high-quality, diverse product defect samples, resulting in insufficient generalization ability of deep learning models in industrial defect detection. This is especially true under conditions of scarce and unbalanced real data, making it difficult to meet the demands for high-precision detection.

Method used

By acquiring a first product image containing defects and a second product image without defects, image recognition and segmentation are performed. After randomly selecting local images and performing color and texture correction, a gradient domain fusion algorithm is used to integrate the local images into the effective region of the second product image, generating a large number of high-quality defect samples.

🎯Benefits of technology

The generated defect samples are realistic and diverse, significantly improving the model's generalization ability and robustness. The entire process is automated and requires no manual annotation, making it suitable for surface defect detection of various industrial products.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122243772A_ABST
    Figure CN122243772A_ABST
Patent Text Reader

Abstract

This invention provides an image fusion method, system, device, and storage medium for product defect samples. The method includes: acquiring a first product image containing defects as a first image set; segmenting and identifying various local regions of the defective product and locating the local region where the product defect is located; acquiring a second product image as a fusion background as a second image set; segmenting and identifying various local regions of the target product and an effective region for defining the allowed location of defects; randomly selecting a first product image and a second product image; extracting a local image of the product defect from the first product image; and performing color and texture correction on the local image based on the second product image; and performing image fusion to generate product defect samples. This invention can automatically generate a large number of high-quality, scene-adapted, and physically plausible damaged images, while achieving zero manual annotation costs, greatly improving data preparation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of model training, and more specifically, to an image fusion method, system, device, and storage medium for product defect samples. Background Technology

[0002] In modern industrial manufacturing systems, product quality is the lifeline for maintaining a company's core competitiveness and market reputation. Surface defects, such as scratches, dents, stains, holes, and cracks, are common quality problems affecting product appearance, function, and even safety. Traditional manual visual inspection methods are not only inefficient and costly, but also prone to missed detections or misjudgments due to human factors such as fatigue and distraction, making them unsuitable for the demands of large-scale, high-paced production lines. With breakthroughs in artificial intelligence technology, deep learning-based automatic surface defect detection technology has emerged and has been rapidly adopted in various industries, including semiconductors, precision electronics, automotive manufacturing, metal processing, textiles, and photovoltaics. This technology automatically learns the visual features of defects through models such as convolutional neural networks, enabling rapid, accurate, and consistent online detection, significantly improving the automation and intelligence of quality control.

[0003] However, deep learning models are inherently a data-driven approach, and their superior performance heavily depends on the scale, quality, and diversity of the data used during the training phase. Specifically, a robust defect detection model needs to access a massive amount of precisely labeled defect samples to fully learn the complex representations of defects under various shapes, sizes, textures, lighting, backgrounds, and locations, and to establish a reliable mapping from high-dimensional image space to defect categories and locations. The richness of the training data directly determines the model's recognition accuracy, its diversity relates to the model's generalization ability to new, unseen samples and scenarios, and its realism is crucial for the effective transfer of learned features to real industrial environments. In short, the completeness of the training data is the cornerstone limiting the in-depth application and performance limits of deep learning in industrial defect detection.

[0004] In stark contrast to the data-driven nature of deep learning models, obtaining sufficient and high-quality defect sample datasets in actual industrial production environments faces insurmountable objective bottlenecks. First, driven by economic efficiency and brand reputation considerations, modern manufacturing enterprises generally establish rigorous end-to-end quality control systems, resulting in extremely high product qualification rates (e.g., above 99%). Therefore, samples with surface defects are themselves low-probability anomalies in the production process, with an extremely low natural occurrence rate, leading to an inherently scarce number of real defect samples available for collection. This absolute scarcity of defect samples constitutes the primary data bottleneck for model training. Second, even if some defect samples can be collected through long-term accumulation or specific channels, their category distribution often exhibits severe imbalance, the so-called long-tail distribution. Common and easily detectable defect types (such as obvious scratches) may be relatively numerous, while some specific and rare defect morphologies (such as micropores of special shapes, hidden cracks in specific materials, and composite defects) have extremely few samples, or are even absent. This uneven distribution makes trained models prone to overfitting to common defect categories at the head of the machine, while exhibiting weak recognition capabilities for rare defect categories at the tail, resulting in a high false negative rate and failing to meet the requirements of comprehensive and thorough quality inspection. The core challenge of data scarcity and uneven distribution is collectively defined in academia and industry as the "small sample size problem." This problem has become a major obstacle hindering the large-scale deployment and further performance improvement of deep learning technology in industrial vision inspection scenarios with high precision and reliability requirements (such as aerospace component inspection and precision medical device surface inspection).

[0005] To alleviate the model training difficulties caused by small sample sizes, traditional technical solutions mainly rely on data augmentation methods. These methods aim to artificially expand the size of the dataset by applying a series of predefined image transformations to a limited number of original training images. Common transformations include geometric transformations (such as random rotation, translation, scaling, cropping, and mirroring) and photometric transformations (such as randomly adjusting brightness, contrast, saturation, and hue, adding noise, and color jittering). Although these traditional data augmentation methods are easy to implement and can improve the robustness of the model to certain geometric deformations or lighting changes to some extent, their inherent limitations are quite obvious: these methods can only perturb the overall appearance of the image, essentially rearranging or numerically adjusting existing sample pixels, and cannot create truly novel and diverse defect instances at a deeper, more semantically informative level, such as the morphological structure, internal fine texture, semantic category, and location on the product surface. For example, traditional augmentation cannot "turn" a scratch into a dent, nor can it "place" a defect in a reasonable new location where it has never appeared before. Therefore, traditional data augmentation is difficult to simulate the infinite possible variations of defects in real industrial production. Its contribution to improving the model's ability to generalize to unprecedented new defect forms, complex background interference, or extreme imaging conditions has a clear ceiling, and it cannot fundamentally solve the problem of small sample learning.

[0006] In view of this, the purpose of the present invention is to provide an image fusion method, system, device and storage medium for product defect samples to solve the above problems. Summary of the Invention

[0007] To address the problems in the prior art, the present invention aims to provide an image fusion method, system, device, and storage medium for product defect samples, which overcomes the difficulties of the prior art and can automatically generate a large number of high-quality, scene-adapted, and physically reasonable damaged images, providing an efficient and low-cost data solution for training robust automatic defect detection models.

[0008] An embodiment of the present invention provides an image fusion method for product defect samples, comprising the following steps: S110. Obtain a first product image containing defects as a first image set, perform image recognition on the first product image to segment and identify each local area of ​​the defective product and locate the local area where the product defect is located. S120. Obtain a second product image that does not contain defects as a fusion background as a second image set, and perform image recognition on the second product image to segment and identify various local regions of the target product and the effective region for defining the location where defects are allowed to occur. S130. Randomly select a first product image and a second product image, extract a local image of the product defect from the first product image, and perform color and texture correction on the local image based on the second product image. S140. Perform image fusion, and integrate the corrected local image into the effective area of ​​the selected second product image; S150, Repeat steps S130 to S140 to generate product defect samples in batches.

[0009] Preferably, in step S130, the color and texture correction of the local image based on the second product image includes: Statistically based color migration and / or histogram matching; The statistically based color transfer calculates the mean and standard deviation of pixel values ​​in the target background region of the local image and the second product image respectively, and performs a linear transformation on the local image based on this to match its color and illumination distribution with the target background region of the second product image. The histogram matching achieves the same contrast and brightness distribution by matching the grayscale or color histogram of the local image to the second product image.

[0010] Preferably, step S140 includes: determining a random position within the effective area of ​​the second product image, and integrating the corrected local image into that position using a gradient domain fusion algorithm.

[0011] Preferably, step S130 further includes: obtaining the image center point of the local image; Step S140 includes: S141. Statistically analyze the various defect categories of the first product image in the first image set and the distribution probability Pi of various defect categories on different local areas of the surface of the defective product to establish a hotspot probability mapping table, where i represents the type of various local areas. S142. Based on the total number of pixels Sn contained in each local region that is an effective region in the second product image, and the distribution probability Pi, calculate the initial weight Win of each local region as the target fusion region, Win = Sn × Pi; normalize all the initial weights Win to obtain the probability Wn of the candidate image center point coordinates falling in each local region. S143. Based on the occurrence probability Wn, randomly select a local region in the effective region as the target fusion region, and randomly select a point among the pixels in the target fusion region as the coordinates of the candidate image center point. S144. After aligning the center of the local image with the center point coordinates of the candidate image, determine whether the overall pixel range of the local image is completely within the target fusion region; if yes, proceed to step S145; if no, abandon this fusion and return to step S130 to reselect an image or center point. S145. The corrected local image is aligned with the coordinates of the center point of the candidate image, and then integrated into the selected second product image using a gradient domain fusion algorithm.

[0012] Preferably, in step S145, the gradient domain fusion algorithm is a Poisson fusion algorithm.

[0013] Preferably, in step S145, the gradient domain fusion algorithm is the Laplace pyramid fusion algorithm.

[0014] Preferably, step S150 includes: Steps S130 to S140 are executed repeatedly to collect a second product image that has been fused with local images as a product defect sample set until the number of product defect samples in the product defect sample set meets a preset threshold.

[0015] Embodiments of the present invention also provide an image fusion system for product defect samples, used to implement the above-described image fusion method for product defect samples, wherein the image fusion system for product defect samples includes: The first identification module acquires a first product image containing defects as a first image set, performs image recognition on the first product image to segment and identify each local area of ​​the defective product and locate the local area where the product defect is located. The second recognition module acquires a second product image that does not contain defects as a fusion background as a second image set, and performs image recognition on the second product image to segment and identify various local regions of the target product and the effective region for defining the location where defects are allowed to occur. The image correction module randomly selects a first product image and a second product image, extracts a local image of the product defect from the first product image, and performs color and texture correction on the local image based on the second product image. The image fusion module performs image fusion, integrating the corrected local image into the effective area of ​​the selected second product image; The loop control module is used to control the image correction module and the image fusion module to run in a loop to generate product defect samples in batches.

[0016] Embodiments of the present invention also provide an image fusion device for product defect samples, comprising: processor; A memory in which executable instructions of the processor are stored; The processor is configured to perform the steps of the image fusion method for the product defect samples described above by executing the executable instructions.

[0017] Embodiments of the present invention also provide a computer-readable storage medium for storing a program, which, when executed, implements the steps of the image fusion method for product defect samples described above.

[0018] Compared with the prior art, the beneficial effects of the present invention are as follows: Precise and efficient solution to the small sample problem: This invention intelligently fuses a small number of real defects as "foreground material" with a large number of normal product images as "background canvas". It can generate a nearly infinite and highly diverse synthetic training dataset from a limited number of real samples, fundamentally alleviating the extreme dependence of model training on scarce and expensive real defect data.

[0019] The generated samples are highly realistic and fully controllable: Color transfer / histogram matching ensures consistent appearance, and gradient domain fusion achieves seamless visual integration. The generated defect samples are visually highly similar to real-life defect images. Furthermore, the type and shape of the defect are determined by the source image, while its location is randomly generated by an intelligent algorithm under technological constraints. The entire process is fully controllable, avoiding the randomness and uncertainty of methods like GANs, and eliminating the generation of low-quality images such as artifacts and distortions.

[0020] Significantly improves model generalization and robustness: By generating the same defect in a large number of different normal product backgrounds and in different locations that conform to process rules, the spatial and background diversity of the training data is greatly increased. This forces the subsequently trained defect detection model to learn the essential features of the defect, rather than memorizing specific backgrounds or location patterns, thereby significantly improving the model's generalization ability and robustness to defects appearing in different environments and locations.

[0021] Achieving full automation and zero annotation cost: The entire generation process, from image matching, appearance correction, location generation, seamless fusion to annotation calculation, is completed automatically by the algorithm without any manual intervention, resulting in extremely high generation efficiency. More importantly, accurate annotations (boundary boxes or masks) of defects in the synthesized image can be automatically exported based on the original mask and fusion location, achieving "zero cost" annotation and saving the time-consuming, labor-intensive, and expensive manual annotation process in traditional methods.

[0022] It has good scalability and applicability: This method does not depend on specific product types or defect morphologies. As long as the defect source image, corresponding mask, and normal background image can be provided, it can be applied to the generation of surface defect samples for various industrial products, such as metal parts, plastic parts, glass, textiles, semiconductors, etc., and has broad industry application prospects.

[0023] The purpose of this invention is to provide an image fusion method, system, device, and storage medium for product defect samples, which can automatically generate a large number of high-quality, scene-adapted, and physically reasonable damaged images. It solves the problems of scarce real data, boundary artifacts in traditional synthesis, poor scene generalization, and unreasonable location, and provides an efficient and low-cost data solution for training robust automatic defect detection models. Attached Figure Description

[0024] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings.

[0025] Figure 1 This is a flowchart of the image fusion method for product defect samples according to the present invention.

[0026] Figure 2 This is a schematic diagram of the overall process of implementing the image fusion method for product defect samples of the present invention.

[0027] Figure 3 This is an overall architecture diagram of the image fusion system for product defect samples of the present invention.

[0028] Figure 4 This is a schematic diagram of the structure of the image fusion device for product defect samples of the present invention.

[0029] Figure 5 This is a schematic diagram of the structure of a computer-readable storage medium according to an embodiment of the present invention. Detailed Implementation

[0030] The following specific examples illustrate the implementation methods of this application. Those skilled in the art can easily understand the other advantages and effects of this application from the content disclosed herein. This application can also be implemented or applied through other different specific embodiments, and various details in this application can be modified or changed according to different viewpoints and application systems without departing from the spirit of this application. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be combined with each other.

[0031] The embodiments of this application will now be described in detail with reference to the accompanying drawings, so that those skilled in the art can easily implement the application. This application may be embodied in many different forms and is not limited to the embodiments described herein.

[0032] In this application, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics represented in connection with that embodiment or example, which are included in at least one embodiment or example of this application. Furthermore, the specific features, structures, materials, or characteristics represented may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate different embodiments or examples represented in this application, as well as features of different embodiments or examples.

[0033] Furthermore, the terms "first" and "second" are used for illustrative purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the representation of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0034] For the purpose of clearly describing this application, devices that are not relevant to the description are omitted, and the same or similar components throughout the specification are given the same reference numerals.

[0035] Throughout this specification, when it is said that a device is "connected" to another device, this includes not only "direct connection" but also "indirect connection" by placing other components in between. Furthermore, when it is said that a device "comprises" a certain constituent element, unless otherwise stated otherwise, this does not exclude other constituent elements, but rather implies that other constituent elements may be included.

[0036] When we say that a device is "above" another device, this can mean that it is directly above the other device, or it can mean that other devices are present in between. Conversely, when we say that a device is "directly" "above" another device, there are no other devices present in between.

[0037] Although the terms first, second, etc., are used in some instances herein to refer to various elements, these elements should not be limited by these terms. These terms are used only to distinguish one element from another. For example, first interface and second interface, etc., are used. Furthermore, as used herein, the singular forms “a,” “an,” and “the” are intended to also include the plural forms unless the context indicates otherwise. It should be further understood that the terms “comprising,” “including,” indicate the presence of features, steps, operations, elements, components, items, kinds, and / or groups, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, items, kinds, and / or groups. The terms “or” and “and / or” as used herein are interpreted as inclusive, or mean any one or any combination thereof. Thus, “A, B, or C” or “A, B, and / or C” means “any one of: A; B; C; A and B; A and C; B and C; A, B, and C.” Exceptions to this definition will only occur if the combination of elements, functions, steps, or operations is inherently mutually exclusive in some way.

[0038] The technical terms used herein are for reference only to specific embodiments and are not intended to limit the scope of this application. The singular form used herein includes the plural form unless the statement explicitly indicates otherwise. The word "comprising" as used in the specification means to specify a particular characteristic, region, integer, step, operation, element, and / or component, and does not exclude the presence or addition of other characteristics, regions, integers, steps, operations, elements, and / or components.

[0039] Although not explicitly defined, all terms, including technical and scientific terms used herein, shall have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. Terms defined in commonly used dictionaries shall be further interpreted as having a meaning consistent with the relevant technical literature and the content of this present application, and shall not be over-interpreted as having an ideal or overly formulaic meaning unless otherwise defined.

[0040] In recent years, with the rapid development of generative artificial intelligence, especially the maturity of generative adversarial networks (GANs), a new paradigm for data generation has emerged. GANs can learn the distribution of real training data through adversarial training and generate new images that are visually similar to it. Theoretically, this makes it possible to create new defect samples from scratch. However, directly applying GANs to industrial defect sample generation scenarios, where the requirements for realism, controllability, and reliability are extremely stringent, still faces a series of severe technical challenges. First, the generation process of standard GANs has inherent randomness and uncontrollability. Users find it difficult to accurately specify the specific category, precise geometry, absolute size, and exact coordinates of the generated defect in the background image, which are precisely the rigid requirements for defect localization, quantitative analysis, and classification statistics in industrial inspection. Second, the training process of GANs is unstable. When the training data itself is scarce (i.e., small sample size), pattern collapse is prone to occur, resulting in poor diversity of generated images or images containing unreasonable visual flaws such as obvious artifacts, texture distortion, and structural distortion. These synthetic defects may be discernible to the human eye, but once input into a model as training data, they can severely mislead the model into learning unrealistic and pseudo-correlated feature patterns, thereby impairing the model's discriminative performance and reliability in real-world scenarios. Finally, ensuring that the generated product defects can be physically believably and visually seamlessly integrated with complex and varied industrial backgrounds (such as diverse material reflections, non-uniform lighting, structural component occlusion, and environmental noise) remains a challenge that GAN-based methods have not yet adequately addressed. Simple pasting and overlaying produces obvious boundary artifacts and lighting inconsistencies, while existing GAN-based image translation methods still fall short in terms of detail preservation and local fusion quality. Therefore, existing GAN-based defect generation methods are still insufficient to meet the stringent data requirements of high-precision, high-reliability industrial vision inspection systems in terms of the realism of generated samples, the control precision of the generation process, and the reliability of the synthesized results.

[0041] In summary, the field of intelligent industrial defect detection is currently mired in a sharp contradiction: on the one hand, powerful deep learning models urgently require massive amounts of high-quality, diverse labeled data to fully unleash their potential; on the other hand, the collection of real defect data is extremely costly and time-consuming, and existing data augmentation and generation technologies cannot provide satisfactory solutions. This contradiction is particularly prominent in strategic industries with extremely high detection accuracy requirements and extremely low defect tolerance (such as semiconductor manufacturing and aero-engine blade inspection). Therefore, this field urgently needs a breakthrough technological solution that can simultaneously achieve the following key objectives: first, "controllability," meaning the ability to precisely control the type, shape, size, and position of generated defects in the background based on prior knowledge or user needs; second, "realism," meaning the generated defect samples are visually indistinguishable from real defects, naturally blending with complex industrial backgrounds in terms of color, lighting, and texture, without any artificial traces; and third, "efficiency," enabling the rapid and automated generation of a large-scale defect sample library that covers a wide range of scene variations (different backgrounds, lighting, and viewing angles) and conforms to the real statistical distribution patterns of industrial scenarios. This approach is expected to fundamentally solve the problem of scarce small sample data, laying a solid data foundation for training a more powerful, robust, and generalizable next-generation industrial AI detection model, thereby powerfully promoting the evolution of the intelligent manufacturing quality control system to a higher level.

[0042] Figure 1 This is a flowchart of the image fusion method for product defect samples according to the present invention. Figure 1 As shown, the first aspect of the present invention provides an image fusion method for product defect samples based on foreground-background fusion, comprising the following steps: S110. Obtain a first set of product images containing at least one product defect, perform image recognition and semantic segmentation on each first product image to segment and identify multiple predefined local regions on the defective product, and accurately locate the specific local region where the product defect is located. At the same time, obtain a binary defect mask corresponding to each first product image that accurately outlines the product defect.

[0043] S120. Obtain a set of second product images that do not contain the same type of defects as the fusion background. Perform image recognition and semantic segmentation on each second product image to segment and identify multiple predefined local regions on the target product, and generate an effective region label map. The effective region label map is used to define one or more local regions on the target product that are allowed to perform defect fusion.

[0044] S130. Randomly select a first product image and a second product image. Based on a binary defect mask, accurately extract a local image of the product defect from the selected first product image as the foreground. Based on statistical color migration methods and / or histogram matching methods, perform color and texture correction on the local image to ensure that its color distribution, lighting conditions and texture features are consistent with the appearance features of the corresponding area to be fused in the selected second product image.

[0045] S140. Perform image fusion: First, analyze the effective region label map. Based on the predefined probability distribution model of defects appearing in different local regions, adaptively calculate a random candidate fusion position coordinate that conforms to the process rules within the allowable range defined by the effective region label map. Next, verify whether all pixels of the local image are completely within the effective region after aligning the center point of the local image to the candidate fusion position coordinate. If the verification passes, use the gradient domain fusion algorithm to seamlessly integrate the color and texture corrected local image into the candidate fusion position of the selected second product image to generate a synthetic defect sample image. Then, automatically calculate the bounding box or pixel-level mask annotation information of the defect in the synthetic defect sample image based on the binary defect mask and the candidate fusion position coordinate.

[0046] S150, Repeat steps S130 to S140 until the number of generated product defect samples reaches a preset threshold, thereby constructing a large-scale, diverse industrial defect training dataset with accurate annotations.

[0047] In a preferred embodiment, step S130, the statistical color transfer method specifically includes: calculating the mean and standard deviation of pixel values ​​of all pixels in the local image, and the mean and standard deviation of pixel values ​​of pixels within the corresponding range of the target background area in the selected second product image; and performing a linear transformation on each pixel value of the local image based on the two sets of mean and standard deviation, so that the pixel value distribution of the transformed local image matches the pixel value distribution of the target background area, but is not limited thereto.

[0048] In a preferred embodiment, step S130, the histogram matching method specifically includes: converting the local image into a specified color space or grayscale image, and calculating its color histogram or grayscale histogram; calculating the color histogram or grayscale histogram of the image within the range corresponding to the target background region in the selected second product image; and matching the histogram of the local image to the histogram of the target background region through cumulative distribution function mapping, thereby adjusting the contrast and brightness distribution of the local image, but not limited thereto.

[0049] In a preferred embodiment, step S140 adaptively calculates the candidate fusion location coordinates based on a predefined probability distribution model of defects appearing in different local regions, including the following sub-steps: S141. Based on the first image set, statistically analyze the historical frequency of various defect categories in different local areas on the surface of the defective product, and establish a defect category-local area hotspot probability mapping table, where the probability of a defect occurring in the i-th type of local area is denoted as Pi.

[0050] S142. For the selected second product image, based on its effective region label map, calculate the total number of pixels Sn contained in each type of local region that is marked as effective; combine the corresponding probability Pi in the hotspot probability mapping table, calculate the initial weight Win for each type of effective local region as the target fusion region, Win = Sn × Pi.

[0051] S143. Normalize the initial weights Win of all effective local regions to obtain the final probability Wn of each effective local region being selected as the target fusion region.

[0052] S144. Based on the final probability Wn, use a weighted random sampling algorithm to select one of the effective local regions as the target local region for this fusion.

[0053] S145. Among all pixels in the target local area, randomly and uniformly select the coordinates of one pixel as the candidate fusion position coordinates, but this is not a limitation.

[0054] In a preferred embodiment, in step S140, the gradient domain fusion algorithm is a Poisson fusion algorithm, specifically employing a hybrid cloning mode. By solving the Poisson equation, it maximizes the preservation of gradient information within the local image while ensuring a smooth transition between the pixel values ​​at the boundary and the background of the selected second product image, but this is not a limitation. The Poisson fusion algorithm used in this embodiment is an existing image fusion algorithm; the specific calculation process will not be described here.

[0055] In a preferred embodiment, in step S140, the gradient domain fusion algorithm is a Laplacian pyramid fusion algorithm. Specifically, it involves constructing a Laplacian pyramid and a Gaussian pyramid for the corresponding regions of the local image and the selected second product image, performing weighted fusion using a soft mask across multiple scales, and finally generating the fused result image through pyramid reconstruction. However, this is not a limitation. The Laplacian pyramid fusion algorithm used in this embodiment is an existing image fusion algorithm, and its specific calculation process will not be described here.

[0056] In a preferred embodiment, the image recognition and semantic segmentation in steps S110 and S120 are implemented using a semantic segmentation model based on deep learning. The predefined local regions are divided according to the physical structure, functional areas or material characteristics of the product, including but not limited to planar regions, curved surface regions, edge regions, areas around holes, and specific functional areas, but not limited thereto.

[0057] The following details the specific implementation process of this invention: Figure 2 This is a schematic diagram illustrating the overall process of the image fusion method for product defect samples implementing the present invention. The following is a detailed explanation in conjunction with the attached diagram. Figure 1 and 2 The embodiments of the present invention will be described in detail below. Figure 2 The overall flow of an image fusion method for product defect samples according to an embodiment of the present invention is shown, which mainly includes five core stages: S1 data preparation and preprocessing, S2 appearance consistency correction, S3 adaptive position generation, S4 gradient domain seamless fusion, and S5 automated data pipeline.

[0058] Phase 1: S1 Data Preparation and Preprocessing.

[0059] The goal of this stage is to prepare high-quality source material (defective images) and target canvas (normal images), and to provide accurate structured information for subsequent processing.

[0060] Step S110: Obtain the first set of product images containing defects (source image set). These images typically come from defective product sampling on the production line, historical quality inspection records, or specially collected images. For each first product image, perform semantic segmentation based on deep learning. Using a pre-trained or product-specific fine-tuned semantic segmentation model (such as DeepLabV3+, Mask R-CNN, U-Net, etc.), the product image is segmented into multiple predefined, meaningful local regions. The division of these local regions is based on the product's physical structure (such as the front, sides, and top of the box), functional areas (such as label pasting areas and interface areas), or material characteristics (such as smooth areas and textured areas). The segmentation result is a label map of the same size as the input image, where each pixel value represents the category of its local region. Simultaneously, using this segmentation model or an independent instance segmentation model, the location of product defects (such as holes and scratches) in the image is accurately located, and a pixel-accurate binary mask (Defect Mask) is obtained. In this mask, the pixel value of the product defect is 1 (or 255), and the pixel value of the background area is 0. By combining the segmentation label map, we can determine which specific local area of ​​the product the defect is located in (e.g., "the hole defect is located in the front area of ​​the casing"). This information is crucial for subsequent statistical analysis of defect location distribution.

[0061] Step S120: Obtain a second set of product images 2 (target image set) that does not contain similar defects. These images consist of a large number of normal product images, serving as the background for defect fusion. They can come from qualified product assembly line photos, product 3D model renderings, or other defect-free image sources. For each second product image, semantic segmentation is performed to identify the local regions defined in step S110. Based on process knowledge or prior rules (e.g., "scratches can only appear on the outer surface of the product, not on the internal structure or background"), an "effective region label map" is generated based on the segmented label map. This map clearly indicates which local regions in the current target image 21 are allowed to have defects implanted. For example, for container inspection, defects may only be allowed to be implanted on the container surface (front and side), while areas such as the sky, ground, and background objects are marked as invalid. The effective region label map provides spatial constraints for subsequent fusion location generation.

[0062] Phase Two: S2 Appearance Consistency Correction

[0063] The core of this stage is to resolve the differences in lighting, color, and contrast that may exist between the product defect 12 (foreground) extracted from the source image 11 and the background of the target image, so that the foreground can visually "pre-adapt" to the background, laying the foundation for seamless integration.

[0064] Step S130: Randomly select a source image 11 from the first image set and a target image 21 from the second image set to form a processing pair. Using the binary defect mask corresponding to the source image 11, extract the local image 12 (foreground patch) of the product defect from the source image 11. This local image is the core object of subsequent processing.

[0065] Next, color and texture correction is performed, mainly using one or a combination of the following methods: Statistical-based color transfer: The mean (μ_s) and standard deviation (σ_s) of all pixels (in RGB or Lab color space) within the foreground patch are calculated. Simultaneously, in the target image 21, based on the initially selected fusion candidate regions (which can be the entire effective region or a specific local region determined in subsequent step S3), the mean (μ_t) and standard deviation (σ_t) of the corresponding region's pixels are calculated. Then, the following linear transformation is performed on each pixel value I_s in the foreground patch: I_s' = (σ_t / σ_s) (I_s-μ_s)+μ_t After transformation, the pixel value distribution (mean, standard deviation) of the foreground patch will match the target background area, thus becoming consistent in color and overall brightness / contrast.

[0066] Histogram matching: Convert both the foreground patch and the target background region into grayscale images or a specific color channel (e.g., the luminance channel L). Calculate their grayscale / channel histograms respectively. By calculating the cumulative distribution function and establishing a mapping relationship, the histogram shape of the foreground patch is "stretched" or "compressed" to match the histogram shape of the target background region. This method allows for more precise adjustment of the image's contrast distribution and luminance levels.

[0067] Through the correction in the S2 stage, the appearance features of defects that might have been captured under different lighting conditions are adapted to the visual environment of the current target image 21, significantly reducing the abruptness of colors or the sense of incoordination of lighting that may result from direct fusion.

[0068] Phase 3: S3 Adaptive Position Generation

[0069] This stage aims to select a location for defect fusion in target image 21 that is both random and diverse, and conforms to the actual production process rules, so as to ensure the spatial rationality and diversity of the generated data.

[0070] The location generation part in step S140 is an intelligent decision-making process based on a probabilistic model: Sub-step S141: Establish a hotspot probability mapping table. During system initialization or offline analysis, traverse the entire first image set (real defect samples). For each defect, perform statistics based on its local region category (obtained from step S110). Ultimately, the historical frequency Pi of each defect category (or all defects) appearing in various local regions of the product can be calculated. For example, statistics show that 60% of "scratch" defects appear in the "front flat area," 30% in the "edge area," and 10% in the "side area." This forms a probabilistic prior knowledge reflecting the natural occurrence pattern of defects.

[0071] Sub-steps S142-S144: Probability-weighted region selection. For the currently selected target image 21 and its effective region label map, identify all local region categories marked as "effective". For each effective region category, calculate the total number of pixels Sn (region area) it occupies in the current image. Combining the defect occurrence probability Pi corresponding to the region in the hotspot probability mapping table, calculate the initial weight Win = Sn × Pi for this region to become the "target region" in this fusion. The weight considers both the physical size of the region itself (larger areas are more likely to be selected) and the prior probability of defect occurrence (hotspot regions are more likely to be selected). Normalize Win for all effective regions to obtain the final probability Wn of each region being selected. Subsequently, based on the probability distribution {Wn}, perform a weighted random sampling to select a specific local region as the target local region for this fusion.

[0072] Sub-step S145: Random location within the region. Within the selected target local region, all pixels are considered as candidate locations with equal probability. The system randomly and uniformly selects a pixel within this region, and its coordinates are determined as the "candidate image center point coordinates" for this fusion.

[0073] Sub-step S146: Integrity Verification. Align the center point of the corrected foreground patch (assuming its size is W_p×H_p) with the candidate coordinates obtained in the previous step. Calculate the rectangular area covered by the foreground patch. Check whether all pixels within this rectangular area fall within the "valid" area defined by the valid area label map (i.e., inside the target local area). If all are inside, the verification passes; if any part is outside the valid area (e.g., part of the foreground falls into the background or invalid area), it is considered an invalid position, and the candidate coordinates are discarded. Return to sub-step S144 or S145 to reselect the area or coordinates, or directly discard this image pair and restart S130.

[0074] Through the S3 stage, the generated defect locations are no longer completely random, but rather random and conform to the prior distribution, guided by process knowledge (reflected through probability mapping) and physical constraints (effective area), making the synthetic data closer to the data distribution in the real world.

[0075] Phase 4: Seamless Fusion of S4 Gradient Domains

[0076] This stage is a key technical step in achieving the final visual realism of the generated image. Its goal is to seamlessly "embed" the appearance-corrected foreground patch into the target background image at the position determined by S3.

[0077] In the fusion part of step S140, the gradient domain fusion algorithm is preferably adopted. Its core idea is to operate in the gradient domain to preserve the texture and edge details (strong gradient) inside the source image 11 (defect) to the greatest extent, while making the fusion boundary and background transition smoothly.

[0078] Poisson Fusion (Preferred Solution): Poisson fusion transforms the image fusion problem into solving a Poisson equation. Given the source image f (defect patch), the target image g (background), the fusion region boundary Ω, and the boundary conditions, solve for a new function f. Within Ω, its gradient is made to be as close as possible to the gradient of the source image f (preserving defect details), while at the boundary... The value of Ω should be as close as possible to the value of the target image g (to achieve a smooth transition). This invention particularly favors the use of a "hybrid cloning" mode, which considers the gradient directions of both the source and target images when constructing the guiding vector field. For defects with significant gradients, such as scratches and dents, this mode better preserves their sharp features while avoiding color distortion. In practical applications, this can be efficiently achieved by calling the cv2.seamlessClone function from libraries such as OpenCV and setting the cv2.MIXED_CLONE flag.

[0079] Laplacian Pyramid Fusion (Alternative): This method fuses images across multiple scales to obtain samples. First, Gaussian and Laplacian pyramids are constructed for the fusion regions of the source and target images, respectively. Then, guided by a mask (alpha mask) with smooth edges corresponding to the fusion region, the Laplacian coefficients of the source and target images are weighted and fused at different pyramid levels. Finally, starting from the top layer, the fused image is reconstructed layer by layer through upsampling and summation. This method provides very smooth color fusion transitions and is suitable for scenarios with extremely high requirements for color consistency and where the gradients of defects are not particularly sharp.

[0080] Regardless of the algorithm used, a high-quality synthetic defect sample image is obtained after fusion. Simultaneously, since the binary defect mask records the precise shape of the defect and the fusion position coordinates are known, the mask can be easily mapped to the corresponding position in the synthetic image through coordinate transformation, thereby automatically generating pixel-level mask annotations for the defects in the synthetic image. Furthermore, the minimum bounding rectangle of this mask can be calculated to obtain the bounding box annotation. Thus, "simultaneous image generation and annotation" is achieved.

[0081] Phase 5: S5 Automated Data Pipeline

[0082] Step S150: This stage encapsulates S2 to S4 into a loopable automated process. The system pre-sets the number of image samples to be generated to N (e.g., 100,000 images). The loop control module continuously and randomly selects new pairs (source image 11, target image 21), performs appearance correction, intelligent position generation, seamless fusion, and annotation calculation, and saves the generated synthetic image and its corresponding automatically annotated file (such as COCO annotations in JSON format, or a separate mask image) to a specified directory. This loop continues until the number of generated samples reaches N. Finally, a large-scale, well-structured, and accurately annotated industrial defect training dataset 3 (i.e., product defect samples) is output.

[0083] The systematic solution of this invention brings significant technological progress and application value: A revolutionary improvement in data preparation efficiency: transforming the preparation of defective data from relying on scarce physical objects and time-consuming and labor-intensive collection and annotation to automated, pipeline-style generation based on algorithms and existing images, improving efficiency by hundreds or even thousands of times.

[0084] A substantial leap in model performance: The model is provided with a data scale and diversity far exceeding those of the past, especially in terms of spatial and background diversity. This has significantly improved the generalization ability, robustness, and recognition rate of rare defects of the trained defect detection model, while reducing the risk of overfitting.

[0085] Significantly reduced quality control costs: High-quality training data is continuously generated at near-zero marginal cost, supporting continuous iterative optimization of the model. Simultaneously, the accuracy of automatic detection is improved, reducing quality risks and after-sales costs associated with missed and false detections.

[0086] The technical solution has broad applicability: its methodology is not tied to specific products or defects. By adjusting the segmentation model and local region definition, it can be quickly transferred to different industrial vision inspection tasks, and has strong industry universality and scalability.

[0087] Figure 3 This is an overall architecture diagram of the image fusion system for product defect samples according to the present invention. Figure 3 As shown, the image fusion system for product defect samples of the present invention includes: The first identification module 51 acquires a first product image containing defects as a first image set, performs image recognition on the first product image to segment and identify each local area of ​​the defective product and locate the local area where the product defect is located.

[0088] The second recognition module 52 acquires a second product image that does not contain defects as a fusion background as a second image set, and performs image recognition on the second product image to segment and identify various local areas of the target product and effective areas for defining the allowed locations of defects.

[0089] The image correction module 53 randomly selects a first product image and a second product image, extracts a local image of the product defect from the first product image, and performs color and texture correction on the local image based on the second product image.

[0090] The image fusion module 54 performs image fusion, integrating the corrected local image into the effective area of ​​the selected second product image.

[0091] The loop control module 55 is used to control the image correction module and the image fusion module to run in a loop to generate product defect samples in batches.

[0092] In a preferred embodiment, the image correction module 53 is further configured to perform statistical color migration and / or histogram matching. Statistical color migration involves calculating the mean and standard deviation of pixel values ​​for the target background region in both the local image and the second product image, and then performing a linear transformation on the local image based on these values ​​to match its color and illumination distribution with that of the target background region in the second product image. Histogram matching achieves similar contrast and brightness distribution by matching the grayscale or color histogram of the local image to the second product image, but is not limited to this.

[0093] In a preferred embodiment, the image fusion module 54 is configured to determine a random location within the effective area of ​​the second product image and integrate the corrected local image into that location using a gradient domain fusion algorithm, but is not limited thereto.

[0094] In a preferred embodiment, the image correction module 53 is further configured to obtain the image center point of the local image. The image fusion module 54 is configured to statistically analyze the various defect categories of the first product image in the first image set and the distribution probability Pi of each defect category on different local regions of the surface of the defective product to establish a hotspot probability mapping table, where i represents the type of various local regions. Based on the total number of pixels Sn contained in each local region that is an effective region in the second product image, and the distribution probability Pi, the initial weight Win of each local region as the target fusion region is calculated, Win = Sn × Pi. All initial weights Win are normalized to obtain the probability Wn of the candidate image center point coordinates falling in various local regions. Based on the probability Wn, a local region is randomly selected from the effective regions as the target fusion region, and a point is randomly selected from the pixels of the target fusion region as the candidate image center point coordinates. After aligning the center of the local image with the candidate image center point coordinates, it is determined whether the overall pixel range of the local image is completely within the target fusion region. If so, the corrected local image, with its image center point aligned with the candidate image center point coordinates, is integrated into the selected second product image using a gradient domain fusion algorithm. If not, then abandon this fusion and return to the image correction module 53 to reselect the image or center point, but this is not the only option.

[0095] In a preferred embodiment, the gradient domain fusion algorithm in the image fusion module 54 is a Poisson fusion algorithm, but it is not limited thereto.

[0096] In a preferred embodiment, the gradient domain fusion algorithm in the image fusion module 54 is the Laplacian pyramid fusion algorithm, but it is not limited thereto.

[0097] In a preferred embodiment, the loop control module 55 is configured to collect a second product image fused with local images as a product defect sample set until the number of product defect samples in the product defect sample set meets a preset threshold, but is not limited thereto.

[0098] In summary, the image fusion system for product defect samples of the present invention can automatically generate a large number of high-quality, scene-adapted and physically reasonable damaged images, solving problems such as scarcity of real data, boundary artifacts in traditional synthesis, poor scene generalization and unreasonable location, and providing an efficient and low-cost data solution for training robust automatic defect detection models.

[0099] This invention also provides an image fusion apparatus for product defect samples, including a processor and a memory storing executable instructions for the processor. The processor is configured to execute steps of an image fusion method for product defect samples by executing the executable instructions.

[0100] As shown above, the image fusion device for product defect samples of this invention in this embodiment can automatically generate a large number of high-quality, scene-adapted and physically reasonable damaged images, solving problems such as scarcity of real data, boundary artifacts in traditional synthesis, poor scene generalization and unreasonable position, and providing an efficient and low-cost data solution for training robust automatic defect detection models.

[0101] Those skilled in the art will understand that various aspects of the present invention can be implemented as systems, methods, or program products. Therefore, various aspects of the present invention can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "platform."

[0102] Figure 4 This is a schematic diagram of the image fusion device for product defect samples according to the present invention. See below for reference. Figure 4 To describe an electronic device 600 according to this embodiment of the present invention. Figure 4 The electronic device 600 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0103] like Figure 4 As shown, the electronic device 600 is presented in the form of a general-purpose computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different platform components (including storage unit 620 and processing unit 610), a display unit 640, etc.

[0104] The storage unit stores program code, which can be executed by the processing unit 610 to perform the steps described in the method section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 610 can perform actions such as... Figure 1 The steps are shown in the figure.

[0105] Storage unit 620 may include readable media in the form of volatile storage units, such as random access memory (RAM) 6201 and / or cache memory 6202, and may further include read-only memory (ROM) 6203.

[0106] Storage unit 620 may also include a program / utility 6204 having a set (at least one) program module 6205, such program module 6205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0107] Bus 630 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the multiple bus structures.

[0108] Electronic device 600 can also communicate with one or more external devices 700 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 650. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 660. Network adapter 660 can communicate with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage platforms.

[0109] This invention also provides a computer-readable storage medium for storing a program, which, when executed, implements the steps of an image fusion method for product defect samples. In some possible implementations, various aspects of the invention can also be implemented as a program product comprising program code that, when run on a terminal device, causes the terminal device to perform the steps described in the above-described method section of this specification according to various exemplary embodiments of the invention.

[0110] As shown above, the image fusion system for product defect samples of this invention in this embodiment can automatically generate a large number of high-quality, scene-adapted and physically reasonable damaged images, solving problems such as scarcity of real data, boundary artifacts in traditional synthesis, poor scene generalization and unreasonable position, and providing an efficient and low-cost data solution for training robust automatic defect detection models.

[0111] Figure 5 This is a schematic diagram of the structure of the computer-readable storage medium of the present invention. (Reference) Figure 5 As shown, a program product 800 for implementing the above-described method according to an embodiment of the present invention is described. It may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0112] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0113] Computer-readable storage media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable storage medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0114] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0115] In summary, the purpose of this invention is to provide an image fusion method, system, device, and storage medium for product defect samples, which can automatically generate a large number of high-quality, scene-adapted, and physically reasonable damaged images. This solves the problems of scarce real data, boundary artifacts in traditional synthesis, poor scene generalization, and unreasonable location, and provides an efficient and low-cost data solution for training robust automatic defect detection models.

[0116] The above description, in conjunction with specific preferred embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such modifications and substitutions should be considered within the scope of protection of the present invention.

Claims

1. An image fusion method of a product defect sample, characterized by, Includes the following steps: S110. Obtain a first product image containing defects as a first image set, perform image recognition on the first product image to segment and identify each local area of ​​the defective product and locate the local area where the product defect is located. S120. Obtain a second product image that does not contain defects as a fusion background as a second image set, and perform image recognition on the second product image to segment and identify various local regions of the target product and the effective region for defining the location where defects are allowed to occur. S130. Randomly select a first product image and a second product image, extract a local image of the product defect from the first product image, and perform color and texture correction on the local image based on the second product image. S140. Perform image fusion, and integrate the corrected local image into the effective area of ​​the selected second product image; S150, Repeat steps S130 to S140 to generate product defect samples in batches.

2. The image fusion method of a product defect sample according to claim 1, wherein, In step S130, the color and texture correction of the local image based on the second product image includes: Statistically based color migration and / or histogram matching; The statistically based color transfer calculates the mean and standard deviation of pixel values ​​in the target background region of the local image and the second product image respectively, and performs a linear transformation on the local image based on this to match its color and illumination distribution with the target background region of the second product image. The histogram matching achieves the same contrast and brightness distribution by matching the grayscale or color histogram of the local image to the second product image.

3. The image fusion method of a product defect sample according to claim 1, wherein, Step S140 includes: determining a random position within the effective area of ​​the second product image, and integrating the corrected local image into that position using a gradient domain fusion algorithm.

4. The image fusion method of a product defect sample according to claim 1, wherein, Step S130 further includes: obtaining the image center point of the local image; Step S140 includes: S141. Statistically analyze the various defect categories of the first product image in the first image set and the distribution probability Pi of various defect categories on different local areas of the surface of the defective product to establish a hotspot probability mapping table, where i represents the type of various local areas. S142. Based on the total number of pixels Sn contained in each local region that is an effective region in the second product image, and the distribution probability Pi, calculate the initial weight Win of each local region as the target fusion region, Win = Sn × Pi; normalize all the initial weights Win to obtain the probability Wn of the candidate image center point coordinates falling in each local region. S143. Based on the occurrence probability Wn, randomly select a local region in the effective region as the target fusion region, and randomly select a point among the pixels in the target fusion region as the coordinates of the candidate image center point. S144. After aligning the center of the local image with the center point coordinates of the candidate image, determine whether the overall pixel range of the local image is completely within the target fusion region; if yes, proceed to step S145; if no, abandon this fusion and return to step S130 to reselect an image or center point. S145. The corrected local image is aligned with the coordinates of the center point of the candidate image, and then integrated into the selected second product image using a gradient domain fusion algorithm.

5. The image fusion method of a product defect sample according to claim 4, wherein, In step S145, the gradient domain fusion algorithm is the Poisson fusion algorithm.

6. The image fusion method of a product defect sample according to claim 4, wherein, In step S145, the gradient domain fusion algorithm is the Laplace pyramid fusion algorithm.

7. The image fusion method of a product defect sample according to claim 4, wherein, Step S150 includes: Steps S130 to S140 are executed repeatedly to collect a second product image that has been fused with local images as a product defect sample set until the number of product defect samples in the product defect sample set meets a preset threshold.

8. An image fusion system of a product defect sample for implementing the image fusion method of a product defect sample according to claim 1, characterized by, include: The first identification module acquires a first product image containing defects as a first image set, performs image recognition on the first product image to segment and identify each local area of ​​the defective product and locate the local area where the product defect is located. The second recognition module acquires a second product image that does not contain defects as a fusion background as a second image set, and performs image recognition on the second product image to segment and identify various local regions of the target product and the effective region for defining the location where defects are allowed to occur. The image correction module randomly selects a first product image and a second product image, extracts a local image of the product defect from the first product image, and performs color and texture correction on the local image based on the second product image. The image fusion module performs image fusion, integrating the corrected local image into the effective area of ​​the selected second product image; The loop control module is used to control the image correction module and the image fusion module to run in a loop to generate product defect samples in batches.

9. An image fusion device of a product defect sample, characterized by, include: processor; A memory in which executable instructions of the processor are stored; The processor is configured to perform the steps of the image fusion method for product defect samples according to any one of claims 1 to 7 by executing the executable instructions.

10. A computer readable storage medium for storing a program, characterized in that, When the program is executed by the processor, it implements the steps of the image fusion method for product defect samples as described in any one of claims 1 to 7.