Method, device and storage medium for background replacement of an image

By using differential image repair and affine transformation techniques, the foreground region of semiconductor wafers can be accurately extracted, solving the problem of poor background replacement in existing technologies. This achieves an efficient and low-cost background replacement solution that is applicable to wafer products of different sizes.

CN121280424BActive Publication Date: 2026-02-27SUZHOU GAOSHI SEMICON TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511832435.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-08
Publication Date
2026-02-27
Estimated Expiration
2045-12-08

AI Technical Summary

Technical Problem

Existing background replacement techniques struggle to accurately extract the foreground region of semiconductor wafers, resulting in poor background replacement performance. Furthermore, relying on complex deep learning models is time-consuming and labor-intensive, making them unsuitable for processing wafers of different sizes.

Method used

By acquiring standard product images and actual product images, foreground mask images are extracted separately, difference images are calculated and repaired, and the actual foreground mask image is repaired by combining an affine transformation matrix. Finally, the background area is set to a preset color for background replacement.

Benefits of technology

It achieves precise background replacement of semiconductor wafers, improves processing speed, reduces costs, is applicable to wafer products of different sizes, and does not require the support of complex deep learning models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121280424B_ABST
    Figure CN121280424B_ABST
Patent Text Reader

Abstract

The application discloses a method, device and storage medium for background replacement of an image, the method comprising: obtaining a standard product image and an actual product image to be background replaced; extracting foreground regions of the standard product image and the actual product image respectively to obtain a standard foreground mask image and an actual foreground mask image; obtaining a difference image of the standard foreground mask image and the actual foreground mask image; repairing the actual foreground mask image based on the difference image and the standard foreground mask image to obtain a repaired actual foreground mask image; and setting a background region of the actual product image to a preset background color based on the repaired actual foreground mask image to achieve background replacement of the actual product image. The scheme of the application can improve processing speed and reduce cost while ensuring the accuracy and stability of background replacement, and is suitable for background replacement requirements of different sizes of wafer products.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application generally relates to the technical field of image processing. More particularly, the present application relates to a method, device and computer readable storage medium for background replacement of an image. BACKGROUND

[0002] In the industrial field such as semiconductor manufacturing, image detection of products is an important link of quality control. In order to clearly present the characteristics of the products themselves and exclude background interference, background replacement processing is often needed for product images. Among them, as a core product, the imaging quality of semiconductor wafers directly affects the accuracy of subsequent detection analysis, and the background replacement technology plays an indispensable role in wafer image processing.

[0003] At present, the background replacement technology for product images has been applied, but when processing such specific products as semiconductor wafers, many challenges are faced. Due to the fact that wafer products are prone to defects, distortion and gray scale changes during imaging, existing background replacement technologies often have difficulty in accurately extracting the foreground region of the actual product, resulting in poor background replacement effect. Some technologies rely on complex deep learning models, which require a large amount of manual data labeling and model training, not only consuming a lot of time and labor cost, but also being difficult to adapt to the processing needs of wafers of different sizes, and at the same time, there is a problem of being unable to accurately locate the actual product region due to product imaging abnormalities.

[0004] Therefore, the present application provides a scheme for background replacement of an image, so as to effectively improve the processing speed and reduce the cost while ensuring the accuracy and stability of background replacement, and is suitable for the background replacement needs of wafers of different sizes. SUMMARY

[0005] In order to at least solve one or more of the above-mentioned technical problems, the present application provides a scheme for background replacement of an image in multiple aspects.

[0006] In a first aspect, the present application provides a method for background replacement of an image, comprising: obtaining a standard product image and an actual product image to be background replaced; extracting foreground regions of the standard product image and the actual product image respectively to obtain a standard foreground mask image and an actual foreground mask image; obtaining a difference image of the standard foreground mask image and the actual foreground mask image; repairing the actual foreground mask image based on the difference image and the standard foreground mask image to obtain a repaired actual foreground mask image; and setting a background region of the actual product image to a preset background color based on the repaired actual foreground mask image to achieve background replacement of the actual product image.

