Image background replacement method, device, storage medium, and terminal

CN122176086APending Publication Date: 2026-06-09BEIJING QIHOOD TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING QIHOOD TECHNOLOGY CO LTD
Filing Date
2024-12-03
Publication Date
2026-06-09

Smart Images

  • Figure CN122176086A_ABST
    Figure CN122176086A_ABST
Patent Text Reader

Abstract

This application discloses an image background replacement method, apparatus, storage medium, and terminal. In response to a user's image upload operation of at least two initial images, the initial background of each initial image is removed to obtain the corresponding main image. In response to a background processing request triggered by the user for a target background theme, a background image conforming to the target background theme is generated for each main image. The main images and their corresponding background images are then merged to obtain a background replacement image for each initial image. Users can upload multiple images at once through the image upload operation and can further select their desired style as the target background theme for replacing each image. After selecting a target background theme, the user replaces the background images belonging to the target background theme with the main images, thus achieving the effect of batch replacing multiple initial images with backgrounds of a specific style.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to an image background replacement method, apparatus, storage medium, and terminal. Background Technology

[0002] With the rise of social media and e-commerce in the internet sector, people's demand for image enhancement and personalization is constantly increasing. Image background replacement technology, as an effective image processing method, meets users' image transformation needs. By replacing the background, the visual effect and attractiveness of an image can be improved. In this process, users can choose a suitable background to replace according to their own needs, thereby achieving personalized image creation. Relying on the improvement of computer hardware performance and the continuous optimization of algorithms, image processing technology has also developed rapidly in recent years. However, when it is necessary to replace the backgrounds of batch images, users often need to perform a lot of repetitive manual operations, resulting in very low processing efficiency for image background replacement. Summary of the Invention

[0003] This application provides an image background replacement method, apparatus, storage medium, and terminal, which can solve the technical problem of low processing efficiency in image background replacement in related technologies.

[0004] In a first aspect, embodiments of this application provide an image background replacement method, the method comprising:

[0005] In response to a user's image upload operation for at least two initial images, the initial background in each initial image is removed to obtain the corresponding main image of each initial image;

[0006] In response to the background processing request triggered by the user for the target background theme, a background image that conforms to the target background theme is generated for each main image of the material.

[0007] By merging the main images of each material with their corresponding background images, a background replacement image corresponding to each initial image is obtained, and each background replacement image is displayed in the image display area of ​​the terminal display interface.

[0008] Secondly, embodiments of this application provide an image background replacement apparatus, the apparatus comprising:

[0009] The image upload module is used to respond to the user's image upload operation of at least two initial images, remove the initial background from each initial image to obtain the corresponding main image of each initial image;

[0010] The background generation module is used to respond to the background processing request triggered by the user for the target background theme and generate background images that conform to the target background theme for each main image of the material.

[0011] The background replacement module is used to merge the main images of each material with the corresponding background images to obtain the background replacement images corresponding to each initial image, and then display each background replacement image in the image display area of ​​the terminal display interface.

[0012] Thirdly, embodiments of this application provide a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the steps of the method described above.

[0013] Fourthly, embodiments of this application provide a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being adapted to be loaded by the processor and to execute the steps of the above-described method.

[0014] The beneficial effects of the technical solutions provided in some embodiments of this application include at least the following:

[0015] This application provides an image background replacement method. In response to a user's image upload operation of at least two initial images, the method removes the initial background from each initial image to obtain the corresponding main image. In response to a user-triggered background processing request for a target background theme, it generates background images conforming to the target background theme for each main image. The method then merges the main images and their corresponding background images to obtain replacement background images for each initial image, and displays these replacement images in the image display area of ​​the terminal display interface. Users can upload multiple images at once. After uniformly segmenting the main images to obtain the corresponding main images for each initial image, users can further select their desired style as the target background theme for replacing each image. After selecting the target background theme, background images belonging to the target background theme are generated for each main image. By merging the main images and their corresponding backgrounds, the method achieves the effect of batch replacing multiple initial images with backgrounds of a specific style. This generates different backgrounds for multiple images but belonging to the same theme, improving the efficiency of image background replacement and ensuring the uniformity of background style among a batch of images, thus meeting users' needs for batch image processing. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 An exemplary system architecture diagram of an image background replacement method provided in this application embodiment;

[0018] Figure 2 A schematic flowchart illustrating an image background replacement method provided in an embodiment of this application;

[0019] Figure 3 A schematic diagram of an image upload interface in an image background replacement method provided in an embodiment of this application;

[0020] Figure 4 A schematic diagram of the background processing interface in an image background replacement method provided in an embodiment of this application;

[0021] Figure 5 A schematic flowchart illustrating an image background replacement method provided in an embodiment of this application;

[0022] Figure 6 This is a schematic diagram of a cutout processing area in a terminal display interface provided in an embodiment of this application;

[0023] Figure 7 A schematic flowchart illustrating an image background replacement method provided in an embodiment of this application;

[0024] Figure 8 A structural block diagram of an image background replacement device provided in an embodiment of this application;

[0025] Figure 9 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application. Detailed Implementation

