Image processing method and device

By preprocessing the pending images on the server side and generating the target grayscale image, the problem of image style migration in the prior art is solved, resulting in excessive storage space occupied by the client, efficient image processing is achieved and normal operation of the client is reduced. The impact of

CN113205448BActive Publication Date: 2025-02-11ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110556604.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-21
Publication Date
2025-02-11
Estimated Expiration
2041-05-21

AI Technical Summary

Technical Problem

When performing image style migration, the prior art requires multiple processing and large amounts of storage of images to be processed, resulting in excessive storage space of client and affecting normal operation.

Method used

Preprocessing the pending image on the server side, generating a target grayscale image that reflects the changes in the pending image relative to the style image template, and sending the template pixel values ​​of the pending image, the target grayscale image and the style image template to the client. The client generates the target style image based on this information.

Benefits of technology

It reduces the storage space of the client, improves image processing efficiency, and avoids the impact on the normal operation of the client.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113205448B_ABST
    Figure CN113205448B_ABST
Patent Text Reader

Abstract

This specification provides an image processing method and device, wherein the image processing method includes: receiving an image style transfer instruction for an image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template; based on the image identifier and the template identifier, obtaining the image to be processed, a target grayscale image obtained by pre-processing the image to be processed, and a template pixel value corresponding to the at least one style image template, wherein the target grayscale image is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed; and sending the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template to a client. This solution can reduce the storage space occupied by the client, thereby avoiding affecting the normal operation of the client.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to image processing methods and devices, computing equipment, and computer-readable storage media. Background Art

[0002] In the field of image processing, the application of various tools and filters developed based on artificial intelligence technology makes image style transfer possible. Image style transfer refers to transferring the style of one image to another, and the resulting image presents a perfect combination of different image content and image style.

[0003] In the prior art, when performing image style transfer, the server usually uses a certain style image as a template to perform image style transfer processing on the image to be processed through the template to obtain a style image, and then inputs the style image and the image to be processed into the client, and the client obtains the target style image based on the image to be processed and the style image. However, when this method needs to perform image style transfer processing of multiple styles on the same image to be processed, it is necessary to perform image style transfer processing on the image to be processed multiple times, and multiple style images need to be input into the client for processing, which requires a large amount of storage space on the client, which may affect the normal operation of the client. Summary of the invention

[0004] In view of this, the embodiment of this specification provides an image processing method. This specification also relates to an image processing device, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.

[0005] According to a first aspect of an embodiment of this specification, there is provided an image processing method, which is applied to a server and includes:

[0006] Receiving an image style transfer instruction for an image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template;

[0007] Based on the image identifier and the template identifier, obtaining the image to be processed, a target grayscale image obtained by pre-processing the image to be processed, and a template pixel value corresponding to the at least one style image template, wherein the target grayscale image is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed;

[0008] The image to be processed, the target grayscale image and the template pixel values ​​corresponding to the at least one style image template are sent to the client.

[0009] According to a second aspect of an embodiment of this specification, there is provided an image processing method, which is applied to a client and includes:

[0010] Sending an image style transfer instruction for the image to be processed to a server, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template;

[0011] Receiving the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template returned by the server in response to the image style transfer instruction, wherein the target grayscale image is obtained by pre-processing the image to be processed by the server and is used to characterize the influence of the at least one style image template on the image style of the image to be processed;

[0012] At least one target style image is determined based on the image to be processed, the target grayscale image, and template pixel values ​​corresponding to at least one style image template.

[0013] According to a third aspect of an embodiment of this specification, there is provided an image processing device, applied to a server, comprising:

[0014] A first receiving module is configured to receive an image style transfer instruction for an image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template;

[0015] an acquisition module, configured to acquire, based on the image identifier and the template identifier, the image to be processed, a target grayscale image obtained by pre-processing the image to be processed, and template pixel values ​​corresponding to the at least one style image template, wherein the target grayscale image is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed;

[0016] The first sending module is configured to send the image to be processed, the target grayscale image and the template pixel values ​​corresponding to the at least one style image template to the client.

[0017] According to a fourth aspect of the embodiments of this specification, there is provided an image processing device, applied to a client, comprising:

[0018] A second sending module is configured to send an image style transfer instruction for the image to be processed to the server, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template;

[0019] A second receiving module is configured to receive the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template returned by the server in response to the image style transfer instruction, wherein the target grayscale image is obtained by pre-processing the image to be processed by the server and is used to characterize the influence of the at least one style image template on the image style of the image to be processed;

[0020] The determination module is configured to determine at least one target style image based on the image to be processed, the target grayscale image and template pixel values ​​corresponding to at least one style image template.

[0021] According to a fifth aspect of an embodiment of this specification, a computing device is provided, including:

[0022] Memory and processor;

[0023] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the image processing methods described in the above aspects.

[0024] According to a sixth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the image processing method described in the above aspects are implemented.

[0025] The image processing method provided in the present specification receives an image style transfer instruction for an image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template; based on the image identifier and the template identifier, obtains the image to be processed, a target grayscale image obtained by pre-processing the image to be processed, and template pixel values ​​corresponding to the at least one style image template, wherein the target grayscale image is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed; and sends the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template to a client. This solution can process the image to be processed in advance to obtain a target grayscale image that reflects the changes of the image to be processed relative to the style image template. When image style transfer is required, the image to be processed, the target grayscale image and the pixel values ​​corresponding to each style image template in at least one style image template can be sent to the client. Since the target grayscale image is a single-channel image, the memory occupied is relatively small, and the pixel value of the style image template has a smaller data volume than the style image template, and the memory occupied is also relatively small. Therefore, this method can reduce the storage space occupied by the client, thereby avoiding affecting the normal operation of the client.

[0026] The image processing method provided in this specification sends an image style transfer instruction for an image to be processed to a server, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template; receives the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template returned by the server in response to the image style transfer instruction, wherein the target grayscale image is obtained by pre-processing the image to be processed by the server and is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed; and determines at least one target style image based on the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template. In the above method, the client can obtain the target style image according to the image to be processed, the single-channel target grayscale image, and the template pixel values ​​of the style image template, thereby reducing the memory usage of the client, and when there are multiple style image templates, multiple target style images can be obtained based on one target grayscale image, thereby improving the image processing efficiency of the client. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 is a flow chart of an image processing method provided by an embodiment of this specification;

[0028] Figure 2 is a schematic diagram of a grayscale image to be processed provided by an embodiment of this specification;

[0029] Figure 3 is a schematic diagram of a style grayscale image provided in an embodiment of this specification;

[0030] Figure 4 is a schematic diagram of a weighted grayscale image provided in an embodiment of this specification;

[0031] Figure 5 is a schematic diagram of a target grayscale image provided in an embodiment of this specification;

[0032] Figure 6 is a flow chart of another image processing method provided by an embodiment of this specification;