[0007] In some embodiments, the repairing the actual foreground mask image based on the difference image and the standard foreground mask image to obtain a repaired actual foreground mask image comprises: fusing the difference image to the actual foreground mask image to obtain a fused actual foreground mask image; determining geometric features of the standard product and the actual product respectively based on the standard foreground mask image and the fused actual foreground mask image to obtain standard product geometric features and actual product geometric features; calculating an affine transformation matrix of the standard foreground mask image relative to the fused actual foreground mask image based on the standard product geometric features and the actual product geometric features; performing affine transformation on the standard foreground mask image based on the affine transformation matrix to obtain an affine transformed standard foreground mask image; and obtaining the repaired actual foreground mask image based on the actual product geometric features and the affine transformed standard foreground mask image.

[0008] In some embodiments, the geometric features comprise a center coordinate and a radius, and the affine transformation matrix comprises a scaling coefficient and a translation amount, wherein the scaling coefficient is obtained based on a ratio of the actual radius to the standard radius, and the translation amount is calculated based on a difference between the actual center coordinate and the standard center coordinate.

[0009] In some embodiments, the determining geometric features of the standard product and the actual product respectively based on the standard foreground mask image and the fused actual foreground mask image to obtain standard product geometric features and actual product geometric features comprises: extracting contour curves from the standard foreground mask image and the fused actual foreground mask image respectively using an edge detection algorithm to obtain standard contour curves and actual contour curves; performing minimum circumscribed circle fitting on the standard contour curves and the actual contour curves respectively to obtain a standard minimum circumscribed circle and an actual minimum circumscribed circle; and determining a standard center coordinate and a standard radius, and an actual center coordinate and an actual radius based on the standard minimum circumscribed circle and the actual minimum circumscribed circle.

[0010] In some embodiments, the determining geometric features of the standard product and the actual product respectively based on the standard foreground mask image and the fused actual foreground mask image to obtain standard product geometric features and actual product geometric features comprises: traversing all foreground pixels in the standard foreground mask image and the fused actual foreground mask image, respectively calculating coordinate means of all foreground pixels to obtain standard centroid coordinates and actual centroid coordinates as the standard center coordinate and the actual center coordinate; and respectively calculating Euclidean distances of each foreground pixel to the corresponding centroid coordinates, and taking the maximum distance as the standard radius and the actual radius.

[0011] In some embodiments, based on the actual product geometry and the affine-transformed standard foreground mask map, obtaining the repaired actual foreground mask map comprises: drawing a circular mask map consistent with the resolution of the standard foreground mask map based on the actual center coordinates and actual radius; performing an AND operation on the circular mask map and the affine-transformed standard foreground mask map to obtain the repaired actual foreground mask map.

[0012] In some embodiments, fusing the difference map into the actual foreground mask map comprises: performing denoising processing on the difference map using a morphological opening operation to obtain a denoised difference map; and fusing the denoised difference map into the actual foreground mask map.

[0013] In some embodiments, the morphological opening operation uses a circular structural element, the radius of the circular structural element is 1-3 pixels; and after the morphological opening operation, the denoised difference map is subjected to connected region analysis to retain connected regions with an area greater than a preset area threshold, the preset area threshold being 0.5%-1% of the area of the standard foreground mask map.

[0014] In a second aspect, the present application provides a device for background replacement of an image, comprising: a processor; and a memory storing program instructions for background replacement of an image, when the program is executed by the processor, the program instructions cause the implementation of the method according to any one of the preceding first aspect and embodiments.

[0015] In a third aspect, the present application provides a computer-readable storage medium having stored thereon computer-readable instructions for background replacement of an image, the computer-readable instructions being executed by one or more processors to implement the method according to any one of the preceding first aspect and embodiments.