[0026] To make the features and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0027] In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims. Furthermore, in the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; the word "and / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist, for example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Additionally, in the description of the embodiments of this application, "multiple" refers to two or more.

[0028] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.

[0029] With the rise of social media and e-commerce in the internet sector, people's pursuit of image enhancement has moved beyond simple color adjustments or filter applications; the demand for more personalized and creative image processing is constantly increasing. Image background replacement technology, as an effective image processing method, meets users' image transformation needs. By replacing the background, cluttered or unattractive backgrounds in the original image can be removed, enhancing the image's visual effect and appeal. During this process, users can choose a suitable background to replace according to their needs, thus achieving personalized image creation. Image background replacement technology is not only applied to personal photo enhancement but also widely used in commercial advertising, film special effects, virtual reality, and many other fields. Especially for industries that require frequent image processing (such as advertising and film), image background replacement technology can significantly improve work efficiency. Thanks to improvements in computer hardware performance and continuous algorithm optimization, image processing technology has also developed rapidly in recent years.

[0030] Image processing technology, through image processing algorithms, can identify and separate the subject and background in an image, allowing users to replace the original background of an initial image with a new scene according to their preferences, scene requirements, or creative ideas. However, in scenarios such as e-commerce product displays and advertising production that require batch processing of multiple images, traditional background replacement methods often require users to replace the background of each image individually. This process involves a large amount of repetitive and tedious manual operation, which not only consumes a lot of users' time and energy but also seriously affects the overall processing efficiency of batch images.

[0031] Therefore, this application provides an image background replacement method to solve the technical problem of low processing efficiency in image background replacement.

[0032] Please see Figure 1 , Figure 1 This is an exemplary system architecture diagram of an image background replacement method provided in an embodiment of this application.

[0033] like Figure 1 As shown, the system architecture may include a terminal 101, a network 102, and a server 103. The network 102 serves as the medium for providing a communication link between the terminal 101 and the server 103. The network 102 may include various types of wired or wireless communication links, such as wired communication links including fiber optic cables, twisted-pair cables, or coaxial cables, and wireless communication links including Bluetooth communication links, Wireless-Fidelity (Wi-Fi) communication links, or microwave communication links, etc.

[0034] Terminal 101 can interact with server 103 via network 102 to receive messages from or send messages to server 103. Alternatively, terminal 101 can interact with server 103 via network 102 to receive messages or data sent to server 103 by other users. Terminal 101 can be hardware or software. When terminal 101 is hardware, it can be various electronic devices, including but not limited to smartphones, tablets, laptops, and desktop computers. When terminal 101 is software, it can be installed in the aforementioned electronic devices and can be implemented as multiple software programs or software modules (e.g., to provide distributed services) or as a single software program or software module; no specific limitation is made here.

[0035] Server 103 can be a business server providing various services. It should be noted that server 103 can be either hardware or software. When server 103 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When server 103 is software, it can be implemented as multiple software programs or software modules (e.g., used to provide distributed services), or as a single software program or software module; no specific limitations are made here.

[0036] Alternatively, the system architecture may not include server 103. In other words, server 103 may be an optional device in the embodiments of this specification. That is, the method provided in the embodiments of this specification can be applied to a system structure that only includes terminal 101. The embodiments of this application do not limit this.

[0037] In this embodiment, terminal 101 first responds to the user's image upload operation on at least two initial images by removing the initial background from each initial image to obtain the corresponding main image of each initial image; further, when the user needs to replace the background of a certain theme, terminal 101 responds to the background processing request triggered by the user for the target background theme by generating a background image that conforms to the target background theme for each main image of the material; further, terminal 101 merges each main image of the material and the corresponding background image to obtain the background replacement image corresponding to each initial image, and displays each background replacement image in the image display area of ​​the terminal display interface.

[0038] It should be understood that Figure 1 The number of terminals, networks, and servers shown is only illustrative; the number can be any number of terminals, networks, and servers depending on the implementation requirements.

[0039] Please see Figure 2 , Figure 2 This is a flowchart illustrating an image background replacement method provided in an embodiment of this application. The execution entity in this embodiment can be a terminal performing image background replacement, a processor within the terminal performing the image background replacement method, or an image background replacement service within the terminal performing the image background replacement method. For ease of description, the following example uses a processor within the terminal as the execution entity to illustrate the specific execution process of the image background replacement method.

[0040] like Figure 2 As shown, an image background replacement method may include at least:

[0041] S202. In response to the user's image upload operation on at least two initial images, remove the initial background from each initial image to obtain the main image of the material corresponding to each initial image.

[0042] Alternatively, with the booming development of the e-commerce industry, the demand for image processing in product display, advertising production, and other fields is increasing, especially when dealing with scenarios requiring batch processing of multiple images. Traditional background replacement methods are proving inadequate. Previous image background replacement methods often required users to open each image individually and perform a series of complex operations such as background identification, selection, deletion, and addition of new backgrounds for each image. Furthermore, when batch processing images, users may need to replace the backgrounds of multiple images with images of the same style. However, the backgrounds of each image may differ significantly in terms of scene, lighting, etc., leading to the need for users to perform background replacement or modification multiple times for each image. Therefore, such image background replacement processes are not only extremely time-consuming and labor-intensive but also highly susceptible to inconsistencies and inefficiencies due to human factors.