[0033] Figure 7 is a flowchart of another image processing method provided by an embodiment of this specification;

[0034] Figure 8 is a structural schematic diagram of an image processing device provided by an embodiment of this specification;

[0035] Fig. 9 is a structural schematic diagram of another image processing device provided by an embodiment of this specification;

[0036] Fig.10 It is a structural block diagram of a computing device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0037] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0038] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0039] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0040] First, the terms involved in one or more embodiments of this specification are explained.

[0041] Image style transfer: The style of one image is transferred to another image, and the final image presents a perfect combination of different image content and image style.

[0042] In this specification, an image processing method is provided. This specification also relates to an image processing apparatus, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.

[0043] Figure 1 A flowchart of an image processing method provided according to an embodiment of the present specification is shown. The image processing method is applied to a server and may specifically include the following steps:

[0044] Step 102: receiving an image style transfer instruction for an image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template.

[0045] The image to be processed is an image that needs to be processed for image style transfer. The style image template is an image template corresponding to the image style presented after the image style transfer is performed on the image to be processed.

[0046] In some embodiments, if image style transfer processing is required for the image to be processed, the user can select the image style on the client and send an image style transfer instruction to the server through the client. Since image style transfer requires at least a content image and a style image, and the content image is the image to be processed and the style image is the style image template, the image style transfer instruction can include the image identifier of the image to be processed and the template identifier of at least one style image template, so that the server can determine which picture to process into which style.

[0047] In addition, in the embodiment of the present application, the image style transfer of the processed image also requires the use of a pre-processed target grayscale image, which can be used to indicate the degree of influence of the style image template on the image style of the processed image. In this way, when the image style transfer process is performed on the processed image, the pixel values ​​of different pixels can be processed differently according to the degree of influence, which can improve the effect of the final target style image.

[0048] Furthermore, in order to promptly feed back the required target grayscale image to the client upon receiving the image style transfer instruction, before this step, the target grayscale image may be generated in advance according to the image to be processed and at least one style image template.

[0049] In implementation, before receiving an image style transfer instruction for an image to be processed, the method further includes: performing image style transfer processing on the image to be processed according to the at least one style image template to obtain at least one initial style image; and determining the target grayscale image based on the image to be processed and the at least one initial style image.

[0050] The initial style image is an image that combines the image content of the image to be processed and the style of the style image template after image style transfer is performed on the image to be processed.

[0051] As an example, the image to be processed and the initial style image may both be three-channel images. The target grayscale image is a single-channel image, and the pixel value of each pixel is the grayscale value.

[0052] In some embodiments, the image style transfer of the image to be processed can be implemented through an image style transfer model to obtain an initial style image. As an example, the image style transfer model may include a coding layer, an image processing layer, and a decoding layer. The image to be processed and at least one style image can be input into the image style transfer model, and the content feature value of the image to be processed and the style feature value of at least one style image can be extracted through the coding layer, and the content feature value and the style feature value of at least one style image can be input into the image processing layer. The content feature value and the style feature value of at least one style image are normalized through the image processing layer to obtain at least one image feature value, and the at least one image feature value is input into the decoding layer, and then the at least one image feature value can be decoded through the decoding layer to obtain at least one initial style image.

[0053] In some embodiments, based on the image to be processed and the at least one initial style image, the specific implementation of determining the target grayscale image may include: performing grayscale processing on the image to be processed to obtain the grayscale image to be processed, and performing grayscale processing on the at least one initial style image to obtain at least one style grayscale image; based on the grayscale image to be processed and the at least one style grayscale image, determining the target grayscale image.

[0054] That is to say, in order to save memory, the image to be processed and at least one initial style image can be converted into grayscale images to obtain a grayscale image to be processed and at least one style grayscale image respectively, and the target grayscale image is determined based on the grayscale image to be processed and at least one style grayscale image.

[0055] For example, see Figure 2 , Figure 2 is a schematic diagram of a grayscale image to be processed. Assuming that the number of at least one style image template is four, four initial style images can be obtained, see Figure 3 , Figure 3 These are four style grayscale images obtained after grayscale processing of the four initial style images.

[0056] When determining the target grayscale image, the influence of multiple styles on the image to be processed can be integrated and reflected on the target grayscale image, or a target grayscale image can be determined for each style, and the target grayscale image can reflect the influence of its corresponding style on the image to be processed. Moreover, if the number of style image templates is one, an initial style image can be obtained, and the determined target grayscale image is also one, and if the number of style image templates is at least two, the target grayscale image can be determined by the above two methods.

[0057] In a possible implementation, if the number of the at least one initial style image is one, and the initial style image corresponds to a style grayscale image, the specific implementation of determining the target grayscale image based on the grayscale image to be processed and the at least one style grayscale image may include: determining a weighted grayscale image based on the grayscale image to be processed and the style grayscale image, wherein the value of each pixel in each weighted grayscale image is used to characterize the degree to which the pixel value of the pixel is affected by the image style; and normalizing the weighted grayscale image to obtain the target grayscale image.

[0058] That is to say, when at least one style image template is one, the number of initial style images is one, and the number of style grayscale images is one. A weighted grayscale image that can reflect the changes in each pixel in the image to be processed relative to the style image template can be determined based on the grayscale image to be processed and the style grayscale image, and the weighted grayscale image is normalized to obtain the target grayscale image.

[0059] As an example, the style grayscale image can be subtracted from the grayscale image to be processed, that is, the pixel values ​​of the pixels at the same position can be subtracted to obtain new pixel values, and the image determined based on the new pixel values ​​can be called a weighted grayscale image. The pixel value of each pixel in the weighted grayscale image is normalized to obtain a new pixel value of each pixel, and the target grayscale image can be determined based on the new pixel value.

[0060] In another possible implementation, when the number of initial style images is at least two, a target grayscale image may be determined for each style, or the effects of at least two styles on the image to be processed may be combined and reflected on the target grayscale image.

[0061] The first implementation method: If the number of the at least one initial style image is at least two, and each initial style image corresponds to a style grayscale image, the specific implementation of determining the target grayscale image based on the grayscale image to be processed and the at least one style grayscale image may include: determining at least two weighted grayscale images based on the grayscale image to be processed and the at least two style grayscale images, wherein each weighted grayscale image corresponds to a style image template, and the pixel value of each pixel in each weighted grayscale image is used to characterize the degree to which the pixel value of the pixel is affected by the image style of the style image template corresponding to the weighted grayscale image; and normalizing the at least two weighted grayscale images respectively to obtain at least two target grayscale images, wherein each target grayscale image corresponds to a style image template.

[0062] That is to say, when the number of at least one style image template is at least two, the number of initial style images is at least two, and each initial style image corresponds to a style grayscale image, then the number of style grayscale images is at least two. The weighted grayscale image can be determined based on the grayscale image to be processed and each style grayscale image, then at least two weighted grayscale images can be obtained, and each weighted grayscale image can reflect the change in the pixel value of each pixel point in the image to be processed relative to the style image template corresponding to the weighted grayscale image. And each weighted grayscale image can be normalized to obtain a target grayscale image corresponding to each weighted grayscale image, that is, at least two target grayscale images can be obtained.

