Image processing method and device, electronic equipment, storage medium and product
By performing object segmentation and color information processing on the image to be processed, a color distance image is generated. Then, a machine learning model is used for background curtain segmentation, which solves the problems of low segmentation accuracy and efficiency in existing technologies and achieves a more efficient curtain segmentation effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-05
- Publication Date
- 2026-03-31
AI Technical Summary
The accuracy and efficiency of background screen segmentation in existing technologies are relatively low.
By acquiring the image to be processed, object segmentation is performed to generate a mask image, determine color information, generate a color distance image, generate the position information of the target object in the image based on the color distance image, use a machine learning model to perform object segmentation, and perform image fusion to improve segmentation accuracy and efficiency.
It improves the accuracy and efficiency of background screen segmentation, reduces the need for manual parameter setting, adapts to changes in different shooting conditions, and reduces image noise interference.
Smart Images

Figure CN115345891B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and in particular to an image processing method, apparatus, electronic device, storage medium, and product. Background Technology
[0002] With the development of live video streaming technology, background matting technology has been widely used in the field of video image processing. Background matting is essentially a task of segmenting a background backdrop from a target object, and it can be applied to video editing, beautification, live streaming, and other fields for background replacement.
[0003] In related technologies, in order to achieve the separation of the background screen from the target object, the user needs to manually set a fixed main color of the screen and the removal intensity. The device then filters out the colors of the pixels in the image or video frame according to the user's pre-set main color and removal intensity, thereby completing the separation of the background screen.
[0004] Among related technologies, the accuracy and efficiency of background screen segmentation are relatively low. Summary of the Invention
[0005] This disclosure provides an image processing method, apparatus, electronic device, storage medium, and product to at least solve the problem of low accuracy and efficiency in background screen segmentation in related technologies. The technical solution of this disclosure is as follows:
[0006] According to a first aspect of the present disclosure, an image processing method is provided, comprising:
[0007] Obtain the image to be processed;
[0008] The image to be processed is subjected to object segmentation processing to obtain a mask image corresponding to the target object. The mask image includes a first region and a second region. The first region is the region corresponding to the target object, and the second region is the region outside the first region in the mask image.
[0009] Determine the first color information corresponding to each pixel in the image to be processed and the second color information corresponding to the pixel located in the second region of the image to be processed;
[0010] Based on the first color information and the second color information, a color distance image is generated, wherein the color distance image represents the color difference information between the first color information and the second color information;
[0011] Based on the color distance image, a first image corresponding to the image to be processed is generated, and the first image represents the position information of the target object in the image to be processed.
[0012] In one possible design, the first color information includes the original pixel value of each pixel in the target color channel, the second color information includes the target pixel value corresponding to the target color channel, the target pixel value represents the hue information of the region corresponding to the second region, and generating a color distance image based on the first color information and the second color information includes:
[0013] Determine the pixel value distance between the original pixel value and the target pixel value;
[0014] The color distance image is obtained based on the pixel value distance.
[0015] In one possible design, generating a first image corresponding to the image to be processed based on the color distance image includes:
[0016] Based on the pixel value distance, the pixels in the color distance image are classified to obtain pixel category information, which represents the correspondence between the pixels in the color distance image and the target object;
[0017] The first image is generated based on the pixel category information.
[0018] In one possible design, generating a first image corresponding to the image to be processed based on the color distance image includes:
[0019] The color distance image is smoothed to obtain a smoothed image;
[0020] The pixels in the smoothed image are classified to obtain pixel category information, which represents the correspondence between the pixels in the smoothed image and the target object;
[0021] The first image is generated based on the pixel category information.
[0022] In one possible design, determining the first color information corresponding to each pixel in the image to be processed and the second color information corresponding to the pixels located in the second region of the image to be processed includes:
[0023] Obtain the original pixel value of each pixel in the target color channel, wherein each pixel includes the pixels in the second region;
[0024] The original pixel values of the pixels in the second region corresponding to the target color channel are averaged to obtain the target pixel values corresponding to the target color channel.
[0025] The first color information includes the original pixel value, and the second color information includes the target pixel value.
[0026] In one possible design, the step of performing object segmentation processing on the image to be processed to obtain a mask image corresponding to the target object includes:
[0027] The image to be processed is input into the object segmentation model for object segmentation, and the mask image is output.
[0028] The object segmentation model is a machine learning model trained based on sample images and label information. The sample image is an image that includes a sample object and a sample background. The label information includes a first mask image corresponding to the sample image. The first mask image represents the actual segmentation information between the sample object and the sample background.
[0029] In one possible design, the training process of the object segmentation model includes:
[0030] Obtain the sample image and the first mask image;
[0031] The sample image is input into the object segmentation model to be trained for object segmentation processing, and a second mask image is output. The second mask image represents the predicted segmentation information between the sample object and the sample background.
[0032] Based on the first mask image and the second mask image, model loss information is generated;
[0033] Based on the model loss information, the parameters of the object segmentation model to be trained are adjusted to obtain the object segmentation model.
[0034] In one possible design, the method further includes:
[0035] The image to be processed and the first image are fused to obtain a first fused image, which represents the image information of the target object in the image to be processed.
[0036] In one possible design, the fusion process of the image to be processed and the first image to obtain a first fused image includes:
[0037] The image to be processed and the first image are fused together to obtain an intermediate fused image;
[0038] The intermediate fused image is subjected to color overflow processing corresponding to the target color information to obtain the first fused image. The color overflow processing is used to smooth the pixel values of pixels located at the edge of the target object and corresponding to the target color information.
[0039] In one possible design, the method further includes:
[0040] Obtain the target background image;
[0041] The first image is transformed to obtain a second image, which represents the image region in the image to be processed, excluding the target object.
[0042] The target background image and the second image are fused to obtain a second fused image, which represents the image information corresponding to the image region in the target background image.
[0043] A composite image is generated based on the first fused image and the second fused image.
[0044] According to a second aspect of the present disclosure, an image processing apparatus is provided, comprising:
[0045] The image acquisition module is configured to acquire the image to be processed.
[0046] The object segmentation module is configured to perform object segmentation processing on the image to be processed to obtain a mask image corresponding to the target object. The mask image includes a first region and a second region. The first region is the region corresponding to the target object, and the second region is the region outside the first region in the mask image.
[0047] The color determination module is configured to determine the first color information corresponding to each pixel in the image to be processed and the second color information corresponding to the pixel located in the second region of the image to be processed.
[0048] The difference information determination module is configured to generate a color distance image based on the first color information and the second color information, wherein the color distance image represents the color difference information between the first color information and the second color information;
[0049] The image generation module is configured to generate a first image corresponding to the image to be processed based on the color distance image, wherein the first image represents the position information of the target object in the image to be processed.
[0050] In one possible design, the first color information includes the original pixel value of each pixel in the target color channel, the second color information includes the target pixel value corresponding to the target color channel, the target pixel value represents the hue information of the region corresponding to the second region, and the difference information determination module includes:
[0051] A pixel distance determination unit is configured to determine the pixel distance between the original pixel value and the target pixel value.
[0052] The distance image generation unit is configured to perform the operation of obtaining the color distance image based on the pixel value distance.
[0053] In one possible design, the image generation module includes:
[0054] A pixel classification unit is configured to perform classification processing on pixels in the color distance image based on the pixel value distance to obtain pixel category information, wherein the pixel category information represents the correspondence between pixels in the color distance image and the target object;
[0055] The image generation unit is configured to generate the first image based on the pixel category information.
[0056] In one possible design, the image generation module includes:
[0057] An image smoothing unit is configured to perform image smoothing processing on the color distance image to obtain a smoothed image;
[0058] The pixel classification unit is further configured to perform classification processing on the pixels in the smoothed image to obtain pixel category information, wherein the pixel category information represents the correspondence between the pixels in the smoothed image and the target object;
[0059] The image generation unit is configured to generate the first image based on the pixel category information.
[0060] In one possible design, the color determination module includes:
[0061] The pixel value acquisition unit is configured to acquire the original pixel value of each pixel in the target color channel, wherein each pixel includes the pixel in the second region;
[0062] The target pixel value determination unit is configured to perform averaging processing on the original pixel values of the pixels in the second region corresponding to the target color channel to obtain the target pixel value corresponding to the target color channel.
[0063] The first color information includes the original pixel value, and the second color information includes the target pixel value.
[0064] In one possible design, the object segmentation module is specifically configured to input the image to be processed into the object segmentation model for object segmentation processing and output the mask image;
[0065] The object segmentation model is a machine learning model trained based on sample images and label information. The sample image is an image that includes a sample object and a sample background. The label information includes a first mask image corresponding to the sample image. The first mask image represents the actual segmentation information between the sample object and the sample background.
[0066] In one possible design, the training process of the object segmentation model includes:
[0067] Obtain the sample image and the first mask image;
[0068] The sample image is input into the object segmentation model to be trained for object segmentation processing, and a second mask image is output. The second mask image represents the predicted segmentation information between the sample object and the sample background.
[0069] Based on the first mask image and the second mask image, model loss information is generated;
[0070] Based on the model loss information, the parameters of the object segmentation model to be trained are adjusted to obtain the object segmentation model.
[0071] In one possible design, the device further includes:
[0072] An image fusion module is configured to perform fusion processing on the image to be processed and the first image to obtain a first fused image, wherein the first fused image represents the image information of the target object in the image to be processed.
[0073] In one possible design, the image fusion module includes:
[0074] An image fusion unit is configured to perform fusion processing on the image to be processed and the first image to obtain an intermediate fused image;
[0075] The color overflow processing unit is configured to perform color overflow processing on the intermediate fused image corresponding to the target color information to obtain the first fused image. The color overflow processing is used to smooth the pixel values of pixels located at the edge of the target object and corresponding to the target color information.
[0076] In one possible design, the device further includes:
[0077] The background image acquisition module is configured to acquire the target background image.
[0078] An image transformation module is configured to perform transformation processing on the first image to obtain a second image, wherein the second image represents the image region in the image to be processed, excluding the target object;
[0079] The image fusion module is further configured to perform a fusion process on the target background image and the second image to obtain a second fused image, wherein the second fused image represents the image information corresponding to the image region in the target background image;
[0080] The image synthesis module is configured to generate a synthesized image based on the first fused image and the second fused image.
[0081] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method as described in any one of the first aspects above.
[0082] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided such that, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform any of the methods described in the first aspect of the present disclosure.
[0083] According to a fifth aspect of the present disclosure, a computer program product including instructions is provided that, when run on a computer, causes the computer to perform any of the methods described in the first aspect of the present disclosure.
[0084] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects:
[0085] By performing object segmentation on the image to be processed, a mask image corresponding to the target object can be obtained. Based on the mask image, the color information of the region outside the target object in the image to be processed can be determined, as well as the color difference information between this color information and the color information of each pixel in the image to be processed. This allows for the determination of an image that can characterize the location information of the target object, thus achieving object segmentation and improving the accuracy and efficiency of object segmentation.
[0086] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0087] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0088] Figure 1 This is a schematic diagram illustrating an application environment according to an exemplary embodiment.
[0089] Figure 2 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 1 ;
[0090] Figure 3 An exemplary schematic diagram of an image to be processed is shown;
[0091] Figure 4 An exemplary schematic diagram of a mask image is shown;
[0092] Figure 5 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 2 ;
[0093] Figure 6 This is a flowchart illustrating an object segmentation model training method according to an exemplary embodiment;
[0094] Figure 7 An exemplary schematic diagram of a color distance image is shown;
[0095] Figure 8 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 3 ;
[0096] Figure 9 An exemplary schematic diagram of a first smoothed image is shown;
[0097] Figure 10 An exemplary schematic diagram of a second smoothed image is shown;
[0098] Figure 11 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 4 ;
[0099] Figure 12 An exemplary schematic diagram of a first fused image is shown;
[0100] Figure 13 This is a block diagram of an image processing apparatus according to an exemplary embodiment;
[0101] Figure 14 This is a block diagram illustrating an electronic device for image processing according to an exemplary embodiment. Detailed Implementation
[0102] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0103] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0104] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0105] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating an application environment according to an exemplary embodiment, such as... Figure 1 As shown, the application environment may include terminal 100 and server 200.
[0106] Terminal 100 can be used to provide image processing services to any user, such as background screen segmentation and replacement. Specifically, terminal 100 can be, but is not limited to, electronic devices such as smartphones, desktop computers, tablets, laptops, smart speakers, digital assistants, augmented reality (AR) / virtual reality (VR) devices, and smart wearable devices, or software running on the aforementioned electronic devices, such as applications. Optionally, the operating system running on the electronic device can be, but is not limited to, Android, iOS, Linux, and Windows.
[0107] In an optional embodiment, server 200 can provide background services to terminal 100, generating image processing results to be displayed by terminal 100, such as the first image, second image, fused image, and composite image in the following embodiments. Specifically, server 200 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0108] In addition, it should be noted that, Figure 1 The example shown is merely one application environment provided by this disclosure. In practical applications, other application environments may also be included, such as more terminals.
[0109] In the embodiments described in this specification, the terminal 100 and the server 200 can be directly or indirectly connected through wired or wireless communication, and this disclosure does not impose any restrictions.
[0110] Figure 2 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 1 ,like Figure 2 As shown, the image processing method is used in electronic devices (such as terminals or servers) and includes the following steps (210-250).
[0111] Step 210: Obtain the image to be processed.
[0112] Optionally, the image to be processed includes a target object. The target object can be a user-preset target recognition object.
[0113] In one possible implementation, the image to be processed is an image obtained by photographing the target object against a preset backdrop. Optionally, the preset backdrop may include a green screen.
[0114] Optionally, the image to be processed includes video frames in a video stream, such as a live video stream, a recorded video stream, or an animated video stream.
[0115] In one example, such as Figure 3 As shown, it exemplarily illustrates a schematic diagram of an image to be processed. Figure 3 The target object 31 in the image 30 to be processed is shown.
[0116] Step 220: Perform object segmentation processing on the image to be processed to obtain the mask image corresponding to the target object.
[0117] Optionally, the mask image includes a first region and a second region, where the first region is the region corresponding to the target object, and the second region is the region outside the first region in the mask image.
[0118] Optionally, the target object is a foreground object, which refers to an object in the image to be processed other than the preset screen. Accordingly, when the target object is a foreground object, the first region is the foreground region, which is the image region in the image to be processed other than the preset screen (i.e., the image region corresponding to the target object). Accordingly, the second region is the background region, which is the image region in the image to be processed corresponding to the preset screen.
[0119] Optionally, the image parameters corresponding to the mask image, such as image size and image resolution, may be the same as or different from the image to be processed. The mask image may be a grayscale image or a binary image, and this embodiment of the disclosure does not limit this.
[0120] In one example, such as Figure 4 As shown, it exemplifies a schematic diagram of a mask image. Figure 4 A mask image 40 corresponding to the image to be processed 30 is shown. The mask image 40 includes a first region 41 and a second region 42. The first region 41 is the image region corresponding to the target object 31, and the second region 42 is the image region outside the image region corresponding to the target object 31.
[0121] In an exemplary embodiment, such as Figure 5 As shown, the implementation process of step 220 above includes the following step 221. Figure 5 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 2 .
[0122] Step 221: Input the image to be processed into the object segmentation model for object segmentation processing and output a mask image.
[0123] The object segmentation model is a machine learning model trained on sample images and label information. The sample image is an image that includes the sample object and the sample background. The label information includes the first mask image corresponding to the sample image. The first mask image represents the actual segmentation information between the sample object and the sample background.
[0124] Optionally, the object segmentation model described above includes a foreground object segmentation model. The foreground object segmentation model is used to segment foreground objects and background elements in an image.
[0125] In practical applications, such as live video streaming, the color of pixels in the region containing the target object (foreground) is often similar to the color of other regions (background). Related technologies, when performing object segmentation, often classify pixels in the target object (foreground) region that have similar colors to other regions as pixels from other regions and modify their pixel values, leading to object segmentation errors. The technical solution provided in this exemplary embodiment, however, uses a pre-trained object segmentation model to segment the image to be processed. This accurately outputs a mask image corresponding to the target object, effectively distinguishing the boundary between the target object region and other regions, avoiding the aforementioned object segmentation errors, and improving the accuracy of object segmentation.
[0126] In one possible implementation, such as Figure 6 As shown, the training process of the above object segmentation model includes the following steps (601-604). Figure 6 This is a flowchart illustrating an object segmentation model training method according to an exemplary embodiment.
[0127] Step 601: Obtain the sample image and the first mask image.
[0128] Optionally, the first mask image is a mask image generated by marking the edges between the sample object and the sample background in the sample image. Therefore, the first mask image can characterize the actual segmentation information between the sample object and the sample background.
[0129] Optionally, the aforementioned sample images include images obtained by photographing the sample object against a sample background backdrop under at least one shooting condition. Optionally, the aforementioned shooting conditions include at least one light intensity, at least one light direction, at least one light source type, at least one shooting scene, etc. Optionally, the aforementioned sample objects include at least one sample item, at least one sample person, etc. The sample objects in each sample image may be different or the same, and this disclosure does not limit this.
[0130] Step 602: Input the sample image into the object segmentation model to be trained for object segmentation processing, and output the second mask image.
[0131] Optionally, the second mask image represents the predicted segmentation information between the sample object and the sample background curtain.
[0132] Optionally, the above object segmentation model adopts the Unet structure and a lightweight network structure is designed accordingly.
[0133] Step 603: Generate model loss information based on the first mask image and the second mask image.
[0134] Optionally, binary cross-entropy loss (bceloss) data is generated based on the first mask image and the second mask image, and the above model loss information includes contrastive loss data.
[0135] Step 604: Based on the model loss information, perform parameter adjustment processing on the object segmentation model to be trained to obtain the object segmentation model.
[0136] Optionally, it can be determined whether the binary cross-entropy loss data is less than or equal to a preset loss data threshold; if the binary cross-entropy loss data is greater than the preset loss data threshold, then the parameters of the object segmentation model to be trained are adjusted; if the binary cross-entropy loss data is less than or equal to the preset loss data threshold, then the trained object segmentation model is obtained.
[0137] In this embodiment, the actual mask image corresponding to the sample object in the sample image (i.e., the first mask image mentioned above) is used as the label information of the sample image, and the predicted mask image output by the object segmentation model to be trained (i.e., the second mask image mentioned above) is compared with the actual mask image to generate model loss information, and then the model parameters are adjusted to obtain a highly accurate object segmentation model and improve the accuracy of object segmentation.
[0138] Step 230: Determine the first color information corresponding to each pixel in the image to be processed and the second color information corresponding to the pixels located in the second region of the image to be processed.
[0139] Optionally, the first color information includes the original pixel value of each pixel in the target color channel.
[0140] Optionally, the second color information includes the target pixel value corresponding to the target color channel. Optionally, the target pixel value represents the regional hue information corresponding to the second region. For example, the target pixel value can represent the background color, average color, or main color corresponding to the second region, and the background color, average color, or main color can all be the aforementioned regional hue information.
[0141] Optionally, the target color channels mentioned above include color channels corresponding to the YCbCr color space and the Lab color space. Specifically, the color channels corresponding to the YCbCr color space include the Cb channel and the Cr channel, and the color channels corresponding to the Lab color space include the a channel and the b channel.
[0142] In the YCbCr color space described above, Y refers to the luminance component, Cb refers to the blue chromaticity component, and Cr refers to the red chromaticity component. In the Lab color space, the L component represents the luminance of a pixel, with a value range of [0, 100], representing pure black to pure white; a represents the range from red to green, with a value range of [127, -128]; and b represents the range from yellow to blue, with a value range of [127, -128]. Optionally, the YCbCr color space and the Lab color space have a corresponding color space transformation relationship.
[0143] Accordingly, the target pixel values corresponding to the above target color channels include the Cb channel target value (keycolor_cb) for the Cb channel, the Cr channel target value (keycolor_cr) for the Cr channel, the a channel target value (keycolor_a) for the a channel, and the b channel target value (keycolor_b) for the b channel.
[0144] In an exemplary embodiment, such as Figure 5 As shown, the implementation process of step 230 above includes the following steps (231-232).
[0145] Step 231: Obtain the original pixel value of each pixel in the target color channel.
[0146] The aforementioned pixels include those in the second region. The original pixel values of each pixel in the image to be processed, corresponding to the target color channel, are obtained; that is, the original pixel values of the pixels located in the second region of the image to be processed, corresponding to the target color channel, are obtained.
[0147] Step 232: Average the original pixel values of the pixels in the second region corresponding to the target color channel to obtain the target pixel values corresponding to the target color channel.
[0148] The first color information includes the original pixel value, and the second color information includes the target pixel value.
[0149] Optionally, the pixel values of the pixels located in the second region of the image to be processed in the target color channel are averaged to obtain the average pixel value of the pixels located in the second region of the image to be processed in the target color channel, and the average pixel value is determined as the target pixel value.
[0150] Optionally, the pixel values of the pixels located in the second region of the image to be processed in the Cb channel are averaged to obtain the target value of the Cb channel (keycolor_cb); the pixel values of the pixels located in the second region of the image to be processed in the Cr channel are averaged to obtain the target value of the Cr channel (keycolor_cb); the pixel values of the pixels located in the second region of the image to be processed in the a channel are averaged to obtain the target value of the a channel (keycolor_a); and the pixel values of the pixels located in the second region of the image to be processed in the b channel are averaged to obtain the target value of the b channel (keycolor_b).
[0151] The technical solution provided in this exemplary embodiment automatically determines the target pixel value corresponding to the target color channel, i.e., the dominant color of the second region in the image to be processed, by averaging the pixel values of the pixels located in the second region of the image to be processed in the target color channel. This improves the efficiency of object segmentation, eliminates the need for users to manually set parameters such as the dominant color of the image and the intensity subtraction. Furthermore, the target pixel value is not only automatically determined but also corresponds to the image to be processed, which can adapt to changes in different shooting conditions, such as changes in lighting and shooting scene, effectively avoiding image noise interference and improving the accuracy of object segmentation.
[0152] Step 240: Generate a color distance image based on the first color information and the second color information.
[0153] Optionally, the color distance image represents the color difference information between the first color information and the second color information.
[0154] In an exemplary embodiment, such as Figure 5 As shown, the implementation process of step 240 above may include the following steps (241-242).
[0155] Step 241: Determine the pixel value distance between the original pixel value and the target pixel value.
[0156] Optionally, the original pixel value is subtracted from the target pixel value to obtain the difference between the original pixel value and the target pixel value, which is the aforementioned pixel value distance.
[0157] Step 242: Obtain the color distance image based on the pixel value distance.
[0158] Optionally, the pixel value distance corresponding to the pixel point in the image to be processed is determined as the pixel value of the corresponding pixel point on the target color channel, thereby obtaining the above color distance image.
[0159] In one example, such as Figure 7 As shown, it exemplarily illustrates a schematic diagram of a color distance image. Figure 7 The color distance image 70 corresponding to the image 30 to be processed is shown. In the color distance image 70, the pixel value of each pixel in the target color channel is the difference between the original pixel value of each pixel in the target color channel and the target pixel value of the target color channel.
[0160] The technical solution provided in this exemplary embodiment can accurately generate a color distance image that can characterize the above-mentioned color difference information by determining the pixel value distance between the original pixel value and the target pixel value corresponding to each pixel point in the image to be processed. This improves the accuracy and reliability of the color distance image, thereby ensuring the correctness of subsequent steps and ensuring the accuracy of object segmentation.
[0161] Step 250: Generate the first image corresponding to the image to be processed based on the color distance image.
[0162] Optionally, the first image represents the location information of the target object in the image to be processed.
[0163] Optionally, the pixel value corresponding to the pixel in the target color channel of the above color distance image is the above pixel value distance. Therefore, the correspondence between each pixel and the target object can be determined based on the above pixel value distance. For example, the pixel value distance is less than or equal to the pixel value distance threshold and is the pixel corresponding to the background curtain. The pixel value distance is greater than the pixel value distance threshold and is the pixel corresponding to the target object. Then, the above first image can be determined based on the above correspondence.
[0164] Optionally, the type of the first image mentioned above includes, but is not limited to, masking images, transparency images, binarized images, grayscale images, etc., which can be configured according to the actual application scenario. This application embodiment does not limit this. Accordingly, since the first image can represent the position information of the target object in the image to be processed, the first image can be used for masking and segmentation. This application embodiment does not limit this.
[0165] In one possible implementation, such as Figure 5 As shown, the implementation process of step 250 above may include the following steps (251-252).
[0166] Step 251: Based on pixel value distance, classify the pixels in the color distance image to obtain pixel category information.
[0167] Pixel category information represents the correspondence between pixels in the color distance image and the target object.
[0168] Optionally, based on the aforementioned pixel value distance, the pixels in the color distance image are clustered to obtain at least two categories of pixels. These at least two categories include a first category of pixels and a second category of pixels. The first category consists of pixels corresponding to the target object, and the second category consists of pixels other than the target object. The pixel category information includes both the first and second categories of pixels.
[0169] Step 252: Generate the first image based on pixel category information.
[0170] Optionally, the pixel value corresponding to the first type of pixel is set as the first pixel value, and the pixel value corresponding to the second type of pixel is set as the second pixel value to obtain the first image. The pixel value obtained by fusing the first pixel value with other pixel values is another pixel value, which facilitates the extraction of image information corresponding to the target object in the image to be processed; the pixel value obtained by fusing the second pixel value with other pixel values is still the second pixel value, which facilitates the filtering out of image information other than the target object in the image to be processed.
[0171] The technical solution provided in this embodiment classifies pixels by pixel value distance, which can determine the pixel category information that can characterize the correspondence between pixels and target objects. Then, based on the pixel category information, the first image mentioned above can be accurately generated, thereby improving the accuracy of object segmentation.
[0172] In another possible implementation, such as Figure 8 As shown, the implementation process of step 250 above may include the following steps (25a to 25c). Figure 8 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 3 .
[0173] Step 25a: Perform image smoothing on the color distance image to obtain a smoothed image.
[0174] Optionally, the color distance image is smoothed based on a smoothing step function to obtain a first smoothed image. In one example, such as... Figure 9 As shown, it exemplarily illustrates a schematic diagram of a first smoothed image. Figure 9 The image shown is the first smoothed image 90 corresponding to the aforementioned color distance image 70.
[0175] Optionally, the first smoothed image is Gaussian smoothed and then subjected to image erosion to shrink it, resulting in a second smoothed image. In one example, such as... Figure 10 As shown, it exemplarily illustrates a schematic diagram of a second smoothed image. Figure 10The image shown is a second smoothed image 100 corresponding to the aforementioned color distance image 70.
[0176] Step 25b: Classify the pixels in the smoothed image to obtain pixel category information.
[0177] Optionally, pixel category information represents the correspondence between pixels in the smoothed image and the target object.
[0178] Optionally, the pixel values corresponding to the pixels in the smoothed image are obtained, and the pixels in the smoothed image are clustered based on the pixel values to obtain the first type of pixels and the second type of pixels mentioned above.
[0179] Step 25c: Generate the first image based on pixel category information.
[0180] The technical solution provided in this embodiment can obtain a smooth image with smoothed edges of the target object by smoothing the color distance image, thereby improving the image segmentation effect. Then, the smoothed image is classified into pixels to determine the pixel category information that can represent the correspondence between the pixels and the target object. Based on the pixel category information, the first image mentioned above can be accurately generated, thereby improving the image segmentation effect and accuracy of object segmentation.
[0181] In summary, the technical solution provided by the embodiments of this disclosure can obtain a mask image corresponding to the target object by performing object segmentation processing on the image to be processed. Based on the mask image, the color information corresponding to the region outside the target object in the image to be processed, as well as the color difference information between the color information and the color information of each pixel in the image to be processed, can be determined, thereby determining an image that can characterize the location information of the target object, realizing object segmentation, and improving the accuracy and efficiency of object segmentation.
[0182] Figure 11 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 4 ,like Figure 2 As shown, the image processing method is used in electronic devices (such as terminals or servers) and includes the following steps (210-300).
[0183] Step 210: Obtain the image to be processed.
[0184] Step 220: Perform object segmentation processing on the image to be processed to obtain the mask image corresponding to the target object.
[0185] Step 230: Determine the first color information corresponding to each pixel in the image to be processed and the second color information corresponding to the pixels located in the second region of the image to be processed.
[0186] Step 240: Generate a color distance image based on the first color information and the second color information.
[0187] Step 250: Generate the first image corresponding to the image to be processed based on the color distance image.
[0188] For a description of steps 210 to 250, please refer to the previous method embodiment; it will not be repeated here.
[0189] Step 260: Perform a fusion process on the image to be processed and the first image to obtain the first fused image.
[0190] Optionally, the first fused image represents the image information of the target object in the image to be processed.
[0191] Optionally, the first image includes a first type of pixel and a second type of pixel. Since the pixel value obtained by fusing the first pixel value corresponding to the first type of pixel with other pixel values is other pixel values, and the pixel value obtained by fusing the second pixel value corresponding to the second type of pixel with other pixel values is still the aforementioned second pixel value, fusing the image to be processed and the first image can realize the extraction of image information corresponding to the target object in the image to be processed and the filtering of image information other than the target object in the image to be processed, thereby obtaining a first fused image that can characterize the image information of the target object in the image to be processed.
[0192] In one example, such as Figure 12 As shown, Figure 12 An exemplary schematic diagram of a first fused image is shown. Figure 12 The first fused image 120 corresponding to the above-mentioned image to be processed 30 is shown. The first fused image 120 only retains the image information corresponding to the target object 31 in the image to be processed 30.
[0193] In an exemplary embodiment, the image to be processed and the first image are fused to obtain an intermediate fused image; the intermediate fused image is then subjected to color overflow processing corresponding to the target color information to obtain a first fused image. The color overflow processing is used to smooth the pixel values of pixels located at the edge of the target object and corresponding to the target color information.
[0194] In some practical applications, the area in the image to be processed other than the target object is the background. In such cases, the above intermediate fused image can be processed using despill to remove the background edges (edges at the edge of the target object that are similar or the same color as the background).
[0195] The technical solution disclosed in this exemplary embodiment can eliminate the background area edge at the edge of the target object in the fused image by performing color overflow processing on the intermediate fused image obtained by fusing the image to be processed and the first image, thereby improving the image fusion quality.
[0196] Step 270: Obtain the target background image.
[0197] Optionally, the aforementioned target background image is a preset background image that can be used to replace the image information of the image area outside the target object in the image to be processed, such as replacing the background curtain in the image to be processed.
[0198] Step 280: Transform the first image to obtain the second image.
[0199] Optionally, the second image represents the image region in the image to be processed, excluding the target object. Optionally, similar to the first image described above, the type of the second image includes, but is not limited to, masking images, transparency images, binarized images, grayscale images, etc., and can be configured according to the actual application scenario; this embodiment does not limit this. Accordingly, since the second image can represent the image region in the image to be processed, excluding the target object, the second image can be used for masking and segmentation; this embodiment does not limit this.
[0200] In one possible implementation, the first image is inversely processed to obtain the second image. Optionally, the pixel values corresponding to the first type of pixels in the first image are updated to second pixel values, and the pixel values corresponding to the second type of pixels are updated to first pixel values to obtain the second image. In the second image, the pixel values obtained by fusing the first pixel values with other pixel values are other pixel values, so as to extract background information outside the image area corresponding to the target object in the target background image; the pixel values obtained by fusing the second pixel values with other pixel values are still the second pixel values, so as to filter out the image information of the image area corresponding to the target object in the target background image.
[0201] Step 290: Perform a fusion process on the target background image and the second image to obtain the second fused image.
[0202] Optionally, the second fused image represents the image information corresponding to the image region in the target background image.
[0203] Optionally, the second image includes a first type of pixel and a second type of pixel. Since the pixel value obtained after fusing the second pixel value corresponding to the first type of pixel with other pixel values is still the second pixel value, and the pixel value obtained after fusing the first pixel value corresponding to the second type of pixel with other pixel values is other pixel values, fusing the target background image and the second image can extract image information outside the image area corresponding to the target object in the target background image, and filter out image information of the image area corresponding to the target object in the target background image, thereby obtaining a second fused image that can represent the image information corresponding to the image area outside the target object in the target background image.
[0204] Step 300: Generate a composite image based on the first fused image and the second fused image.
[0205] Optionally, the first fused image and the second fused image can be fused to generate a composite image, which includes background information corresponding to the target object and the target background image.
[0206] Optionally, the pixel values corresponding to the second type of pixels in the first fused image are set to 0 or transparent, and the pixel values corresponding to the first type of pixels in the second fused image are set to 0 or transparent. The first fused image and the second fused image after setting are superimposed to obtain the above-mentioned composite image, thereby realizing the background replacement of the image to be processed.
[0207] In summary, the technical solution provided by the embodiments of this disclosure can obtain a mask image corresponding to the target object by performing object segmentation processing on the image to be processed. Based on the mask image, the color information corresponding to the region outside the target object in the image to be processed, as well as the color difference information between the color information and the color information of each pixel in the image to be processed, can be determined. This allows for the determination of a first image that can characterize the location information of the target object. Then, the image to be processed and the first image are fused to obtain a first fused image that can characterize the image information of the target object in the image to be processed. This achieves the segmentation and extraction of the target object, improving the accuracy and efficiency of object segmentation and extraction.
[0208] Furthermore, the technical solution provided in this disclosure also transforms the first image to obtain a second image. Since the second image can represent the image region in the image to be processed other than the target object, the second image is fused with the target background image to obtain a second fused image that can represent the image information corresponding to the image region in the target background image. Based on the first fused image and the second fused image, a composite image can be generated to realize the background replacement of the image to be processed, thereby improving the efficiency and accuracy of image background replacement.
[0209] The beneficial effects of the technical solutions provided in this disclosure will be described below in conjunction with specific application scenarios. Live video streaming is a typical application scenario corresponding to the technical solutions provided in this disclosure, especially with the rapid development of live video streaming, green screen keying technology has been widely used in the field of video image processing. Green screen keying technology can be applied to video editing, beautification, live streaming, etc., for background replacement.
[0210] Green screen keying is essentially a foreground-background segmentation task. In related technologies, the device filters out the colors of pixels in an image or video frame based on the user-defined primary background color. This method typically requires users to manually set the primary image color and keying intensity, which is difficult for them. Furthermore, when lighting changes, the set primary color and keying intensity need to be reset, hindering adjustments. Additionally, because the user-defined primary background color is fixed, the technology cannot handle issues such as color bleeding, reflections, and shadows caused by uneven lighting, resulting in black borders and large shadow areas in the keyed image. Moreover, in live video streaming scenarios, the foreground color of the target object is often similar to the background color; related technologies often remove the foreground of the target object as well, severely impacting the visual effect.
[0211] The technical solution provided in this disclosure uses an object segmentation model for assistance, automatically outputting object segmentation results and automatically calculating the primary background color of the image based on these results, thereby reducing parameter tuning costs, parameter configuration volume, and operational complexity. Furthermore, compared to related technologies that require manual setting of the primary color, the primary color automatically extracted by the technical solution provided in this disclosure is more robust. This disclosure also incorporates an overflow color processing scheme, ensuring robust operation in scenarios with multiple people, different lighting conditions, and changing lighting, resulting in better image cutout effects. The technical solution provided in this disclosure also utilizes the aforementioned primary background color to cluster image pixels. Pixels closest to the primary color pixel value in the corresponding color space are clustered as background; otherwise, they are clustered as foreground. This enables accurate foreground and background segmentation, improving image segmentation efficiency and accuracy, and ultimately achieving precise background replacement to obtain a composite image, thus improving the quality of the composite image.
[0212] Figure 13 This is a block diagram of an image processing apparatus according to an exemplary embodiment. (Refer to...) Figure 13 The device 1300 includes: an image acquisition module 1310, an object segmentation module 1320, a color determination module 1330, a difference information determination module 1340, and an image generation module 1350.
[0213] Image acquisition module 1310 is configured to acquire an image to be processed;
[0214] The object segmentation module 1320 is configured to perform object segmentation processing on the image to be processed to obtain a mask image corresponding to the target object. The mask image includes a first region and a second region. The first region is the region corresponding to the target object, and the second region is the region outside the first region in the mask image.
[0215] Color determination module 1330 is configured to determine the first color information corresponding to each pixel in the image to be processed and the second color information corresponding to the pixel located in the second region of the image to be processed.
[0216] The difference information determination module 1340 is configured to generate a color distance image based on the first color information and the second color information, wherein the color distance image represents the color difference information between the first color information and the second color information;
[0217] The image generation module 1350 is configured to generate a first image corresponding to the image to be processed based on the color distance image, wherein the first image represents the position information of the target object in the image to be processed.
[0218] In one possible design, the first color information includes the original pixel value of each pixel in the target color channel, the second color information includes the target pixel value corresponding to the target color channel, the target pixel value represents the hue information of the region corresponding to the second region, and the difference information determination module 1340 includes:
[0219] A pixel distance determination unit is configured to determine the pixel distance between the original pixel value and the target pixel value.
[0220] The distance image generation unit is configured to perform the operation of obtaining the color distance image based on the pixel value distance.
[0221] In one possible design, the image generation module 1350 includes:
[0222] A pixel classification unit is configured to perform classification processing on pixels in the color distance image based on the pixel value distance to obtain pixel category information, wherein the pixel category information represents the correspondence between pixels in the color distance image and the target object;
[0223] The image generation unit is configured to generate the first image based on the pixel category information.
[0224] In one possible design, the image generation module 1350 includes:
[0225] An image smoothing unit is configured to perform image smoothing processing on the color distance image to obtain a smoothed image;
[0226] The pixel classification unit is further configured to perform classification processing on the pixels in the smoothed image to obtain pixel category information, wherein the pixel category information represents the correspondence between the pixels in the smoothed image and the target object;
[0227] The image generation unit is configured to generate the first image based on the pixel category information.
[0228] In one possible design, the color determination module 1330 includes:
[0229] The pixel value acquisition unit is configured to acquire the original pixel value of each pixel in the target color channel, wherein each pixel includes the pixel in the second region;
[0230] The target pixel value determination unit is configured to perform averaging processing on the original pixel values of the pixels in the second region corresponding to the target color channel to obtain the target pixel value corresponding to the target color channel.
[0231] The first color information includes the original pixel value, and the second color information includes the target pixel value.
[0232] In one possible design, the object segmentation module 1320 is specifically configured to input the image to be processed into the object segmentation model for object segmentation processing and output the mask image;
[0233] The object segmentation model is a machine learning model trained based on sample images and label information. The sample image is an image that includes a sample object and a sample background. The label information includes a first mask image corresponding to the sample image. The first mask image represents the actual segmentation information between the sample object and the sample background.
[0234] In one possible design, the training process of the object segmentation model includes:
[0235] Obtain the sample image and the first mask image;
[0236] The sample image is input into the object segmentation model to be trained for object segmentation processing, and a second mask image is output. The second mask image represents the predicted segmentation information between the sample object and the sample background.
[0237] Based on the first mask image and the second mask image, model loss information is generated;
[0238] Based on the model loss information, the parameters of the object segmentation model to be trained are adjusted to obtain the object segmentation model.
[0239] In one possible design, the device 1300 further includes:
[0240] An image fusion module is configured to perform fusion processing on the image to be processed and the first image to obtain a first fused image, wherein the first fused image represents the image information of the target object in the image to be processed.
[0241] In one possible design, the image fusion module includes:
[0242] An image fusion unit is configured to perform fusion processing on the image to be processed and the first image to obtain an intermediate fused image;
[0243] The color overflow processing unit is configured to perform color overflow processing on the intermediate fused image corresponding to the target color information to obtain the first fused image. The color overflow processing is used to smooth the pixel values of pixels located at the edge of the target object and corresponding to the target color information.
[0244] In one possible design, the device 1300 further includes:
[0245] The background image acquisition module is configured to acquire the target background image.
[0246] An image transformation module is configured to perform transformation processing on the first image to obtain a second image, wherein the second image represents the image region in the image to be processed, excluding the target object;
[0247] The image fusion module is further configured to perform a fusion process on the target background image and the second image to obtain a second fused image, wherein the second fused image represents the image information corresponding to the image region in the target background image;
[0248] The image synthesis module is configured to generate a synthesized image based on the first fused image and the second fused image.
[0249] In summary, the technical solution provided by the embodiments of this disclosure can obtain a mask image corresponding to the target object by performing object segmentation processing on the image to be processed. Based on the mask image, the color information corresponding to the region outside the target object in the image to be processed, as well as the color difference information between the color information and the color information of each pixel in the image to be processed, can be determined, thereby determining an image that can characterize the location information of the target object, realizing object segmentation, and improving the accuracy and efficiency of object segmentation.
[0250] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0251] Figure 14 This is a block diagram illustrating an electronic device for image processing according to an exemplary embodiment. The electronic device may be a terminal, and its internal structure diagram may be as follows: Figure 14 As shown, the electronic device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements an image processing method. The display screen can be a liquid crystal display (LCD) or an e-ink display. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the device's casing, or an external keyboard, touchpad, or mouse.
[0252] Those skilled in the art will understand that Figure 14 The structure shown is merely a block diagram of a portion of the structure related to the present disclosure and does not constitute a limitation on the electronic device to which the present disclosure is applied. A specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0253] In an exemplary embodiment, an electronic device is also provided, including: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the image processing method as described in the embodiments of this disclosure.
[0254] In an exemplary embodiment, a computer-readable storage medium is also provided, wherein when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the image processing method of the present disclosure.
[0255] In an exemplary embodiment, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform the image processing method of the present disclosure embodiments.
[0256] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0257] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0258] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized by, The method comprises: acquiring a to-be-processed image; inputting the to-be-processed image into an object segmentation model for object segmentation processing, and outputting a mask image corresponding to a target object, wherein the object segmentation model is a machine learning model trained based on sample images and label information, the sample image is an image comprising a sample object and a sample background curtain, the label information comprises a first mask image corresponding to the sample image, the first mask image represents actual segmentation information between the sample object and the sample background curtain, the target object is a target recognition object or a foreground object preset by a user, and the mask image comprises a first region and a second region, the first region is a region corresponding to the target object, and the second region is a region outside the first region in the mask image; determining first color information corresponding to each pixel point in the to-be-processed image and second color information corresponding to a pixel point located in the second region in the to-be-processed image; generating a color distance image based on the first color information and the second color information, wherein the color distance image represents color difference information between the first color information and the second color information; generating a first image corresponding to the to-be-processed image based on the color distance image, wherein the first image represents position information of the target object in the to-be-processed image.
2. The method of claim 1, wherein, The first color information comprises an original pixel value corresponding to a target color channel of each pixel point, the second color information comprises a target pixel value corresponding to the target color channel, the target pixel value represents region tone information corresponding to the second region, and the generating of the color distance image based on the first color information and the second color information comprises: determining a pixel value distance between the original pixel value and the target pixel value; and obtaining the color distance image based on the pixel value distance.
3. The method of claim 2, wherein, The generating of the first image corresponding to the to-be-processed image based on the color distance image comprises: classifying pixel points in the color distance image based on the pixel value distance to obtain pixel point category information, wherein the pixel point category information represents a corresponding relationship between the pixel points in the color distance image and the target object; and generating the first image based on the pixel point category information.
4. The method of claim 2, wherein, The generating of the first image corresponding to the to-be-processed image based on the color distance image comprises: performing image smoothing processing on the color distance image to obtain a smoothed image; classifying pixel points in the smoothed image to obtain pixel point category information, wherein the pixel point category information represents a corresponding relationship between the pixel points in the smoothed image and the target object; and generating the first image based on the pixel point category information.
5. The method of claim 1, wherein, The determining of the first color information corresponding to each pixel point in the to-be-processed image and the second color information corresponding to the pixel point located in the second region in the to-be-processed image comprises: acquiring an original pixel value corresponding to a target color channel of each pixel point, wherein the each pixel point comprises a pixel point in the second region. averaging the original pixel values corresponding to the target color channel of the pixels in the second region to obtain a target pixel value corresponding to the target color channel; wherein the first color information comprises the original pixel values, and the second color information comprises the target pixel value.
6. The method of claim 1, wherein, The training process of the object segmentation model comprises: obtaining the sample image and the first mask image; inputting the sample image into the object segmentation model to be trained for object segmentation processing, and outputting a second mask image, wherein the second mask image represents predicted segmentation information between the sample object and the sample background curtain; generating model loss information based on the first mask image and the second mask image; adjusting parameters of the object segmentation model to be trained based on the model loss information to obtain the object segmentation model.
7. The method according to any one of claims 1 to 6, characterized in that, The method further comprises: fusing the to-be-processed image and the first image to obtain a first fused image, wherein the first fused image represents image information of the target object in the to-be-processed image.
8. The method of claim 7, wherein, The method further comprises: fusing the to-be-processed image and the first image to obtain an intermediate fused image; performing color bleeding processing corresponding to target color information on the intermediate fused image to obtain the first fused image, wherein the color bleeding processing is used to smooth pixel values of pixels corresponding to the target color information and located at edges of the target object.
9. The method of claim 7, wherein, The method further comprises: obtaining a target background image; transforming the first image to obtain a second image, wherein the second image represents an image region in the to-be-processed image except the target object; fusing the target background image and the second image to obtain a second fused image, wherein the second fused image represents image information corresponding to the image region in the target background image; generating a composite image based on the first fused image and the second fused image.
10. An image processing apparatus characterized by comprising: The method comprises: an image acquisition module configured to perform obtaining a to-be-processed image; an object segmentation module configured to perform inputting the to-be-processed image into an object segmentation model for object segmentation processing to output a mask image corresponding to a target object, wherein the object segmentation model is a machine learning model trained based on a sample image and label information, the sample image is an image comprising a sample object and a sample background curtain, the label information comprises a first mask image corresponding to the sample image, the first mask image represents actual segmentation information between the sample object and the sample background curtain, the target object is a target recognition object or a foreground object preset by a user, the mask image comprises a first region and a second region, the first region is a region corresponding to the target object, and the second region is a region outside the first region in the mask image; a color determination module configured to perform determining first color information corresponding to each pixel in the to-be-processed image and second color information corresponding to pixels in the second region in the to-be-processed image. The difference information determining module is configured to generate a color distance image based on the first color information and the second color information, the color distance image representing color difference information between the first color information and the second color information. The image generating module is configured to generate a first image corresponding to the to-be-processed image based on the color distance image, the first image representing position information of the target object in the to-be-processed image.
11. An electronic device, comprising: The image processing device comprises: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the image processing method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is enabled to perform the image processing method according to any one of claims 1 to 9.
13. A computer program product comprising computer instructions, characterized in that, The computer instructions, when executed by the processor, implement the image processing method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Pure-color background image automatic matting algorithm, computer readable storage medium and equipment
CN112101370A