[0043] Optionally, in order to meet users' needs for simultaneous processing of multiple images, an entry point for uploading multiple images at the same time can be provided to users in the terminal's display interface, so that users can upload multiple images at once, which facilitates subsequent batch processing of images.

[0044] Specifically, please refer to Figure 3 , Figure 3 This is a schematic diagram of an image upload interface in an image background replacement method provided in an embodiment of this application. The terminal's display interface 300 includes an image display area 310, which is used to display images being processed and processed images. When the user has not yet uploaded an image, such as... Figure 3 As shown in (A), an "Image Upload" button can be displayed in the image display area 310. When a user triggers the "Upload" button on the screen using a mouse, keyboard, touch, or other means, they can select at least two initial images from the pop-up image path. After the user selects the images and clicks "Confirm," these selected initial images can be loaded into the image background replacement process. In another feasible implementation, such as... Figure 3 As shown, the image display area 310 can also directly support users to upload multiple images via "drag and drop" and "copy and paste". Users can drag the selected image set directly into the indicator box in the image display area 310, or copy the image set and then paste it into the indicator box. The terminal can respond promptly to the user's image upload operation of at least two initial images. It should be noted that users can also upload only one image. The image processing flow for a single image is the same as that for multiple images, and will not be described again in this embodiment.

[0045] Optionally, after determining the multiple initial images uploaded by the user, it is necessary to remove the original background from each initial image to obtain the corresponding main image. The main image is the primary object in the image, such as a building, person, or object that occupies a large portion of the image. The main image and background occupy different positions and proportions in the image. Therefore, based on the distinguishing features between the main image and background, an image segmentation algorithm can be used to identify the initial background elements in each image, separating the background from the main image. The resulting main image will have the same main area as the initial image, while the background area will be filled with a uniform solid color or a simple pattern. After obtaining the main image, as follows... Figure 3 As shown in (B), these main images of the materials can be displayed in the image display area 310 of the terminal display interface so that users can view the background removal effect, check whether the cropping of the main material is correct, and improve the image effect of subsequent background replacement.

[0046] Furthermore, machine learning and deep learning technologies can be introduced to remove the initial background. A pre-trained matting model can automatically learn and identify the main features in the image, achieving fast and accurate background separation and replacement. This model excels at batch processing large numbers of images, significantly improving work efficiency while ensuring consistency and high quality in background removal results.

[0047] S204. In response to the background processing request triggered by the user for the target background theme, generate background images that conform to the target background theme for each main image of the material.

[0048] Optionally, in the image processing flow, the initial backgrounds of multiple user-uploaded initial images have been removed, so that the terminal display interface shows the user these main subject images containing only the subject. Next, please refer to... Figure 4 , Figure 4 This is a schematic diagram of the background processing interface in an image background replacement method provided in an embodiment of this application. For example... Figure 4 As shown in (A), in addition to the image display area 310, the terminal display interface 300 also includes a background replacement operation area 410 next to the image display area 310. The background replacement operation area 410 provides users with various fill styles for the background area of ​​the main image and a variety of selectable background themes. This area has a built-in library of background materials in various styles, covering natural scenery, cityscapes, abstract art, festival celebrations, and more, to meet the diverse aesthetic and needs of users. Within this area, users can select the fill style for the background area of ​​the main image and choose the target background theme for image replacement according to their own needs.

[0049] Furthermore, when a user initiates a background processing request for a specific target background theme, the terminal can generate background images that conform to the target background theme for each main image of the source material, based on the characteristics of the target background theme. These backgrounds are not only harmonious in color and unified in style, but also complement the original source material in detail, creating a refreshing visual effect.

[0050] S206. Merge the main images of each material with the corresponding background images to obtain the background replacement images corresponding to each initial image, and display each background replacement image in the image display area of ​​the terminal display interface.

[0051] Optionally, after generating background images for each main image, the next step is the fusion stage, which directly affects the final image effect. This stage merges each main image with its corresponding background image to obtain a background replacement image for each initial image. During fusion, the main image and its corresponding background image must be seamlessly integrated to ensure natural and smooth edge transitions and harmonious lighting effects. Furthermore, users can be provided with more adjustment options, allowing them to fine-tune the background replacement image as a whole, or specific background or main image areas, such as adjusting background brightness, contrast, saturation, or applying filter effects to meet their personalized pursuit of the final image effect.

[0052] Furthermore, such as Figure 4 As shown in (B), after obtaining all the background replacement images, they can be further displayed in the image display area 310 of the terminal display interface, where users can view each image. The entire background replacement process, from the precise identification of materials to the intelligent generation of background images, and finally the fusion of effects, allows users to easily obtain a batch of background images that match the target background theme with simple batch uploads and style selection operations. This greatly improves the convenience and efficiency of image processing and ensures the uniformity of background style among a batch of images, meeting users' needs for batch image processing.