[0063] As an example, at least two style grayscale images can be used to subtract the grayscale image to be processed respectively. For any reference style grayscale image among the at least two style grayscale images, the pixel values ​​of the pixels at the same position in the reference style grayscale image and the grayscale image to be processed are subtracted to obtain a new pixel value for each pixel. The image determined based on the new pixel value can be called a weighted grayscale image, and the weighted grayscale image can reflect the changes in each pixel in the image to be processed relative to the style image template corresponding to the reference style grayscale image. In this way, at least two weighted grayscale images can be obtained. For any reference weighted grayscale image among the at least two weighted grayscale images, the pixel value of each pixel in the reference weighted grayscale image can be normalized to obtain a new pixel value for each pixel, and based on the new pixel value, the target grayscale image corresponding to the reference weighted grayscale image can be determined. In this way, at least two target grayscale images can be obtained, and one target grayscale image corresponds to one style image template.

[0064] For example, if the number of at least two style image templates is four, see Figure 4 , Figure 4 is a schematic diagram of four weighted grayscale images.

[0065] The second implementation method: If the number of the at least one initial style image is at least two, and each initial style image corresponds to a style grayscale image, the specific implementation of determining the target grayscale image based on the grayscale image to be processed and the at least one style grayscale image may include: determining at least two weighted grayscale images based on the grayscale image to be processed and the at least two style grayscale images, wherein each weighted grayscale image corresponds to a style image template, and the pixel value of each pixel in each weighted grayscale image is used to characterize the degree to which the pixel value of the pixel is affected by the image style of the style image template corresponding to the weighted grayscale image; superimposing the at least two weighted grayscale images to obtain an intermediate grayscale image; and normalizing the intermediate grayscale image to obtain the target grayscale image.

[0066] That is to say, when there are at least two style image templates, the number of initial style images is at least two, and each initial style image corresponds to a style grayscale image, and the number of style grayscale images is at least two. The weighted grayscale image can be determined based on the grayscale image to be processed and each style grayscale image, and at least two weighted grayscale images can be obtained, and each weighted grayscale image can reflect the change in the pixel value of each pixel point in the image to be processed relative to the style image template corresponding to the weighted grayscale image. At least two weighted images can be superimposed to obtain an intermediate grayscale image, and the intermediate grayscale image can be normalized to obtain a target grayscale image, which integrates the influence of at least two style image templates on the image to be processed.

[0067] As an example, at least two style grayscale images can be used to subtract the grayscale image to be processed respectively. For any reference style grayscale image in the at least two style grayscale images, the pixel values ​​of the pixels at the same position in the reference style grayscale image and the grayscale image to be processed are subtracted to obtain a new pixel value for each pixel. The image determined based on the new pixel value can be called a weighted grayscale image, and the weighted grayscale image can reflect the change of each pixel in the image to be processed relative to the style image template corresponding to the reference style grayscale image. In this way, at least two weighted grayscale images can be obtained. The at least two weighted grayscale images are added, that is, the pixel values ​​of the pixels at the same position are added to obtain a new pixel value for each pixel. The image determined based on the new pixel value can be called an intermediate grayscale image. Then, the pixel value of each pixel in the intermediate grayscale image is normalized to obtain a new pixel value for each pixel, and the target grayscale image can be determined based on the new pixel value.

[0068] For example, see Figure 5 , Figure 5 Yes Figure 4 Schematic diagram of the target grayscale image obtained by superimposing and normalizing four weighted grayscale images.

[0069] In an embodiment of the present application, the image to be processed is processed in advance, and the changes of the image to be processed relative to at least two styles are summarized in a target grayscale image. For each style, it is actually only necessary to obtain the target style image for at least two styles based on the target grayscale image and the template pixel values ​​of the style image template. Compared with the prior art, which requires inputting an initial style image each time an image style transfer is performed, the client memory occupied by the image style transfer process is saved.

[0070] Step 104: Based on the image identifier and the template identifier, obtain the image to be processed, the target grayscale image obtained by pre-processing the image to be processed, and the template pixel values ​​corresponding to the at least one style image template, wherein the target grayscale image is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed.

[0071] In some embodiments, after generating the target grayscale image, the image identification of the target grayscale image can be determined based on the image identification of the image to be processed and the template identification of at least one style image template. As an example, the combination of the image identification of the image to be processed and the template identification can be referred to as the image identification.

[0072] For example, assuming that the image identifier of the image to be processed is P1, the target grayscale image corresponds to a style image template, and the template identifier of the style image template is F1, then the image identifier of the target grayscale image can be determined as P1F1. Assuming that the image identifier of the image to be processed is P1, the target grayscale image is obtained by fusing the image styles of two style image templates, and the template identifier of one style image template is F1 and the template identifier of the other style image template is F2, then the image identifier of the target grayscale image can be determined as P1F1F2.

[0073] In a specific implementation, the image to be processed may be determined according to the image identifier, at least one style image template may be determined according to the template identifier, and the target grayscale image may be determined according to the image identifier and the template identifier.

[0074] As an example, after obtaining at least one style image template, the main color value of the at least one style image template can be extracted as the template pixel value. Exemplarily, the server can store the style name of each style image template and the main color value corresponding to the style name, so the main color value corresponding to the style name of the at least one style image template can be obtained as the template pixel value.

[0075] As an example, a grayscale image including the image identifier and the template identifier may be used as a target grayscale image.

[0076] In an embodiment of the present application, the image to be processed can be processed in advance based on the style image template to obtain a target grayscale image. In this way, when an image style transfer instruction is received, the image to be processed, the target grayscale image, and at least one template pixel value can be quickly acquired, thereby improving the efficiency of image acquisition.

[0077] In some embodiments, if the image style for which image style transfer is performed on an image to be processed is a new image style, and the server has not processed the image to be processed based on a style image template corresponding to the new image style, then a target grayscale image corresponding to the image to be processed and the style image template may not exist in the server. Therefore, it is necessary to determine and store the target grayscale image based on the image to be processed and the style image template for subsequent use.

[0078] Therefore, before obtaining the template pixel values ​​corresponding to the image to be processed, the target grayscale image and the at least one style image template based on the image identifier and the template identifier of the at least one style image template, it also includes: querying the target grayscale image based on the image identifier and the template identifier of the at least one style image template; if the target grayscale image does not exist, performing image style transfer processing on the image to be processed according to the at least one style image template to obtain at least one initial style image, and determining the target grayscale image based on the image to be processed and the at least one initial style image.

