Image processing method and device, electronic equipment and storage medium

By cropping images on the client side and performing background removal and secondary cropping on the server side, the problem of low background removal efficiency on the client side is solved, the transmission speed and server processing efficiency are improved, and the burden on the client side is reduced.

CN115578558BActive Publication Date: 2026-04-07BRILLIANT JUPITER PTE LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-09
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Image background removal on the client side is inefficient and increases processing burden. How can we improve the efficiency of image background removal and reduce the processing burden on the client side?

Method used

The first sub-image is generated by cropping the image to be processed on the client side and then sent to the server for background removal. The second sub-image is then cropped to generate the target image containing the target object and returned to the client.

Benefits of technology

It improves the image transmission speed between the client and the server, enhances the server's processing efficiency, reduces the client's waiting time, and reduces the processing burden.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115578558B_ABST
    Figure CN115578558B_ABST
Patent Text Reader

Abstract

The application provides an image processing method and device, electronic equipment and storage medium, wherein the method comprises the following steps: receiving an image background removal request sent by a client, wherein the image background removal request comprises a first sub-image, and the first sub-image is obtained by performing cropping processing on a to-be-processed image; performing background removal processing on the first sub-image to obtain a second sub-image; performing cropping processing on the second sub-image to obtain a target image containing a target object; and sending an image background removal response to the client, wherein the image background removal response comprises the target image. Thus, by performing twice cropping processing on the image, the transmission speed of the image between the client and the server can be improved, and the server performs background removal processing on the cropped image, so that the processing efficiency of the server and the efficiency of background removal in the image are improved, thereby reducing the waiting time of the client.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, and particularly relates to an image processing method and device, electronic equipment and a storage medium. BACKGROUND

[0002] In the related art, image background removal processing is usually operated locally on a client. However, the image background removal locally on the client is limited by the size of resources on the client side, has low processing efficiency, and increases the processing burden of the client.

[0003] Therefore, how to improve the efficiency of background removal in an image and reduce the processing burden of the client is very important. SUMMARY

[0004] The present application provides an image processing method and device, electronic equipment and a storage medium to improve the transmission speed of images between a client and a server by twice image cropping processing, improve the processing efficiency of the server by the server performing background removal on the cropped image, improve the efficiency of background removal in an image, and thus reduce the waiting time of the client. In addition, the processing burden of the client can be reduced by the server performing background removal on the image.

[0005] An image processing method is provided in the first aspect of the present application and applied to a server, and the method comprises the following steps: receiving an image background removal request sent by a client, wherein the image background removal request comprises a first sub-image, and the first sub-image is obtained by cropping processing on a to-be-processed image; performing background removal processing on the first sub-image to obtain a second sub-image in response to the image background removal request; performing cropping processing on the second sub-image to obtain a target image containing a target object; and sending an image background removal response to the client, wherein the image background removal response comprises the target image.

[0006] As a possible implementation manner of the first aspect of the present application, the step of performing background removal processing on the first sub-image to obtain a second sub-image in response to the image background removal request comprises the following steps: performing background identification on the first sub-image to obtain a background region in the first sub-image in response to the image background removal request; adding an alpha channel to each first pixel in the background region; and setting the channel value of the alpha channel of each first pixel in the first sub-image to obtain the second sub-image, wherein the channel value of the alpha channel is used to indicate that the corresponding pixel is transparent.

[0007] As another possible implementation of the first aspect of the present application, the second sub-image is cropped to obtain a target image containing the target object, including: generating a scan line at each boundary of the second sub-image, and determining a scan direction of the corresponding scan line according to the position information of each boundary; for any scan line of each scan line, moving the scan line along the scan direction corresponding to the scan line to scan the first sub-image; in response to the scan line first scanning a second pixel, stopping moving the scan line; wherein the second pixel does not contain an alpha channel; according to the position of each scan line when it stops moving, the second sub-image is cropped to obtain the target image.

[0008] As another possible implementation of the first aspect of the present application, the second sub-image is cropped to obtain a target image containing the target object, including: generating a scan line at each boundary of the second sub-image, and determining a scan direction of the corresponding scan line according to the position information of each boundary; for any scan line of each scan line, moving the scan line along the scan direction corresponding to the scan line to scan the first sub-image; in response to the scan line first scanning a second pixel, stopping moving the scan line; wherein the second pixel does not contain an alpha channel; according to the position of each scan line when it stops moving, the second sub-image is cropped to obtain the target image.

[0009] As another possible implementation of the first aspect of the present application, the second sub-image is cropped to obtain a target image containing the target object, including: generating a scan line at each boundary of the second sub-image, and determining a scan direction of the corresponding scan line according to the position information of each boundary; for any scan line of each scan line, moving the scan line along the scan direction corresponding to the scan line to scan the first sub-image; in response to the scan line first scanning a second pixel, stopping moving the scan line; wherein the second pixel does not contain an alpha channel; according to the position of each scan line when it stops moving, the second sub-image is cropped to obtain the target image.

[0010] As another possible implementation of the first aspect of the present application, the second sub-image is cropped to obtain a target image containing the target object, including: generating a scan line at each boundary of the second sub-image, and determining a scan direction of the corresponding scan line according to the position information of each boundary; for any scan line of each scan line, moving the scan line along the scan direction corresponding to the scan line to scan the first sub-image; in response to the scan line first scanning a second pixel, stopping moving the scan line; wherein the second pixel does not contain an alpha channel; according to the position of each scan line when it stops moving, the second sub-image is cropped to obtain the target image.

[0011] As another possible implementation manner of the first aspect of the present application, the background removal processing of the first sub-image to obtain a second sub-image in response to the image background removal request comprises: in response to the image background removal request, performing background identification on the first sub-image by using a trained image background removal model to obtain a background region in the first sub-image; and performing removal processing on the background region in the first sub-image by using the image background removal model to obtain the second sub-image.

[0012] The second aspect of the present application further provides an image processing method applied to a client, comprising: obtaining a to-be-processed image; performing cropping processing on the to-be-processed image to obtain a first sub-image; sending an image background removal request to a server according to the first sub-image, wherein the image background removal request is used for the server to perform background removal processing on the first sub-image to obtain a second sub-image, and to perform cropping processing on the second sub-image to obtain a target image containing a target object; and receiving an image background removal response sent by the server, wherein the target image is included in the image background removal response.

[0013] As a possible implementation manner of the second aspect of the present application, the cropping processing on the to-be-processed image to obtain a first sub-image comprises: performing target detection on the to-be-processed image to obtain at least one detection frame; determining a target detection frame from the at least one detection frame, wherein the target object is contained in the target detection frame; and cropping an image region in the target detection frame in the to-be-processed image to obtain a first sub-image containing the image region.

[0014] As another possible implementation manner of the second aspect of the present application, the cropping processing on the to-be-processed image to obtain a first sub-image comprises: in response to a framing operation on the to-be-processed image, extracting the first sub-image from the to-be-processed image.

[0015] As another possible implementation manner of the second aspect of the present application, after the to-be-processed image is obtained, the method further comprises: performing preprocessing on the to-be-processed image; and the preprocessing comprises at least one of denoising processing, compression processing, filtering processing and enhancement processing.