[0053] Optionally, after completing the background replacement operation of the initial image, a highly flexible editing environment is also provided for the user, allowing the user to further undo or recreate the processed image according to personal preferences or design needs. When the user decides to recreate the image that has been background replaced, the background in the background replacement image needs to be undone first. At this time, the terminal can intelligently recognize the fill processing operation triggered by the user for the target preset style. In this process, all the complex replacement effects previously applied to the background area will be undone, and the background area will be filled with a new style according to the latest background fill style selected by the user. For example, the "target fill style" is one of the multiple selectable "fill styles" selected by the user. There are many selectable fill styles, including but not limited to: (1) Mosaic style: The color and arrangement of the mosaic can be customized to meet the needs of different scenes and atmospheres; (2) Single color style: A rich color palette is provided for the user to choose from, including black, white, gray or bright colors, or even gradient effects; (3) Texture style: In addition to simple color fill, the user can also choose various natural or artificial textures as backgrounds, such as wood texture, fabric texture, marble texture, etc.

[0054] In this embodiment, an image background replacement method is provided. In response to a user's image upload operation of at least two initial images, the initial background of each initial image is removed to obtain the corresponding main image. In response to a background processing request triggered by the user for a target background theme, a background image conforming to the target background theme is generated for each main image. The main images and corresponding background images are then merged to obtain a background replacement image for each initial image. These background replacement images are then displayed in the image display area of ​​the terminal display interface. Users can upload multiple images at once through the image upload operation. After uniformly segmenting the main images of these simultaneously uploaded images to obtain the main images corresponding to each initial image, the user can further select their desired style as the target background theme for replacing each image. After the user selects the target background theme, background images belonging to the target background theme are generated for each main image. By merging the main images and corresponding backgrounds, the effect of batch replacing multiple initial images with backgrounds of a specific style is achieved. This method generates different backgrounds for multiple images but belonging to the same theme, improving the efficiency of image background replacement and ensuring the uniformity of background style among a batch of images, thus meeting the user's needs for batch image processing.

[0055] Please see Figure 5 , Figure 5 This is a flowchart illustrating an image background replacement method provided in an embodiment of this application.

[0056] like Figure 5 As shown, an image background replacement method may include at least:

[0057] S502, In response to the user's image upload operation on at least two initial images, remove the initial background from each initial image to obtain the main image of the material corresponding to each initial image.

[0058] For details regarding step S502, please refer to the description in step S202; it will not be repeated here.

[0059] S504. Generate the cutout optimization control corresponding to the main image of each material.

[0060] Optionally, when automatically removing the initial background of the initial image, the division between the subject and background may differ from the user's expectations, such as insufficiently smooth edges, missing subject edges, or redundant background edges. Therefore, to obtain a subject image that meets the user's needs, the user can be allowed to perform further manual background removal adjustments on the subject image.

[0061] Specifically, when the main image of the source material is displayed in the image display area of ​​the terminal display interface, dedicated background removal optimization controls corresponding to each main image of the source material can be automatically generated simultaneously. Each background removal optimization control is displayed in a suitable manner, corresponding one-to-one with each main image of the source material, such as... Figure 3 As shown in (B), each main image can have a corresponding cutout optimization control in the upper right corner. These controls are displayed in an intuitive and easy-to-understand way, allowing users to clearly identify the operations that can be performed at this time.

[0062] S506. If a user triggers an operation on the target cutout optimization control, the cutout processing area corresponding to the target cutout optimization control is displayed on the terminal display interface. The cutout processing area includes at least the cutout operation area of ​​the target initial image corresponding to the target cutout optimization control.

[0063] Optionally, when a user wants to adjust the cutout of a target image, a trigger operation will be executed on the target cutout optimization control corresponding to the target image, such as clicking, double-clicking, or long-pressing. When a trigger operation is received for the target cutout optimization control, the cutout processing area corresponding to the target cutout optimization control will be displayed on the terminal display interface.

[0064] Optionally, such as Figure 6 As shown in the schematic diagram of the cutout processing area in a terminal display interface provided in this application embodiment, the cutout processing area 610 includes at least a cutout operation area 620 for the target initial image corresponding to the target cutout optimization control. Within the cutout operation area 620, not only is the cutout result of the current main image displayed, but it also includes a series of tools and functions to support the cutout operation. Users can utilize these tools and functions for fine-tuning the cutout. These tools include, but are not limited to: a freeform selection brush, allowing users to hand-draw complex cutout boundaries; edge smoothing and feathering tools, used to optimize the natural transition of cutout edges; and intelligent recognition and repair functions, capable of automatically detecting and correcting flaws or breaks caused by improper cutout. Through the comprehensive use of these tools, users can easily achieve precise control and optimization of the cutout area in the target initial image.

[0065] S508. Based on the user's cutout operation on the target initial image in the cutout operation area, modify the target material main image corresponding to the target initial image.

[0066] Optionally, with each user's operation within the cutout area, such as erasing, patching, brush adjustment, resetting, undoing, or screen movement, the terminal can capture and process these changes in real time, dynamically modifying the target subject image corresponding to the initial target image. Through the user's active adjustments, a subject image that meets their needs can be obtained, serving as the basis for subsequent background replacement.

[0067] S510. Display the modified target material's main image in the effect preview area.

