Image processing method and device, electronic equipment, storage medium and program product

Image style transfer is achieved by adjusting image pixel values ​​using a preset mapping relationship. This solves the problems of high sample set requirements and long training time in existing technologies, and realizes fast and convenient image style transfer and efficient debugging and optimization.

CN121937281APending Publication Date: 2026-04-28BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING XIAOMI MOBILE SOFTWARE CO LTD
Filing Date
2024-10-28
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Existing image style transfer methods require a large number of samples to train neural network models, resulting in low training flexibility, long training time, and low efficiency in model debugging and optimization.

Method used

By obtaining the initial pixel values ​​of the image to be processed, using a preset mapping relationship to find the target parameters, and adjusting the pixel values ​​to achieve image style transfer, the requirement for the number of sample sets is reduced, the training process is simplified, and flexibility is improved.

Benefits of technology

It enables fast and convenient image style transfer, reduces the training time and complexity of neural network models, and improves the flexibility and debugging efficiency of image style transfer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121937281A_ABST
    Figure CN121937281A_ABST
Patent Text Reader

Abstract

The invention relates to an image processing method and device, electronic equipment, a storage medium and a program product. The image processing method comprises the following steps: acquiring a to-be-processed image; based on an initial pixel of the to-be-processed image, in a preset mapping relation corresponding to an image category to which the to-be-processed image belongs, searching for a target parameter corresponding to a pixel value of the initial pixel; adjusting the to-be-processed image based on the target parameter to obtain a target image; wherein the target parameters are different, and the image styles of the target images are different. According to the embodiment of the invention, the target image can be obtained according to the preset mapping relation corresponding to the image category to which the to-be-processed image belongs, so that image style migration can be quickly and conveniently realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of image processing technology, and in particular to an image processing method and apparatus, electronic device, storage medium, and program product. Background Technology

[0002] Image style transfer is a computer image processing technique that combines the content features of a content image with specified style features to obtain a new image; the new image has both the content features of the content image and the specified image style.

[0003] Commonly used image style transfer methods in related technologies utilize convolutional neural network (CNN) models. These models automatically learn features such as edges, textures, and colors, and then perform image style transfer based on these features. However, using neural network models for image style transfer requires training the model with a large number of samples, limiting training flexibility and time consumption. Furthermore, a large sample set with consistent styles is necessary; if untrained image styles are present, the complex internal workings of the neural network lead to low efficiency in model debugging and optimization. Summary of the Invention

[0004] To overcome the problems existing in related technologies, this disclosure provides an image processing method and apparatus, electronic device, storage medium, and program product. Embodiments of this disclosure can obtain a target image based on a preset mapping relationship corresponding to the image category to which the image to be processed belongs, thereby achieving rapid and convenient image style transfer.

[0005] According to a first aspect of the present disclosure, an image processing method is provided, comprising:

[0006] Obtain the image to be processed;

[0007] Based on the initial pixels of the image to be processed, the target parameter corresponding to the pixel value of the initial pixel is found in the preset mapping relationship corresponding to the image category to which the image to be processed belongs;

[0008] The image to be processed is adjusted based on the target parameters to obtain the target image; wherein, different target parameters result in different image styles for the target images.

[0009] In some embodiments, the step of searching for a target parameter corresponding to the pixel value of the initial pixel in a preset mapping relationship corresponding to the image category to which the image to be processed belongs, based on the initial pixel of the image to be processed, includes:

[0010] If the pixel value bit of the initial pixel is the same as the pixel value bit of the preset mapping relationship, the target pixel value is obtained by searching in the preset mapping relationship based on the pixel value of the initial pixel of the image to be processed.

[0011] The step of adjusting the image to be processed based on the target parameters to obtain the target image includes:

[0012] The pixel value of the initial pixel is adjusted to the target pixel value to obtain the target image.

[0013] In some embodiments, the step of searching for a target parameter corresponding to the pixel value of the initial pixel in a preset mapping relationship corresponding to the image category to which the image to be processed belongs, based on the initial pixel of the image to be processed, includes:

[0014] If the pixel value bit of the initial pixel is different from the pixel value bit of the preset mapping relationship, the pixel value of the initial pixel is adjusted to obtain the adjusted pixel value, and the target gain value is obtained by searching in the preset mapping relationship based on the adjusted pixel value.

[0015] The step of adjusting the image to be processed based on the target parameters to obtain the target image includes:

[0016] Based on the target gain value, the pixel values ​​of the initial pixels of the image to be processed are adjusted to obtain the target image.

[0017] In some embodiments, the method further includes:

[0018] Obtain multiple initial sample images belonging to different image categories;

[0019] Based on the image category to which each initial sample image belongs, multiple target sample images corresponding to multiple initial sample images in the same image category are determined. Each target sample image has the same image category and image content as the corresponding initial sample image, and the target sample image has a preset image style associated with its image category.

[0020] Based on the multiple initial sample images and multiple target sample images corresponding to each image category, a preset mapping relationship is obtained between the multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category; and / or,

[0021] Based on the multiple initial sample images and multiple target sample images corresponding to each image category, multiple initial pixel values ​​corresponding to each image category are obtained, as well as multiple target gain values ​​corresponding to the multiple initial pixel values ​​in each image category;

[0022] Based on the multiple initial pixel values ​​and the multiple target gain values, a preset mapping relationship is obtained between the multiple initial pixel values ​​and the multiple target gain values ​​in each image category.

[0023] In some embodiments, obtaining the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on multiple initial sample images and multiple target sample images corresponding to each image category includes:

[0024] Based on the pixel grayscale value of each initial sample image, determine the different initial pixel values ​​corresponding to each initial sample image;

[0025] Based on the target sample image corresponding to each initial sample image, determine the first candidate pixel value corresponding to each initial pixel value of each initial sample image;

[0026] Based on the different initial pixel values ​​corresponding to each initial sample image in the same image category and the first candidate pixel value corresponding to each initial pixel value, the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category is determined.

[0027] In some embodiments, determining a first candidate pixel value corresponding to each initial pixel value of each initial sample image based on the target sample image corresponding to each initial sample image includes:

[0028] For each initial pixel value in each initial sample image, determine the first pixel position of each initial pixel value in each initial sample image, and determine the first target pixel located at the first pixel position in each target sample image corresponding to each initial sample image;

[0029] Based on the pixel grayscale value of the first target pixel, determine the first candidate pixel value corresponding to each initial pixel value.

[0030] In some embodiments, determining the first candidate pixel value corresponding to each of the initial pixel values ​​based on the pixel grayscale value of the first target pixel includes:

[0031] When there are multiple first target pixels, the average of the pixel grayscale values ​​of the multiple first target pixels is determined as the first candidate pixel value corresponding to each initial pixel value;

[0032] or,

[0033] Obtain multiple second target pixels located at the second pixel position in the target sample image; wherein the second pixel position is adjacent to the first pixel position;

[0034] Based on the pixel grayscale value of the first target pixel and the pixel grayscale values ​​of multiple second target pixels, a second candidate pixel value corresponding to each first target pixel is determined;

[0035] When there are multiple first target pixels, the average value of multiple second candidate pixel values ​​corresponding to the multiple first target pixels is determined as the first candidate pixel value corresponding to each initial pixel value.

[0036] In some embodiments, determining the second candidate pixel value corresponding to each first target pixel based on the pixel grayscale value of the first target pixel and the pixel grayscale values ​​of a plurality of second target pixels includes:

[0037] The difference between the pixel grayscale value of each second target pixel and the pixel grayscale value of the first target pixel is determined respectively;

[0038] If all the differences are within the preset difference range, the pixel grayscale value of the first target pixel is used as the second candidate pixel value corresponding to the first target pixel.

[0039] If any of the differences is outside the preset difference range, the pixel grayscale value of the first target pixel is filtered to obtain the second candidate pixel value corresponding to the first target pixel.

[0040] In some embodiments, determining the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on different initial pixel values ​​corresponding to each initial sample image in the same image category and the first candidate pixel value corresponding to each initial pixel value includes:

[0041] For each initial pixel value corresponding to each initial sample image in each image category, if the initial pixel value corresponds to an initial sample image, the first candidate pixel value corresponding to the initial pixel value is used as the target pixel value corresponding to the initial pixel value;

[0042] In the case where the initial pixel value corresponds to multiple initial sample images, the average value of multiple first candidate pixel values ​​corresponding to the same initial pixel value is taken as the target pixel value corresponding to the initial pixel value.

[0043] Based on the target pixel value corresponding to each initial pixel value in each image category, a preset mapping relationship is determined between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category.

[0044] In some embodiments, the method further includes:

[0045] The image to be processed is parsed to obtain at least one image parameter of the image to be processed, wherein different image parameters are used to describe different display effects of the image to be processed;

[0046] Based on at least one image parameter of the image to be processed, determine the image category to which the image to be processed belongs.

[0047] According to a second aspect of the present disclosure, an image processing apparatus is provided, comprising:

[0048] The acquisition module is configured to acquire the image to be processed.

[0049] The search module is configured to search for a target parameter corresponding to the pixel value of the initial pixel in a preset mapping relationship corresponding to the image category to which the image to be processed belongs, based on the initial pixel of the image to be processed.

[0050] The adjustment module is configured to adjust the image to be processed based on the target parameters to obtain a target image; wherein, different target parameters result in different image styles for the target images.