[0079] In a specific implementation, it is possible to first query in the server whether there is a grayscale image whose identifier includes both the image identifier and the template identifier of at least one style image template. If not, it means that the server has not processed the image to be processed based on the at least one style image template. Therefore, the image to be processed can be subjected to image style transfer processing according to the at least one style image template to obtain an initial style image, and then the target grayscale image is determined based on the initial style image and the image to be processed.

[0080] It should be noted that the specific implementation of determining the target grayscale image is the same as the operation performed before obtaining the template pixel values ​​corresponding to the image to be processed, the target grayscale image and the at least one style image template based on the image identifier and the template identifier in step 102. The specific implementation can be found in the relevant description of the above embodiment, and this embodiment is not limited to this.

[0081] In an embodiment of the present application, after receiving an image style transfer instruction, it can be determined whether a target grayscale image corresponding to the image to be processed and the style image template is stored. If not, the target grayscale image can be generated. This can avoid the situation where after receiving the image style transfer instruction, no feedback can be provided to the client due to the absence of the target grayscale image.

[0082] Step 106: Send the image to be processed, the target grayscale image and the template pixel values ​​corresponding to the at least one style image template to the client.

[0083] The image processing method provided in the present specification receives an image style transfer instruction for an image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template; based on the image identifier and the template identifier, obtains the image to be processed, a target grayscale image obtained by pre-processing the image to be processed, and template pixel values ​​corresponding to the at least one style image template, wherein the target grayscale image is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed; and sends the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template to a client. This solution can process the image to be processed in advance to obtain a target grayscale image that reflects the changes of the image to be processed relative to the style image template. When image style transfer is required, the image to be processed, the target grayscale image and the pixel values ​​corresponding to each style image template in at least one style image template can be sent to the client. Since the target grayscale image is a single-channel image, the memory occupied is relatively small, and the pixel value of the style image template has a smaller data volume than the style image template, and the memory occupied is also relatively small. Therefore, this method can reduce the storage space occupied by the client, thereby avoiding affecting the normal operation of the client.

[0084] Figure 6 A flowchart of another image processing method provided according to an embodiment of the present specification is shown. The image processing method is applied to a client and may specifically include the following steps:

[0085] Step 602: Send an image style transfer instruction for the image to be processed to the server, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template.

[0086] In some embodiments, after the server generates the target grayscale image, it can determine the image identification of the target grayscale image based on the image identification of the image to be processed and the template identification of at least one style image template. As an example, the combination of the image identification of the image to be processed and the template identification can be referred to as the image identification.

[0087] For example, assuming that the image identifier of the image to be processed is P1, the target grayscale image corresponds to a style image template, and the template identifier of the style image template is F1, then the image identifier of the target grayscale image can be determined as P1F1. Assuming that the image identifier of the image to be processed is P1, the target grayscale image is obtained by fusing the image styles of two style image templates, and the template identifier of one style image template is F1 and the template identifier of the other style image template is F2, then the image identifier of the target grayscale image can be determined as P1F1F2.

[0088] In implementation, if image style transfer processing is required for the image to be processed, the user can usually select the style on the client, and send an image style transfer instruction for the image to be processed to the server through the client. Since image style transfer requires the template pixel values ​​of the image to be processed, the target grayscale image and at least one style image template, and the identifier of the target grayscale image can be obtained based on the image identifier of the image to be processed and the template identifier of at least one style image template, the image style transfer instruction can include the image identifier of the image to be processed and the template identifier of at least one style image template.

[0089] Step 604: Receive the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template returned by the server in response to the image style transfer instruction.

[0090] The target grayscale image is obtained by pre-processing the image to be processed by the server, and is used to characterize the influence of the at least one style image template on the image style of the image to be processed.

[0091] In implementation, after receiving the image style transfer instruction, the server can obtain the image to be processed based on the image identifier of the image to be processed, obtain the target grayscale image based on the image identifier of the image to be processed and the template identifier of the at least one style image template, and obtain the template pixel value corresponding to at least one style image template based on the template identifier of at least one style image template.

[0092] It should be noted that the template pixel values ​​corresponding to the image to be processed, the target grayscale image and the at least one style image template can be obtained through the relevant steps of the image processing method applied to the server and sent to the client, and the client can receive it. In addition, the target grayscale image corresponds to the image to be processed, and the target grayscale image corresponds to at least one style image template.

[0093] Step 606: Determine at least one target style image based on the image to be processed, the target grayscale image, and template pixel values ​​corresponding to at least one style image template.

[0094] As an example, determining at least one target style image can be achieved by a GPU (Graphics Processing Unit) of the client. Specifically, the image to be processed, at least one template pixel value, and the target grayscale image can be sent to the GPU for processing to obtain at least one target style image.

[0095] In implementation, the specific implementation of this step may include: obtaining a pixel value group of the image to be processed to obtain an original pixel value group, and obtaining a pixel value group of the target grayscale image to obtain a weighted pixel value group; based on the original pixel value group, at least one template pixel value and the weighted pixel value group, determining at least one target style image.

[0096] That is to say, in the embodiment of the present application, image style transfer for the image to be processed is to adjust the pixel values ​​of the pixels in the image to be processed. Therefore, the template pixel value group of each style image template, the weighted pixel value group of the target grayscale image and the original pixel value group of the image to be processed can be obtained, and the target style image can be determined based on the three pixel value groups obtained.

[0097] In some embodiments, the original pixel value group includes the pixel value of each pixel in the image to be processed. Based on the original pixel value group, at least one template pixel value and the weight pixel value group, the specific implementation of determining the at least one target style image may include: taking the pixel value of the pixel at each position in the target grayscale image as the style weight value, and taking the difference between the pixel value of the pixel at each position in the target grayscale image and a preset value as the content weight value; determining at least one target style image based on the style weight value and content weight value of the pixel at each position, the original pixel value group and the at least one template pixel value group.

[0098] In a specific implementation, if the original pixel value group includes the pixel value of each pixel in the image to be processed, the pixel value of the pixel in the target grayscale image can be used as the style weight value, and the difference between 1 and the style weight value can be used as the content weight value. The style weight value and content weight value of each pixel can be determined, and then at least one target style image can be obtained based on the style weight value of each pixel and at least one template pixel value group, and based on the content weight value of each pixel and the original pixel value group.

[0099] In a possible implementation manner, if the number of the at least one style image template is at least two, the number of the target grayscale images may be one or at least two, so determining at least one target style image can be divided into two implementation manners.

[0100] The first implementation method: the number of target grayscale images is one.

[0101] In some embodiments, if the number of at least one style image template is at least two, and the target grayscale image is obtained by fusing the style influence of the at least two style image templates on the image to be processed, the specific implementation of determining at least one target style image based on the style weight value and content weight value of the pixel at each position, the original pixel value group and the at least one template pixel value group may include: determining the style pixel value of the pixel at each position based on the style weight value of the pixel at each position in the target grayscale image and the template pixel value of the reference style image template, wherein the reference style image template is any one of the at least one style image template; determining the content pixel value of the pixel at each position based on the content weight value of the pixel at each position in the target grayscale image and the original pixel value of the pixel at the corresponding position in the image to be processed; determining the target pixel value of the pixel at each position based on the style pixel value and the content pixel value of the pixel at each position, to obtain the target style image, wherein the style of the target style image corresponds to the style of the reference style image template.