[0068] Optionally, such as Figure 6 As shown, the cutout processing area 610 also includes an effect preview area 630 for the target material main image corresponding to the target cutout optimization control. As the user performs cutout operations, the effect preview area 630 can display the result of each cutout operation. This process not only ensures the instant visibility of the cutout result, but also greatly improves the efficiency and flexibility of the editing work.

[0069] Optionally, once the user obtains a satisfactory main image, they can use the "Complete Modification" control in the cutout processing area to confirm that the main image displayed in the current effect preview area is the final modified result, and return to the original image display area to continue with subsequent background generation and replacement operations. Alternatively, if the user needs to restore the main image to its original state, they can use the "Cancel" control in the cutout processing area to cancel the current active modification operation and continue with the automatically cutout main image for subsequent background generation and replacement.

[0070] S512. In response to the background processing request triggered by the user for the target background theme, generate background images that conform to the target background theme for each main image of the material.

[0071] S514. Merge the main images of each material with the corresponding background images to obtain the background replacement images corresponding to each initial image, and display each background replacement image in the image display area of ​​the terminal display interface.

[0072] For details regarding steps S512-S514, please refer to the detailed descriptions in steps S204-S206, which will not be repeated here.

[0073] In this embodiment, an image background replacement method is provided. After removing the initial background from each initial image to obtain the corresponding main image, a cutout optimization control is generated for each main image to support further manual cutout adjustments by the user. If a user triggers an operation on the target cutout optimization control, the cutout processing area corresponding to the target cutout optimization control is displayed on the terminal display interface. The cutout operation area of ​​the cutout processing area not only displays the cutout result of the current main image but also includes a series of tools and functions to support cutout operations. Users can use these tools and functions to perform fine-tuning of the cutout. With each operation by the user in the cutout operation area, the terminal can capture and process these changes in real time, dynamically modifying the target main image corresponding to the target initial image. Simultaneously, with each cutout operation performed by the user, the effect preview area of ​​the cutout processing area displays the result of each cutout operation. This process not only ensures the immediate visibility of the cutout results but also greatly improves the efficiency and flexibility of the editing work.

[0074] Please see Figure 7 , Figure 7 This is a flowchart illustrating an image background replacement method provided in an embodiment of this application.

[0075] like Figure 7 As shown, an image background replacement method may include at least:

[0076] S702, in response to the user's image upload operation on at least two initial images, identify and divide the subject region and background region in each initial image.

[0077] Optionally, in the process of removing the initial background from the initial image, image recognition technology, such as convolutional neural networks (CNNs) in deep learning algorithms, is first used to identify the subject region and background region in each initial image. The subject region typically refers to the part of the image that occupies the visual center and expresses the core content, such as people, animals, buildings, or specific objects; while the background region refers to the remaining parts surrounding the subject, used to complement or create atmosphere. Through algorithms such as edge detection and color contrast analysis, the boundaries between the two are accurately defined, ensuring the accuracy of subsequent processing.

[0078] S704. Remove the initial background from the background area and fill it according to the preset style. Reassemble the background area and the main body area of ​​the preset style to obtain the material main image corresponding to each initial image.

[0079] Optionally, after clearly distinguishing the subject from the background, the initial background elements in the background area are further removed. This process not only requires clean and thorough removal but also needs to maintain a natural transition at the edges of the subject, avoiding incompleteness of the subject in the initial image and the creation of harsh boundaries or color discontinuities. Simultaneously, the background area is filled with various preset background styles. These preset styles may include solid color backgrounds, gradient backgrounds, textured backgrounds, or artistic backgrounds designed according to a specific theme. The preset styles can be default or user-selected.

[0080] Optionally, after the background replacement is complete, the processed background area needs to be stitched together with the original subject area. This process involves fine-tuning color balance, lighting and shadow coordination, and perspective to ensure a natural blend between the new background and the subject. During this process, overall image detail optimization can also be performed, such as sharpening subject edges, adjusting brightness and contrast, and enhancing color saturation.

[0081] S706. In response to a background processing request triggered by a user for a target background theme, generate background images that conform to the target background theme for each main image of the material.

[0082] S708. Merge the main images of each material with the corresponding background images to obtain the background replacement images corresponding to each initial image, and display each background replacement image in the image display area of ​​the terminal display interface.

[0083] For details regarding steps S706-S708, please refer to the detailed descriptions in steps S204-S206, which will not be repeated here.

[0084] S710. Determine the subject replacement image uploaded by the user, remove the original background from the subject replacement image to obtain the replacement material subject image corresponding to the subject replacement image.

[0085] Optionally, after obtaining the background replacement image, the user may be satisfied with the background and want to apply it directly to images of other subjects. In this case, the user could be allowed to replace the subject portion of the background replacement image to meet their subject replacement needs.

[0086] Optionally, users can upload an image to replace the current subject. The original background in the replacement image can be removed based on the user's upload, resulting in the replacement subject image.

[0087] S712. Determine the target background area of ​​the target background replacement image selected by the user, and merge the current background in the target background area with the main image of the replacement material to obtain the background replacement image corresponding to the main image replacement image.