[0051] In some embodiments, the search module is further configured to, when the pixel value bit of the initial pixel is the same as the pixel value bit corresponding to the preset mapping relationship, search in the preset mapping relationship based on the pixel value of the initial pixel of the image to be processed to obtain the target pixel value;

[0052] The adjustment module is further configured to adjust the pixel value of the initial pixel to the target pixel value to obtain the target image.

[0053] In some embodiments, the search module is further configured to adjust the pixel value of the initial pixel when the pixel value bit of the initial pixel is different from the pixel value bit of the preset mapping relationship, to obtain an adjusted pixel value, and to search in the preset mapping relationship based on the adjusted pixel value to obtain a target gain value;

[0054] The adjustment module is further configured to adjust the pixel values ​​of the initial pixels of the image to be processed based on the target gain value to obtain the target image.

[0055] In some embodiments, the image processing apparatus further includes: a mapping relationship construction module;

[0056] The mapping relationship construction module is configured to: acquire multiple initial sample images belonging to different image categories; determine multiple target sample images corresponding to the multiple initial sample images in the same image category based on the image category to which each initial sample image belongs, wherein each target sample image and its corresponding initial sample image have the same image category and image content, and the target sample image has a preset image style associated with its image category; obtain the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on the multiple initial sample images and multiple target sample images corresponding to each image category; and / or, obtain multiple initial pixel values ​​corresponding to each image category and multiple target gain values ​​corresponding to the multiple initial pixel values ​​in each image category based on the multiple initial sample images and multiple target sample images corresponding to each image category; obtain the preset mapping relationship between multiple initial pixel values ​​and multiple target gain values ​​in each image category based on the multiple initial pixel values ​​and multiple target gain values.

[0057] In some embodiments, the mapping relationship construction module is further configured to: determine different initial pixel values ​​corresponding to each initial sample image based on the pixel grayscale value of each initial sample image; determine a first candidate pixel value corresponding to each initial pixel value of each initial sample image based on the target sample image corresponding to each initial sample image; and determine the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on the different initial pixel values ​​corresponding to each initial sample image in the same image category and the first candidate pixel value corresponding to each initial pixel value.

[0058] In some embodiments, the mapping relationship construction module is further configured to, for each initial pixel value of each initial sample image, determine the first pixel position of each initial pixel value in each initial sample image, and determine the first target pixel located at the first pixel position in each target sample image corresponding to each initial sample image; and determine the first candidate pixel value corresponding to each initial pixel value based on the pixel grayscale value of the first target pixel.

[0059] In some embodiments, the mapping relationship construction module is further configured to, when there are multiple first target pixels, determine the average of the pixel grayscale values ​​of the multiple first target pixels as the first candidate pixel value corresponding to each initial pixel value; or, acquire multiple second target pixels located at second pixel positions in the target sample image; wherein the second pixel positions are adjacent to the first pixel positions; determine the second candidate pixel value corresponding to each first target pixel based on the pixel grayscale values ​​of the first target pixels and the pixel grayscale values ​​of the multiple second target pixels; when there are multiple first target pixels, determine the average of the multiple second candidate pixel values ​​corresponding to the multiple first target pixels as the first candidate pixel value corresponding to each initial pixel value.

[0060] In some embodiments, the mapping relationship construction module is further configured to determine the difference between the pixel grayscale value of each second target pixel and the pixel grayscale value of the first target pixel; when all the differences are within a preset difference range, the pixel grayscale value of the first target pixel is used as the second candidate pixel value corresponding to the first target pixel; when any of the differences are outside the preset difference range, the pixel grayscale value of the first target pixel is filtered to obtain the second candidate pixel value corresponding to the first target pixel.

[0061] In some embodiments, the mapping relationship construction module is further configured to, for each initial pixel value corresponding to each initial sample image in each image category, if the initial pixel value corresponds to one initial sample image, use the first candidate pixel value corresponding to the initial pixel value as the target pixel value corresponding to the initial pixel value; if the initial pixel value corresponds to multiple initial sample images, use the average of the multiple first candidate pixel values ​​corresponding to the same initial pixel value as the target pixel value corresponding to the initial pixel value; and determine the preset mapping relationship between the multiple initial pixel values ​​and the multiple target pixel values ​​corresponding to each image category based on the target pixel value corresponding to each initial pixel value in each image category.

[0062] In some embodiments, the acquisition module is further configured to parse the image to be processed to obtain at least one image parameter of the image to be processed, wherein different image parameters are used to describe different display effects of the image to be processed; and to determine the image category to which the image to be processed belongs based on at least one image parameter of the image to be processed.

[0063] According to a third aspect of the present disclosure, an electronic device is provided, including a processor; a memory for storing computer programs or instructions; wherein the processor executes the computer programs or instructions to implement the steps of the method described in the first aspect above.

[0064] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, the storage medium storing a computer program or instructions, wherein when the computer program or instructions in the storage medium are executed by a processor, the steps of the method described in the first aspect are implemented.

[0065] According to a fifth aspect of the present disclosure, a computer program product is provided, wherein when the computer program or instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

[0066] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:

[0067] The image processing method provided in this disclosure can obtain a preset mapping relationship using a small number of samples, and find the preset mapping relationship corresponding to the image category to which the image to be processed belongs based on the pixel values ​​of the initial pixels of the image to be processed, thereby obtaining the target parameters. By adjusting the pixels using the target parameters, the image style transfer of the same image category can be achieved quickly and conveniently. Thus, compared with training and using neural network models for style transfer, the above image processing method reduces the requirement for a large number of samples, thereby reducing the time and complexity of training the neural network model; it also eliminates the need to adapt to the complex internal working mechanism of the neural network model, improving the flexibility of the image style transfer method; furthermore, the method proposed in this disclosure allows for individual processing of each image category to define or update the corresponding image style. Compared with defining new image style transfers or iteratively training image styles in a neural network model, this disclosure offers higher efficiency in debugging and optimizing image style transfer.

[0068] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0069] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0070] Figure 1 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 1 .

[0071] Figure 2 This is a schematic diagram illustrating an initial sample image and a target sample image according to an exemplary embodiment.

[0072] Figure 3 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 2 .

[0073] Figure 4 This is a structural block diagram of an image processing apparatus according to an exemplary embodiment.

[0074] Figure 5 This is a structural block diagram of an electronic device according to an exemplary embodiment. Detailed Implementation

[0075] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0076] Figure 1 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 1 .like Figure 1 As shown, this image processing method is used in electronic devices, and the method mainly includes the following steps:

[0077] Step 101: Obtain the image to be processed;

[0078] Step 102: Based on the initial pixels of the image to be processed, find the target parameter corresponding to the pixel value of the initial pixel in the preset mapping relationship corresponding to the image category to which the image to be processed belongs;

[0079] Step 103: Adjust the image to be processed based on the target parameters to obtain the target image;

[0080] Different target parameters result in different image styles for the target images.

[0081] Here, the image processing method proposed in this disclosure is applied to an electronic device, capable of performing image style conversion processing on one or a batch of images to be processed, resulting in one or a batch of target images with an image style matching the image category of the images to be processed. The electronic device includes a terminal or a portable device; the terminal includes, but is not limited to, mobile phones, tablets, etc.; the portable device includes, but is not limited to, smartwatches, etc., and this disclosure does not impose any limitations on these.

[0082] In step 101, the electronic device acquires the image to be processed in response to the image processing instruction.

[0083] Here, the acquisition of the image to be processed in the embodiments of this disclosure can occur in a scene of taking a picture, in a scene of image processing software processing an input image, or in a scene of training other image processing models.

[0084] In some examples, the central processing unit of the electronic device responds to image processing instructions and preprocesses the image signal output from the image sensor based on the image processing module (ISP) to obtain the image to be processed. The preprocessing includes, but is not limited to, color conversion, gamma correction, and color correction. After obtaining the image to be processed, the ISP executes steps 102 to 103 to perform pixel transfer on the image to be processed to obtain a style-transferred target image. The final target image can be output to the display module for display or further image post-processing, such as dead pixel correction.

[0085] In other examples, the image processing software of an electronic device responds to image processing instructions by acquiring an input image imported from image storage software, i.e., acquiring the image to be processed.

[0086] In some other examples, the electronic device can also acquire images to be processed in batches, thereby generating corresponding target images using subsequent steps 102 to 103, so as to batch process multiple images to be processed to obtain multiple target images, and use the batch-processed target images to form training samples for other image processing models, such as training samples for a generative adversarial network model for face correction.

[0087] In step 102, the electronic device first determines the image category to which the image to be processed belongs, and obtains a preset mapping relationship corresponding to the image category to which the image to be processed belongs; then, based on the initial pixels of the image to be processed read, it searches for the target parameter corresponding to the pixel value of the initial pixel in the preset mapping relationship corresponding to the image category to which the image to be processed belongs.

[0088] In this embodiment of the disclosure, the electronic device may determine the image category of the image to be processed by using an open-source image classification model for classification processing, or by detecting and analyzing the image to be processed. This embodiment of the disclosure does not limit the method.

[0089] Different image categories reflect different image content and scenes; for example, different image categories can be landscape, biological, object, and architectural categories, etc.; different image categories can also be backlight scene categories, front light scene categories, etc.; of course, they can also be obtained by combining the above categories, for example, different image categories can be backlight scene biological categories, front light scene architectural categories, etc., and this disclosure does not limit or elaborate on these aspects.