[0102] In a specific implementation, if the number of target grayscale images is one, that is, the target grayscale image is obtained by fusing the style influence of the at least two style image templates on the original image, then the content weight value and the style weight value for each style are the same, so that under different image styles, the degree of change of the image to be processed is the same, and it just changes to different colors. The style weight value of each pixel is multiplied by the template pixel value of the reference style image template to obtain the style pixel value of each pixel. In addition, the content weight value of each pixel is multiplied by the original pixel value of the pixel at the corresponding position in the image to be processed to obtain the content pixel value of each pixel. The style pixel value and the content pixel value of the pixel at each position are added to obtain the target pixel value of the pixel at each position. Image rendering is performed based on the target pixel value to obtain the target style image, and the target style image combines the image content of the image to be processed and the image style of the reference style image template.

[0103] For example, for the reference pixel with coordinates (2, 2), assuming that the RGB value of the reference pixel in the image to be processed is (190, 150, 130), the RGB value of the reference pixel in the reference style image template is (0, 0, 50), and the pixel value of the reference pixel in the target grayscale image is 25, then 25 divided by 255 is approximately equal to 0.1, then it can be determined that the content pixel value of the reference pixel is (190, 150, 130)×(1-0.1)=(171, 135, 117), and the style pixel value of the reference pixel is (0, 0, 50)×0.1=(0, 0, 5), then it can be determined that the target pixel value of the reference pixel is (171, 135, 122).

[0104] In this implementation, the content weight value and style weight value for each style are the same. In this way, the degree of change of the image to be processed for different styles is the same, that is, the target style images corresponding to different styles have the same degree of change relative to the image to be processed, which can bring a better visual experience to users.

[0105] A second implementation manner: the number of target grayscale images is at least two, and each target grayscale image corresponds to one of the at least one style image template.

[0106] In some embodiments, if the number of the at least one style image template is at least two, and each style image template corresponds to a target grayscale image, the specific implementation of determining at least one target style image based on the style weight value and content weight value of the pixel at each position, the original pixel value group and the at least one template pixel value group may include: determining the style pixel value of the pixel at each position based on the style weight value of the pixel at each position in the reference target grayscale image and the template pixel value of the reference style image template, wherein the reference style image template is any one of the at least two style image templates, and the reference target grayscale image is the target grayscale image corresponding to the reference style image template in the at least two target grayscale images; determining the content pixel value of the pixel at each position based on the content weight value of the pixel at each position in the reference target grayscale image and the original pixel value of the pixel at the corresponding position in the image to be processed; determining the target pixel value of the pixel at each position based on the style pixel value and the content pixel value of the pixel at each position, to obtain the target style image, wherein the style of the target style image corresponds to the style of the reference style image template.

[0107] In a specific implementation, when the target grayscale image corresponds to a single style image template, the content weight values ​​and style weight values ​​for different styles may be different. The style weight value of each pixel in the reference target grayscale image is multiplied by the template pixel value of the reference style image template to obtain the style pixel value of each pixel. In addition, the content weight value of each pixel in the reference target grayscale image is multiplied by the original pixel value of the pixel at the corresponding position in the image to be processed to obtain the content pixel value of each pixel. The style pixel value and the content pixel value of the pixel at each position are added to obtain the target pixel value of the pixel at each position. Image rendering is performed based on the target pixel value to obtain the target style image, and the target style image corresponds to the reference style image template.

[0108] In this implementation, the content weight values ​​and style weight values ​​for different styles may be different, so the degree of change of the obtained target style image to each style relative to the image to be processed is different, which can reflect the differences in different style conversions.

[0109] In another possible implementation, if the number of the at least one style image template is one, the specific implementation of determining at least one target style image based on the style weight value and content weight value of the pixel at each position, the original pixel value group and the at least one template pixel value group may include: determining the style pixel value of the pixel at each position based on the style weight value of the pixel at each position in the target grayscale image and the template pixel value of the reference style image template, wherein the reference style image template is any one of the at least one style image template; determining the content pixel value of the pixel at each position based on the content weight value of the pixel at each position in the target grayscale image and the original pixel value of the pixel at the corresponding position in the image to be processed; determining the target pixel value of the pixel at each position based on the style pixel value and content pixel value of the pixel at each position, and obtaining the target style image, wherein the style of the target style image corresponds to the style of the style image template. .

[0110] In a specific implementation, if the number of at least one style image template is one, then the target grayscale image corresponds to the style image template, and the style weight value of each pixel in the target grayscale image can be multiplied by the template pixel value of the style image template to obtain the style pixel value of each pixel. In addition, the content weight value of each pixel in the target grayscale image is multiplied by the original pixel value of the pixel at the corresponding position in the image to be processed to obtain the content pixel value of each pixel. The style pixel value and the content pixel value of the pixel at each position are added together to obtain the target pixel value of the pixel at each position. Image rendering is performed based on the target pixel value to obtain the target style image, and the target style image corresponds to the style image template.

[0111] The image processing method provided in this specification sends an image style transfer instruction for an image to be processed to a server, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template; receives the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template returned by the server in response to the image style transfer instruction, wherein the target grayscale image is obtained by pre-processing the image to be processed by the server and is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed; and determines at least one target style image based on the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template. In the above method, the client can obtain the target style image according to the image to be processed, the single-channel target grayscale image, and the template pixel values ​​of the style image template, thereby reducing the memory usage of the client, and when there are multiple style image templates, multiple target style images can be obtained based on one target grayscale image, thereby improving the image processing efficiency of the client.

[0112] Figure 7 This is a flowchart of another image processing method provided by an embodiment of this specification, which may specifically include the following steps:

[0113] Step 702: The server performs image style transfer processing on the image to be processed according to four style image templates to obtain four initial style images.

[0114] Step 704: the server performs grayscale processing on the image to be processed to obtain a grayscale image to be processed, and performs grayscale processing on the four initial style images respectively to obtain four style grayscale images.

[0115] Step 706: The server determines four weighted grayscale images based on the grayscale image to be processed and the four style grayscale images.

[0116] Step 708: The server superimposes the four weighted grayscale images to obtain an intermediate grayscale image.

[0117] Step 710: The server normalizes the intermediate grayscale image to obtain a target grayscale image.

[0118] Step 712: The client sends an image style transfer instruction for the image to be processed to the server.

[0119] The image style transfer instruction includes the image identifier of the image to be processed and the template identifier of at least one style image template, and the server receives the image style transfer instruction for the image to be processed.

[0120] Step 714: The server obtains the template pixel values ​​corresponding to the image to be processed, the target grayscale image, and the four style image templates based on the image identifier and the template identifier.

