Image processing method, device, equipment, computer-readable storage medium and product
By generating a background color-filled head mask and fusing it with the three-dimensional head model, the problem of mismatched head decorations is solved, and the decoration effect and user experience are optimized.
Patent Information
- Application Number
- CN202210872116.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-22
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-07-22
AI Technical Summary
Existing head decoration methods cannot achieve matching between the decoration and the user's head without changing the original face occlusion relationship, resulting in poor decoration effect and failure to meet the actual needs of users.
Generate a head mask filled with a background color that matches the target head decoration coverage area selected by the user, and fuse the 3D head model corresponding to the image to be processed with the target head decoration to optimize the decoration effect.
When the target head decoration matches the user's head, the decoration can block part of the face and display the background, thereby improving the user experience.
Smart Images

Figure CN115131260B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of image processing technology, and in particular to an image processing method, apparatus, device, computer-readable storage medium, and product. Background Art
[0002] To tailor images to meet users' personalized needs, existing applications (APPs) offer image editing features. These allow users to personalize image colors and sizes. Furthermore, APPs offer special effects, decorations, stickers, and other features for further image enhancement and display optimization.
[0003] In actual applications, users can select two-dimensional or three-dimensional decorations according to actual needs. After obtaining the decorations selected by the user, the decorations can be directly fused with the three-dimensional head model corresponding to the user.
[0004] However, when using the above method to decorate the head or face, the decoration may not match the size or shape of the user's head or face. Directly placing the decoration will result in poor decorative effect and fail to meet the user's actual needs, resulting in a poor user experience. Summary of the Invention
[0005] The embodiments of the present disclosure provide an image processing method, apparatus, device, computer-readable storage medium, and product, which are used to solve the technical problem that existing head decoration methods have poor decoration effects and cannot meet the actual needs of users.
[0006] In a first aspect, an embodiment of the present disclosure provides an image processing method, comprising:
[0007] Obtaining a head decoration request, wherein the head decoration request includes an image to be processed and a target head decoration, wherein the target head decoration is used to decorate a portion of a head area;
[0008] Performing an image processing operation on the image to be processed according to the head decoration request to obtain a head mask filled with a background color that matches the target head decoration coverage area;
[0009] generating a three-dimensional head model corresponding to the image to be processed, and fusing the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model;
[0010] A fusion operation is performed on the target three-dimensional model and the background color-filled head mask to obtain a head decoration result.
[0011] In a second aspect, an embodiment of the present disclosure provides an image processing device, including:
[0012] An acquisition module is configured to acquire a head decoration request, wherein the head decoration request includes an image to be processed and a target head decoration, wherein the target head decoration is used to decorate a portion of a head area;
[0013] a processing module, configured to perform an image processing operation on the image to be processed according to the head decoration request, to obtain a head mask filled with a background color that matches the target head decoration coverage area;
[0014] a generating module, configured to generate a three-dimensional head model corresponding to the image to be processed, and fuse the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model;
[0015] The fusion module is used to perform a fusion operation on the target three-dimensional model and the background color-filled head mask to obtain a head decoration result.
[0016] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor and a memory;
[0017] The memory stores computer-executable instructions;
[0018] The processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the image processing method described in the first aspect and various possible designs of the first aspect.
[0019] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the image processing method described in the first aspect and various possible designs of the first aspect is implemented.
[0020] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the image processing method described in the first aspect and various possible designs of the first aspect.
[0021] The image processing method, apparatus, device, computer-readable storage medium, and product provided in this embodiment, after obtaining a head decoration request, generate a background color-filled head mask that matches the target head decoration coverage area selected by the user, and generate a three-dimensional head model corresponding to the image to be processed. The three-dimensional head model corresponding to the image to be processed is fused with the target head decoration to obtain a target three-dimensional model. After the target three-dimensional model is fused with the background color-filled head mask, the background can be displayed on the part of the face obscured by the target head decoration when the target head decoration matches the user's head, thereby optimizing the display effect of the head decoration and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0023] Figure 1 A schematic diagram of the system architecture on which the present disclosure is based;
[0024] Figure 2 A flowchart of an image processing method provided by an embodiment of the present disclosure;
[0025] Figure 3 A schematic diagram of a head decoration provided in an embodiment of the present disclosure;
[0026] Figure 4 A flowchart of an image processing method provided by another embodiment of the present disclosure;
[0027] Figure 5 A schematic diagram of mask processing provided in an embodiment of the present disclosure;
[0028] Figure 6 A schematic diagram of mask expansion provided in an embodiment of the present disclosure;
[0029] Figure 7 A schematic diagram of the structure of an image processing device provided in an embodiment of the present disclosure;
[0030] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present disclosure without making any creative efforts shall fall within the scope of protection of the present disclosure.
[0032] In response to the technical problem mentioned above that the existing head decoration methods have poor decoration effects and cannot meet the actual needs of users, the present disclosure provides an image processing method, device, equipment, computer-readable storage medium and product.
[0033] It should be noted that the image processing methods, devices, equipment, computer-readable storage media and products provided by the present disclosure can be used in various scenarios requiring head decoration.
[0034] Existing head decoration methods generally involve directly placing the headdress effect at the corresponding position on the 3D head model without changing the original face occlusion relationship. However, this method cannot achieve the headdress effect of partially obscuring the face regardless of the size and shape of the head, and it cannot use glass materials in the obscured area.
[0035] In solving the above technical problems, the inventors discovered through research that, in order to achieve a decorative effect that obscures a portion of a person's face and utilize glass materials in areas where the face is obscured, after receiving a head decoration request, a head mask filled with a background color matching the target head decoration coverage area selected by the user can be generated. Specifically, the background color-filled head mask can be a head mask filled with the background color. The target head decoration selected by the user is preprocessed and then fused with the background color-filled head mask to obtain the head decoration result.
[0036] Figure 1 This is a schematic diagram of the system architecture based on which the present disclosure is based. Figure 1 As shown, the system architecture based on which the present disclosure is based includes at least: a terminal device 11 and a server 12, wherein the server 12 is provided with an image processing device, which can be written in languages such as C / C++, Java, Shell or Python; the terminal device 11 can be, for example, a desktop computer, a tablet computer, etc.
[0037] Based on the above system architecture, the image processing device in the server 12 can obtain the head decoration request sent by the terminal device 11, and generate a head decoration result 15 based on the head decoration request, so as to display the background on the part of the face blocked by the target head decoration when the target head decoration 13 matches the user's head 14.
[0038] Figure 2 A flow chart of the image processing method provided by the embodiment of the present disclosure is shown as follows: Figure 2 As shown, the method includes:
[0039] Step 201: Obtain a head decoration request, wherein the head decoration request includes an image to be processed and a target head decoration, and the target head decoration is used to decorate a part of the head area.
[0040] The execution subject of this embodiment is an image processing device, which can be coupled to a server. The server is capable of communicating with a terminal device, thereby obtaining head decoration requests initiated by a user through a triggering operation on the terminal device. Optionally, the image processing device can also be coupled to the terminal device, thereby performing head decoration operations in response to the head decoration requests triggered by the user on the terminal device.
[0041] The image processing method provided by this embodiment can be applied to the application scenario of online fitting, for example, it can simulate the decorative effect of the user's actual wear according to the headwear such as hats selected by the user. Alternatively, the image processing method provided by this embodiment can be applied to the application scenario of image processing, for example, it can add the headwear selected by the user to the user's head area according to the special effects, stickers and other headwear selected by the user. Alternatively, the image processing method provided by this embodiment can be applied to the decoration scenario of digital accessories. Among them, the digital accessories can be of different materials, for example, they can be made of transparent glass, or they can be made of opaque materials, etc. For example, when the target head decoration selected by the user is made of glass, the image processing method provided by this embodiment can be used to achieve the display effect of displaying the background on the part of the face blocked by the target head decoration when the target head decoration matches the user's head. The present disclosure does not limit the application scenario.
[0042] In this embodiment, a user can browse and select head decorations on a terminal device. Once the user's selected target head decoration is obtained, an image to be processed that includes at least the user's head can be obtained, where the target head decoration is used to decorate a portion of the head area. Specifically, the image to be processed can be captured in real time by an image capture device preset in the terminal device, or a pre-stored image to be processed can be selected from a preset storage path based on the user's selection, although this disclosure does not impose any restrictions on this.
[0043] Accordingly, after obtaining the target head device selected by the user and the image to be processed, the terminal device can initiate a head decoration request. Accordingly, the image processing device can obtain the head decoration request.
[0044] Step 202: Perform image processing on the image to be processed according to the head decoration request to obtain a head mask filled with a background color that matches the target head decoration coverage area.
[0045] In this embodiment, in order to optimize the decoration effect of the target head decoration, after the head decoration request is obtained, an image processing operation may be performed on the image to be processed according to the head decoration request.
[0046] Optionally, a segmentation operation can be performed on the head mask that matches the target head decoration in the processed image. The head segmentation operation can be implemented using a head segmentation algorithm, or any other method can be used to implement the head segmentation operation, which is not limited by the present disclosure.
[0047] Optionally, the pixel value corresponding to the head area in the head mask is 1, and the pixel values corresponding to other areas are 0, so that the display effect of the target head decoration can be optimized based on the head mask.
[0048] Furthermore, the target head decoration can be made of a transparent material, such as glass, or an opaque material. To further optimize the display effect, the background can be displayed through the transparent material within the area covered by the target head decoration. Therefore, after obtaining a head mask that matches the target head decoration, the head mask can be blurred to obtain a head mask filled with the background color that matches the area covered by the target head decoration.
[0049] Step 203: Generate a three-dimensional head model corresponding to the image to be processed, and fuse the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model.
[0050] In this embodiment, the target head ornament can also be processed accordingly based on the head ornament request. The target head ornament can be a three-dimensional ornament model. Therefore, based on the image to be processed in the head ornament request, a three-dimensional head mold corresponding to the head region in the image to be processed can be generated. The three-dimensional head mold corresponding to the image to be processed is then fused with the target head ornament to obtain the target three-dimensional model.
[0051] Step 204: performing a fusion operation on the target three-dimensional model and the background color-filled head mask to obtain a head decoration result.
[0052] In this embodiment, after obtaining the target 3D model and the background color-filled head mask, a fusion operation can be performed on the target 3D model and the background color-filled head mask to obtain the head decoration result. Because the pixel values corresponding to the head area in the background color-filled head mask are 1, and the pixel values corresponding to other areas are 0, by fusing the target 3D model with the background color-filled head mask, the target head decoration can be more accurately displayed within the area covered by the target head decoration, while the user's head can be displayed in other areas. For example, the target head decoration can be a headdress that covers the upper half of the face. After completing the above image processing, the target head decoration can be displayed on the upper half of the head, while the user's face can be displayed on the upper half of the head.
[0053] Figure 3 A schematic diagram of a head decoration provided in an embodiment of the present disclosure is shown in FIG. Figure 3 As shown, a user-selected target head decoration 31 and an image to be processed are obtained. A head region 32 in the image to be processed is segmented, and a head decoration result 33 is obtained by performing image processing on the target head decoration 31 and the head region 32. This head decoration result 33 can achieve a decorative effect by obscuring a portion of a person's face.
[0054] Furthermore, based on any of the above embodiments, generating a three-dimensional head model corresponding to the image to be processed includes:
[0055] The texture of the head area in the image to be processed is mapped onto a preset three-dimensional head model to obtain the three-dimensional head model corresponding to the image to be processed.
[0056] In this embodiment, a texture mapping method may be used to implement the generation operation of the three-dimensional head model corresponding to the image to be processed.
[0057] Specifically, the texture of the head area in the image to be processed may be mapped onto a preset three-dimensional head model to obtain a three-dimensional head model corresponding to the image to be processed.
[0058] The image processing method provided in this embodiment generates a background color-filled head mask that matches the target head decoration coverage area selected by the user after obtaining a head decoration request, generates a three-dimensional head model corresponding to the image to be processed, and fuses the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model. After the target three-dimensional model is fused with the background color-filled head mask, the background can be displayed on the part of the face obscured by the target head decoration when the target head decoration matches the user's head, thereby optimizing the display effect of the head decoration and improving the user experience.
[0059] Figure 4A flowchart of an image processing method provided by another embodiment of the present disclosure is provided. Based on any of the above embodiments, Figure 4 As shown, step 202 includes:
[0060] Step 401: Segment the head region in the image to be processed using a preset head segmentation algorithm to obtain a head mask to be processed.
[0061] Step 402: Determine the coverage area corresponding to the target head decoration, and segment the head mask to be processed according to the coverage area to obtain a target head mask that matches the coverage area.
[0062] Step 403: Fill the target head mask with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain the background color-filled head mask.
[0063] In this embodiment, in order to optimize the decoration effect of the target head decoration, after obtaining the head decoration request, an image processing operation may be performed on the image to be processed according to the head decoration request to obtain a head mask filled with a background color.
[0064] First, a head segmentation algorithm can be used to segment the head region in the image to be processed to obtain a head mask to be processed. The head segmentation algorithm can accurately segment the head, hair, and other contents.
[0065] Furthermore, since the target head decoration can be a decoration that covers part of the head area, different head decorations cover different areas. Therefore, in order to make the target head decoration fit the user's head area more closely and further enhance the decorative effect of the target head decoration, after obtaining the head mask to be processed, the corresponding coverage area of the target head decoration can be determined. For example, the coverage area of the target head decoration can be the upper half of the face, the lower half of the face, the hair part, the left face, the right face, etc. Therefore, after determining the corresponding coverage area of the target head decoration, the head mask to be processed can be segmented according to the coverage area to obtain a target head mask that matches the coverage area. For example, when the coverage area of the target head decoration is the upper half of the face, the head mask to be processed can be segmented to obtain a target head mask that only includes the upper half of the face.
[0066] Furthermore, the target head decoration can be made of a transparent material, such as glass, or an opaque material. To accommodate different decorative materials, after obtaining a head mask to be processed that matches the coverage area, a preset fuzzy algorithm can be used to process the target head mask to obtain a background color-filled head mask. Specifically, an image inpainting algorithm can be used to fill the target head mask with the background color corresponding to the image to be processed to obtain a background color-filled head mask.
[0067] The image processing method provided in this embodiment, after receiving a head decoration request, segments the head region in the image to be processed to obtain a head mask to be processed. By segmenting the head mask to be processed based on the coverage area corresponding to the target head decoration, the target head mask is obtained. This ensures that the coverage area of the target head mask is more closely aligned with the target head decoration, thereby enhancing the decorative effect of the target head decoration during subsequent fusion. Furthermore, by filling the target head mask with the background color corresponding to the image to be processed, the background effect can be displayed through the glass when the target head decoration is made of glass, thereby optimizing the display effect of the target head decoration.
[0068] Further, based on any of the above embodiments, step 402 includes:
[0069] Determine coordinate information in the head mask to be processed that matches an edge position of the coverage area.
[0070] According to the coordinate information, a hiding operation is performed on the area of the head mask to be processed that does not match the coverage area to obtain the target head mask.
[0071] In this embodiment, in order to obtain the head mask to be processed that matches the coverage area, a segmentation operation of the head mask to be processed may be implemented specifically through coordinates.
[0072] Specifically, coordinate information matching the edge position of the coverage area in the head mask to be processed can be determined. Based on the coordinate information, the area of the head mask to be processed that does not match the coverage area is hidden to obtain the head mask to be processed that matches the coverage area.
[0073] Figure 5 A schematic diagram of mask processing provided in an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, after the head area in the image to be processed is segmented to obtain the head mask 51 to be processed, if the coverage area corresponding to the target head decoration is the upper half of the face, the lower half of the face to be processed mask 51 can be hidden to obtain the head mask 52 to be processed that matches the coverage area.
[0074] like Figure 5 As shown, the coordinate value of the upper left corner of the head mask 51 to be processed can be (0,0) of uv, and the coordinate value of the lower right corner can be (1,1) of uv. Therefore, based on the above coordinate values, in order to achieve the segmentation operation of the head mask to be processed corresponding to the upper half of the face, the area with a uv value < 0.5 can be filtered and hidden to obtain a head mask to be processed that matches the covered area.
[0075] The image processing method provided in this embodiment partially hides the head mask to be processed based on coordinate information that matches the edge position of the coverage area, thereby accurately retaining the head mask to be processed that matches the coverage area, so that the coverage area of the head mask to be processed is more closely aligned with the target head decoration, and thus in the subsequent fusion process, the decorative effect of the target head decoration can be improved.
[0076] Further, based on any of the above embodiments, step 403 includes:
[0077] A preset fuzzy algorithm is used to fill the human body area in the image to be processed with the background color corresponding to the image to be processed to obtain a fuzzy human body image.
[0078] A fusion operation is performed on the blurred human body image and the target head mask to obtain the background color-filled head mask.
[0079] In this embodiment, to obtain a head mask filled with the background color, a preset fuzzy algorithm is first used to fill the human body region in the image to be processed with the background color corresponding to the image to be processed, thereby achieving scene color transfer and obtaining a blurred human body image. A fusion operation is then performed on the blurred human body image and the head mask to be processed that matches the covered area. The intersection of the blurred human body image and the head mask to be processed that matches the covered area is taken to obtain a head mask filled with the background color. Specifically, the preset fuzzy algorithm can be an image inpainting algorithm that transfers scene color based on the human body segmentation mask, using the scene color to fill the human body.
[0080] Optionally, after obtaining the head mask to be processed that matches the coverage area, a preset fuzzy algorithm may be directly used to perform fuzzy processing on the head mask to be processed that matches the coverage area to obtain a head mask filled with the background color.
[0081] The image processing method provided in this embodiment obtains a blurred human body image by filling the human body area in the image to be processed with the background color corresponding to the image to be processed, and then fuses the blurred human body image and the head mask to be processed that matches the covered area, thereby obtaining a head mask filled with the background color that matches the covered area. When the target head decoration is made of glass, the background effect can be displayed through the glass, thereby optimizing the display effect of the target head decoration.
[0082] Furthermore, based on any of the above embodiments, after step 401, the following steps may be further included:
[0083] Performing a dilation operation on the area corresponding to the head mask to be processed.
[0084] In this embodiment, due to possible errors in the image processing process, the generated head mask to be processed may have some incomplete edge processing. For example, some hair pixels may remain in the hair details and are not included in the output result. As a result, when the head mask to be processed is directly used for subsequent image processing, the hair edges may have jagged residues.
[0085] Therefore, in order to further improve the decorative effect of the target head decoration, a dilation operation may be performed on the area corresponding to the head mask to be processed.
[0086] The image processing method provided in this embodiment performs a dilation operation on the area corresponding to the head mask to be processed, thereby ensuring the integrity of the edge area, avoiding insufficient detail processing, and further improving the effect of head decoration.
[0087] Furthermore, based on any of the above embodiments, the dilation operation on the area corresponding to the head mask to be processed includes:
[0088] A preset rectangular template is used to perform a traversal operation on each pixel in the image to be processed, wherein the pixel value of the area corresponding to the mask of the head to be processed in the image to be processed is greater than the pixel value of the area corresponding to the mask of the non-head to be processed.
[0089] During the traversal process, it is determined whether the pixel value of the central area of the rectangular template is greater than the pixel value of the surrounding area.
[0090] If so, the pixel values of the area covered by the rectangular template are adjusted to be the same as the pixel values of the area corresponding to the head mask to be processed.
[0091] Checking whether the traversal operation for each pixel in the image to be processed has been completed. If not, returning to the step of traversing each pixel in the image to be processed using the preset rectangular template until the traversal operation for each pixel in the image to be processed is completed. If so, determining that the dilation operation for the head mask to be processed has been completed.
[0092] In this embodiment, a rectangular template may be preset, for example, a 3*3 rectangular template, and the rectangular template is used to implement the dilation operation on the area corresponding to the head mask to be processed.
[0093] Specifically, the pixel value of the area corresponding to the head mask to be processed in the image to be processed is greater than the pixel value of the area corresponding to the non-head mask to be processed. For example, the pixel value of the area corresponding to the head mask to be processed is 1, while the pixel values of other areas are 0.
[0094] A preset rectangular template can be used to traverse each pixel in the image to be processed. During the traversal process, the pixel value at the center of the rectangular template is checked to see if it is greater than the pixel values in the surrounding area. If so, the center of the rectangular template is covered by the mask for the head to be processed, while the remaining area is not. Therefore, the pixel values of the area covered by the rectangular template can be adjusted to match the pixel values of the area corresponding to the mask for the head to be processed.
[0095] A check is performed to determine whether the traversal operation for each pixel in the image to be processed has been completed. If so, the dilation operation for the head mask to be processed has been completed. Otherwise, the dilation operation for the head mask to be processed has not yet been completed. The process can return to the step of traversing each pixel in the image to be processed using a preset rectangular template until the traversal operation for each pixel in the image to be processed is completed, thereby achieving the dilation operation for the head mask to be processed.
[0096] Figure 6 A schematic diagram of mask expansion provided by an embodiment of the present disclosure, such as Figure 6 As shown, a preset 3*3 rectangular template 61 can be used to traverse an image 62 to be processed, which includes a head mask 63 to be processed. During the traversal process, the head mask is expanded by comparing the central pixel value of rectangular template 61 with the surrounding pixel values, obtaining a final expansion result 64.
[0097] The image processing method provided in this embodiment uses a preset rectangular template to traverse the image to be processed, and expands the mask area based on the comparison between the central pixel of the rectangular template and the surrounding pixels, thereby being able to quickly implement the expansion operation of the head mask to be processed, thereby avoiding the technical problem of poor edge detail processing.
[0098] Furthermore, based on any of the above embodiments, before step 204, the following steps may be further included:
[0099] Rendering operations are performed on the three-dimensional head model and the target head decoration corresponding to the image to be processed respectively according to a preset rendering order.
[0100] The preset rendering order is to render the target head decoration first, and then render the three-dimensional head model corresponding to the image to be processed after the target head decoration is rendered.
[0101] In this embodiment, the target head decorations vary widely. For example, a glass head decoration may also include decorative elements such as flowers. Therefore, to fully display the target head decorations without being obscured by details of the user's face, a pre-set rendering order can be used. The pre-set rendering order prioritizes rendering the target head decorations, followed by rendering the 3D head model corresponding to the image to be processed.
[0102] Since the 3D head model corresponding to the image to be processed is a model with a human face texture mapped onto it, rendering the target head decoration first and then the 3D head model corresponding to the image to be processed allows the facial features in the areas not covered by the target head decoration to be correctly displayed based on depth contrast without obscuring the decorative details in the target head decoration. Therefore, to further optimize the decorative effect of the target head decoration, the 3D head model corresponding to the image to be processed and the target head decoration can be rendered separately according to a preset rendering order.
[0103] The image processing method provided in this embodiment prioritizes rendering of the target head decoration. After the target head decoration is rendered, the 3D head model corresponding to the image to be processed is rendered. This method can achieve the correct occlusion relationship between the target head decoration and the human face, avoid occlusion of the target head decoration by the human face, and further optimize the decoration effect.
[0104] Furthermore, based on any of the above embodiments, after step 204, the following steps may be further included:
[0105] The ear region in the image to be processed is segmented using a preset ear segmentation algorithm.
[0106] Accordingly, step 204 includes:
[0107] A fusion operation is performed on the target three-dimensional model, the background color-filled head mask, and the ear region to obtain the head decoration result.
[0108] In this embodiment, some target head decorations require the user's ears to be visible, but the 3D head model corresponding to the processed image does not include ears. Therefore, to better match the decorative effect of the target head decoration, a preset ear segmentation algorithm can be used to segment the ear region in the processed image. A fusion operation is performed on the target 3D model, the background color-filled head mask, and the ear region to obtain the head decoration result.
[0109] The image processing method provided in this embodiment segments the ear region in the image to be processed through a preset ear segmentation algorithm, and adds the ear region to the final decoration result, thereby ensuring the integrity of the head.
[0110] Figure 7 A schematic diagram of the structure of an image processing device provided in an embodiment of the present disclosure is shown in FIG. Figure 7 As shown, the device includes: an acquisition module 71, a processing module 72, a generation module 73, and a fusion module 74. The acquisition module 71 is used to obtain a head decoration request, wherein the head decoration request includes an image to be processed and a target head decoration, and the target head decoration is used to decorate a part of the head area. The processing module 72 is used to perform image processing operations on the image to be processed according to the head decoration request to obtain a background color-filled head mask that matches the area covered by the target head decoration. The generation module 73 is used to generate a three-dimensional head model corresponding to the image to be processed, and fuse the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model. The fusion module 74 is used to fuse the target three-dimensional model with the background color-filled head mask to obtain a head decoration result.
[0111] Furthermore, based on any of the above embodiments, the processing module is configured to: segment the head region in the image to be processed using a preset head segmentation algorithm to obtain a head mask to be processed; determine a coverage area corresponding to the target head decoration, segment the head mask to be processed based on the coverage area to obtain a target head mask that matches the coverage area; and fill the target head mask with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain a background-color-filled head mask.
[0112] Furthermore, based on any of the above embodiments, the processing module is configured to determine coordinate information of an edge position of the head mask to be processed that matches the edge position of the coverage area, and perform a concealment operation on the area of the head mask to be processed that does not match the coverage area based on the coordinate information to obtain the target head mask.
[0113] Furthermore, based on any of the above embodiments, the processing module is configured to: fill a human body region in the image to be processed with a background color corresponding to the image to be processed using a preset blurring algorithm to obtain a blurred human body image; and fuse the blurred human body image with the target head mask to obtain the background color-filled head mask.
[0114] Furthermore, based on any of the above embodiments, the processing module is configured to: perform a dilation operation on a region corresponding to the head mask to be processed.
[0115] Furthermore, based on any of the above embodiments, the processing module is used to: use a preset rectangular template to perform a traversal operation on each pixel in the image to be processed, wherein the pixel value of the area corresponding to the mask of the head to be processed in the image to be processed is greater than the pixel value of the area corresponding to the mask of the head not to be processed. During the traversal process, determine whether the pixel value of the central area of the rectangular template is greater than the pixel value of the surrounding area. If so, adjust the pixel value of the area covered by the rectangular template to the same pixel value as the area corresponding to the mask of the head to be processed. Detect whether the traversal operation of each pixel in the image to be processed has been completed. If not, return to the step of performing the traversal operation on each pixel in the image to be processed using the preset rectangular template until the traversal operation of each pixel in the image to be processed is completed. If so, determine that the dilation operation of the mask of the head to be processed has been completed.
[0116] Furthermore, based on any of the above embodiments, the generating module is configured to: map the texture of the head region in the image to be processed onto a preset three-dimensional head model to obtain the three-dimensional head model corresponding to the image to be processed.
[0117] Furthermore, based on any of the above embodiments, the apparatus further includes a rendering module configured to render the three-dimensional head model corresponding to the image to be processed and the target head decoration according to a preset rendering order. The preset rendering order is to render the target head decoration first, and then render the three-dimensional head model corresponding to the image to be processed after the target head decoration is rendered.
[0118] Furthermore, based on any of the above embodiments, the apparatus further includes: a segmentation module configured to segment the ear region in the image to be processed using a preset ear segmentation algorithm; and a fusion module configured to perform a fusion operation on the target 3D model, the background color-filled head mask, and the ear region to obtain the head decoration result.
[0119] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail in this embodiment.
[0120] In order to implement the above embodiment, an embodiment of the present disclosure further provides an electronic device, including: a processor and a memory.
[0121] The memory stores computer-executable instructions.
[0122] The processor executes the computer-executable instructions stored in the memory, so that the processor performs the image processing method as described in any of the above embodiments.
[0123] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure, such as Figure 8 As shown, the electronic device 800 may be a terminal device or a server. The terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (PMPs), and vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 8 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0124] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. Various programs and data required for the operation of the electronic device 800 are also stored in the RAM 803. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0125] Typically, the following devices may be connected to the I / O interface 805: an input device 806 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 808 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 The electronic device 800 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0126] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network via the communication device 809, or installed from the storage device 808, or installed from the ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0127] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0128] An embodiment of the present disclosure further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the image processing method described in any of the above embodiments is implemented.
[0129] An embodiment of the present disclosure further provides a computer program product, including a computer program, which, when executed by a processor, implements the image processing method as described in any of the above embodiments.
[0130] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0131] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.
[0132] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0133] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0134] The units involved in the embodiments described in this disclosure may be implemented in software or hardware. In some cases, the name of a unit does not limit the unit itself. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses."
[0135] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0136] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0137] In a first aspect, according to one or more embodiments of the present disclosure, there is provided an image processing method, comprising:
[0138] Obtaining a head decoration request, wherein the head decoration request includes an image to be processed and a target head decoration, wherein the target head decoration is used to decorate a portion of a head area;
[0139] Performing an image processing operation on the image to be processed according to the head decoration request to obtain a head mask filled with a background color that matches the target head decoration coverage area;
[0140] generating a three-dimensional head model corresponding to the image to be processed, and fusing the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model;
[0141] A fusion operation is performed on the target three-dimensional model and the background color-filled head mask to obtain a head decoration result.
[0142] According to one or more embodiments of the present disclosure, performing an image processing operation on the image to be processed according to the head decoration request to obtain a head mask filled with a background color that matches the target head decoration coverage area includes:
[0143] Performing a segmentation operation on the head region in the image to be processed using a preset head segmentation algorithm to obtain a head mask to be processed;
[0144] Determine a coverage area corresponding to the target head decoration, and segment the head mask to be processed according to the coverage area to obtain a target head mask that matches the coverage area;
[0145] The target head mask is filled with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain the background color-filled head mask.
[0146] According to one or more embodiments of the present disclosure, determining the coverage area corresponding to the target head decoration, and performing a segmentation operation on the head mask to be processed according to the coverage area to obtain the target head mask includes:
[0147] Determining coordinate information of the head mask to be processed that matches an edge position of the coverage area;
[0148] According to the coordinate information, a hiding operation is performed on the area of the head mask to be processed that does not match the coverage area to obtain the target head mask.
[0149] According to one or more embodiments of the present disclosure, the step of filling the target head mask with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain the background color-filled head mask includes:
[0150] Filling the human body region in the image to be processed with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain a fuzzy human body image;
[0151] A fusion operation is performed on the blurred human body image and the target head mask to obtain the background color-filled head mask.
[0152] According to one or more embodiments of the present disclosure, after performing a segmentation operation on the head region in the image to be processed using a preset head segmentation algorithm to obtain a head mask to be processed, the method further includes:
[0153] Performing a dilation operation on the area corresponding to the head mask to be processed.
[0154] According to one or more embodiments of the present disclosure, the dilation operation on the area corresponding to the head mask to be processed includes:
[0155] A preset rectangular template is used to perform a traversal operation on each pixel in the image to be processed, wherein the pixel value of the area corresponding to the mask of the head to be processed in the image to be processed is greater than the pixel value of the area corresponding to the mask of the non-head to be processed;
[0156] During the traversal process, determining whether the pixel value of the central area of the rectangular template is greater than the pixel value of the surrounding area;
[0157] If yes, then the pixel values of the area covered by the rectangular template are adjusted to be the same as the pixel values of the area corresponding to the head mask to be processed;
[0158] Check whether the traversal operation on each pixel in the image to be processed has been completed. If not, return to the step of performing the traversal operation on each pixel in the image to be processed using a preset rectangular template until the traversal operation on each pixel in the image to be processed is completed; if so, determine that the dilation operation on the head mask to be processed has been completed.
[0159] According to one or more embodiments of the present disclosure, generating a three-dimensional head model corresponding to the image to be processed includes:
[0160] The texture of the head area in the image to be processed is mapped onto a preset three-dimensional head model to obtain the three-dimensional head model corresponding to the image to be processed.
[0161] According to one or more embodiments of the present disclosure, before fusing the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain the target three-dimensional model, the process further includes:
[0162] Rendering operations are performed on the three-dimensional head model and the target head decoration corresponding to the image to be processed respectively according to a preset rendering order;
[0163] The preset rendering order is to render the target head decoration first, and then render the three-dimensional head model corresponding to the image to be processed after the target head decoration is rendered.
[0164] According to one or more embodiments of the present disclosure, after fusing the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain the target three-dimensional model, the method further includes:
[0165] Segmenting the ear region in the image to be processed using a preset ear segmentation algorithm;
[0166] The step of fusing the target three-dimensional model with the background color-filled head mask to obtain a head decoration result includes:
[0167] A fusion operation is performed on the target three-dimensional model, the background color-filled head mask, and the ear region to obtain the head decoration result.
[0168] In a second aspect, according to one or more embodiments of the present disclosure, there is provided an image processing device, including:
[0169] An acquisition module is configured to acquire a head decoration request, wherein the head decoration request includes an image to be processed and a target head decoration, wherein the target head decoration is used to decorate a portion of a head area;
[0170] a processing module, configured to perform an image processing operation on the image to be processed according to the head decoration request, to obtain a head mask filled with a background color that matches the target head decoration coverage area;
[0171] a generating module, configured to generate a three-dimensional head model corresponding to the image to be processed, and fuse the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model;
[0172] The fusion module is used to perform a fusion operation on the target three-dimensional model and the background color-filled head mask to obtain a head decoration result.
[0173] According to one or more embodiments of the present disclosure, the processing module is configured to:
[0174] Performing a segmentation operation on the head region in the image to be processed using a preset head segmentation algorithm to obtain a head mask to be processed;
[0175] Determine the coverage area corresponding to the target head decoration, segment the head mask to be processed according to the coverage area, and obtain the target head mask that matches the coverage area
[0176] The target head mask is filled with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain the background color-filled head mask.
[0177] According to one or more embodiments of the present disclosure, the processing module is configured to:
[0178] Determining coordinate information of the head mask to be processed that matches an edge position of the coverage area;
[0179] According to the coordinate information, a hiding operation is performed on the area of the head mask to be processed that does not match the coverage area to obtain the target head mask.
[0180] According to one or more embodiments of the present disclosure, the processing module is configured to:
[0181] Filling the human body region in the image to be processed with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain a fuzzy human body image;
[0182] A fusion operation is performed on the blurred human body image and the target head mask to obtain the background color-filled head mask.
[0183] According to one or more embodiments of the present disclosure, the processing module is configured to:
[0184] Performing a dilation operation on the area corresponding to the head mask to be processed.
[0185] According to one or more embodiments of the present disclosure, the processing module is configured to:
[0186] A preset rectangular template is used to perform a traversal operation on each pixel in the image to be processed, wherein the pixel value of the area corresponding to the mask of the head to be processed in the image to be processed is greater than the pixel value of the area corresponding to the mask of the non-head to be processed;
[0187] During the traversal process, determining whether the pixel value of the central area of the rectangular template is greater than the pixel value of the surrounding area;
[0188] If yes, then the pixel values of the area covered by the rectangular template are adjusted to be the same as the pixel values of the area corresponding to the head mask to be processed;
[0189] Check whether the traversal operation on each pixel in the image to be processed has been completed. If not, return to the step of performing the traversal operation on each pixel in the image to be processed using a preset rectangular template until the traversal operation on each pixel in the image to be processed is completed; if so, determine that the dilation operation on the head mask to be processed has been completed.
[0190] According to one or more embodiments of the present disclosure, the generating module is configured to:
[0191] The texture of the head area in the image to be processed is mapped onto a preset three-dimensional head model to obtain the three-dimensional head model corresponding to the image to be processed.
[0192] According to one or more embodiments of the present disclosure, the apparatus further includes:
[0193] a rendering module, configured to render the three-dimensional head model and the target head decoration corresponding to the image to be processed respectively according to a preset rendering order;
[0194] The preset rendering order is to render the target head decoration first, and then render the three-dimensional head model corresponding to the image to be processed after the target head decoration is rendered.
[0195] According to one or more embodiments of the present disclosure, the apparatus further includes:
[0196] a segmentation module, configured to segment the ear region in the image to be processed using a preset ear segmentation algorithm;
[0197] The fusion module is used to:
[0198] A fusion operation is performed on the target three-dimensional model, the background color-filled head mask, and the ear region to obtain the head decoration result.
[0199] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, comprising: at least one processor and a memory;
[0200] The memory stores computer-executable instructions;
[0201] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the image processing method described in the first aspect and various possible designs of the first aspect.
[0202] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the image processing method described in the first aspect and various possible designs of the first aspect is implemented.
[0203] In a fifth aspect, according to one or more embodiments of the present disclosure, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the image processing method described in the first aspect and various possible designs of the first aspect is implemented.
[0204] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0205] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0206] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. An image processing method, characterized in that: include: Obtaining a head decoration request, wherein the head decoration request includes an image to be processed and a target head decoration, wherein the target head decoration is used to decorate a portion of a head area; Performing an image processing operation on the image to be processed according to the head decoration request to obtain a head mask filled with a background color that matches the target head decoration coverage area; generating a three-dimensional head model corresponding to the image to be processed, and fusing the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model; Performing a fusion operation on the target three-dimensional model and the background color-filled head mask to obtain a head decoration result; The performing an image processing operation on the image to be processed according to the head decoration request to obtain a head mask filled with a background color that matches the target head decoration coverage area includes: Performing a segmentation operation on the head region in the image to be processed using a preset head segmentation algorithm to obtain a head mask to be processed; Determine a coverage area corresponding to the target head decoration, and segment the head mask to be processed according to the coverage area to obtain a target head mask that matches the coverage area; The target head mask is filled with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain the background color-filled head mask.
2. The method according to claim 1, characterized in that The determining of the coverage area corresponding to the target head decoration, segmenting the head mask to be processed according to the coverage area, and obtaining the target head mask matching the coverage area includes: Determining coordinate information of the head mask to be processed that matches an edge position of the coverage area; According to the coordinate information, a hiding operation is performed on the area of the head mask to be processed that does not match the coverage area to obtain the target head mask.
3. The method according to claim 1, characterized in that The method of filling the target head mask with the background color corresponding to the image to be processed by a preset fuzzy algorithm to obtain the background color-filled head mask includes: Filling the human body region in the image to be processed with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain a fuzzy human body image; A fusion operation is performed on the blurred human body image and the target head mask to obtain the background color-filled head mask.
4. The method according to claim 1, wherein After performing a segmentation operation on the head region in the image to be processed by a preset head segmentation algorithm to obtain a head mask to be processed, the method further includes: Performing a dilation operation on the area corresponding to the head mask to be processed.
5. The method according to claim 4, characterized in that The dilating operation on the area corresponding to the head mask to be processed includes: A preset rectangular template is used to perform a traversal operation on each pixel in the image to be processed, wherein the pixel value of the area corresponding to the mask of the head to be processed in the image to be processed is greater than the pixel value of the area corresponding to the mask of the non-head to be processed; During the traversal process, determining whether the pixel value of the central area of the rectangular template is greater than the pixel value of the surrounding area; If yes, then the pixel values of the area covered by the rectangular template are adjusted to be the same as the pixel values of the area corresponding to the head mask to be processed; Check whether the traversal operation on each pixel in the image to be processed has been completed. If not, return to the step of performing the traversal operation on each pixel in the image to be processed using a preset rectangular template until the traversal operation on each pixel in the image to be processed is completed; if so, determine that the dilation operation on the head mask to be processed has been completed.
6. The method according to any one of claims 1 to 5, characterized in that The generating of a three-dimensional head model corresponding to the image to be processed includes: The texture of the head area in the image to be processed is mapped onto a preset three-dimensional head model to obtain the three-dimensional head model corresponding to the image to be processed.
7. The method according to any one of claims 1 to 5, characterized in that Before fusing the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain the target three-dimensional model, the method further includes: Rendering operations are performed on the three-dimensional head model and the target head decoration corresponding to the image to be processed respectively according to a preset rendering order; The preset rendering order is to render the target head decoration first, and then render the three-dimensional head model corresponding to the image to be processed after the target head decoration is rendered.
8. The method according to any one of claims 1 to 5, characterized in that After fusing the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model, the method further includes: Segmenting the ear region in the image to be processed using a preset ear segmentation algorithm; The step of fusing the target three-dimensional model with the background color-filled head mask to obtain a head decoration result includes: A fusion operation is performed on the target three-dimensional model, the background color-filled head mask, and the ear region to obtain the head decoration result.
9. An image processing device, characterized in that: include: An acquisition module is configured to acquire a head decoration request, wherein the head decoration request includes an image to be processed and a target head decoration, wherein the target head decoration is used to decorate a portion of a head area; a processing module, configured to perform an image processing operation on the image to be processed according to the head decoration request, to obtain a head mask filled with a background color that matches the target head decoration coverage area; a generating module, configured to generate a three-dimensional head model corresponding to the image to be processed, and fuse the three-dimensional head model corresponding to the image to be processed with the target head decoration to obtain a target three-dimensional model; a fusion module, configured to fuse the target three-dimensional model with the background color-filled head mask to obtain a head decoration result; The processing module is used to: segment the head area in the image to be processed using a preset head segmentation algorithm to obtain a head mask to be processed; determine the coverage area corresponding to the target head decoration, segment the head mask to be processed based on the coverage area, and obtain a target head mask that matches the coverage area; and fill the target head mask with the background color corresponding to the image to be processed using a preset fuzzy algorithm to obtain a head mask filled with the background color.
10. An electronic device, characterized in that: include: processor and memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the image processing method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the image processing method according to any one of claims 1 to 8 is implemented.
12. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
3D special effect image generation method, device and equipment
CN109840881A
Image processing method, manicure method, makeup method and device, and terminal equipment
CN113298956A