[0016] Through the method for background replacement of an image as provided above, the embodiments of the present application achieve accurate extraction and repair of the foreground region of an actual product by comparative analysis of a standard product image and an actual product image, combined with difference map repair and affine transformation, and thus complete background replacement. The scheme can adapt to the defects, distortion and gray scale changes of a wafer product, does not need complex deep learning model support, effectively improves processing speed and reduces cost while ensuring the accuracy and stability of background replacement, and is suitable for background replacement requirements of wafer products of different sizes. BRIEF DESCRIPTION OF DRAWINGS

[0017] The above and other objects, features and advantages of the present application will become more apparent from the following detailed description read in conjunction with the accompanying drawings, in which:

[0018] Figure 1 An exemplary flowchart of a method for background replacement of an image according to an embodiment of the present application is shown;

[0019] Figure 2 An exemplary process diagram of a method for background replacement of an image according to an embodiment of the present application is shown;

[0020] Figure 3 Exemplary examples of background replacement of an image according to an embodiment of the present application are shown;

[0021] Figure 4 An exemplary flowchart of a repair process of a foreground mask according to an embodiment of the present application is shown;

[0022] Figure 5 An exemplary structural block diagram of an apparatus for background replacement of an image according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0023] The technical solutions in the embodiments of the present application will be apparently and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person skilled in the art without any creative work fall within the protection scope of the present application.

[0024] It should be understood that the terms "comprise" and "include" used in the specification and claims of the present application indicate the presence of the described features, integers, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0025] It should also be understood that the terms used in the specification of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. As used in the specification and claims of the present application, unless otherwise clearly indicated by the context, the singular forms "a", "an" and "the" are intended to include the plural forms. It should be further understood that the term "and / or" used in the specification and claims of the present application means any combination of one or more of the associated listed items and all possible combinations thereof, and includes these combinations.

[0026] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0027] The specific embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0028] Figure 1 An exemplary flowchart of a method 100 for background replacement of an image according to an embodiment of this application is shown. It is understood that method 100 can be executed by any suitable device with data processing capabilities, such as, but not limited to, terminal devices and servers. The terminal device may specifically be an image processing workstation, and the server may specifically be a cloud server with GPU acceleration capabilities to meet the high-efficiency processing requirements of wafer images.

[0029] like Figure 1 As shown, in step S101, a standard product image and an actual product image to be replaced can be acquired. The product referred to here can specifically be a semiconductor wafer. Therefore, in the actual quality inspection scenario of semiconductor wafers, after each acquisition of an image of the semiconductor wafer, method 100 of this application can be executed to replace the background of the wafer image.

[0030] Standard product images need to be pre-acquired and screened. Only qualified wafer images with no defects, no distortion, and uniform grayscale should be selected and stored in a designated storage area of ​​the execution device. When method 100 reaches step S101, it can directly retrieve the image from this area, improving background replacement efficiency. To ensure the accuracy of subsequent processing, the standard product image and the actual product image to be replaced must be acquired using the same device and have the same resolution, shooting angle, lighting conditions, and lens parameters.

[0031] Next, in step S102, the foreground regions of the standard product image and the actual product image are extracted respectively to obtain a standard foreground mask image (e.g., ...). Figure 2 (as shown in (a)) and the actual foreground mask (as shown in (a)). Figure 2 As shown in (b)). It can be understood that both the standard foreground mask and the actual foreground mask contain foreground and background regions, and are binary images, with the foreground region being white (pixel value 255) and the background region being black (pixel value 0).

[0032] Specifically, a threshold segmentation method combining Otsu adaptive thresholding and manually set thresholds can be used to extract the foreground region. First, the initial threshold is automatically obtained using the Otsu algorithm. Then, the manual threshold is fine-tuned based on the grayscale distribution of the actual product image to ensure clear separation between the foreground and background. Regions with grayscale values ​​higher than the threshold are identified as foreground regions, and regions with grayscale values ​​lower than the threshold are identified as background regions. Since the standard product image and the actual product image have the same resolution, the standard foreground mask image obtained here also has the same resolution as the actual foreground mask image.