[0088] Optionally, after selecting the target background replacement image for which the subject wants to be replaced, the user determines the target background area of ​​the target background replacement image, and merges the current background in the target background area with the subject image to obtain the background replacement image corresponding to the subject replacement image. The processing steps for dividing the subject and background in the subject replacement image can be similar to those for the initial image, and will not be elaborated further in this embodiment.

[0089] S714. In response to a user's download request, determine the user's download permission level and the user's download settings.

[0090] Optionally, users can download processed images from the image display area to their local devices for personalized use. The terminal can determine a download request by triggering the "Download" control on the terminal's display interface. Upon receiving a download request, a rigorous verification process is first performed to ensure the request originates from a legitimate and authenticated user. Subsequently, the target resource information in the request is parsed to clarify the specific content the user wishes to download.

[0091] Optionally, to protect image copyright information, a built-in watermark function can be implemented to add various watermark styles to images downloaded locally. When adding a watermark, the specific watermark style for each user can be determined based on their download permission level and personalized settings. This embodiment supports users managing their accounts to upgrade their download permission levels, thus meeting the needs of users with different download requirements. When a user needs to download, their download permission level needs to be determined based on their account information and a preset permission management strategy. This process may involve checking the user's role (e.g., ordinary user, member), historical behavior records (e.g., whether there are any unauthorized download records), and whether related fees have been paid. Users with different permission levels can enjoy different download permissions and service quality. In addition to determining download permissions, the user's personalized download settings can be further queried and parsed. This information may include, but is not limited to, the watermark's activation status, watermark transparency, location preferences (e.g., top left, bottom right), watermark text content (e.g., user ID, copyright statement), and whether specific format or size conversions of the downloaded image are allowed.

[0092] S716. Determine the target watermark style based on the download permission level and download settings information.

[0093] Optionally, the target watermark style for a user is determined based on the user's download permission level and download settings. The target watermark style specifies the watermark's activation status, transparency, color, font, size, and position to ensure that the watermark effectively protects copyright without excessively affecting the image's visual appeal.

[0094] S718. Add a watermark to the target background replacement image corresponding to the download request according to the target watermark style, and download the target background replacement image with the watermark.

[0095] Optionally, after determining the target watermark style, the target background replacement image requested by the user is processed. This typically includes loading the target background replacement image file, adding the watermark at a specified location according to the watermark style, and possibly performing necessary image blending processing to ensure a natural integration of the watermark with the image background, avoiding any abruptness. In one feasible implementation, a quality check is also performed after adding the watermark to ensure that the addition of the watermark does not introduce any visible flaws or errors, and the image is formatted or resized according to the user's download settings to meet the user's specific needs.

[0096] Optionally, the processed target background replacement image with the watermark can be downloaded. Download steps include generating a download link, initiating a file transfer protocol (such as HTTP download), or directly sending the file to the user's specified storage location (such as a cloud storage service). Once the entire download process is complete, relevant operation logs will be uploaded and stored in the cloud, including download time, downloaded content, and user information. Simultaneously, a notification of successful download or a confirmation link will be displayed to the user on the terminal, enhancing the user experience.

[0097] This application provides a method for replacing the background of an image. After replacing the background of an initially uploaded image, if a user needs to change the main product image, they can directly upload a new product image, extract the main subject, and then stitch the new main subject and the current background together to obtain a new background-replaced image. When a user wants to download a specific background-replaced image, the method determines whether to add a watermark and the watermark style based on user permissions and user-defined settings, thereby satisfying various download needs and improving the user experience.

[0098] Please see Figure 8 , Figure 8 This is a structural block diagram of an image background replacement device provided in an embodiment of this application. Figure 8 As shown, the image background replacement device 800 includes:

[0099] The image upload module 810 is used to respond to the user's image upload operation on at least two initial images, and remove the initial background from each initial image to obtain the material main image corresponding to each initial image;

[0100] Background generation module 820 is used to generate background images that conform to the target background theme for each main image of the material in response to a background processing request triggered by the user for the target background theme;

[0101] Background replacement module 830 is used to merge the main images of each material with the corresponding background images to obtain the background replacement images corresponding to each initial image, and display each background replacement image in the image display area of ​​the terminal display interface.

[0102] Optionally, the image background replacement device 800 further includes: a manual modification module for generating cutout optimization controls corresponding to the main images of each material; if a user trigger operation on the target cutout optimization control is obtained, the cutout processing area corresponding to the target cutout optimization control is displayed on the terminal display interface, and the cutout processing area includes at least the cutout operation area of ​​the target initial image corresponding to the target cutout optimization control; based on the cutout operation performed by the user on the target initial image in the cutout operation area, the target material main image corresponding to the target initial image is modified.

[0103] Optionally, the cutout processing area also includes an effect preview area for the target material main image corresponding to the target cutout optimization control; the image background replacement device 800 also includes a cutout preview module, used to display the modified target material main image in the effect preview area.

[0104] Optionally, the image uploading module 810 is also used to identify and divide the main body area and background area in each initial image; remove the initial background in the background area and fill it according to a preset style, and re-sew the background area and main body area of ​​the preset style to obtain the material main image corresponding to each initial image.