[0016] The third aspect of the present application provides an image processing device, applied to a server, the device comprising: a receiving module configured to receive an image background removal request sent by a client, wherein the image background removal request comprises a first sub-image, and the first sub-image is obtained by cropping a to-be-processed image; a processing module configured to perform background removal processing on the first sub-image to obtain a second sub-image in response to the image background removal request; a cropping module configured to crop the second sub-image to obtain a target image containing a target object; and a sending module configured to send an image background removal response to the client, wherein the image background removal response comprises the target image.

[0017] As a possible implementation manner of the third aspect of the present application, the processing module is specifically configured to: perform background identification on the first sub-image to obtain a background region in the first sub-image in response to the image background removal request; add an alpha channel to each first pixel in the background region; and set a channel value of the alpha channel of each first pixel in the first sub-image to obtain the second sub-image, wherein the channel value of the alpha channel is used to indicate that the corresponding pixel is transparent.

[0018] As another possible implementation manner of the third aspect of the present application, the cropping module is specifically configured to: generate a scan line at each boundary of the second sub-image, and determine a scan direction of the corresponding scan line according to position information of each boundary; move the scan line along the scan direction corresponding to the scan line to scan the first sub-image for any scan line in each scan line; stop moving the scan line in response to the scan line scanning a second pixel for the first time; wherein the second pixel does not contain an alpha channel; and crop the second sub-image according to the position of each scan line when the scan line stops moving to obtain the target image.

[0019] As another possible implementation manner of the third aspect of the present application, the cropping module is specifically configured to: crop the second sub-image according to the position of each scan line when the scan line stops moving to crop the image region between the boundary corresponding to the scan line and the position of the scan line when the scan line stops moving from the second sub-image for any scan line in each scan line; and take the cropped second sub-image as the target image.

[0020] As another possible implementation of the third aspect of the present application, the processing module is specifically configured to: in response to the image background removal request, perform semantic segmentation on the first sub-image to obtain each object region containing a same object; determine a target region to which the target object belongs from each of the object regions; take the remaining region of the first sub-image except the target region as a background region in the first sub-image; and set a pixel value of each third pixel in the background region to a set value to obtain the second sub-image.

[0021] As another possible implementation of the third aspect of the present application, the clipping module is specifically configured to: generate a scan line at each boundary of the second sub-image, and determine a scan direction of the corresponding scan line according to position information of each boundary; move the scan line along the scan direction corresponding to the scan line for any one of the scan lines to scan the first sub-image; stop moving the scan line in response to the scan line scanning a fourth pixel for the first time; wherein the pixel value of the fourth pixel is not the set value; and clip the second sub-image according to a position at which each scan line stops moving to obtain the target image.

[0022] As another possible implementation of the third aspect of the present application, the processing module is specifically configured to: in response to the image background removal request, perform background identification on the first sub-image by using a trained image background removal model to obtain a background region in the first sub-image; and perform removal processing on the background region in the first sub-image by using the image background removal model to obtain the second sub-image.

[0023] The fourth aspect of the present application proposes an image processing apparatus applied to a client, the apparatus comprising: an acquisition module configured to acquire a to-be-processed image; a clipping module configured to perform clipping processing on the to-be-processed image to obtain a first sub-image; a sending module configured to send an image background removal request to a server according to the first sub-image, wherein the image background removal request is used for the server to perform background removal processing on the first sub-image to obtain a second sub-image, and to perform clipping processing on the second sub-image to obtain a target image containing a target object; and a receiving module configured to receive an image background removal response sent by the server, wherein the target image is included in the image background removal response.

[0024] As a possible implementation manner of the fourth aspect of the present application, the cropping module is specifically configured to: perform target detection on the to-be-processed image to obtain at least one detection frame; determine a target detection frame from the at least one detection frame, wherein the target detection frame contains the target object; and crop an image region in the target detection frame in the to-be-processed image to obtain a first sub-image containing the image region.

[0025] As another possible implementation manner of the fourth aspect of the present application, the cropping module is specifically configured to: in response to a framing operation on the to-be-processed image, extract the first sub-image from the to-be-processed image.

[0026] As another possible implementation manner of the fourth aspect of the present application, the image processing apparatus further includes a preprocessing module configured to perform preprocessing on the to-be-processed image, wherein the preprocessing includes at least one of denoising processing, compression processing, filtering processing and enhancement processing.

[0027] The fifth aspect of the present application provides an electronic device, which 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 perform the image processing method according to the first aspect of the present application or the image processing method according to the second aspect of the present application.

[0028] The sixth aspect of the present application provides a computer readable storage medium, which stores a computer program, wherein the program is executed by a processor to implement the image processing method according to the first aspect of the present application or the image processing method according to the second aspect of the present application.

[0029] The seventh aspect of the present application provides a computer program product, which includes a computer program, wherein the computer program is executed by a processor to implement the image processing method according to the first aspect of the present application or the image processing method according to the second aspect of the present application.

[0030] The technical scheme provided by the present application has the following beneficial effects:

[0031] The image background removal request sent by the client is received, wherein the image background removal request includes a first sub-image, and the first sub-image is obtained by performing cropping processing on the to-be-processed image. In response to the image background removal request, the first sub-image is subjected to background removal processing to obtain a second sub-image. The second sub-image is subjected to cropping processing to obtain a target image containing a target object. An image background removal response is sent to the client, wherein the image background removal response includes the target image. In this way, the transmission speed of the image between the client and the server can be improved by twice cropping processing of the image. The server performs background removal processing on the cropped image, which can improve the processing efficiency of the server, improve the efficiency of background removal in the image, and thus reduce the waiting time of the client. In addition, the server performs background removal processing on the image, which can reduce the processing burden of the client.

[0032] Additional aspects and advantages of the present application will be made apparent by the following description and the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS

[0033] The above and / or additional aspects and advantages of the present application will become apparent and be readily understood from the following description, taken in conjunction with the accompanying drawings, in which:

[0034] Figure 1 A flowchart of an image processing method provided by Embodiment One of the present application;

[0035] Figure 2 A flowchart of an image processing method provided by Embodiment Two of the present application;

[0036] Figure 3 A flowchart of an image processing method provided by Embodiment Three of the present application;

[0037] Figure 4 A flowchart of an image processing method provided by Embodiment Four of the present application;

[0038] Figure 5 A flowchart of an image processing method provided by Embodiment Five of the present application;

[0039] Figure 6 A to-be-processed image provided by the present application;

[0040] Figure 7 A first sub-image provided by the present application;

[0041] Figure 8 A second sub-image provided by the present application;

[0042] Figure 9A target image schematic diagram provided by an embodiment of the present application;

[0043] Figure 10 A structure schematic diagram of an image processing apparatus provided by an embodiment six of the present application;

[0044] Figure 11 A structure schematic diagram of an image processing apparatus provided by an embodiment seven of the present application;

[0045] Figure 12 A structure schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0046] Embodiments of the present application are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar notations represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by reference to the drawings are exemplary and are intended to explain the present application, and cannot be understood as a limitation of the present application.

[0047] At present, AI (Artificial Intelligence) technology is increasingly developed, among which, the technology of image background removal using AI has reached a usable stage. In the related art, the AI background removal technology of the client often depends on calling through a network API (Application Program Interface), transmitting an image to a server for image background removal processing, and then transmitting the image with the background removed to the client after the image background removal. However, when the image or subject to be removed from the background is changing, the effect of the background removal is often positively correlated with the size or dimension of the image in the above-mentioned AI background removal technology.