[0121] Step 716: The server sends the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the four style image templates to the client.

[0122] That is, the client can receive the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the four style image templates returned by the server in response to the image style transfer instruction.

[0123] Step 718: The client obtains the pixel value group of the image to be processed to obtain the original pixel value group, and obtains the pixel value group of the target grayscale image to obtain the weighted pixel value group.

[0124] Step 720: The client uses the pixel value of each pixel at each position in the target grayscale image as the style weight value, and uses the difference between the pixel value of each pixel at each position in the target grayscale image and 1 as the content weight value.

[0125] Step 722: The client determines the style pixel value of the pixel at each position in the target grayscale image based on the style weight value of the pixel at each position and the template pixel value of the reference style image template.

[0126] The reference style image template is any one of the at least one style image template.

[0127] Step 724: The client determines the content pixel value of each pixel at each position based on the content weight value of the pixel at each position in the target grayscale image and the original pixel value of the pixel at the corresponding position in the image to be processed.

[0128] Step 726: The client determines the target pixel value of each pixel at each position based on the style pixel value and the content pixel value of the pixel at each position to obtain a target style image.

[0129] The style of the target style image corresponds to the style of the reference style image template.

[0130] This solution can process the image to be processed in advance to obtain a target grayscale image that reflects the changes of the image to be processed relative to the style image template. When image style transfer is required, the image to be processed, the target grayscale image and the pixel values ​​corresponding to each style image template in at least one style image template can be sent to the client. Since the target grayscale image is a single-channel image, the memory occupied is relatively small, and the pixel value of the style image template is smaller than the data volume of the style image template, and the memory occupied is also relatively small, so this method can reduce the storage space occupied by the client, thereby avoiding affecting the normal operation of the client. In addition, when there are multiple style image templates, multiple target style images can be obtained based on one target grayscale image, which improves the image processing efficiency of the client.

[0131] Corresponding to the above-mentioned method embodiment applied to the server, this specification also provides an image processing device embodiment, Figure 8 FIG. 1 shows a schematic diagram of the structure of an image processing device provided by an embodiment of the present specification. Figure 8 As shown, the device comprises:

[0132] A first receiving module 802 is configured to receive an image style transfer instruction for an image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template;

[0133] The acquisition module 804 is configured to acquire the image to be processed, a target grayscale image obtained by pre-processing the image to be processed, and a template pixel value corresponding to the at least one style image template based on the image identifier and the template identifier, wherein the target grayscale image is used to represent the influence of the at least one style image template on the image style of the image to be processed;

[0134] The first sending module 806 is configured to send the image to be processed, the target grayscale image and the template pixel values ​​corresponding to the at least one style image template to the client.

[0135] Optionally, the first receiving module 802 is further configured to:

[0136] Performing image style migration processing on the image to be processed according to the at least one style image template to obtain at least one initial style image;

[0137] The target grayscale image is determined based on the image to be processed and the at least one initial style image.

[0138] Optionally, the first receiving module 802 is further configured to:

[0139] Performing grayscale processing on the image to be processed to obtain a grayscale image to be processed, and performing grayscale processing on the at least one initial style image to obtain at least one style grayscale image;

[0140] The target grayscale image is determined based on the grayscale image to be processed and the at least one style grayscale image.

[0141] Optionally, the first receiving module 802 is further configured to:

[0142] If the number of the at least one initial style image is one, and the initial style image corresponds to a style grayscale image, a weighted grayscale image is determined based on the grayscale image to be processed and the style grayscale image, wherein the value of each pixel in each weighted grayscale image is used to characterize the degree to which the pixel value of the pixel is affected by the image style;

[0143] The weighted grayscale image is normalized to obtain the target grayscale image.

[0144] Optionally, the first receiving module 802 is further configured to:

[0145] If the number of the at least one initial style image is at least two, and each initial style image corresponds to a style grayscale image, at least two weighted grayscale images are determined based on the grayscale image to be processed and the at least two style grayscale images, wherein each weighted grayscale image corresponds to a style image template, and the pixel value of each pixel in each weighted grayscale image is used to represent the degree to which the pixel value of the pixel is affected by the image style of the style image template corresponding to the weighted grayscale image;

[0146] The at least two weighted grayscale images are respectively normalized to obtain at least two target grayscale images, wherein each target grayscale image corresponds to a style image template.

[0147] Optionally, the first receiving module 802 is further configured to:

[0148] If the number of the at least one initial style image is at least two, and each initial style image corresponds to a style grayscale image, at least two weighted grayscale images are determined based on the grayscale image to be processed and the at least two style grayscale images, wherein each weighted grayscale image corresponds to a style image template, and the pixel value of each pixel in each weighted grayscale image is used to represent the degree to which the pixel value of the pixel is affected by the image style of the style image template corresponding to the weighted grayscale image;

[0149] Superimposing the at least two weighted grayscale images to obtain an intermediate grayscale image;

[0150] The intermediate grayscale image is normalized to obtain the target grayscale image.

[0151] Optionally, the acquisition module 804 is further configured to:

[0152] querying the target grayscale image based on the image identifier and the template identifier of the at least one style image template;

[0153] If the target grayscale image does not exist, image style transfer processing is performed on the image to be processed according to the at least one style image template to obtain at least one initial style image, and the target grayscale image is determined based on the image to be processed and the at least one initial style image.

[0154] The image processing device provided in the present specification receives an image style transfer instruction for an image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template; based on the image identifier and the template identifier, obtains the image to be processed, a target grayscale image obtained by pre-processing the image to be processed, and template pixel values ​​corresponding to the at least one style image template, wherein the target grayscale image is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed; and sends the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template to a client. This solution can process the image to be processed in advance to obtain a target grayscale image that reflects the changes of the image to be processed relative to the style image template. When image style transfer is required, the image to be processed, the target grayscale image and the pixel values ​​corresponding to each style image template in at least one style image template can be sent to the client. Since the target grayscale image is a single-channel image, the memory occupied is relatively small, and the pixel value of the style image template has a smaller data volume than the style image template, and the memory occupied is also relatively small. Therefore, this method can reduce the storage space occupied by the client, thereby avoiding affecting the normal operation of the client.

[0155] The above is a schematic scheme of an image processing device of this embodiment. It should be noted that the technical scheme of the image processing device and the technical scheme of the image processing method applied to the server belong to the same concept, and the details not described in detail in the technical scheme of the image processing device can be referred to the description of the technical scheme of the image processing method.

[0156] Corresponding to the above-mentioned method embodiment applied to the client, this specification also provides an image processing device embodiment, Fig. 9 FIG. 1 shows a schematic diagram of the structure of an image processing device provided by an embodiment of the present specification. Fig. 9 As shown, the device comprises:

[0157] A second sending module 902 is configured to send an image style transfer instruction for the image to be processed to the server, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template;