[0105] Optionally, the image background replacement device 800 further includes a fill reset module, which is used to remove the current background in the background area of ​​each background replacement image in response to a fill processing operation triggered by the user for a target preset style, and fill the background area according to the target preset style.

[0106] Optionally, the image background replacement device 800 further includes: a subject replacement module, used to determine the subject replacement image uploaded by the user, remove the original background from the subject replacement image to obtain the replacement material subject image corresponding to the subject replacement image; determine the target background area of ​​the target background replacement image selected by the user, and merge the current background in the target background area with the replacement material subject image to obtain the background replacement image corresponding to the subject replacement image.

[0107] Optionally, the image background replacement device 800 further includes: a download module, configured to respond to a user's download request, determine the user's download permission level and download settings information; determine a target watermark style based on the download permission level and download settings information; add a watermark identifier to the target background replacement image corresponding to the download request according to the target watermark style, and download the target background replacement image with the watermark identifier.

[0108] In this embodiment, an image background replacement device is provided. The device includes an image upload module, configured to, in response to a user's image upload operation of at least two initial images, remove the initial background from each initial image to obtain a corresponding main image; a background generation module, configured to, in response to a user's background processing request triggered by a target background theme, generate a background image conforming to the target background theme for each main image; and a background replacement module, configured to, merge each main image and its corresponding background image to obtain a background replacement image for each initial image, and display each background replacement image in the image display area of ​​the terminal display interface. Users can upload multiple images at once. These simultaneously uploaded images undergo a unified subject segmentation process, resulting in subject images for each initial image. Users can then select their desired style as the target background theme for each image. After selecting the target background theme, background images belonging to that theme are generated for each subject image. Finally, the subject images and their corresponding backgrounds are merged, achieving the effect of batch replacing multiple initial images with backgrounds of a specific style. This method of generating different backgrounds for multiple images but belonging to the same theme improves the efficiency of image background replacement and ensures the uniformity of background style across a batch of images, meeting users' needs for batch image processing.

[0109] This application also provides a computer storage medium that can store multiple instructions adapted for loading by a processor and executing the steps of any of the methods described in the above embodiments.

[0110] Please see Figure 9 , Figure 9 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application. Figure 9 As shown, terminal 900 may include: at least one terminal processor 901, at least one network interface 904, user interface 903, memory 905, and at least one communication bus 902.

[0111] The communication bus 902 is used to enable communication between these components.

[0112] The user interface 903 may include a display screen and a camera. Optionally, the user interface 903 may also include a standard wired interface and a wireless interface.

[0113] The network interface 904 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).

[0114] The terminal processor 901 may include one or more processing cores. The terminal processor 901 connects to various parts within the terminal 900 using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 905, and by calling data stored in the memory 905. Optionally, the terminal processor 901 may be implemented using at least one hardware form selected from Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The terminal processor 901 may integrate one or more of the following: a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), and a modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content to be displayed on the screen; and the modem handles wireless communication. It is understood that the modem may also be implemented as a separate chip without being integrated into the terminal processor 901.

[0115] The memory 905 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 905 may include a non-transitory computer-readable storage medium. The memory 905 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 905 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), instructions for implementing the various method embodiments described above, etc.; the data storage area may store data involved in the various method embodiments described above, etc. Optionally, the memory 905 may also be at least one storage device located remotely from the aforementioned terminal processor 901. Figure 9 As shown, the memory 905, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an image background replacement program.

[0116] exist Figure 9 In the terminal 900 shown, the user interface 903 is mainly used to provide an input interface for the user and to obtain the user's input data; while the terminal processor 901 can be used to call the image background replacement program stored in the memory 905 and specifically perform the following operations:

[0117] In response to a user's image upload operation for at least two initial images, the initial background in each initial image is removed to obtain the corresponding main image of each initial image;

[0118] In response to a user's background processing request triggered by a target background theme, generate background images that conform to the target background theme for each main image of the material;

[0119] By merging the main images of each material with their corresponding background images, a background replacement image corresponding to each initial image is obtained, and each background replacement image is displayed in the image display area of ​​the terminal display interface.

[0120] In some embodiments, after the terminal processor 901 removes the initial background from each initial image to obtain the corresponding main image of each initial image, it further performs the following steps: generating a cutout optimization control corresponding to each main image of the material; if a user trigger operation on the target cutout optimization control is obtained, the cutout processing area corresponding to the target cutout optimization control is displayed in the terminal display interface, the cutout processing area including at least the cutout operation area of ​​the target initial image corresponding to the target cutout optimization control; based on the cutout operation performed by the user on the target initial image in the cutout operation area, the target main image of the material corresponding to the target initial image is modified.

[0121] In some embodiments, the cutout processing area also includes an effect preview area for the target material main image corresponding to the target cutout optimization control; after the terminal processor 901 performs the cutout operation based on the user's cutout operation area on the target initial image and modifies the target material main image corresponding to the target initial image, it further performs the following steps: displaying the modified target material main image in the effect preview area.