[0090] It should be noted that the electronic device stores multiple preset mapping relationships corresponding to image categories. These preset mapping relationships can be stored in the form of key-value pairs or in the form of a two-dimensional mapping table. In this embodiment, each image category corresponds to a preset mapping relationship, or similar image categories correspond to a preset mapping relationship. The preset mapping relationship corresponding to each image category is obtained by image processing using one or more sets of sample images of the corresponding image category, specifically including multiple two-dimensional mappings related to pixel values.

[0091] Here, each two-dimensional mapping related to a pixel value represents the trend of a pixel value's change. Multiple two-dimensional mappings for each image category can achieve changes in multiple pixel values, thereby influencing image brightness, contrast, or color, thus achieving style transfer. For example, each of these pixel-value-related two-dimensional mappings can be a mapping between pixel values, such as the mapping between pixel values ​​before and after style transfer, or a mapping between pixel values ​​and pixel adjustment parameters, such as the mapping between pixel values ​​before style transfer and the pixel adjustment parameters used to implement style transfer. For example, these pixel adjustment parameters can be filter parameters used to filter the pixel values ​​before style transfer.

[0092] Thus, in this embodiment of the present disclosure, after reading the image to be processed pixel by pixel, the pixel value before style transfer corresponding to the pixel value of the initial pixel of the image to be processed is found in the preset mapping relationship corresponding to the category. The target parameter is found based on the pixel value before style transfer. The target parameter is the pixel value after style transfer or the pixel adjustment parameter. In this way, different target parameters can reflect different pixel value change trends, so that the style of the transferred image is different. That is, each image category has a specified style of transferred image reflected by the target parameter.

[0093] It is understood that the method of obtaining the preset mapping relationship in this embodiment is relatively simple and does not require a large number of sample images. Compared with training a neural network model for image style transfer, the requirements for the sample set are lower, the training process is simpler, and the time consumption is shorter. Furthermore, if it is necessary to adjust the style transfer corresponding to each image category, only the sample images corresponding to that image category can be processed without retraining the neural network model, which makes debugging and optimization more efficient.

[0094] In step 103, after obtaining the target parameters, the image to be processed is adjusted according to the target parameters; for example, the target parameters are used to cover the pixel values ​​of the initial pixels, or the target parameters are used to adjust the initial values ​​of the initial pixels, thereby obtaining the target image after pixel adjustment.

[0095] In this embodiment of the disclosure, if no pixel value before style transfer is found based on the pixel value of the initial pixel of the image to be processed, the pixel value of the initial pixel may not be processed. In this case, the target image is obtained based on the unprocessed initial pixel and each processed initial pixel.

[0096] It is understandable that by adjusting multiple initial pixels in the image to be processed according to the target parameters, the resulting target image has a specified image style corresponding to its image category, thus achieving image style transfer.

[0097] The image processing method provided in this disclosure can obtain a preset mapping relationship using a small number of samples, and find the preset mapping relationship corresponding to the image category to which the image to be processed belongs based on the pixel values ​​of the initial pixels of the image to be processed, thereby obtaining the target parameters. By adjusting the pixels using the target parameters, the image style transfer of the same image category can be achieved quickly and conveniently. Thus, compared with training and using neural network models for style transfer, the above image processing method reduces the requirement for a large number of samples, thereby reducing the time and complexity of training the neural network model; it also eliminates the need to adapt to the complex internal working mechanism of the neural network model, improving the flexibility of the image style transfer method; furthermore, the method proposed in this disclosure allows for individual processing of each image category to define or update the corresponding image style. Compared with defining new image style transfers or iteratively training image styles in a neural network model, this disclosure offers higher efficiency in debugging and optimizing image style transfer.

[0098] In some embodiments, the above-mentioned method of finding the target parameter corresponding to the pixel value of the initial pixel in a preset mapping relationship corresponding to the image category to which the image to be processed belongs, based on the initial pixel of the image to be processed, includes:

[0099] If the pixel value bits of the initial pixel are the same as the pixel value bits corresponding to the preset mapping relationship, the target pixel value is obtained by searching in the preset mapping relationship based on the pixel value of the initial pixel of the image to be processed.

[0100] The image to be processed is adjusted based on the target parameters to obtain the target image, including:

[0101] The initial pixel values ​​are adjusted to the target pixel values ​​to obtain the target image.