[0158] The second receiving module 904 is configured to receive the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template returned by the server in response to the image style transfer instruction, wherein the target grayscale image is obtained by pre-processing the image to be processed by the server and is used to characterize the influence of the at least one style image template on the image style of the image to be processed;

[0159] The determination module 906 is configured to determine at least one target style image based on the image to be processed, the target grayscale image and template pixel values ​​corresponding to at least one style image template.

[0160] Optionally, the determination module 906 is configured to:

[0161] Obtaining a pixel value group of the image to be processed to obtain an original pixel value group, and obtaining a pixel value group of the target grayscale image to obtain a weighted pixel value group;

[0162] The at least one target style image is determined based on the original pixel value group, at least one template pixel value and the weight pixel value group.

[0163] Optionally, the determination module 906 is configured to:

[0164] The original pixel value group includes the pixel value of each pixel in the image to be processed, the pixel value of each pixel at each position in the target grayscale image is used as the style weight value, and the difference between the pixel value of each pixel at each position in the target grayscale image and a preset value is used as the content weight value;

[0165] At least one target style image is determined based on the style weight value and the content weight value of the pixel point at each position, the original pixel value group and the at least one template pixel value group.

[0166] Optionally, the determination module 906 is configured to:

[0167] If the number of the at least one style image template is at least two, and the target grayscale image is obtained by fusing the style influence of the at least two style image templates on the image to be processed, the style pixel value of the pixel at each position in the target grayscale image is determined based on the style weight value of the pixel at each position in the target grayscale image and the template pixel value of the reference style image template, wherein the reference style image template is any one of the at least one style image template;

[0168] Determine the content pixel value of each pixel at each position based on the content weight value of the pixel at each position in the target grayscale image and the original pixel value of the pixel at the corresponding position in the image to be processed;

[0169] Based on the style pixel value and the content pixel value of the pixel at each position, a target pixel value at each position is determined to obtain the target style image, wherein the style of the target style image corresponds to the style of the reference style image template.

[0170] Optionally, the determination module 906 is configured to:

[0171] If the number of the at least one style image template is at least two, and each style image template corresponds to a target grayscale image, determining the style pixel value of the pixel at each position in the reference target grayscale image and the template pixel value of the reference style image template, wherein the reference style image template is any one of the at least two style image templates, and the reference target grayscale image is a target grayscale image corresponding to the reference style image template in the at least two target grayscale images;

[0172] Determine the content pixel value of each pixel at each position based on the content weight value of the pixel at each position in the reference target grayscale image and the original pixel value of the pixel at the corresponding position in the image to be processed;

[0173] Based on the style pixel value and the content pixel value of the pixel at each position, a target pixel value at each position is determined to obtain the target style image, wherein the style of the target style image corresponds to the style of the reference style image template.

[0174] Optionally, the determination module 906 is configured to:

[0175] If the number of the at least one style image template is one, determining a style pixel value of the pixel at each position in the target grayscale image based on a style weight value of the pixel at each position and a template pixel value of a reference style image template, wherein the reference style image template is any one of the at least one style image template;

[0176] Determine the content pixel value of each pixel at each position based on the content weight value of the pixel at each position in the target grayscale image and the original pixel value of the pixel at the corresponding position in the image to be processed;

[0177] Based on the style pixel value and the content pixel value of the pixel at each position, a target pixel value at each position is determined to obtain the target style image, wherein the style of the target style image corresponds to the style of the style image template.

[0178] The image processing device provided in this specification sends an image style transfer instruction for an image to be processed to a server, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template; receives the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template returned by the server in response to the image style transfer instruction, wherein the target grayscale image is obtained by pre-processing the image to be processed by the server and is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed; and determines at least one target style image based on the image to be processed, the target grayscale image, and the template pixel values ​​corresponding to the at least one style image template. In the above method, the client can obtain the target style image based on the image to be processed, the single-channel target grayscale image, and the template pixel values ​​of the style image template, thereby reducing the memory usage of the client, and when there are multiple style image templates, multiple target style images can be obtained based on one target grayscale image, thereby improving the image processing efficiency of the client.

[0179] The above is a schematic scheme of an image processing device of this embodiment. It should be noted that the technical scheme of the image processing device and the technical scheme of the image processing method applied to the client are of the same concept, and the details not described in detail in the technical scheme of the image processing device can be found in the description of the technical scheme of the image processing method.

[0180] Fig.10 The structure block diagram of a computing device 1000 provided according to an embodiment of the present specification is shown. The components of the computing device 1000 include but are not limited to a memory 1010 and a processor 1020. The processor 1020 is connected to the memory 1010 via a bus 1030, and the database 1050 is used to store data.

[0181] The computing device 1000 also includes an access device 1040 that enables the computing device 1000 to communicate via one or more networks 1060. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1040 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0182] In one embodiment of the present specification, the above components of the computing device 1000 and Fig.10 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.10 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0183] The computing device 1000 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 1000 may also be a mobile or stationary server.

[0184] The processor 1020 is used to execute computer executable instructions to implement the image processing methods described in the above embodiments.

[0185] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned image processing method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned image processing method.

[0186] An embodiment of the present specification further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the image processing methods described in the above embodiments.

[0187] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned image processing method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned image processing method.

[0188] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0189] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0190] It should be noted that, for the convenience of description, the aforementioned method embodiments are all described as a series of action combinations, but those skilled in the art should be aware that this specification is not limited by the order of the actions described, because according to this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this specification.

[0191] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0192] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims

1. An image processing method, characterized in that: Applicable to servers, including: Performing image style migration processing on the image to be processed according to at least one style image template to obtain at least one initial style image, wherein the initial style image refers to an image that combines the image content of the image to be processed and the style of the style image template; Determining a target grayscale image based on the image to be processed and the at least one initial style image; receiving an image style transfer instruction for the image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of the at least one style image template; Based on the image identifier and the template identifier, obtaining the template pixel values ​​corresponding to the image to be processed, the target grayscale image, and the at least one style image template, wherein the target grayscale image is used to characterize the influence of the at least one style image template on the image style of the image to be processed; The image to be processed, the target grayscale image and the template pixel values ​​corresponding to the at least one style image template are sent to the client.

2. The image processing method according to claim 1, characterized in that: Determining a target grayscale image based on the image to be processed and the at least one initial style image includes: Performing grayscale processing on the image to be processed to obtain a grayscale image to be processed, and performing grayscale processing on the at least one initial style image to obtain at least one style grayscale image; The target grayscale image is determined based on the grayscale image to be processed and the at least one style grayscale image.