[0122] In some embodiments, when the terminal processor 901 removes the initial background from each initial image to obtain the material subject image corresponding to each initial image, it specifically performs the following steps: identifying and dividing the subject area and background area in each initial image; removing the initial background in the background area and filling it according to a preset style; re-splicing the background area and subject area of ​​the preset style to obtain the material subject image corresponding to each initial image.

[0123] In some embodiments, after the terminal processor 901 displays each background replacement image in the image display area of ​​the terminal display interface, it further performs the following steps: in response to a fill processing operation triggered by the user for a target preset style, it removes the current background in the background area of ​​each background replacement image and fills the background area according to the target preset style.

[0124] In some embodiments, after the terminal processor 901 displays each background replacement image in the image display area of ​​the terminal display interface, it further performs the following steps: determining the subject replacement image uploaded by the user, removing the original background from the subject replacement image to obtain the replacement material subject image corresponding to the subject replacement image; determining the target background area of ​​the target background replacement image selected by the user, and merging the current background in the target background area with the replacement material subject image to obtain the background replacement image corresponding to the subject replacement image.

[0125] In some embodiments, the terminal processor 901 further performs the following steps: in response to a user's download request, determining the user's download permission level and the user's download settings information; determining a target watermark style based on the download permission level and download settings information; adding a watermark identifier to the target background replacement image corresponding to the download request according to the target watermark style, and downloading the target background replacement image with the watermark identifier.

[0126] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0127] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0128] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this specification are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The aforementioned available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., Digital Versatile Discs (DVDs)), or semiconductor media (e.g., Solid State Disks (SSDs)).

[0129] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0130] Furthermore, it should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in the embodiments of this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the initial images involved in this application were obtained under full authorization.

[0131] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0132] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0133] The above is a description of an image background replacement method, apparatus, storage medium, and terminal provided in this application. For those skilled in the art, based on the ideas of the embodiments of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for replacing an image background, characterized in that, The method includes: In response to a user's image upload operation for at least two initial images, the initial background in each initial image is removed to obtain the corresponding main image of each initial image; In response to the background processing request triggered by the user for the target background theme, background images that conform to the target background theme are generated for each main image of the material; By merging the main images of each material with their corresponding background images, a background replacement image corresponding to each initial image is obtained, and each background replacement image is displayed in the image display area of ​​the terminal display interface.

2. The method according to claim 1, characterized in that, After removing the initial background from each initial image to obtain the corresponding main image of each initial image, the process further includes: Generate background removal optimization controls for each main image source; If the user triggers an operation on the target cutout optimization control, the cutout processing area corresponding to the target cutout optimization control is displayed on the terminal display interface. The cutout processing area includes at least the cutout operation area of ​​the target initial image corresponding to the target cutout optimization control. Based on the background removal operation performed by the user on the target initial image in the background removal operation area, the target material main image corresponding to the target initial image is modified.

3. The method according to claim 2, characterized in that, The image cutout processing area also includes an effect preview area for the target material's main image corresponding to the target image cutout optimization control; The method, after modifying the target material subject image corresponding to the target initial image based on the user's cutout operation on the target initial image in the cutout operation area, further includes: The modified target material image is displayed in the effect preview area.

4. The method according to claim 1, characterized in that, The process of removing the initial background from each initial image to obtain the corresponding main image includes: Identify and segment the subject region and background region in each initial image; Remove the initial background from the background area and fill it with a preset style. Then, reassemble the background area and the main body area according to the preset style to obtain the material main image corresponding to each initial image.

5. The method according to claim 1, characterized in that, After displaying each background replacement image in the image display area of ​​the terminal display interface, the method further includes: In response to the user's fill processing operation triggered by the target preset style, the current background in the background area of ​​each background replacement image is removed, and the background area is filled according to the target preset style.

6. The method according to claim 1, characterized in that, After displaying each background replacement image in the image display area of ​​the terminal display interface, the method further includes: Determine the subject replacement image uploaded by the user, and remove the original background from the subject replacement image to obtain the replacement material subject image corresponding to the subject replacement image; The target background region of the target background replacement image selected by the user is determined, and the current background in the target background region is merged with the main image of the replacement material to obtain the background replacement image corresponding to the main image replacement image.

7. The method according to claim 1, characterized in that, The method further includes: In response to the user's download request, determine the user's download permission level and the user's download settings information; The target watermark style is determined based on the download permission level and the download settings information; Add a watermark to the target background replacement image corresponding to the download request according to the target watermark style, and download the target background replacement image with the watermark.

8. An image background replacement device, characterized in that, The device includes: The image upload module is used to respond to the user's image upload operation of at least two initial images, remove the initial background from each initial image to obtain the corresponding main image of each initial image; The background generation module is used to respond to the background processing request triggered by the user for the target background theme and generate background images that conform to the target background theme for each main image of the material. The background replacement module is used to merge the main images of each material with the corresponding background images to obtain the background replacement images corresponding to each initial image, and then display each background replacement image in the image display area of ​​the terminal display interface.

9. A computer storage medium, characterized in that, The computer storage medium stores a plurality of instructions adapted for loading by a processor and executing the steps of the method as described in any one of claims 1 to 7.

10. A terminal, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method as described in any one of claims 1 to 7.