[0033] Next, in step S103, the difference map between the standard foreground mask image and the actual foreground mask image is obtained (e.g., ...). Figure 2 (as shown in (c)). The difference map is obtained by performing pixel-level subtraction between the standard foreground mask and the actual foreground mask, retaining the areas that exist in the standard foreground mask but are missing in the actual foreground mask.

[0034] Furthermore, after obtaining the difference image, morphological opening operations can be used to denoise it. The morphological opening operation first performs erosion to remove tiny noise points, and then performs dilation to restore the original contour of the foreground region, thus obtaining the denoised difference image (e.g., ...). Figure 2 As shown in (d) in the figure, the denoised difference map can then be used for subsequent operations, such as fusing the denoised difference map into the actual foreground mask map.

[0035] In practical applications, the morphological opening operation uses a circular structuring element with a radius of 1 to 3 pixels. Furthermore, after the morphological opening operation, connected component analysis can be performed on the denoised difference image to retain connected regions with an area greater than a preset area threshold and remove isolated noise regions with too small an area. It is understood that those skilled in the art can select a specific value for the preset area threshold according to actual needs; for example, the preset area threshold may be 0.5%-1% of the area of ​​the standard foreground mask image, and this application does not impose a specific limitation on it.

[0036] Next, in step S104, the actual foreground mask image is repaired based on the difference map and the standard foreground mask image to obtain the repaired actual foreground mask image. To facilitate understanding, how the actual foreground mask image is repaired based on the difference map and the standard foreground mask image will be explained later in conjunction with... Figure 4 The process of repairing the actual foreground mask image will be explained in detail, and will not be repeated here.

[0037] After obtaining the repaired actual foreground mask image, at step S105, the background region of the actual product image can be set to a preset background color based on the repaired actual foreground mask image to achieve background replacement of the actual product image, and an actual product image after background replacement is obtained (as shown in (i) of Figure 2 ).

[0038] Here, the background region in the actual product image refers to the region in the actual product image corresponding to the background region in the repaired actual foreground mask image. In terms of implementation, the repaired actual foreground mask image and the actual product image can be first subjected to a pixel-level and operation, the foreground region retains the original pixel value of the actual product image, and the background region (black region) is set to a preset background color to achieve background replacement of the actual product image. The preset background color can be set according to actual detection requirements, for example, white (RGB(255,255,255)), black (RGB(0,0,0)), or other specified colors, which are directly defined by RGB color values, HSV color values, or grayscale values.

[0039] As an example, Figure 3 a plurality of instances of background replacement of an image are shown. As shown in Figure 3 , the three images in the left column are actual product images, and the three images in the right column are actual product images after background replacement.

[0040] Comparing Figure 3 a1 and a2, b1 and b2, and c1 and c2, it can be found that the method for background replacement of an image provided by the embodiments of the present application achieves accurate extraction and repair of the actual product foreground region through comparison and analysis of the standard product image and the actual product image, combined with difference map repair and affine transformation, and then completes background replacement. This scheme can adapt to the defects, distortions, and grayscale changes of wafer products, and does not require complex deep learning model support. While ensuring the accuracy and stability of background replacement, it effectively improves processing speed and reduces costs, and is suitable for background replacement requirements of wafer products of different sizes.

[0041] Figure 4 An exemplary flowchart of the repair process 400 of the actual foreground mask image of the embodiments of the present application is shown. It can be understood that the following description in conjunction with Figure 4 is a specific implementation of the foregoing step S104. Therefore, the features described in the foregoing in conjunction with Figure 1 may be similarly applicable.