[0102] It should be noted that the pixel value bits of an image represent the number of bits required for each pixel, determining the color depth and grayscale levels of the image; for example, when the pixel value bits in the preset mapping relationship are 8 bits, it can represent 256(2 8 The grayscale level of the initial pixel is 8 bits, which can represent 256 (2 8 The gray levels of ).

[0103] In this embodiment, the pixel value bits of the initial pixel can typically correspond to the gray level of the pixel gray value in the image to be processed, or to the color depth of a color channel (red R channel, green G channel, or blue B channel). Thus, if the pixel value bits of the initial pixel are the same as the pixel value bits corresponding to the preset mapping relationship, and the pixel value of the initial pixel is the same as the pixel value before style transfer, then it can represent the same pixel value. Conversely, if the pixel value bits of the initial pixel are different from the pixel value bits corresponding to the preset mapping relationship, and the pixel value of the initial pixel is the same as the pixel value before style transfer, then it cannot represent the same pixel value. For example, in practical applications, a pixel value of 10 with 8 bits and a pixel value of 40 with 10 bits represent the same pixel value.

[0104] Therefore, in this embodiment of the present disclosure, when the pixel value bit of the initial pixel is the same as the pixel value bit corresponding to the preset mapping relationship, the pixel value before style transfer with the same value can be found based on the pixel value of the initial pixel, and the target parameter can be found based on the pixel value before style transfer. Here, the preset mapping relationship includes a two-dimensional mapping of multiple pixel values ​​before style transfer and pixel values ​​after style transfer (i.e., target pixel values). Thus, in this example, the target parameter found is the target pixel value after style mapping.

[0105] In this embodiment of the disclosure, the pixel value of the successfully found initial pixel can be adjusted to the target pixel value, thereby obtaining a target image with a specified image style corresponding to its image category.

[0106] In this embodiment of the disclosure, after finding the target pixel value in an initial pixel, the initial pixel value can be directly updated to the target pixel value, or the pixel value of the successfully found initial pixel can be adjusted to the target pixel value after traversing and searching all initial pixels.

[0107] It should be noted that, in some examples, the pixel value of the initial pixel in this embodiment can be a pixel grayscale value, and the target pixel value being searched is also a pixel grayscale value; after being adjusted to the target pixel value, color adjustment processing can be performed using the grayscale image formed based on each target pixel value, thereby obtaining the target image. In other examples, the pixel value of the initial pixel in this embodiment can be the color pixel value of one of the three color channels (RGB channels), and the target pixel value being searched is also the color pixel value of the corresponding channel; after obtaining the target pixel values ​​of the three color channels respectively, the target image can be obtained.

[0108] Thus, in this embodiment, when the pixel value bit of the initial pixel is the same as the pixel value bit corresponding to the preset mapping relationship, the pixel value before style transfer with the same value can be directly found based on the pixel value of the initial pixel, and the target pixel value can be found based on the pixel value before style transfer, thereby obtaining the target image. This improves the accuracy, flexibility and efficiency of image style transfer.

[0109] In some embodiments, the above-mentioned method of finding the target parameter corresponding to the pixel value of the initial pixel in a preset mapping relationship corresponding to the image category to which the image to be processed belongs, based on the initial pixel of the image to be processed, includes:

[0110] If the pixel value bit of the initial pixel is different from the pixel value bit of the preset mapping relationship, the pixel value of the initial pixel is adjusted to obtain the adjusted pixel value, and the target gain value is obtained by searching in the preset mapping relationship based on the adjusted pixel value.

[0111] The above-mentioned method of adjusting the image to be processed based on the target parameters to obtain the target image includes:

[0112] Based on the target gain value, the pixel values ​​of the initial pixels of the image to be processed are adjusted to obtain the target image.

[0113] As described above in the embodiments of this disclosure, it is understood that if the pixel value bits of the initial pixel are different from the pixel value bits corresponding to the preset mapping relationship, and the pixel value of the initial pixel is the same as the pixel value before style transfer, then the same pixel value cannot be represented. Therefore, in this embodiment, the pixel value of the initial pixel is first adjusted to obtain an adjusted pixel value, wherein the pixel value bits of the adjusted pixel value are the same as the pixel value bits corresponding to the preset mapping relationship. After adjustment, the pixel value before style transfer with the same value can be found based on the adjusted pixel value, and the target parameter can be found based on the pixel value before style transfer.

[0114] In this example, the preset mapping relationship includes a two-dimensional mapping between multiple pixel values ​​before style transfer and target gain values. The gain value is a pixel adjustment parameter as described above, and the target gain value corresponding to the pixel value before style transfer is obtained by calculating the pixel value after style transfer (i.e., the target pixel value) and the pixel value before style transfer, such as the ratio or the difference between the two.

[0115] In this embodiment of the disclosure, the pixel value of the successfully found initial pixel can be calculated with the target gain value to obtain the calculated pixel value, and the pixel value of the initial pixel can be updated using the calculated pixel value to obtain a target image with a specified image style corresponding to its image category.

[0116] In this embodiment, after finding the target gain value of an initial pixel, the calculated pixel value can be obtained directly, and the pixel value of the initial pixel can be updated to the calculated pixel value; alternatively, after searching through all initial pixels, the pixel values ​​of the successfully found initial pixels can be calculated and adjusted to the calculated pixel value.

[0117] Thus, in this embodiment, when the pixel value bits of the initial pixel are different from the pixel value bits corresponding to the preset mapping relationship, the pixel bits are first adjusted to be the same, and then the target gain value corresponding to the pixel value of the initial pixel is found, thereby performing gain processing to obtain the target image. In this way, not only is the accuracy of finding the target parameter improved, but the step of adjusting the target pixel value bit by bit to the pixel value bits of the initial pixel is also saved, thereby improving the efficiency of image style transfer.

[0118] In this embodiment, the image to be processed has a corresponding original tone curve, which reflects the relationship between the pixel values ​​of the original pixels and the pixel values ​​of the initial pixels of the image to be processed after preprocessing to generate the initial style. Thus, this embodiment can find the target pixel value or target gain value based on the pixel values ​​of the initial pixels and a preset mapping relationship to obtain the target tone curve, and reflect the image style of the obtained target image based on this target tone curve. In the process of converting the original tone curve and the preset mapping relationship to obtain the target tone curve, the conversion needs to be performed with consistent pixel value bits; that is, during the conversion process, attention should be paid to ensuring that pixel values ​​with the same value represent the same meaning. The specific process is not limited in this embodiment.

[0119] It should be noted that, in practical applications, the target tonal curve can be used to reflect image style (image quality) or to correct image display effects.

[0120] In some embodiments of the present disclosure, the image processing method further includes:

[0121] Obtain multiple initial sample images belonging to different image categories;

[0122] Based on the image category to which each initial sample image belongs, multiple target sample images corresponding to multiple initial sample images in the same image category are determined. Each target sample image has the same image category and image content as its corresponding initial sample image, and the target sample image has a preset image style associated with its image category.

[0123] Based on multiple initial sample images and multiple target sample images corresponding to each image category, a preset mapping relationship is obtained between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category; and / or,

[0124] Based on multiple initial sample images and multiple target sample images corresponding to each image category, multiple initial pixel values ​​corresponding to each image category are obtained, as well as multiple target gain values ​​corresponding to the multiple initial pixel values ​​in each image category;

[0125] Based on multiple initial pixel values ​​and multiple target gain values, a preset mapping relationship between multiple initial pixel values ​​and multiple target gain values ​​in each image category is obtained.

[0126] Here, the embodiments of this disclosure require image processing and analysis (which can be understood as training) using multiple initial sample images and target sample images of different categories to obtain a preset mapping relationship corresponding to each image category.

[0127] In the training phase of this embodiment, multiple initial sample images are first acquired, and these initial sample images are then classified to obtain the image category of each initial sample image, resulting in initial sample images of different image categories. The classification of the multiple initial sample images can be performed using an open-source image classification model or an image classification algorithm from an electronic device. For example, this embodiment parses the initial sample images to obtain at least one image parameter, each image parameter describing a display effect of the initial sample image.

[0128] In some examples of embodiments of this disclosure, the above-mentioned image parameters include primary image parameters; wherein the primary image parameters include, but are not limited to, image brightness and light ratio, which are used to describe the basic scene of the initial sample image; for example, the primary image parameters can be used to determine outdoor backlight scene, outdoor frontlight scene, ..., night scene frontlight scene and night scene backlight scene, etc. In embodiments of this disclosure, the above-mentioned scenes can be defined as various image categories, that is, outdoor backlight scene is classified as O1, outdoor frontlight scene O2, ..., night scene frontlight scene On-1 and night scene backlight scene On.

[0129] Of course, in other examples, the image can be further analyzed to obtain secondary image parameters according to customized needs; the scene can be further subdivided through secondary image parameters; for example, secondary image parameters include shape features, texture features and / or color features, etc., and these secondary image parameters can represent the type of objects in the image; for example, flowers, green plants, clouds, people, animals, etc. have obvious differences in shape; there are large differences in texture between flowers, green plants, and organisms; and specific color combinations and distribution patterns can also be used to identify object types. For example, if an image has a large amount of pink, red, yellow, etc., it can be determined that there are flowers in the image.

[0130] Thus, image categories can be further divided using secondary image parameters. For example, image category Q1 corresponding to an indoor backlit scene can be further divided into image category Q11 corresponding to an outdoor backlit scene + portrait, image category Q12 corresponding to an outdoor backlit scene + green plants, ..., image category Q1n corresponding to an outdoor backlit scene + flowers, etc. Other image categories can also be further divided, which will not be elaborated in this embodiment.

[0131] For different image categories, this embodiment of the disclosure can define a specified image style for each image category, and perform unified image rendering processing on each initial sample image of the same image category according to the image style. For example, the main flower in an outdoor backlit scene with flowers is darkened, or the background in a night scene with front lighting is brightened, etc. This embodiment of the disclosure does not limit this. In this way, the rendered target sample image has the same image category and image content as the corresponding initial sample image, and has a preset image style associated with the image category. Furthermore, through the preset image style, the target sample image has a better display effect than the corresponding initial sample image and is more in line with the scene and image content.

[0132] See Figure 2 , Figure 2 This is a schematic diagram of an initial sample image and a target sample image according to an exemplary embodiment. For example, if the image category to which the initial sample image (a) belongs indicates that the initial sample image is a backlit scene and there is a human figure in the image, then the image style of the target sample image (b) is defined as a low-exposure image style, for example, by reducing the brightness of the human figure portion in the initial sample image (a) to obtain the target sample image (b).

[0133] After obtaining the corresponding target sample image by performing the above rendering process on each initial sample image of each image category, the embodiments of this disclosure can construct the preset mapping relationship proposed in the above embodiments for each image category.

[0134] In some examples, for the same image category, based on multiple initial sample images and target sample images corresponding to each initial sample image, a preset mapping relationship is obtained between multiple initial pixel values ​​(which can be understood as pixel values ​​before style mapping) and multiple target pixel values ​​(which can be understood as pixel values ​​after style mapping) corresponding to an image category.

[0135] Here, an initial pixel value corresponds to a target pixel value; the initial pixel value is the color pixel value (corresponding to one color channel of multiple color channels) or pixel grayscale value of the initial sample image, and the target pixel value is determined by mapping the pixel values ​​of pixels at the same position in the initial sample image and the target sample image; if the pixel corresponding to each initial pixel value has the same pixel value at the same position in the target sample image, then the same value is determined as the corresponding target pixel value; if these pixel values ​​at the same position are different, then according to the same minimum pixel value range in which these pixel values ​​are located, the specified value (maximum value, minimum value, or median value) of the minimum pixel value range is taken as the target pixel value.

[0136] By performing pixel-by-pixel traversal processing on each initial pixel value in each initial sample image of the same image category, the unique target pixel value corresponding to each of the multiple initial pixel values ​​in the same image category is obtained.

[0137] In other examples, for the same image category, a preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to an image category is first obtained based on multiple initial sample images and target sample images corresponding to each initial sample image, as described in the examples above, and will not be repeated here. After obtaining the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to an image category, a target gain value (ratio or difference) corresponding to an initial pixel value is obtained based on the difference between an initial pixel value and a target pixel value, thereby obtaining the preset mapping relationship between multiple initial pixel values ​​and multiple target gain values ​​for each image category.

[0138] It should be noted that, in this embodiment of the present disclosure, the electronic device can store both preset mapping relationships corresponding to the initial pixel values ​​obtained in the above example into the database, so that in actual application, a search and match can be performed in the appropriate preset mapping relationship based on the comparison results of the pixel value bits.

[0139] In this embodiment, a preset mapping relationship related to image categories can be obtained using a small sample set, thereby achieving style transfer based on this mapping relationship. Compared to training a neural network model for style transfer using a large sample set, this method requires fewer training samples, has a simpler training mechanism, and is less time-consuming. In addition, parameter adjustment is simple and convenient, and can be quickly implemented with simple code, improving the flexibility and efficiency of image transfer. At the same time, because the preset mapping relationship related to image categories can directly reflect the corresponding preset image style, even if the content of the image to be processed and the sample image are different, or the initial image style of the image to be processed is not the initial image style that appears in the initial sample image, effective image style transfer can still be achieved based on the image category, improving the comprehensiveness, flexibility, and efficiency of image style transfer.

[0140] In some embodiments, the above-mentioned method of obtaining a preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on multiple initial sample images and multiple target sample images corresponding to each image category includes:

[0141] Based on the pixel grayscale value of each initial sample image, determine the different initial pixel values ​​corresponding to each initial sample image;

[0142] Based on the target sample image corresponding to each initial sample image, determine the first candidate pixel value corresponding to each initial pixel value of each initial sample image;

[0143] Based on the different initial pixel values ​​corresponding to each initial sample image in the same image category and the first candidate pixel value corresponding to each initial pixel value, a preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category is determined.

[0144] Here, the pixel grayscale value represents the depth of pixel color; in this embodiment of the present disclosure, the pixel grayscale value of each initial sample image is obtained by first converting the initial sample image into an initial grayscale image, and then obtaining the value of each pixel in the initial grayscale image as the individual pixel grayscale value; wherein, the method of converting the initial sample image into an initial grayscale image can be to give different weights to the red, green and blue channel values ​​of each pixel in the initial sample image, and then perform a weighted average. See formula (1):

[0145] Gary =0.299*R+0.587*G+0.114*B (1);

[0146] Where Gray represents the grayscale value, R, G, and B represent the pixel values ​​of the red, green, and blue channels, respectively, and 0.299, 0.587, and 0.114 are preset weights. The pixel grayscale value (grayscale value) corresponding to each pixel in the initial grayscale image can be obtained by formula (1).

[0147] In this embodiment of the disclosure, each initial pixel value of each initial sample image is determined based on the pixel grayscale value of each pixel in the initial grayscale image. In some examples, at least one pixel grayscale value with the same value can be used as an initial pixel value, that is, the values ​​of each initial pixel value in each initial sample image are different. In other examples, the target grayscale image corresponding to the target sample image and the initial grayscale image can be combined to determine whether the pixel values ​​at the same pixel position are different. If they are different, the pixel grayscale values ​​of these pixels in the initial grayscale image are used as the initial pixel values ​​of an initial sample image.

[0148] After determining the initial pixel values ​​of each initial sample image, based on the correspondence between the initial grayscale image and the target grayscale image, and the pixels in the target grayscale image, a first candidate pixel value uniquely corresponding to each initial pixel value is determined. Here, the first candidate pixel value can be a pixel value in the target grayscale image, or it can be a pixel value obtained after data processing of the pixel values ​​in the target grayscale image.

[0149] Thus, in this embodiment of the present disclosure, based on the different initial pixel values ​​corresponding to each initial sample image and the multiple initial sample images of each image category, it can determine whether each initial pixel value appears repeatedly in multiple initial sample images; for an initial pixel value that appears only once, a preset mapping relationship between the initial pixel value and the target pixel value is determined based on the relationship between the initial pixel value and the first candidate pixel value; for an initial pixel value that appears repeatedly, a preset mapping relationship between the initial pixel value and the target pixel value is determined based on each of the first candidate pixel values ​​corresponding to the initial pixel value.

[0150] In this embodiment of the disclosure, since pixel grayscale values ​​can reflect the brightness of an image, the initial pixel values ​​of the initial sample image are determined based on the pixel grayscale values, and the first candidate pixel values ​​corresponding to the initial pixel values ​​are determined based on the corresponding target sample image. This can reflect the change between the initial image style of the initial sample image and the image style of the target sample image. Thus, by combining the different initial pixel values ​​corresponding to each initial sample image in the same image category and the first candidate pixel values ​​corresponding to each initial pixel value, the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category can be fully determined. In this way, the preset mapping relationship of an image category can be used to realize the style transfer of any initial image style under that image category towards a specified image style.

[0151] In some embodiments, determining the first candidate pixel value corresponding to each initial pixel value of each initial sample image based on the target sample image corresponding to each initial sample image includes:

[0152] For each initial pixel value in each initial sample image, determine the first pixel position of each initial pixel value in each initial sample image, and determine the first target pixel located at the first pixel position in each target sample image corresponding to each initial sample image;

[0153] Based on the pixel grayscale value of the first target pixel, determine the first candidate pixel value corresponding to each initial pixel value.

[0154] Here, for each initial pixel value in the initial sample image, find each pixel in the initial sample image (or initial grayscale image) that corresponds to each initial pixel value, and determine the first pixel position of that pixel in the initial sample image (or initial grayscale image); based on the first pixel position, determine the first target pixel in the target sample image (or target grayscale image that uniquely corresponds to the initial grayscale image) that uniquely corresponds to the initial sample image.

[0155] The first target pixel can be one or more. Based on the pixel grayscale values ​​of one or more first target pixels, the first candidate pixel value corresponding to each initial pixel value is obtained.

[0156] In this embodiment of the disclosure, when there is only one first target pixel, the first candidate pixel value corresponding to the initial pixel value can be the pixel grayscale value of a first target pixel corresponding to the initial pixel value, or it can be the pixel value obtained after data processing of the pixel grayscale value of the first target pixel based on the difference between the initial value and the pixel grayscale value of the corresponding first target pixel.

[0157] When there are multiple first target pixels, the maximum value of the pixel grayscale value of each first target pixel can be used as the first candidate pixel value. Alternatively, the first candidate pixel value can be determined based on the actual situation of the initial and target sample images. Of course, it can also be obtained by statistical processing of the pixel grayscale values ​​of each first target pixel. For example, the method of determining the first candidate pixel value based on the actual situation of the initial and target sample images in this embodiment of the present disclosure can be: if the same initial pixel value corresponds to the pixel grayscale value of two first target pixels in the target sample image, and one of these two first target pixels is a foreground pixel and the other is a background pixel, then in this embodiment of the present disclosure, the pixel grayscale value corresponding to the foreground pixel is used as the first candidate pixel value.

[0158] According to the mapping relationship of the same pixel positions in the initial sample image and the target sample image, the first candidate pixel value corresponding to the initial pixel value is determined. This can fully reflect the changes between pixel values ​​when the initial image style is migrated to the specified image style. Then, the image style migration can be accurately and efficiently realized by using a preset mapping relationship related to the pixel value.

[0159] In some embodiments, determining the first candidate pixel value corresponding to each initial pixel value based on the pixel grayscale value of the first target pixel includes:

[0160] When there are multiple first target pixels, the average of the pixel grayscale values ​​of the multiple first target pixels is determined as the first candidate pixel value corresponding to each initial pixel value;

[0161] or,

[0162] Obtain multiple second target pixels located at the second pixel position in the target sample image; wherein the second pixel position is adjacent to the first pixel position;

[0163] Based on the pixel grayscale value of the first target pixel and the pixel grayscale values ​​of multiple second target pixels, determine the second candidate pixel value corresponding to each first target pixel;

[0164] When there are multiple first target pixels, the average value of multiple second candidate pixel values ​​corresponding to the multiple first target pixels is determined as the first candidate pixel value corresponding to each initial pixel value.

[0165] In one example of this disclosure, when there is only one first target pixel, the pixel grayscale value of the first target pixel is determined as the first candidate pixel value corresponding to the initial pixel value; when there are multiple first target pixels, the average of the pixel grayscale values ​​of the multiple first target pixels is determined as the first candidate pixel value corresponding to the initial pixel value. Thus, by using the average of the pixel grayscale values ​​of the multiple first target pixels, a generalized representation can be made of the pixel value that each initial pixel value should correspond to during the process of transferring an initial image style to a specified image style.

[0166] In another example of this disclosure, multiple second target pixels located at multiple second pixel positions adjacent to the first pixel position in the target sample image are first obtained; then, based on the pixel grayscale value of the first target pixel and the pixel grayscale values ​​of the multiple second target pixels, the second candidate pixel value corresponding to each first target pixel is determined.

[0167] Here, if the grayscale pixel value difference between each pixel and its surrounding pixels is large, the final image may exhibit a color gradation jump problem. Therefore, embodiments of this disclosure can determine the second candidate pixel value corresponding to each first target pixel based on the pixel grayscale value of the first target pixel and the pixel grayscale values ​​of the surrounding plurality of second target pixels, thus minimizing the difference between the second candidate pixel value and the pixel grayscale values ​​of the plurality of second target pixels and improving the color gradation jump problem that occurs during image style transfer. For example, this disclosure can determine the second target pixel by using the eight adjacent pixels surrounding each first target pixel as the second target pixel.

[0168] In this example, when there is only one first target pixel, the second candidate pixel value is used as the first candidate pixel value; when there are multiple first target pixels, the average value of the multiple second candidate pixel values ​​corresponding to the multiple first target pixels is determined as the first candidate pixel value corresponding to each initial pixel value.

[0169] Thus, by averaging the values ​​of multiple second candidate pixels corresponding to multiple first target pixels, a generalized representation can be made of the pixel value that each initial pixel value should correspond to during the process of transferring the initial image style to the specified image style.

[0170] In some embodiments, determining the second candidate pixel value corresponding to each first target pixel based on the pixel grayscale value of the first target pixel and the pixel grayscale values ​​of a plurality of second target pixels includes:

[0171] Determine the difference between the pixel grayscale value of each second target pixel and the pixel grayscale value of the first target pixel;

[0172] If all differences are within the preset difference range, the pixel grayscale value of the first target pixel is used as the second candidate pixel value corresponding to the first target pixel.

[0173] If any difference is outside the preset difference range, the pixel grayscale value of the first target pixel is filtered to obtain the second candidate pixel value corresponding to the first target pixel.

[0174] Here, after determining a plurality of second target pixels surrounding each first target pixel, the differences between the pixel grayscale value of each surrounding second target pixel and the pixel grayscale value of the corresponding first target pixel are obtained. If each difference is within a preset difference range, it indicates that the color level difference between the first target pixel and the surrounding second target pixels is small, and there will be no obvious color level change in the image visually. Therefore, in this case, the pixel grayscale value of the first target pixel is used as the second candidate pixel value corresponding to the first target pixel.

[0175] If any difference is outside the preset difference range, it indicates that there is a color gradation jump between the second target pixel and the first target pixel corresponding to the difference. If this solution still uses the pixel grayscale value of the first target pixel as the second candidate pixel value, then a color gradation jump problem may occur after mapping. In this case, this embodiment of the present disclosure selects to filter the pixel grayscale value of the first target pixel to obtain the second candidate pixel value corresponding to the first target pixel.

[0176] The filtering of the pixel grayscale value of the first target pixel can be achieved using a preset filter. The filtering parameters of the filter can be determined based on the above differences, or they can be set to default parameters. This disclosure does not limit this.

[0177] It should be noted that the preset difference range mentioned above is a pre-set value, used to indicate that if the difference between the grayscale values ​​of two pixels is within the preset difference range, the corresponding pixels will not show a significant color gradation difference visually. Of course, this preset difference range can also be adaptively adjusted when applied to different electronic devices, different shooting scenarios, or when processing different image categories; for example, the preset difference range can be set to 0-5% of the pixel grayscale value of the first target pixel.

[0178] This embodiment analyzes whether the target sample image produces a color gradation jump based on the difference in pixel grayscale values ​​between each first target pixel and each of the surrounding second target pixels, and determines a suitable second candidate pixel value accordingly. This can further improve the color gradation jump problem of the target image finally generated after image style transfer in this embodiment and improve the image display effect.

[0179] In some embodiments, the above-mentioned determination of the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on different initial pixel values ​​corresponding to each initial sample image in the same image category and the first candidate pixel value corresponding to each initial pixel value includes:

[0180] For each initial pixel value corresponding to each initial sample image in each image category, if the initial pixel value corresponds to an initial sample image, the first candidate pixel value corresponding to the initial pixel value is taken as the target pixel value corresponding to the initial pixel value.

[0181] When the initial pixel value corresponds to multiple initial sample images, the average of the multiple first candidate pixel values ​​corresponding to the same initial pixel value is taken as the target pixel value corresponding to the initial pixel value.

[0182] Based on the target pixel value corresponding to each initial pixel value in each image category, a preset mapping relationship is determined between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category.

[0183] Here, when an initial pixel value corresponds to one initial sample image (i.e., the initial pixel value appears only once in each initial sample image), the first candidate pixel value corresponding to the initial pixel value is used as the target pixel value corresponding to the initial pixel value. When an initial pixel value corresponds to multiple initial sample images (i.e., the initial pixel value appears repeatedly in multiple initial sample images), the average of the multiple first candidate pixel values ​​corresponding to the same initial pixel value is used as the target pixel value corresponding to the initial pixel value. Thus, this embodiment of the present disclosure can perform the above processing on each initial pixel value for each image category, thereby obtaining a preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category.

[0184] Thus, the embodiments of this disclosure consider the mapping of multiple initial sample images to target sample images, and use the average value of multiple first candidate pixel values ​​corresponding to the same initial pixel value to determine the mapping relationship. This can improve the problem that the image style transfer accuracy of the same image category is affected by the special characteristics of pixel mapping of individual sample images, and improve the accuracy of the obtained preset mapping relationship.

[0185] In some embodiments, the above image processing method further includes:

[0186] The image to be processed is parsed to obtain at least one image parameter of the image to be processed, wherein different image parameters are used to describe different display effects of the image to be processed;

[0187] Based on at least one image parameter of the image to be processed, determine the image category to which the image belongs.

[0188] Here, the process of parsing the image to be processed to obtain at least one image parameter of the image to be processed in the embodiments of this disclosure can be referred to the processing of the initial sample image in the above embodiments of this disclosure, and will not be repeated here.

[0189] The obtained image parameter includes, but is not limited to, overall brightness, light ratio, texture features, shape features, etc. Based on at least one image parameter of the image to be processed, an image category is determined from the aforementioned defined image categories to which the image to be processed belongs.

[0190] In this embodiment of the disclosure, after determining the image category to which the image to be processed belongs, a preset mapping relationship corresponding to the image category stored in the electronic device is searched, and style transfer is performed according to the preset mapping relationship to obtain the final target image.

[0191] It should be noted that, since image categories have a unique corresponding preset mapping relationship, even if the initial style of the image to be processed is not the initial style that appears in the initial sample image, the embodiments of this disclosure can effectively and accurately transfer the image style of the image to be processed by determining the category to which the image to be processed belongs, and obtain a target image with a specified image style. Therefore, this disclosure can effectively improve the flexibility and efficiency of image style transfer.

[0192] For image style transfer, neural network models have been proposed. These models utilize convolutional neural networks (CNNs) to apply an image style to another image style. First, image features are extracted using convolutional and pooling layers. During training, the image content and style are separated; content is represented by high-level features, while style is represented by low-level features. The first few layers learn low-level features such as edges and colors, while later layers learn high-level features such as shape and texture. During the transfer process, the style image and content image are input into the CNN, and their features at each layer are calculated. Then, a loss function is defined to evaluate the difference between the content / style features of the generated image and the content / style features of the content image. Algorithms such as gradient descent are used to minimize the loss function, making the generated image approximate the content image, resulting in the final generated image.

[0193] However, current methods for image style transfer using neural network models have several problems. First, due to the poor generalization ability of neural network models, their loss function only becomes smaller when the sample set is large enough. Therefore, for initial image styles not present in the sample set, neural network models cannot accurately and flexibly perform image style transfer, requiring a large amount of sample data. This limits training flexibility and increases training time. Second, when there are initial image styles not present in the initial sample images, the neural network model needs to be retrained, resulting in low debugging efficiency. Third, neural network models only transfer the image style of a single image. If the trained network has large style differences, it cannot take into account both the overall style and the customized needs of special scenes. Therefore, for some customized image style transfers, there is a problem of inflexible adjustment.

[0194] In view of this, this disclosure proposes a fast and accurate image processing method for style transfer to address the problems of large training sets, long processing time, low efficiency, and complex operation caused by the introduction of neural network models for image style transfer. This image processing method trains with a small number of samples to obtain preset mapping relationships corresponding to different image categories, thereby utilizing these preset mapping relationships for style transfer in similar scenarios. Furthermore, for initial sample images with untrained initial image styles, this disclosure can also accurately and quickly achieve style transfer based on the preset mapping relationship corresponding to the image category, after determining the image category to be processed. Moreover, this disclosure can also meet customization needs by defining different image categories and corresponding specified image styles, achieving comprehensive image style transfer and improving debugging efficiency and accuracy.

[0195] See Figure 3 , Figure 3 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 2 This image processing method can be applied to electronic devices such as mobile phones, and can be implemented through the following methods. Figure 2 The following steps are to be performed:

[0196] The first stage is the training phase. This training phase specifically involves constructing preset mapping relationships for multiple image categories through steps 301 to 305 below.

[0197] Step 301: Obtain the initial sample image;

[0198] Here, when multiple initial sample images are obtained, the image information of the initial sample images is first parsed to obtain first-level image parameters (such as image brightness and light ratio). Then, based on the image brightness and light ratio, the image categories existing in the multiple initial samples are obtained. For example, outdoor backlighting scenes are classified as O1, outdoor frontlighting scenes as O2, ..., night scene frontlighting scenes as On-1 and night scene backlighting scenes as On.

[0199] Furthermore, based on customized requirements, this disclosure can further analyze the initial sample images to obtain secondary image parameters (shape features and texture features, etc.), and perform fine classification of the above image categories by nesting more detailed conditional constraints; for example, the image category Q1 corresponding to an indoor backlit scene can further include the image category Q11 corresponding to an outdoor backlit scene + portrait, the image category Q12 corresponding to an outdoor backlit scene + green plants, ... the image category Q1n corresponding to an outdoor backlit scene + flowers, etc.

[0200] Step 302: Obtain the target sample image;

[0201] Here, based on the aforementioned image categories and the image quality requirements of each category, a specified image style is defined for each image category. The specified style images differ for different image categories. Thus, according to the specified image style requirements, the processing module of the electronic device renders each initial sample image under each image category to obtain the target sample image corresponding to each initial sample.

[0202] Step 303: Convert the initial sample image to grayscale;

[0203] Here, the initial sample image is converted from RGB to grayscale through step 303 and the above formula (1) to obtain the initial grayscale image T1.

[0204] Step 304: Convert the target sample image to grayscale.

[0205] Here, the target sample image is converted from RGB to grayscale through step 304 and the above formula (1) to obtain the target grayscale image T2.

[0206] Step 305: Construct a preset mapping relationship;

[0207] Here, in this embodiment of the disclosure, a preset mapping relationship is constructed for each image category, consisting of multiple initial grayscale images T1 and corresponding target grayscale images T2. Based on the principle that images of the same category have a consistent specified image style, this preset mapping relationship also possesses the attribute of a single mapping.

[0208] The specific process of constructing the preset mapping relationship in step 305 is as follows:

[0209] For an initial grayscale image T1 and a corresponding target grayscale image T2 of the same image category, first determine the set U{u1, u2, ..., un} of all pixel grayscale values ​​in the initial grayscale image T1, and determine the set of occurrences C{c1, c2, ..., cn} based on the number of times each pixel grayscale value appears; where ui is a unique pixel grayscale value in the initial grayscale image T1 (different from the values ​​of other pixel grayscale values), and ci is the number of times ui appears.

[0210] For each pixel grayscale value ui in U, find the set P{p1, p2, ..., pm} of all pixel positions in the initial grayscale image T1 where the pixel grayscale value is equal to ui, where pj is the position in the initial grayscale image T1 where the pixel grayscale value is equal to ui, and calculate the average pixel grayscale value of the corresponding position in P for the target grayscale image T2 based on the following formula (2):

[0211] average_optimized_values ​​= (o_p1+o_p2+...+o_pm) / m (2);

[0212] Where o_pj is the second candidate pixel value of the first target pixel at position pj in the target grayscale image T2; here, each pixel grayscale value ui is an initial pixel value, and the average_optimized_values ​​corresponding to each pixel grayscale value ui is used as the first candidate pixel value.

[0213] Here, the second candidate pixel value of the first target pixel is determined based on the second target pixels surrounding the first target pixel. The specific process is described in the above embodiments of this disclosure and will not be repeated here.

[0214] After obtaining the first candidate pixel values ​​corresponding to multiple initial pixel values ​​based on each initial sample image and target sample image, for each initial pixel value, the first candidate pixel values ​​corresponding to each initial pixel value in the same image category are weighted and averaged to obtain the target pixel value that uniquely corresponds to an initial pixel value in the same image category.

[0215] It should be noted that after obtaining the target pixel values ​​corresponding to multiple initial pixel values ​​under the same image category, a preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​can be obtained; the target gain value can also be obtained based on the ratio between the target pixel value and the corresponding initial pixel value, thereby obtaining a preset mapping relationship between multiple initial pixel values ​​and multiple target gain values.

[0216] In this embodiment of the disclosure, after obtaining the preset mapping relationship corresponding to each image category, these preset mapping relationships can be stored in the mobile phone for use in the application stage for image style transfer; here, in the application stage, the image processing method proposed in this embodiment of the disclosure can be implemented through the following steps 306 to 308:

[0217] Step 306: Obtain the image to be processed;

[0218] In response to an image processing instruction, the electronic device acquires the image to be processed.

[0219] Step 307: Obtain the target tonal curve;

[0220] Based on the pixel values ​​of the initial pixels of the image to be processed and the preset mapping relationship, the target gain value corresponding to the pixel value of the initial pixel is found, and the target gain value is superimposed on the original tone curve of the image to be processed to obtain the target tone curve. Here, the target tone curve reflects the brightness change of the pixel and reflects the final image style. The superposition is a product relationship. When superimposing, pay attention to keeping the pixel value bits consistent.

[0221] Step 308, obtain the target image;

[0222] In this embodiment, after obtaining the target tonal curve, a smoothing process is performed on the target tonal curve. Least-squares fitting is applied to the horizontal axis data of the target tonal curve to obtain a smooth curve. This step effectively improves the problem of uneven color transition in the image caused by color level inversion. This embodiment can adjust the pixels of the image to be processed based on the target tonal curve to obtain the target image.

[0223] It should be noted that if the initial image quality of the image to be processed is different from the initial image quality of the initial sample image mentioned above, the embodiments of this disclosure can also obtain a preset mapping relationship by determining the image category of the image to be processed, and then use the preset mapping relationship to obtain a target image with a specified image style corresponding to the image category, so as to complete the image style transfer.

[0224] The image processing method proposed in this embodiment is trained based on a limited number of sample images. During the training phase, the image category can be classified based on the brightness and light ratio of the image, ensuring that similar scenes have the same image quality style and guaranteeing the uniformity and accuracy of the mapping from the initial sample image to the target sample image. Thus, based on the obtained preset mapping relationship, the style transfer of the entire scene can be accurately realized, improving the accuracy of obtaining the target image.

[0225] Furthermore, since neural network models require a long time to process images, changing image styles requires retraining and a large sample set to obtain accurate image styles, making image style customization inflexible. The method proposed in this disclosure can classify images according to their scenes, and the classification rules can be flexibly adjusted. For a specific image style that needs to be customized, further image categories can be determined based on secondary image parameters, and the corresponding images can be trained to obtain the style, thus improving the flexibility and efficiency of style transfer.

[0226] Furthermore, the method proposed in this embodiment can also be implemented in batches based on code. For customized image styles, secondary image parameters can be flexibly added. Both the process and the effect are adjustable. Compared with the complex working mechanism of neural network models, the method proposed in this embodiment is simpler and more efficient, and has better debugging and optimization effects.

[0227] Figure 4 This is a structural block diagram of an image processing apparatus according to an exemplary embodiment. For example... Figure 4 As shown, the image processing device 400 mainly includes:

[0228] The acquisition module 401 is configured to acquire the image to be processed;

[0229] The lookup module 402 is configured to look up the target parameter corresponding to the pixel value of the initial pixel in a preset mapping relationship corresponding to the image category to which the image to be processed belongs, based on the initial pixel of the image to be processed.

[0230] The adjustment module 403 is configured to adjust the image to be processed based on the target parameters to obtain the target image; wherein, different target parameters result in different image styles of the target image.

[0231] In some embodiments, the lookup module 402 is further configured to, when the pixel value bit of the initial pixel is the same as the pixel value bit of the preset mapping relationship, search in the preset mapping relationship based on the pixel value of the initial pixel of the image to be processed to obtain the target pixel value.

[0232] The adjustment module 403 is also configured to adjust the pixel value of the initial pixel to the target pixel value to obtain the target image.

[0233] In some embodiments, the lookup module 402 is further configured to adjust the pixel value of the initial pixel when the pixel value bit of the initial pixel is different from the pixel value bit of the preset mapping relationship, to obtain the adjusted pixel value, and to look up the target gain value in the preset mapping relationship based on the adjusted pixel value.

[0234] The adjustment module 403 is also configured to adjust the pixel values ​​of the initial pixels of the image to be processed based on the target gain value to obtain the target image.

[0235] In some embodiments, the image processing apparatus 400 further includes: a mapping relationship construction module ( Figure 4 (Not shown);

[0236] The mapping relationship construction module is configured to: acquire multiple initial sample images belonging to different image categories; determine multiple target sample images corresponding to the multiple initial sample images in the same image category based on the image category to which each initial sample image belongs, wherein each target sample image and its corresponding initial sample image have the same image category and image content, and the target sample image has a preset image style associated with its image category; obtain a preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on the multiple initial sample images and multiple target sample images corresponding to each image category; and / or, obtain multiple initial pixel values ​​corresponding to each image category and multiple target gain values ​​corresponding to the multiple initial pixel values ​​in each image category based on the multiple initial sample images and multiple target sample images corresponding to each image category; and obtain a preset mapping relationship between multiple initial pixel values ​​and multiple target gain values ​​in each image category based on the multiple initial pixel values ​​and multiple target gain values.

[0237] In some embodiments, the mapping relationship construction module is further configured to determine different initial pixel values ​​corresponding to each initial sample image based on the pixel grayscale value of each initial sample image; determine a first candidate pixel value corresponding to each initial pixel value of each initial sample image based on the target sample image corresponding to each initial sample image; and determine a preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on the different initial pixel values ​​corresponding to each initial sample image in the same image category and the first candidate pixel value corresponding to each initial pixel value.

[0238] In some embodiments, the mapping relationship construction module is further configured to, for each initial pixel value of each initial sample image, determine the first pixel position of each initial pixel value in each initial sample image, and determine the first target pixel located at the first pixel position in each target sample image corresponding to each initial sample image; and determine the first candidate pixel value corresponding to each initial pixel value based on the pixel grayscale value of the first target pixel.

[0239] In some embodiments, the mapping relationship construction module is further configured to, when there are multiple first target pixels, determine the average of the pixel grayscale values ​​of the multiple first target pixels as the first candidate pixel value corresponding to each initial pixel value; or, acquire multiple second target pixels located at the second pixel position in the target sample image; wherein the second pixel position is adjacent to the first pixel position; determine the second candidate pixel value corresponding to each first target pixel based on the pixel grayscale value of the first target pixel and the pixel grayscale values ​​of the multiple second target pixels; when there are multiple first target pixels, determine the average of the multiple second candidate pixel values ​​corresponding to the multiple first target pixels as the first candidate pixel value corresponding to each initial pixel value.

[0240] In some embodiments, the mapping relationship construction module is further configured to determine the difference between the pixel grayscale value of each second target pixel and the pixel grayscale value of the first target pixel; when all differences are within a preset difference range, the pixel grayscale value of the first target pixel is used as the second candidate pixel value corresponding to the first target pixel; when any difference is outside the preset difference range, the pixel grayscale value of the first target pixel is filtered to obtain the second candidate pixel value corresponding to the first target pixel.

[0241] In some embodiments, the mapping relationship construction module is further configured to, for each initial pixel value corresponding to each initial sample image in each image category, if the initial pixel value corresponds to one initial sample image, use the first candidate pixel value corresponding to the initial pixel value as the target pixel value corresponding to the initial pixel value; if the initial pixel value corresponds to multiple initial sample images, use the average of the multiple first candidate pixel values ​​corresponding to the same initial pixel value as the target pixel value corresponding to the initial pixel value; and determine a preset mapping relationship between the multiple initial pixel values ​​and the multiple target pixel values ​​corresponding to each image category based on the target pixel value corresponding to each initial pixel value in each image category.

[0242] In some embodiments, the acquisition module 401 is further configured to parse the image to be processed to obtain at least one image parameter of the image to be processed, wherein different image parameters are used to describe different display effects of the image to be processed; and to determine the image category to which the image to be processed belongs based on at least one image parameter of the image to be processed.

[0243] Regarding the image processing apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0244] Figure 5This is a structural block diagram of an electronic device according to an exemplary embodiment. For example, the electronic device 500 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.

[0245] Reference Figure 5 The electronic device 500 may include one or more of the following components: processing component 502, memory 504, power supply component 506, multimedia component 508, audio component 510, input / output interface 512, sensor component 514, and communication component 516.

[0246] Processing component 502 typically controls the overall operation of electronic device 500, such as operations associated with at least one of display, telephone call, data communication, camera operation, and recording operation. Processing component 502 may include one or more processors 520 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 502 may include one or more modules to facilitate interaction between processing component 502 and other components. For example, processing component 502 may include a multimedia module to facilitate interaction between multimedia component 508 and processing component 502.

[0247] Memory 504 is configured to store various types of data to support operation on electronic device 500. Examples of such data include at least one of the following: instructions for any application or method operating on electronic device 500, contact data, phonebook data, messages, pictures, and videos. Memory 504 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0248] Power supply component 506 provides power to various components of electronic device 500. Power supply component 506 may include at least one of the following: a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 500.