[0048] In order to improve the image background removal effect, the present application proposes an image processing method, device, electronic equipment and storage medium to optimize the process of image background removal.

[0049] This application proposes an image processing method, apparatus, electronic device, and storage medium. The method involves receiving an image background removal request from a client, wherein the request includes a first sub-image, which is obtained by cropping an image to be processed. In response to the background removal request, the method performs background removal processing on the first sub-image to obtain a second sub-image; then crops the second sub-image to obtain a target image containing a target object; and finally sends an image background removal response to the client, wherein the response includes the target image. Therefore, by performing image cropping twice, the image transmission speed between the client and server can be improved. Furthermore, the server-side background removal processing on the cropped image improves server-side processing efficiency and background removal efficiency, thereby reducing client waiting time. Additionally, server-side background removal reduces the processing burden on the client.

[0050] The image processing method, apparatus, electronic device, and storage medium of this application are described below with reference to the accompanying drawings.

[0051] Figure 1 This is a schematic flowchart of the image processing method provided in Embodiment 1 of this application.

[0052] The image processing method of this application can be applied to the server.

[0053] like Figure 1 As shown, the image processing method may include the following steps:

[0054] Step 101: Receive an image background removal request sent by the client, wherein the image background removal request includes a first sub-image, wherein the first sub-image is obtained by cropping the image to be processed.

[0055] The client refers to software programs that run on electronic devices and provide services to users.

[0056] Among them, electronic devices can be any device with computing capabilities, such as personal computers, mobile terminals, etc. Mobile terminals can be hardware devices with various operating systems, touch screens and / or displays, such as mobile phones, tablets, personal digital assistants, wearable devices, etc.

[0057] In this embodiment of the application, the image to be processed may be an image that requires background removal processing.

[0058] The number of images to be processed can be one or more, and this application does not impose any restrictions on this.

[0059] It should be noted that the image format of the image to be processed can be JPEG (Joint Photographic Experts Group), PNG (Portable Network Graphics), BMP (Bitmap, also known as raster image or pixel image), etc., and this application does not impose any restrictions on it.

[0060] In this embodiment of the application, in order to reduce the processing load on the server and improve the processing efficiency of the server on the image to be processed, the image to be processed can be cropped on the client side to obtain the first sub-image.

[0061] In this embodiment of the application, the image background removal request may include a first sub-image obtained by cropping the image to be processed.

[0062] In this embodiment, the client can acquire an image to be processed. The method of acquiring the image is not limited; for example, the image to be processed can be an image captured by the client, or it can be an image captured online, such as through web crawling technology. After acquiring the image to be processed, the client can crop the image to obtain a first sub-image, and generate an image background removal request based on the first sub-image. Then, the client can send the image background removal request to the server, and correspondingly, the server can receive the image background removal request sent by the client.

[0063] Step 102: In response to the image background removal request, perform background removal processing on the first sub-image to obtain the second sub-image.

[0064] In this embodiment of the application, the server can respond to an image background removal request by performing background removal processing on the first sub-image to obtain a second sub-image with the background removed.

[0065] Step 103: Crop the second sub-image to obtain the target image containing the target object.

[0066] In the embodiments of this application, the target object can be an object in the foreground of the image, such as a person, animal, item, building, etc., and this application does not limit it.

[0067] In this embodiment of the application, the target image refers to the image region in the second sub-image that contains the target object.

[0068] It should be noted that after the background removal process is performed on the first sub-image, the size of the second sub-image obtained after the background removal process is the same as that of the first sub-image. Only the pixels of the background part of the first sub-image change. That is, since the background area in the second sub-image has been removed, it only contains the useful pixels in the foreground area. Therefore, in order to improve the image transmission speed between the client and the server, the second sub-image can be cropped again to crop the background part of the image in the second sub-image, thereby obtaining a target image containing the target object, that is, obtaining a target image containing the foreground area in the second sub-image.

[0069] Step 104: Send an image background removal response to the client, wherein the image background removal response includes the target image.

[0070] In this embodiment of the application, after obtaining the target image containing the target object, the server can send an image background removal response including the target image to the client. The image background removal response includes the target image.

[0071] The image processing method of this application embodiment receives an image background removal request sent by a client, wherein the image background removal request includes a first sub-image, which is obtained by cropping an image to be processed; in response to the image background removal request, background removal processing is performed on the first sub-image to obtain a second sub-image; the second sub-image is cropped to obtain a target image containing the target object; and an image background removal response is sent to the client, wherein the image background removal response includes the target image. Therefore, by performing image cropping processing twice, the image transmission speed between the client and the server can be improved, and the server's background removal processing on the cropped image can improve the server's processing efficiency and the efficiency of background removal in the image, thereby reducing the client's waiting time. Furthermore, having the background removal processing performed by the server can reduce the processing burden on the client.

[0072] To clearly illustrate how the background removal process is performed on the first sub-image in any embodiment of this application to obtain the second sub-image, this application also proposes an image processing method.

[0073] Figure 2 This is a schematic flowchart of the image processing method provided in Embodiment 2 of this application.

[0074] like Figure 2 As shown, the image processing method may include the following steps:

[0075] Step 201: Receive an image background removal request sent by the client, wherein the image background removal request includes a first sub-image, wherein the first sub-image is obtained by cropping the image to be processed.

[0076] The execution process of step 201 can be found in any embodiment of this application, and will not be described in detail here.

[0077] Step 202: In response to the image background removal request, perform background recognition on the first sub-image to obtain the background region in the first sub-image.

[0078] In this embodiment of the application, image recognition technology can be used to perform background recognition on the first sub-image in order to obtain the background region in the first sub-image.

[0079] Step 203: Add an alpha channel to each first pixel in the background area.

[0080] As one possible implementation, after obtaining the background region in the first sub-image, it can be first determined whether each first pixel in the background region includes an alpha channel. If each first pixel in the background region includes an alpha channel, steps 204-206 can be executed directly. If each first pixel in the background region does not include an alpha channel, an alpha channel can be added to each first pixel in the background region, and steps 204-206 can be executed.

[0081] Step 204: Set the channel value of the alpha channel of each first pixel in the first sub-image to obtain the second sub-image, wherein the channel value of the alpha channel is used to indicate the transparency of the corresponding pixel.

[0082] In the embodiments of this application, the channel value of the alpha channel can be used to indicate the transparency of the corresponding pixel.

[0083] As an example, when the alpha channel is an 8-bit grayscale channel, the transparency information of the corresponding pixels in the image can be recorded using 256 grayscale levels. When the channel value of the alpha channel corresponding to any pixel is 0, it can indicate that the corresponding pixel is transparent.

[0084] As another example, when the alpha channel is a 1-bit channel, the transparency information of the corresponding pixels in the image can be recorded using 0 and 1. When the channel value of the alpha channel corresponding to any pixel is 0, it can indicate that the corresponding pixel is transparent.

[0085] In this embodiment, the alpha channel value of each first pixel in the background region of the first sub-image can be set to obtain the second sub-image. For example, the alpha channel value of each first pixel in the background region of the first sub-image can be set to 0, thereby obtaining a second sub-image with a partially transparent background region.