[0042] As shown in Figure 4 , at step S401, the difference map is fused into the actual foreground mask image to obtain a fused actual foreground mask image (as shown in Figure 2The fusion operation adopts pixel-level or operation to superimpose the effective area reserved in the difference map to the corresponding position of the actual foreground mask map, and fill the missing part in the actual foreground mask map.

[0043] Then, at step S402, based on the standard foreground mask map and the fused actual foreground mask map, the geometric features of the standard product and the actual product are determined respectively to obtain the standard product geometric features and the actual product geometric features. The geometric features can include the center coordinates and the radius.

[0044] In some implementations of the present application, the following operations can be performed to obtain the standard product geometric features and the actual product geometric features: first, the edge detection algorithm is used to extract the contour curve of the standard foreground mask map and the fused actual foreground mask map respectively to obtain the standard contour curve and the actual contour curve. Here, the edge detection algorithm can be the Canny edge detection algorithm, the low threshold of which can be set to 50-80, and the high threshold can be set to 150-200, and the clear edge contour is obtained through double-threshold screening to obtain the standard contour curve and the actual contour curve. Then, the least-enclosing circle fitting is performed on the standard contour curve and the actual contour curve respectively, and the least square method is used to minimize the distance error between the fitting circle and the contour curve to obtain the standard least-enclosing circle and the actual least-enclosing circle. Finally, based on the standard least-enclosing circle and the actual least-enclosing circle, the standard center coordinates and the standard radius, and the actual center coordinates and the actual radius are determined respectively.

[0045] In some implementations of the present application, the following operations can be performed to obtain the standard product geometric features and the actual product geometric features: first, the edge detection algorithm is used to extract the contour curve of the standard foreground mask map and the fused actual foreground mask map respectively to obtain the standard contour curve and the actual contour curve. Here, the edge detection algorithm can be the Canny edge detection algorithm, the low threshold of which can be set to 50-80, and the high threshold can be set to 150-200, and the clear edge contour is obtained through double-threshold screening to obtain the standard contour curve and the actual contour curve. Then, the least-enclosing circle fitting is performed on the standard contour curve and the actual contour curve respectively, and the least square method is used to minimize the distance error between the fitting circle and the contour curve to obtain the standard least-enclosing circle and the actual least-enclosing circle. Finally, based on the standard least-enclosing circle and the actual least-enclosing circle, the standard center coordinates and the standard radius, and the actual center coordinates and the actual radius are determined respectively.

[0046] Then, at step S403, based on the standard product geometric features and the actual product geometric features, the affine transformation matrix of the standard foreground mask map relative to the fused actual foreground mask map is calculated.

[0047] Specifically, the affine transformation matrix includes the scaling coefficient and the translation amount, wherein the scaling coefficient is obtained based on the ratio of the actual radius to the standard radius, and the translation amount is calculated based on the difference between the actual center coordinates and the standard center coordinates.

[0048] Then, at step S404, based on the affine transformation matrix, the affine transformation is performed on the standard foreground mask map to obtain the affine-transformed standard foreground mask map (as shown in (f) in FIG. 4).Figure 2 (f) of FIG. 6B).

[0049] Finally, at step S405, the repaired actual foreground mask image is obtained based on the actual product geometry and the affine-transformed standard foreground mask image.

[0050] Specifically, first, a circular mask image completely consistent with the resolution of the standard foreground mask image is drawn based on the actual center coordinates and the actual radius (as shown in (g) of FIG. 6B), and the drawing method is to set the pixels in the circular region to white (pixel value 255) on a black canvas (pixel value 0) with the actual center coordinates as the center and the actual radius as the radius. Then, the circular mask image and the affine-transformed standard foreground mask image are subjected to pixel-level AND operation, only the region that is white in both mask images is retained, and the redundant edge part is removed, to obtain the repaired actual foreground mask image (as shown in (h) of FIG. 6B). Figure 2 Figure 2 The above describes the process of repairing the actual foreground mask image provided by the embodiments of the present application. First, the standard product image is used to repair the actual product image through image fusion technology, and then the affine transformation is used to fine-tune the difference between the actual product and the standard product, to avoid the problem that the actual product region cannot be located due to product imaging abnormalities, and to ensure the integrity and accuracy of the foreground region, thereby providing a reliable foundation for subsequent background replacement.