3. The image processing method according to claim 2, characterized in that: If the number of the at least one initial style image is at least two, and each initial style image corresponds to a style grayscale image, determining the target grayscale image based on the grayscale image to be processed and the at least one style grayscale image includes: Based on the grayscale image to be processed and at least two of the style grayscale images, at least two weighted grayscale images are determined, wherein each weighted grayscale image corresponds to a style image template, and the pixel value of each pixel in each weighted grayscale image is used to represent the degree to which the pixel value of the pixel is affected by the image style of the style image template corresponding to the weighted grayscale image; The at least two weighted grayscale images are respectively normalized to obtain at least two target grayscale images, wherein each target grayscale image corresponds to a style image template.

4. The image processing method according to claim 2, wherein: If the number of the at least one initial style image is at least two, and each initial style image corresponds to a style grayscale image, determining the target grayscale image based on the grayscale image to be processed and the at least one style grayscale image includes: Based on the grayscale image to be processed and at least two of the style grayscale images, at least two weighted grayscale images are determined, wherein each weighted grayscale image corresponds to a style image template, and the pixel value of each pixel in each weighted grayscale image is used to represent the degree to which the pixel value of the pixel is affected by the image style of the style image template corresponding to the weighted grayscale image; Superimposing the at least two weighted grayscale images to obtain an intermediate grayscale image; The intermediate grayscale image is normalized to obtain the target grayscale image.

5. The image processing method according to claim 1, wherein: Before obtaining the template pixel values ​​corresponding to the image to be processed, the target grayscale image and the at least one style image template based on the image identifier and the template identifier, the method further includes: querying the target grayscale image based on the image identifier and the template identifier of the at least one style image template; If the target grayscale image does not exist, image style transfer processing is performed on the image to be processed according to the at least one style image template to obtain at least one initial style image, and the target grayscale image is determined based on the image to be processed and the at least one initial style image.

6. An image processing method, characterized in that: Applied to the client, including: Sending an image style transfer instruction for the image to be processed to a server, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template; Receive the template pixel values ​​corresponding to the image to be processed, the target grayscale image and the at least one style image template returned by the server in response to the image style transfer instruction, wherein the target grayscale image is obtained by pre-processing the image to be processed by the server and is used to characterize the influence of the at least one style image template on the image style of the image to be processed, the target grayscale image is determined based on the image to be processed and at least one initial style image, the at least one initial style image is obtained by performing image style transfer processing on the image to be processed according to the at least one style image template, and the initial style image refers to an image that combines the image content of the image to be processed and the style of the style image template; Obtaining a pixel value group of the image to be processed to obtain an original pixel value group, and obtaining a pixel value group of the target grayscale image to obtain a weighted pixel value group; At least one target style image is determined based on the original pixel value group, at least one template pixel value and the weight pixel value group.

7. The image processing method according to claim 6, characterized in that: The original pixel value group includes the pixel value of each pixel in the image to be processed, and based on the original pixel value group, at least one template pixel value and the weight pixel value group, determining the at least one target style image includes: The pixel value of each pixel point at each position in the target grayscale image is used as a style weight value, and the difference between the pixel value of each pixel point at each position in the target grayscale image and a preset value is used as a content weight value; At least one target style image is determined based on the style weight value and the content weight value of the pixel point at each position, the original pixel value group and the at least one template pixel value group.

8. The image processing method according to claim 7, characterized in that: If the number of the at least one style image template is at least two, and the target grayscale image is obtained by fusing the style influence of at least two of the style image templates on the image to be processed, determining at least one target style image based on the style weight value and content weight value of the pixel point at each position, the original pixel value group and the at least one template pixel value group, including: Determine a style pixel value of a pixel at each position in the target grayscale image based on a style weight value of a pixel at each position in the target grayscale image and a template pixel value of a reference style image template, wherein the reference style image template is any one of at least two of the style image templates; Determine the content pixel value of each pixel at each position based on the content weight value of the pixel at each position in the target grayscale image and the original pixel value of the pixel at the corresponding position in the image to be processed; Based on the style pixel value and the content pixel value of the pixel at each position, a target pixel value at each position is determined to obtain the target style image, wherein the style of the target style image corresponds to the style of the reference style image template.

9. The image processing method according to claim 7, characterized in that: If the number of the at least one style image template is at least two, and each style image template corresponds to a target grayscale image, determining at least one target style image based on the style weight value and the content weight value of the pixel point at each position, the original pixel value group, and the at least one template pixel value group, includes: Determining a style pixel value of a pixel at each position based on a style weight value of a pixel at each position in a reference target grayscale image and a template pixel value of a reference style image template, wherein the reference style image template is any one of at least two style image templates, and the reference target grayscale image is a target grayscale image corresponding to the reference style image template in at least two target grayscale images; Determine the content pixel value of each pixel at each position based on the content weight value of the pixel at each position in the reference target grayscale image and the original pixel value of the pixel at the corresponding position in the image to be processed; Based on the style pixel value and the content pixel value of the pixel at each position, a target pixel value at each position is determined to obtain the target style image, wherein the style of the target style image corresponds to the style of the reference style image template.

10. An image processing device, characterized in that: Applicable to servers, including: A first receiving module is configured to perform image style transfer processing on the image to be processed according to at least one style image template to obtain at least one initial style image, wherein the initial style image refers to an image that combines the image content of the image to be processed and the style of the style image template; determine a target grayscale image based on the image to be processed and the at least one initial style image; receive an image style transfer instruction for the image to be processed, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of the at least one style image template; an acquisition module, configured to acquire, based on the image identifier and the template identifier, the image to be processed, the target grayscale image, and template pixel values ​​corresponding to the at least one style image template, wherein the target grayscale image is used to characterize the degree of influence of the at least one style image template on the image style of the image to be processed; The first sending module is configured to send the image to be processed, the target grayscale image and the template pixel values ​​corresponding to the at least one style image template to the client.

11. An image processing device, characterized in that: Applied to the client, including: A second sending module is configured to send an image style transfer instruction for the image to be processed to the server, wherein the image style transfer instruction includes an image identifier of the image to be processed and a template identifier of at least one style image template; a second receiving module, configured to receive the template pixel values ​​corresponding to the image to be processed, the target grayscale image and the at least one style image template returned by the server in response to the image style transfer instruction, wherein the target grayscale image is obtained by pre-processing the image to be processed by the server and is used to characterize the influence of the at least one style image template on the image style of the image to be processed, the target grayscale image is determined based on the image to be processed and at least one initial style image, the at least one initial style image is obtained by performing image style transfer processing on the image to be processed according to the at least one style image template, and the initial style image refers to an image that combines the image content of the image to be processed and the style of the style image template; The determination module is configured to obtain a pixel value group of the image to be processed to obtain an original pixel value group, and to obtain a pixel value group of the target grayscale image to obtain a weighted pixel value group; based on the original pixel value group, at least one template pixel value and the weighted pixel value group, determine at least one target style image.

12. A computing device, characterized in that: include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the image processing method described in any one of claims 1 to 5 or claims 6 to 9.

13. A computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the image processing method according to any one of claims 1 to 5 or claims 6 to 9.

Citation Information

Patent Citations

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

    CN111476851A