[0086] Step 205: Crop the second sub-image to obtain the target image containing the target object.

[0087] Step 206: Send an image background removal response to the client, wherein the image background removal response includes the target image.

[0088] The execution process of steps 205 to 206 can be found in the execution process of any embodiment of this application, and will not be described in detail here.

[0089] The image processing method of this application embodiment, in response to an image background removal request, performs background recognition on a first sub-image to obtain a background region in the first sub-image; adds an alpha channel to each first pixel in the background region; and sets the channel value of the alpha channel of each first pixel in the first sub-image to obtain a second sub-image, wherein the channel value of the alpha channel is used to indicate the transparency of the corresponding pixel. Thus, by setting each first pixel in the background region identified based on image recognition technology to be transparent, the background region in the first sub-image can be effectively removed, thereby obtaining a second sub-image with the background removed.

[0090] To clearly illustrate how the second sub-image is cropped in the above embodiments of this application to obtain a target image containing the target object, this application also proposes an image processing method.

[0091] Figure 3 This is a schematic flowchart of the image processing method provided in Embodiment 3 of this application.

[0092] like Figure 3 As shown, the image processing method may include the following steps:

[0093] Step 301: Receive an image background removal request sent by the client, wherein the image background removal request includes a first sub-image, wherein the first sub-image is obtained by cropping the image to be processed.

[0094] Step 302: In response to the image background removal request, perform background recognition on the first sub-image to obtain the background region in the first sub-image.

[0095] Step 303: Add an alpha channel to each first pixel in the background area.

[0096] Step 304: Set the channel value of the alpha channel of each first pixel in the first sub-image to obtain the second sub-image, wherein the channel value of the alpha channel is used to indicate the transparency of the corresponding pixel.

[0097] The execution process of steps 301 to 304 can be found in the execution process of any embodiment of this application, and will not be described in detail here.

[0098] Step 305: Generate scan lines at each boundary of the second sub-image, and determine the scanning direction of the corresponding scan lines based on the position information of each boundary.

[0099] In this embodiment of the application, a scan line can be generated at each boundary of the second sub-image, and the scanning direction of the corresponding scan line can be determined according to the position information of each boundary.

[0100] As an example, scan lines can be generated at each boundary of the second sub-image. For instance, if the second sub-image has four boundaries—upper, lower, left, and right—a scan line can be generated at each boundary. Furthermore, the scanning direction of the corresponding scan line can be determined based on the position information of each boundary. For example, based on the position information of the upper boundary, the scanning direction of the scan line corresponding to the upper boundary is determined to be downward; based on the position information of the lower boundary, the scanning direction of the scan line corresponding to the lower boundary is determined to be upward; based on the position information of the left boundary, the scanning direction of the scan line corresponding to the left boundary is determined to be to the right; and based on the position information of the right boundary, the scanning direction of the scan line corresponding to the right boundary is determined to be to the left.

[0101] Step 306: For any scan line in each scan line, move the scan line along the corresponding scan direction to scan the first sub-image.

[0102] In this embodiment of the application, for any one of the scan lines, the scan line can be moved along the scanning direction corresponding to the scan line to scan the first sub-image.

[0103] Step 307: In response to the scan line first scanning the second pixel, stop moving the scan line; wherein the second pixel does not contain the alpha channel.

[0104] In this embodiment, the second pixel does not contain an alpha channel. When the scan line first scans the second pixel, it indicates that the scan line has scanned a pixel in the foreground region, such as a pixel belonging to the target object, or the edge of the target object. At this time, the scan line can be stopped.

[0105] It should be noted that the explanation of the target object in step 103 also applies to this embodiment, and will not be repeated here.

[0106] Step 308: Based on the position of each scan line when it stops moving, the second sub-image is cropped to obtain the target image.

[0107] It should be noted that the explanation of the target image in step 103 also applies to this embodiment, and will not be repeated here.

[0108] In this embodiment of the application, the second sub-image can be cropped according to the position of each scan line when it stops moving, thereby obtaining the target image.

[0109] As one possible implementation, for any scan line among the scan lines, the second sub-image can be cropped according to the position of the scan line when it stops moving, so as to crop out the image region between the boundary corresponding to the scan line and the position of the scan line when it stops moving; and the cropped second sub-image can be used as the target image.

[0110] Therefore, cropping the second sub-image, which has already had its background removed, can reduce the image size, thereby improving the image transmission speed between the client and the server.

[0111] Step 309: Send an image background removal response to the client, wherein the image background removal response includes the target image.

[0112] The execution process of step 309 can be found in any embodiment of this application, and will not be described in detail here.

[0113] The image processing method of this application embodiment generates scan lines at each boundary of the second sub-image and determines the scanning direction of the corresponding scan lines based on the position information of each boundary. For any scan line, the scan line is moved along the corresponding scanning direction to scan the first sub-image. The scanning line stops moving when it first scans a second pixel, where the second pixel does not contain an alpha channel. The second sub-image is cropped based on the position of each scan line when it stops moving to obtain the target image. Therefore, it is possible to crop the second sub-image based on scan lines generated from image boundaries, thereby effectively obtaining a target image containing a foreground region.

[0114] To clearly illustrate how the background removal process is performed on the first sub-image in any embodiment of this application to obtain the second sub-image, this application also proposes an image processing method.

[0115] Figure 4 This is a schematic flowchart of the image processing method provided in Embodiment 4 of this application.

[0116] like Figure 4 As shown, the image processing method may include the following steps:

[0117] Step 401: Receive an image background removal request sent by the client, wherein the image background removal request includes a first sub-image, wherein the first sub-image is obtained by cropping the image to be processed.

[0118] The execution process of step 401 can be found in any embodiment of this application, and will not be described in detail here.

[0119] Step 402: In response to the image background removal request, semantic segmentation is performed on the first sub-image to obtain various object regions containing the same object.

[0120] In this embodiment, the first sub-image can be semantically segmented based on semantic segmentation technology to obtain various object regions containing the same object. Each object region contains pixels belonging to the same object in the first sub-image.

[0121] For example, if the first sub-image contains a person, a dog, and a tree, then semantic segmentation can be performed on the first sub-image to obtain object region 1 belonging to the person, object region 2 belonging to the dog, and object region 3 belonging to the tree.

[0122] As an example, semantic segmentation algorithms can be used to perform semantic segmentation on the first sub-image to obtain object regions that contain the same object. For instance, deep learning semantic segmentation models (such as FCN (Fully Convolutional Networks), DeepLab, etc.) can be used to perform semantic segmentation on the first sub-image to obtain object regions that contain the same object.

[0123] Step 403: Determine the target region to which the target object belongs from each object region.

[0124] It should be noted that the explanation of the target object in step 103 also applies to this embodiment, and will not be repeated here.

[0125] In this embodiment of the application, the target area to which the target object belongs can be determined from the object area.

[0126] Using the example above, assuming the target object is a person, we can determine the target area to which the target object belongs as object area 1 from the three object areas.

[0127] Step 404: The remaining areas in the first sub-image, excluding the target area, are taken as the background area in the first sub-image.

[0128] In this embodiment of the application, the remaining areas in the first sub-image other than the target area can be used as the background area in the first sub-image.