[0249] Multimedia component 508 includes a screen that provides an output interface between electronic device 500 and user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen may be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors may sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 508 includes a front-facing camera and / or a rear-facing camera. When electronic device 500 is in an operating mode, such as a shooting mode or video mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0250] Audio component 510 is configured to output and / or input audio signals. For example, audio component 510 includes a microphone (MIC) configured to receive external audio signals when electronic device 500 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 504 or transmitted via communication component 516. In some embodiments, audio component 510 also includes a speaker for outputting audio signals.

[0251] Input / output interface 512 provides an interface between processing component 502 and peripheral interface modules, such as keyboards, click wheels, and buttons. These buttons may include, but are not limited to, home buttons, volume buttons, start buttons, and lock buttons.

[0252] Sensor assembly 514 includes one or more sensors for providing state assessments of various aspects of electronic device 500. For example, sensor assembly 514 may detect the on / off state of electronic device 500, the relative positioning of components such as the display and keypad of electronic device 500, changes in position of electronic device 500 or one of its components, the presence or absence of user contact with electronic device 500, orientation or acceleration / deceleration of electronic device 500, and temperature changes of electronic device 500. Sensor assembly 514 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 514 may also include an optical sensor, such as a complementary metal-oxide-semiconductor (CMOS) or charge-coupled device (CCD) image sensor, for use in imaging applications. In some embodiments, sensor assembly 514 may also include, but is not limited to, at least one of the following: an accelerometer, a gyroscope, a magnetometer, a pressure sensor, and a temperature sensor.