[0051] The above describes the process of repairing the actual foreground mask image provided by the embodiments of the present application. First, the standard product image is used to repair the actual product image through image fusion technology, and then the affine transformation is used to fine-tune the difference between the actual product and the standard product, to avoid the problem that the actual product region cannot be located due to product imaging abnormalities, and to ensure the integrity and accuracy of the foreground region, thereby providing a reliable foundation for subsequent background replacement. Figure 4 Next, an exemplary introduction is made to the device 500 for background replacement of images provided by the embodiments of the present application. The electronic device 500 is specially adapted to the background replacement processing scene of semiconductor wafer images, and can meet the efficient operation and stable processing requirements of image data in industrial quality inspection. As shown in FIG. 7, the electronic device 500 can include a processor 501, a memory 502 and a communication bus 503, wherein the processor 501 serves as the core operation unit responsible for executing image processing algorithms, the memory 502 is used to store related data and program instructions, and the communication bus 503 provides a channel for signal transmission between components.

[0052] Figure 5 Figure 5

[0053] ​​​​In the process of the specific embodiment, the processor 501 can be at least one of an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a CPU, a controller, a microcontroller, or a microprocessor. It can be understood that the electronic device for implementing the above processor functions can also be of other types for different configurations, and the embodiment is not limited in this regard, as long as the operation requirement of the background replacement method can be met.

[0054] In the embodiment of the present application, the communication bus 503 is used to realize the connection and communication between the processor 501 and the memory 502; the memory 502 stores not only the program instructions for background replacement of the image, but also the standard product image data pre-screened, the difference image generated in the process, the fused mask image, and other intermediate data, and the image data after the final background replacement. When the processor 501 executes the program instructions stored in the memory 502, the related data will be called in sequence, and the image acquisition, foreground region extraction, difference image calculation, actual foreground mask repair and background replacement operations are completed in turn, finally realizing the background replacement method of the present application combined with Figures 1 to 4 The method for background replacement of the image is described.

[0055] The above describes Figure 5 The electronic device for background replacement of the image is described, which can be used to execute the present application. It needs to be understood that the device structure or architecture herein is only exemplary, and the implementation mode and implementation entity of the present application are not limited thereto. The electronic device can be a hardware device running independently, a functional module integrated in a wafer detection system or an image processing workstation, or a node device in a distributed processing architecture. Without departing from the spirit of the core technical solution of the present application, those skilled in the art can make reasonable adjustments to the device structure according to the actual application requirement, as long as the overall function of the above background replacement method can be realized, which falls within the protection scope of the present application.

[0056] According to the above description in combination with the drawings, those skilled in the art can also understand that the embodiments of the present application can also be implemented by software programs. Therefore, the present application also provides a computer readable storage medium. The computer readable storage medium stores program instructions for performing background replacement on an image. The program instructions can be used to implement the embodiments of the present application described in combination with the drawings Figures 1 to 4 the method for performing background replacement on an image.

[0057] It can be understood that the description of the present disclosure focuses on the differences between various embodiments, and the same or corresponding parts can be referred to each other. For the purpose of brevity, the present disclosure will not be described one by one.

[0058] It should be noted that although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all of the shown operations must be performed to achieve the desired result. On the contrary, the steps depicted in the flowchart can change the order of execution. Additionally or alternatively, some steps can be omitted, a plurality of steps can be combined into one step, and / or one step can be divided into a plurality of steps.

[0059] Although the embodiments of the present application have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided only by way of example. Those skilled in the art can think of many changes, modifications and alternatives without departing from the idea and spirit of the present application. It should be understood that various alternatives to the embodiments of the present application described herein can be employed in practicing the present application. The appended claims are intended to define the scope of protection of the present application and thus cover equivalent or alternative solutions within the scope of the claims.

Claims