[0129] Step 405: Set the pixel value of each third pixel in the background area to a set value to obtain the second sub-image.

[0130] In the embodiments of this application, the set value can be preset, such as 0, 255, etc., and this application does not limit it.

[0131] It should be noted that, in practical applications, the set values ​​can be adjusted as needed.

[0132] In this embodiment of the application, the pixel value of each third pixel in the background area can be set to a preset value to obtain the second sub-image.

[0133] For example, when the first sub-image is a grayscale image, the pixel value of each third pixel in the background area can be set to 255, at which point the background area will appear white.

[0134] For example, when the first sub-image is a color image, the channel values ​​of the R (Red), G (Green), and B (Blue) channels of each third pixel in the background area can be set to 255. In this case, the background area will appear white.

[0135] In any embodiment of this application, background removal processing can also be performed on the first sub-image based on deep learning technology to obtain a second sub-image with the background removed. For example, a trained image background removal model can be used to perform background recognition on the first sub-image to obtain the background region in the first sub-image; and the image background removal model can then be used to remove the background region in the first sub-image to obtain the second sub-image. Thus, performing background removal processing on the first sub-image based on deep learning technology can improve the image processing effect.

[0136] For example, a trained U2Net model can be used to perform background recognition on the first sub-image to obtain the background region in the first sub-image; and the U2Net model can be used to remove the background region in the first sub-image to obtain the second sub-image.

[0137] Step 406: Crop the second sub-image to obtain the target image containing the target object.

[0138] The explanation of step 406 can be found in the relevant description in any embodiment of this application, and will not be repeated here.

[0139] As one possible implementation, scan lines can be generated at each boundary of the second sub-image, and the scanning direction of the corresponding scan lines can be determined based on the position information of each boundary. For any scan line, the scan line can be moved along the corresponding scanning direction to scan the first sub-image. In response to the scan line first scanning the fourth pixel, the movement of the scan line is stopped. The pixel value of the fourth pixel is not a set value. The second sub-image is then cropped according to the position of each scan line when it stops moving to obtain the target image.

[0140] It should be noted that the explanation of the scan line and the corresponding scan direction in step 305 also applies to this embodiment, and will not be repeated here.

[0141] In this embodiment of the application, the pixel value of the fourth pixel is not a set value. For any scan line, when the scan line is moved along the scan direction corresponding to the scan line to scan the first sub-image, when the scan line first scans the fourth pixel, it indicates that the scan line has scanned a pixel in the foreground area, such as a pixel belonging to the target object, or the edge of the target object. At this time, the movement of the scan line can be stopped.

[0142] Therefore, in this application, the second sub-image can be cropped according to the position of each scan line when it stops moving, thereby obtaining the target image. The specific execution process can be found in the relevant description in step 308, and its implementation principle is similar, so it will not be repeated here.

[0143] Step 407: Send an image background removal response to the client, wherein the image background removal response includes the target image.

[0144] The execution process of step 407 can be found in any embodiment of this application, and will not be described in detail here.

[0145] The image processing method of this application embodiment, in response to an image background removal request, performs semantic segmentation on a first sub-image to obtain various object regions containing the same object; determines the target region to which the target object belongs from each object region; designates the remaining regions in the first sub-image, excluding the target region, as the background region in the first sub-image; and sets the pixel value of each third pixel in the background region to a predetermined value to obtain a second sub-image. Thus, based on semantic segmentation technology, the background region can be identified from the first sub-image, thereby effectively removing the background region to obtain the second sub-image.

[0146] The above are implementation examples of methods executed on the server side. This application also proposes an implementation example of a method executed on the client side.

[0147] Figure 5This is a schematic flowchart of the image processing method provided in Embodiment 5 of this application.

[0148] like Figure 5 As shown, the image processing method may include the following steps:

[0149] Step 501: Obtain the image to be processed.

[0150] In the embodiments of this application, the image to be processed can be an image for which the user needs to remove the background, and the number of images to be processed can be one or more, and this application does not limit this.

[0151] It should be noted that the image format of the image to be processed can be JPEG (Joint Photographic Experts Group), PNG (Portable Network Graphics), BMP (Bitmap, also known as raster image or pixel image), etc., and this application does not impose any restrictions on it.

[0152] In this embodiment of the application, the client can obtain the image to be processed.

[0153] In the embodiments of this application, the method of acquiring the image to be processed is not limited. For example, the image to be processed can be an image taken by the client, or the image to be processed can be an image collected online, such as by web crawling technology, or the image to be processed can be an image stored locally on the electronic device where the client is located, etc. This application does not limit this.

[0154] Step 502: Crop the image to be processed to obtain the first sub-image.

[0155] In this embodiment of the application, in order to reduce the processing load on the server and improve the processing efficiency of the server on the image to be processed, the image to be processed can be cropped on the client side to obtain the first sub-image.

[0156] As one possible implementation, object detection can be performed on the image to be processed to obtain at least one detection box, and a target detection box can be determined from the at least one detection box, wherein the target detection box contains a target object; then, the image region within the target detection box in the image to be processed can be cropped to obtain a first sub-image containing the aforementioned image region.

[0157] The target object can be, for example, a person, an animal, a building, etc., and this application does not impose any restrictions on this.

[0158] In this embodiment, object detection can be performed on the image to be processed based on an object detection algorithm to obtain detection boxes in the image, wherein the number of detection boxes can be at least one. For example, object detection can be performed on the image to be processed based on a deep learning object detection model (such as R-CNN (Region Convolutional Neural Networks), Fast-RCNN (Fast Region Convolutional Neural Networks), SSD (Single Shot MultiBox Detector), etc.) to obtain at least one detection box.

[0159] After identifying at least one detection box, a target detection box containing the target object can be determined from the at least one detection box; thus, the image region within the target detection box in the image to be processed can be cropped to obtain a first sub-image containing the image region.

[0160] As another possible implementation, the client can also respond to the user's selection of the image to be processed by extracting a first sub-image from the image to be processed. This allows for the extraction of the first sub-image requiring background removal from the image to be processed, based on the user's image processing needs, thus satisfying the user's personalized requirements.

[0161] Step 503: Based on the first sub-image, send an image background removal request to the server. The image background removal request is used by the server to perform background removal processing on the first sub-image to obtain a second sub-image, and then perform cropping processing on the second sub-image to obtain a target image containing the target object.

[0162] In this embodiment, the client can generate an image background removal request based on the first sub-image and send the image background removal request to the server. Accordingly, after receiving the image background removal request, the server can respond to the image background removal request by performing background removal processing on the first sub-image to obtain the second sub-image.

[0163] Understandably, after the server performs background removal on the first sub-image, the size of the second sub-image obtained after background removal is the same as that of the first sub-image. Only the pixels of the background part of the first sub-image change. That is, since the background area in the second sub-image has been removed, it only contains the useful pixels in the foreground area. At this time, in order to improve the image transmission speed between the client and the server, the server can also perform cropping on the second sub-image to obtain the target image containing the target object.

[0164] Step 504: Receive the image background removal response sent by the server, wherein the image background removal response includes the target image.

[0165] In this embodiment, after obtaining the target image containing the target object, the server can generate an image background removal response based on the target image and send the image background removal response to the client. Correspondingly, the client can receive the image background removal response sent by the server. The image background removal response may include the target image.