[0253] Communication component 516 is configured to facilitate wired or wireless communication between electronic device 500 and other devices. Electronic device 500 can access wireless networks based on communication standards, such as Wi-Fi, 4G, 5G, or combinations thereof. In one exemplary embodiment, communication component 516 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 516 also includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wide Band (UWB), Bluetooth (BT), and other technologies.

[0254] In an exemplary embodiment, the electronic device 500 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components.

[0255] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 504 including executable instructions or a computer program, which can be executed by a processor 520 of an electronic device 500 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.

[0256] A non-transitory computer-readable storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform any of the image processing methods described above in the embodiments of this disclosure.

[0257] This disclosure provides a computer program product comprising a computer program or executable instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer program or executable instructions from the computer-readable storage medium and executes the computer program or executable instructions, causing the computer device to perform any of the image processing methods described in this disclosure. Here, the computer device may be an example of the aforementioned electronic device, such as a mobile phone or computer.

[0258] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.

[0259] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. An image processing method, characterized in that, include: Obtain the image to be processed; Based on the initial pixels of the image to be processed, the target parameter corresponding to the pixel value of the initial pixel is found in the preset mapping relationship corresponding to the image category to which the image to be processed belongs; The image to be processed is adjusted based on the target parameters to obtain the target image; wherein, different target parameters result in different image styles for the target images.