1. A method for background replacement of an image, characterized in that, The method comprises the following steps: acquiring a standard product image and an actual product image to be background replaced; extracting foreground regions of the standard product image and the actual product image respectively to obtain a standard foreground mask image and an actual foreground mask image; calculating a difference image of the standard foreground mask image and the actual foreground mask image; repairing the actual foreground mask image based on the difference image and the standard foreground mask image to obtain a repaired actual foreground mask image; setting a background region of the actual product image to a preset background color based on the repaired actual foreground mask image to achieve background replacement of the actual product image; wherein repairing the actual foreground mask image to obtain the repaired actual foreground mask image comprises: calculating an affine transformation matrix of the standard foreground mask image relative to the fused actual foreground mask image based on standard product geometric features and actual product geometric features; performing affine transformation on the standard foreground mask image based on the affine transformation matrix to obtain an affine transformed standard foreground mask image; drawing a circular mask image with a resolution completely consistent with the standard foreground mask image based on an actual center coordinate and an actual radius; performing an AND operation on the circular mask image and the affine transformed standard foreground mask image to obtain the repaired actual foreground mask image.

2. The method of claim 1, wherein, Before calculating the affine transformation matrix of the standard foreground mask image relative to the fused actual foreground mask image based on the standard product geometric features and the actual product geometric features, the method comprises: fusing the difference image to the actual foreground mask image to obtain a fused actual foreground mask image; determining geometric features of the standard product and the actual product based on the standard foreground mask image and the fused actual foreground mask image to obtain the standard product geometric features and the actual product geometric features.

3. The method of claim 2, wherein, The geometric features comprise a center coordinate and a radius, and the affine transformation matrix comprises a scaling coefficient and a translation amount, wherein the scaling coefficient is obtained based on a ratio of the actual radius to the standard radius, and the translation amount is calculated based on a difference between the actual center coordinate and the standard center coordinate.

4. The method of claim 3, wherein, Determining the geometric features of the standard product and the actual product based on the standard foreground mask image and the fused actual foreground mask image to obtain the standard product geometric features and the actual product geometric features comprises: extracting contour curves from the standard foreground mask image and the fused actual foreground mask image respectively using an edge detection algorithm to obtain a standard contour curve and an actual contour curve; performing minimum circumscribed circle fitting on the standard contour curve and the actual contour curve respectively to obtain a standard minimum circumscribed circle and an actual minimum circumscribed circle; determining a standard center coordinate and a standard radius, and an actual center coordinate and an actual radius based on the standard minimum circumscribed circle and the actual minimum circumscribed circle.

5. The method of claim 3, wherein, Determining the geometric features of the standard product and the actual product based on the standard foreground mask image and the fused actual foreground mask image to obtain the standard product geometric features and the actual product geometric features comprises: Traverse all foreground pixels in the standard foreground mask image and the fused actual foreground mask image, and calculate coordinate mean values of all foreground pixels respectively to obtain standard centroid coordinates and actual centroid coordinates as standard center coordinates and actual center coordinates; Calculate Euclidean distances of each foreground pixel to corresponding centroid coordinates respectively, and take the maximum distance as standard radius and actual radius.

6. The method of claim 2, wherein, Fusing the difference image to the actual foreground mask image comprises: Performing morphological opening operation on the difference image to obtain a denoised difference image; Fusing the denoised difference image to the actual foreground mask image.

7. The method of claim 6, wherein, The morphological opening operation adopts a circular structural element, the radius of the circular structural element is 1-3 pixels; and after the morphological opening operation, the denoised difference image is subjected to connected region analysis to retain connected regions with an area greater than a preset area threshold, the preset area threshold is 0.5%-1% of the area of the standard foreground mask image.

8. An apparatus for background replacement of an image, characterized by, Comprise: a processor; and a memory storing program instructions for background replacement of an image, when the program instructions are executed by the processor, the method according to any one of claims 1-7 is realized. 9.A computer readable storage medium having stored thereon computer readable instructions for background replacement of an image, the computer readable instructions being executed by one or more processors to implement the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Image inpainting with geometric and photometric transformations

    CN112419165A

  • Image restoration method and device, electronic equipment and storage medium

    CN118279198A

  • Chip surface defect detection method, electronic equipment and readable medium

    CN121033048A