[0166] In one possible implementation of this application embodiment, after the client acquires the image to be processed, it can also perform preprocessing on the image to be processed; wherein, preprocessing may include at least one of noise reduction processing, compression processing, filtering processing and enhancement processing.

[0167] In order to reduce the impact of image noise on the image background removal effect, the image to be processed can be denoised, for example, Gaussian filter, low-pass filter, etc. can be used to denoise the image to be processed. This application does not limit this.

[0168] In order to improve the efficiency of image processing, the image to be processed can be compressed.

[0169] In order to highlight the target object in the image to be processed, so as to facilitate subsequent processing of the image and improve the reliability and accuracy of image background removal, the image to be processed can be enhanced.

[0170] As an example, consider the image to be processed obtained by the client, such as... Figure 6 The example shown is as follows, where, Figure 6 The file size of the image to be processed shown is 501KB, and the dimensions are 413×310. The client crops the image to be processed, and the resulting first sub-image can be shown as follows: Figure 7 As shown, where, Figure 7 The first sub-image shown has a file size of 329KB and a size of 271×310. The client generates an image background removal request based on the first sub-image and sends it to the server. Correspondingly, the server can receive the image background removal request and perform image background removal processing on the first sub-image. For example, an alpha channel can be added to each first pixel in the image area other than the image area corresponding to the target object in the first sub-image, and the channel value of the alpha channel of the first pixel can be set to 0. At this time, each first pixel is transparent, and the resulting second sub-image can be obtained as shown. Figure 8 As shown, where, Figure 8 The file size corresponding to the second sub-image shown is 408KB, and the dimensions are 271×310.

[0171] It should be noted that when performing background removal on the first sub-image, an alpha channel needs to be added to each first pixel in the first sub-image, and the channel value of the alpha channel of the first pixel is set to 0. This will increase the file size of the image, meaning that the file size of the second sub-image is greater than that of the first sub-image.

[0172] To improve the image transmission speed between the client and server, the server can also crop the second sub-image to obtain a target image containing the target object. Figure 9 As shown, where, Figure 9 The target image shown has a file size of 39.7KB and a resolution of 66×153 pixels. After obtaining the target image, the server can generate an image background removal response based on the target image and send this response to the client. The client can then receive this response and display the target image carried in the background removal response, allowing the user to visually understand the image after background removal.

[0173] In summary, by performing image cropping twice, the transmission speed between the client and the server can be improved, the server's processing efficiency can be increased, the efficiency of background removal from the image can be improved, and the client's processing burden and waiting time can be reduced. Furthermore, the size of the target image after background removal is consistent with the size of the target object, with no redundancy, which can effectively improve the user experience.

[0174] The image processing method of this application embodiment involves: acquiring an image to be processed; cropping the image to obtain a first sub-image; sending an image background removal request to a server based on the first sub-image, wherein the image background removal request is used by the server to perform background removal processing on the first sub-image to obtain a second sub-image, and then cropping the second sub-image to obtain a target object containing the target object; and receiving an image background removal response sent by the server, wherein the image background removal response includes the target image. Therefore, by performing image cropping twice, the transmission speed of the image between the client and the server can be improved, and the server's background removal processing on the cropped image can improve the server's processing efficiency and the efficiency of background removal in the image, thereby reducing the client's waiting time. Furthermore, having the server perform background removal processing on the image can reduce the processing burden on the client.

[0175] With the above Figures 1 to 4 Corresponding to the image processing method provided in the embodiments, this application also provides an image processing apparatus. Since the image processing apparatus provided in the embodiments of this application is similar to the one described above…Figures 1 to 4 The image processing method provided in the embodiments corresponds to the image processing apparatus provided in the embodiments of this application, and will not be described in detail in the embodiments of this application.

[0176] Figure 10 This is a schematic diagram of the image processing apparatus provided in Embodiment Six of this application.

[0177] like Figure 10 As shown, the image processing device 1000 may include: a receiving module 1001, a processing module 1002, a cropping module 1003, and a sending module 1004.

[0178] The receiving module 1001 is used to receive an image background removal request sent by the client. The image background removal request includes a first sub-image, which is obtained by cropping the image to be processed.

[0179] The processing module 1002 is used to perform background removal processing on the first sub-image in response to the image background removal request, so as to obtain the second sub-image.

[0180] The cropping module 1003 is used to crop the second sub-image to obtain a target image containing the target object.

[0181] The sending module 1004 is used to send an image background removal response to the client, wherein the image background removal response includes the target image.

[0182] As one possible implementation of this application embodiment, the processing module 1002 is specifically used for:

[0183] In response to the image background removal request, background recognition is performed on the first sub-image to obtain the background region in the first sub-image; an alpha channel is added to each first pixel in the background region; the channel value of the alpha channel of each first pixel in the first sub-image is set to obtain the second sub-image, wherein the channel value of the alpha channel is used to indicate the transparency of the corresponding pixel.

[0184] As one possible implementation of this application embodiment, the cropping module 1003 is specifically used for:

[0185] A scan line is generated at each boundary of the second sub-image, and the scanning direction of the corresponding scan line is determined according to the position information of each boundary. For any scan line, the scan line is moved along the scanning direction corresponding to the scan line to scan the first sub-image. The scan line stops moving when it first scans the second pixel. The second pixel does not contain the alpha channel. The second sub-image is cropped according to the position of each scan line when it stops moving to obtain the target image.

[0186] As one possible implementation of this application embodiment, the cropping module 1003 is further specifically used for:

[0187] For any scan line in each scan line, the second sub-image is cropped according to the position of the scan line when it stops moving, so as to cut off the image area between the boundary corresponding to the scan line and the position of the scan line when it stops moving; the cropped second sub-image is used as the target image.

[0188] As one possible implementation of this application embodiment, the processing module 1002 is specifically used for:

[0189] In response to the image background removal request, semantic segmentation is performed on the first sub-image to obtain various object regions containing the same object; from each object region, the target region to which the target object belongs is determined; the remaining regions in the first sub-image other than the target region are taken as the background region in the first sub-image; the pixel value of each third pixel in the background region is set to a set value to obtain the second sub-image.

[0190] As one possible implementation of this application embodiment, the cropping module 1003 is specifically used for:

[0191] A scan line is generated at each boundary of the second sub-image, and the scanning direction of the corresponding scan line is determined according to the position information of each boundary. For any scan line, the scan line is moved along the corresponding scanning direction to scan the first sub-image. The scan line stops moving when it first scans the fourth pixel. The pixel value of the fourth pixel is not a set value. The second sub-image is cropped according to the position of each scan line when it stops moving to obtain the target image.

[0192] As one possible implementation of this application embodiment, the processing module 1002 is specifically used for:

[0193] In response to the image background removal request, a trained image background removal model is used to perform background recognition on the first sub-image to obtain the background region in the first sub-image; the image background removal model is then used to remove the background region in the first sub-image to obtain the second sub-image.