2. The method according to claim 1, characterized in that, The step of searching for a target parameter corresponding to the pixel value of the initial pixel in a preset mapping relationship corresponding to the image category to which the image to be processed belongs, based on the initial pixel of the image to be processed, includes: If the pixel value bit of the initial pixel is the same as the pixel value bit of the preset mapping relationship, the target pixel value is obtained by searching in the preset mapping relationship based on the pixel value of the initial pixel of the image to be processed. The step of adjusting the image to be processed based on the target parameters to obtain the target image includes: The pixel value of the initial pixel is adjusted to the target pixel value to obtain the target image.

3. The method according to claim 1, characterized in that, The step of searching for a target parameter corresponding to the pixel value of the initial pixel in a preset mapping relationship corresponding to the image category to which the image to be processed belongs, based on the initial pixel of the image to be processed, includes: If the pixel value bit of the initial pixel is different from the pixel value bit of the preset mapping relationship, the pixel value of the initial pixel is adjusted to obtain the adjusted pixel value, and the target gain value is obtained by searching in the preset mapping relationship based on the adjusted pixel value. The step of adjusting the image to be processed based on the target parameters to obtain the target image includes: Based on the target gain value, the pixel values ​​of the initial pixels of the image to be processed are adjusted to obtain the target image.

4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: Obtain multiple initial sample images belonging to different image categories; Based on the image category to which each initial sample image belongs, multiple target sample images corresponding to multiple initial sample images in the same image category are determined. Each target sample image has the same image category and image content as the corresponding initial sample image, and the target sample image has a preset image style associated with its image category. Based on the multiple initial sample images and multiple target sample images corresponding to each image category, a preset mapping relationship is obtained between the multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category; and / or, Based on the multiple initial sample images and multiple target sample images corresponding to each image category, multiple initial pixel values ​​corresponding to each image category are obtained, as well as multiple target gain values ​​corresponding to the multiple initial pixel values ​​in each image category; Based on the multiple initial pixel values ​​and the multiple target gain values, a preset mapping relationship is obtained between the multiple initial pixel values ​​and the multiple target gain values ​​in each image category.