[0194] The image processing apparatus of this application embodiment receives an image background removal request sent by a client, wherein the image background removal request includes a first sub-image, which is obtained by cropping an image to be processed; in response to the image background removal request, it performs background removal processing on the first sub-image to obtain a second sub-image; it then performs cropping processing on the second sub-image to obtain a target image containing a target object; and finally sends an image background removal response to the client, wherein the image background removal response includes the target image. Therefore, by performing image cropping processing twice, the image transmission speed between the client and the server can be improved, and the server's background removal processing on the cropped image can improve the server's processing efficiency and the efficiency of background removal from the image, thereby reducing the client's waiting time. Furthermore, having the server perform background removal processing on the image can reduce the processing burden on the client.

[0195] With the above Figure 5 Corresponding to the image processing method provided in the embodiments, this application also provides an image processing apparatus. Since the image processing apparatus provided in the embodiments of this application is similar to the one described above… Figure 5 The image processing method provided in the embodiments corresponds to the image processing apparatus provided in the embodiments of this application, and will not be described in detail in the embodiments of this application.

[0196] Figure 11 This is a schematic diagram of the image processing apparatus provided in Embodiment 7 of this application.

[0197] like Figure 11 As shown, the image processing device 1100 may include: an acquisition module 1101, a cropping module 1102, a sending module 1103, and a receiving module 1104.

[0198] The acquisition module 1101 is used to acquire the image to be processed.

[0199] The cropping module 1102 is used to crop the image to be processed to obtain the first sub-image.

[0200] The sending module 1103 is used to send an image background removal request to the server based on the first sub-image. The image background removal request is used by the server to perform background removal processing on the first sub-image to obtain a second sub-image, and to perform cropping processing on the second sub-image to obtain a target image containing the target object.

[0201] The receiving module 1104 is used to receive the image background removal response sent by the server, wherein the image background removal response includes the target image.

[0202] As one possible implementation of this application embodiment, the cropping module 1102 is specifically used for:

[0203] Perform object detection on the image to be processed to obtain at least one detection box; determine a target detection box from the at least one detection box, wherein the target detection box contains a target object; crop the image region within the target detection box in the image to be processed to obtain a first sub-image containing the image region.

[0204] As one possible implementation of this application embodiment, the cropping module 1102 is specifically used for:

[0205] In response to a selection operation on the image to be processed, extract the first sub-image from the image to be processed.

[0206] As one possible implementation of this application embodiment, the image processing apparatus 1100 further includes:

[0207] The preprocessing module is used to preprocess the image to be processed; wherein the preprocessing includes at least one of denoising, compression, filtering and enhancement.

[0208] The image processing apparatus of this application embodiment acquires an image to be processed; performs cropping processing on the image to be processed to obtain a first sub-image; sends an image background removal request to a server based on the first sub-image, wherein the image background removal request is used by the server to perform background removal processing on the first sub-image to obtain a second sub-image, and performs cropping processing on the second sub-image to obtain a target object containing the target object; and receives an image background removal response sent by the server, wherein the image background removal response includes the target image. Therefore, by performing image cropping processing twice, the transmission speed of the image between the client and the server can be improved, and the server's background removal processing on the cropped image can improve the server's processing efficiency and the efficiency of background removal in the image, thereby reducing the client's waiting time. Furthermore, having the server perform background removal processing on the image can reduce the processing burden on the client.

[0209] To implement the above embodiments, this application also proposes an electronic device, which may include: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it performs the image processing method proposed in the first aspect of the foregoing embodiments of this application, or performs the image processing method proposed in the second aspect of the foregoing embodiments of this application.

[0210] The electronic devices in the embodiments of this application can be any electronic device such as mobile phones, computers, smart wearable devices, etc., and this application does not impose any restrictions on them.

[0211] It should be noted that the foregoing explanations of the image processing method embodiments proposed in the first aspect embodiment, or the explanations of the image processing method embodiments proposed in the second aspect embodiment, also apply to the electronic device of this embodiment, and will not be repeated here.

[0212] To implement the above embodiments, this application also proposes a computer-readable storage medium storing a computer program thereon, characterized in that, when the program is executed by a processor, it implements the image processing method proposed in the first aspect of the present application, or implements the image processing method proposed in the second aspect of the present application.

[0213] To implement the above embodiments, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the image processing method proposed in the first aspect of the present application, or implements the image processing method proposed in the second aspect of the present application.

[0214] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0215] like Figure 12 As shown, the electronic device may include:

[0216] The memory 1201, the processor 1202, and the computer program stored on the memory 1201 and executable on the processor 1202.

[0217] When processor 1202 executes the program, it implements Figures 1 to 4 The image processing method or implementation provided in any of the illustrated embodiments Figure 5 The image processing method provided in the illustrated embodiment.

[0218] Furthermore, the electronic device may also include:

[0219] Communication interface 1203 is used for communication between memory 1201 and processor 1202.

[0220] The memory 1201 is used to store computer programs that can run on the processor 1202.

[0221] The memory 1201 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0222] Processor 1202, used to implement when executing the program Figures 1 to 4 The image processing method described in any of the illustrated embodiments, or its implementation Figure 5 The image processing method provided in the illustrated embodiment.

[0223] If the memory 1201, processor 1202, and communication interface 1203 are implemented independently, then the communication interface 1203, memory 1201, and processor 1202 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0224] Optionally, in a specific implementation, if the memory 1201, processor 1202, and communication interface 1203 are integrated on a single chip, then the memory 1201, processor 1202, and communication interface 1203 can communicate with each other through an internal interface.

[0225] The processor 1202 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.

[0226] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

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

[0228] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0229] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0230] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0231] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0232] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0233] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.

Claims

1. An image processing method, characterized in that, Applied to the server side, the method includes: Receive an image background removal request sent by a client, wherein the image background removal request includes a first sub-image, wherein the first sub-image is obtained by cropping the image to be processed; In response to the image background removal request, the first sub-image is subjected to background removal processing to obtain the second sub-image; The second sub-image is cropped to obtain a target image containing the target object; Send an image background removal response to the client, wherein the image background removal response includes the target image; In response to the image background removal request, the process of removing the background from the first sub-image to obtain the second sub-image includes: In response to the image background removal request, semantic segmentation is performed on the first sub-image to obtain various object regions containing the same object; From each of the object regions, determine the target region to which the target object belongs; The remaining areas in the first sub-image, excluding the target area, are taken as the background area in the first sub-image. Set the pixel value of each third pixel in the background area to a set value to obtain the second sub-image; The cropping process of the second sub-image to obtain a target image containing the target object includes: A scan line is generated at each boundary of the second sub-image, and the scanning direction of the corresponding scan line is determined according to the position information of each boundary. For any one of the scan lines, the scan line is moved along the scanning direction corresponding to the scan line to scan the first sub-image; In response to the scan line first scanning the fourth pixel, the scan line stops moving; wherein the pixel value of the fourth pixel is not the set value; The second sub-image is cropped according to the position of each scan line when it stops moving, so as to obtain the target image; The step of cropping the second sub-image based on the position of each scan line when it stops moving to obtain the target image includes: For any scan line in each scan line, the second sub-image is cropped according to the position of the scan line when it stops moving, so as to cut off the image area between the boundary corresponding to the scan line and the position of the scan line when it stops moving; and the cropped second sub-image is used as the target image.