5. The method according to claim 4, characterized in that, The step of obtaining the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on multiple initial sample images and multiple target sample images corresponding to each image category includes: Based on the pixel grayscale value of each initial sample image, determine the different initial pixel values ​​corresponding to each initial sample image; Based on the target sample image corresponding to each initial sample image, determine the first candidate pixel value corresponding to each initial pixel value of each initial sample image; Based on the different initial pixel values ​​corresponding to each initial sample image in the same image category and the first candidate pixel value corresponding to each initial pixel value, the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category is determined.

6. The method according to claim 5, characterized in that, The step of determining the first candidate pixel value corresponding to each initial pixel value of each initial sample image based on the target sample image corresponding to each initial sample image includes: For each initial pixel value in each initial sample image, determine the first pixel position of each initial pixel value in each initial sample image, and determine the first target pixel located at the first pixel position in each target sample image corresponding to each initial sample image; Based on the pixel grayscale value of the first target pixel, determine the first candidate pixel value corresponding to each initial pixel value.

7. The method according to claim 6, characterized in that, The step of determining the first candidate pixel value corresponding to each initial pixel value based on the pixel grayscale value of the first target pixel includes: When there are multiple first target pixels, the average of the pixel grayscale values ​​of the multiple first target pixels is determined as the first candidate pixel value corresponding to each initial pixel value; or, Obtain multiple second target pixels located at the second pixel position in the target sample image; wherein the second pixel position is adjacent to the first pixel position; Based on the pixel grayscale value of the first target pixel and the pixel grayscale values ​​of multiple second target pixels, a second candidate pixel value corresponding to each first target pixel is determined; When there are multiple first target pixels, the average value of multiple second candidate pixel values ​​corresponding to the multiple first target pixels is determined as the first candidate pixel value corresponding to each initial pixel value.

8. The method according to claim 7, characterized in that, The step of determining the second candidate pixel value corresponding to each first target pixel based on the pixel grayscale value of the first target pixel and the pixel grayscale values ​​of multiple second target pixels includes: The difference between the pixel grayscale value of each second target pixel and the pixel grayscale value of the first target pixel is determined respectively; If all the differences are within the preset difference range, the pixel grayscale value of the first target pixel is used as the second candidate pixel value corresponding to the first target pixel. If any of the differences is outside the preset difference range, the pixel grayscale value of the first target pixel is filtered to obtain the second candidate pixel value corresponding to the first target pixel.

9. The method according to claim 5, characterized in that, The step of determining the preset mapping relationship between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category based on different initial pixel values ​​corresponding to each initial sample image in the same image category and the first candidate pixel value corresponding to each initial pixel value includes: For each initial pixel value corresponding to each initial sample image in each image category, if the initial pixel value corresponds to an initial sample image, the first candidate pixel value corresponding to the initial pixel value is used as the target pixel value corresponding to the initial pixel value; In the case where the initial pixel value corresponds to multiple initial sample images, the average value of multiple first candidate pixel values ​​corresponding to the same initial pixel value is taken as the target pixel value corresponding to the initial pixel value. Based on the target pixel value corresponding to each initial pixel value in each image category, a preset mapping relationship is determined between multiple initial pixel values ​​and multiple target pixel values ​​corresponding to each image category.

10. The method according to any one of claims 1 to 3, characterized in that, The method further includes: The image to be processed is parsed to obtain at least one image parameter of the image to be processed, wherein different image parameters are used to describe different display effects of the image to be processed; Based on at least one image parameter of the image to be processed, determine the image category to which the image to be processed belongs.

11. An image processing apparatus, characterized in that, include: The acquisition module is configured to acquire the image to be processed. The search module is configured to search for a target parameter corresponding to the pixel value of the initial pixel in a preset mapping relationship corresponding to the image category to which the image to be processed belongs, based on the initial pixel of the image to be processed. The adjustment module is configured to adjust the image to be processed based on the target parameters to obtain a target image; wherein, different target parameters result in different image styles for the target images.

12. An electronic device, characterized in that, include: processor; Memory used to store computer programs or instructions; The processor executes the computer program or instructions to implement the steps of the method according to any one of claims 1 to 10.

13. A non-transitory computer-readable storage medium storing a computer program or instructions, characterized in that, When the computer program or instructions in the storage medium are executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.

14. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 10.