2. The method according to claim 1, characterized in that, In response to the image background removal request, the process of removing the background from the first sub-image to obtain the second sub-image includes: In response to the image background removal request, background recognition is performed on the first sub-image to obtain the background region in the first sub-image; An alpha channel is added to each first pixel in the background region; The alpha channel value of each first pixel in the first sub-image is set to obtain the second sub-image, wherein the alpha channel value is used to indicate the transparency of the corresponding pixel.

3. The method according to claim 2, characterized in that, The cropping process of the second sub-image to obtain a target image containing the target object includes: A scan line is generated at each boundary of the second sub-image, and the scanning direction of the corresponding scan line is determined according to the position information of each boundary. For any one of the scan lines, the scan line is moved along the scanning direction corresponding to the scan line to scan the first sub-image; In response to the scan line first scanning the second pixel, the scan line stops moving; wherein the second pixel does not contain an alpha channel; The second sub-image is cropped according to the position of each scan line when it stops moving, so as to obtain the target image.

4. The method according to claim 3, characterized in that, The step of cropping the second sub-image based on the position of each scan line when it stops moving to obtain the target image includes: For any one of the scan lines, the second sub-image is cropped according to the position of the scan line when it stops moving, so as to crop out the image area between the boundary corresponding to the scan line and the position of the scan line when it stops moving from the second sub-image; The cropped second sub-image is used as the target image.

5. The method according to claim 1, characterized in that, In response to the image background removal request, the process of removing the background from the first sub-image to obtain the second sub-image includes: In response to the image background removal request, a trained image background removal model is used to perform background recognition on the first sub-image to obtain the background region in the first sub-image; The background removal model is used to remove the background region in the first sub-image to obtain the second sub-image.

6. An image processing method, characterized in that, Applied to a client, the method includes: Obtain the image to be processed; The image to be processed is cropped to obtain a first sub-image; Based on the first sub-image, an image background removal request is sent to the server, wherein the image background removal request is used by the server to process the first sub-image using the method described in any one of claims 1 to 5 to obtain a target image containing the target object; The system receives an image background removal response sent by the server, wherein the image background removal response includes the target image.

7. The method according to claim 6, characterized in that, The cropping process of the image to be processed to obtain the first sub-image includes: Target detection is performed on the image to be processed to obtain at least one detection box; From the at least one detection box, a target detection box is determined, wherein the target detection box contains the target object; The image region within the target detection box in the image to be processed is cropped to obtain a first sub-image containing the image region.

8. The method according to claim 7, characterized in that, The cropping process of the image to be processed to obtain the first sub-image includes: In response to a selection operation on the image to be processed, the first sub-image is extracted from the image to be processed.

9. The method according to any one of claims 6-8, characterized in that, After acquiring the image to be processed, the process further includes: The image to be processed is preprocessed; The preprocessing includes at least one of denoising, compression, filtering, and enhancement.

10. An image processing apparatus, characterized in that, Applied to the server side, the device includes: The receiving module is used to receive an image background removal request sent by the client, wherein the image background removal request includes a first sub-image, wherein the first sub-image is obtained by cropping the image to be processed; The processing module is configured to, in response to the image background removal request, perform background removal processing on the first sub-image to obtain the second sub-image; The cropping module is used to crop the second sub-image to obtain a target image containing the target object; A sending module is used to send an image background removal response to the client, wherein the image background removal response includes the target image; The processing module is specifically used for: In response to the image background removal request, semantic segmentation is performed on the first sub-image to obtain various object regions containing the same object; From each of the object regions, determine the target region to which the target object belongs; The remaining areas in the first sub-image, excluding the target area, are taken as the background area in the first sub-image. Set the pixel value of each third pixel in the background area to a set value to obtain the second sub-image; The cropping module is specifically used for: A scan line is generated at each boundary of the second sub-image, and the scanning direction of the corresponding scan line is determined according to the position information of each boundary. For any one of the scan lines, the scan line is moved along the scanning direction corresponding to the scan line to scan the first sub-image; In response to the scan line first scanning the fourth pixel, the scan line stops moving; wherein the pixel value of the fourth pixel is not the set value; The second sub-image is cropped according to the position of each scan line when it stops moving, so as to obtain the target image; The cropping module is specifically used for: For any scan line in each scan line, the second sub-image can be cropped according to the position of the scan line when it stops moving, so as to cut off the image area between the boundary corresponding to the scan line and the position of the scan line when it stops moving; and the cropped second sub-image is used as the target image.

11. The apparatus according to claim 10, characterized in that, The processing module is specifically used for: In response to the image background removal request, background recognition is performed on the first sub-image to obtain the background region in the first sub-image; An alpha channel is added to each first pixel in the background region; The alpha channel value of each first pixel in the first sub-image is set to obtain the second sub-image, wherein the alpha channel value is used to indicate the transparency of the corresponding pixel.

12. The apparatus according to claim 11, characterized in that, The cropping module is specifically used for: A scan line is generated at each boundary of the second sub-image, and the scanning direction of the corresponding scan line is determined according to the position information of each boundary. For any one of the scan lines, the scan line is moved along the scanning direction corresponding to the scan line to scan the first sub-image; In response to the scan line first scanning the second pixel, the scan line stops moving; wherein the second pixel does not contain an alpha channel; The second sub-image is cropped according to the position of each scan line when it stops moving, so as to obtain the target image.

13. The apparatus according to claim 12, characterized in that, The cropping module is also used for: For any one of the scan lines, the second sub-image is cropped according to the position of the scan line when it stops moving, so as to crop out the image area between the boundary corresponding to the scan line and the position of the scan line when it stops moving from the second sub-image; The cropped second sub-image is used as the target image.

14. The apparatus according to claim 10, characterized in that, The processing module is specifically used for: In response to the image background removal request, a trained image background removal model is used to perform background recognition on the first sub-image to obtain the background region in the first sub-image; The background removal model is used to remove the background region in the first sub-image to obtain the second sub-image.

15. An image processing apparatus, characterized in that, Applied to a client, the device includes: The acquisition module is used to acquire the image to be processed; The cropping module is used to crop the image to be processed to obtain a first sub-image; The sending module is configured to send an image background removal request to the server based on the first sub-image, wherein the image background removal request is used to process the first sub-image using the image processing device applied to the server as described in any one of claims 10 to 14 to obtain a target image containing the target object. A receiving module is used to receive an image background removal response sent by the server, wherein the image background removal response includes the target image.

16. The apparatus according to claim 15, characterized in that, The cropping module is specifically used for: Target detection is performed on the image to be processed to obtain at least one detection box; From the at least one detection box, a target detection box is determined, wherein the target detection box contains the target object; The image region within the target detection box in the image to be processed is cropped to obtain a first sub-image containing the image region.

17. The apparatus according to claim 15, characterized in that, The cropping module is specifically used for: In response to a selection operation on the image to be processed, the first sub-image is extracted from the image to be processed.

18. The apparatus according to any one of claims 15-17, characterized in that, The device further includes: The preprocessing module is used to preprocess the image to be processed; The preprocessing includes at least one of denoising, compression, filtering, and enhancement.

19. An electronic device, characterized in that, The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it performs the image processing method as described in any one of claims 1-5, or performs the image processing method as described in any one of claims 6-9.

20. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the image processing method as described in any one of claims 1-5, or performs the image processing method as described in any one of claims 6-9.

Citation Information

Patent Citations

  • Image data processing method and device

    CN107154032A