Image processing method, apparatus and electronic device
Patent Information
- Application Number
- CN202310702001.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-13
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-06-13
AI Technical Summary
但是,随着短视频特效的多样化,特效资源中的图像越来越多,服务器基于相同的编码方式对多个图像进行编码,导致特效资源对应的数据包的数据量较大
[0019] This disclosure provides an image processing method, apparatus, and electronic device. The electronic device can acquire special effects resources to be encoded, wherein the special effects resources may include multiple first images. The image type of each first image is determined. For any given first image, a target encoding method corresponding to the first image is determined based on its image type. The special effects resource is then encoded according to the target encoding method corresponding to each first image. In this method, because the electronic device can determine the target encoding method corresponding to each first image based on its image type, when encoding multiple first images in the special effects resource, each type of first image can be matched with an encoding method. This improves the encoding quality of the first images, reduces the size of the encoded first images, and consequently reduces the data volume of the data packet after encoding the special effects resource.
Smart Images

Figure CN116744035B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and in particular to an image processing method, apparatus, and electronic device. Background Technology
[0002] In short video special effects scenarios, electronic devices can download special effects resources from servers, and then add the corresponding special effects to the short video.
[0003] Currently, servers can encode multiple images in special effects resources using a single encoding method to obtain the corresponding data packet. When an electronic device requests to download the special effects resource, the server can send the data packet to the device. However, with the diversification of short video special effects and the increasing number of images in special effects resources, encoding multiple images using the same encoding method results in a large data size for the data packet corresponding to the special effects resource. Summary of the Invention
[0004] This disclosure provides an image processing method, apparatus, and electronic device to solve one or more technical problems in the prior art.
[0005] In a first aspect, this disclosure provides an image processing method, the method comprising:
[0006] Obtain special effects resources to be encoded, the special effects resources including multiple first images;
[0007] Determine the image type of the first image;
[0008] For any one of the first images, the target encoding method corresponding to the first image is determined according to the image type of the first image;
[0009] The special effects resources are encoded according to the target encoding method corresponding to each first image.
[0010] In a second aspect, this disclosure provides an image processing apparatus, which includes an acquisition module, a first determination module, a second determination module, and an encoding module, wherein:
[0011] The acquisition module is used to acquire special effects resources to be encoded, the special effects resources including multiple first images;
[0012] The first determining module is used to determine the image type of the first image;
[0013] The second determining module is used to determine the target encoding method corresponding to any one of the first images based on the image type of the first image;
[0014] The encoding module is used to encode the special effects resources according to the target encoding method corresponding to each first image.
[0015] Thirdly, embodiments of this disclosure provide an electronic device including: a processor and a memory;
[0016] The memory stores computer-executed instructions;
[0017] The processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the image processing methods described in the first aspect above and various possible aspects of the first aspect.
[0018] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the image processing methods described in the first aspect and various possible aspects thereof.
[0019] This disclosure provides an image processing method, apparatus, and electronic device. The electronic device can acquire special effects resources to be encoded, wherein the special effects resources may include multiple first images. The image type of each first image is determined. For any given first image, a target encoding method corresponding to the first image is determined based on its image type. The special effects resource is then encoded according to the target encoding method corresponding to each first image. In this method, because the electronic device can determine the target encoding method corresponding to each first image based on its image type, when encoding multiple first images in the special effects resource, each type of first image can be matched with an encoding method. This improves the encoding quality of the first images, reduces the size of the encoded first images, and consequently reduces the data volume of the data packet after encoding the special effects resource. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of the present disclosure;
[0022] Figure 2 A schematic flowchart of an image processing method provided in an embodiment of this disclosure;
[0023] Figure 3A schematic diagram of a special effects resource provided in an embodiment of this disclosure;
[0024] Figure 4 This is a schematic diagram of an image for determining a color mapping type, provided in an embodiment of the present disclosure.
[0025] Figure 5 A schematic diagram illustrating the encoding process of a special effects resource provided in this embodiment of the disclosure;
[0026] Figure 6 This is a schematic diagram illustrating a method for determining a target encoding method provided in an embodiment of the present disclosure;
[0027] Figure 7 A schematic diagram illustrating the correspondence between compression ratio and decoding performance provided in this embodiment of the disclosure;
[0028] Figure 8 This is a schematic diagram illustrating another method for determining a target encoding method provided in an embodiment of the present disclosure;
[0029] Figure 9 This is a schematic diagram illustrating a lossless encoding method provided in an embodiment of the present disclosure;
[0030] Figure 10 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of the present disclosure;
[0031] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0032] 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.
[0033] For ease of understanding, the concepts involved in the embodiments of this disclosure will be explained below.
[0034] Electronic device: A device with wireless transceiver capabilities. Electronic devices can be deployed on land, including indoors or outdoors, handheld, wearable, or vehicle-mounted; they can also be deployed on water (such as on ships). These electronic devices can be mobile phones, tablets, computers with wireless transceiver capabilities, virtual reality (VR) electronic devices, augmented reality (AR) electronic devices, wireless terminals in industrial control, vehicle-mounted electronic devices, wireless terminals in self-driving vehicles, wireless electronic devices in remote medical care, wireless electronic devices in smart grids, wireless electronic devices in transportation safety, wireless electronic devices in smart cities, wireless electronic devices in smart homes, wearable electronic devices, etc. The electronic devices involved in the embodiments of this disclosure can also be referred to as terminals, user equipment (UE), access electronic devices, vehicle-mounted terminals, industrial control terminals, UE units, UE stations, mobile stations, mobile stations, remote stations, remote electronic devices, mobile devices, UE electronic devices, wireless communication devices, UE agents, or UE devices, etc. Electronic devices can be fixed or mobile.
[0035] Below, in conjunction with Figure 1 The application scenarios of the embodiments of this disclosure will be described.
[0036] Figure 1 This is a schematic diagram illustrating an application scenario provided by an embodiment of this disclosure. Please refer to [link / reference]. Figure 1 The system comprises: a server, electronic devices, and special effects resources. The special effects resources can include image 1, image 2, ..., image n. After receiving the special effects resources, the server can encode multiple images within the resources to obtain the corresponding data packet. The electronic device's display page includes a video recording page and special effects controls. When a user clicks on a special effects control, the electronic device can send a special effects download request to the server. Upon receiving this request, the server can send the special effects resource data packet back to the electronic device. After receiving the data packet, the electronic device can decode it to obtain the multiple images corresponding to the special effects resources.
[0037] It should be noted that, Figure 1 This is merely an illustrative representation of the application scenarios of the embodiments of this disclosure and is not intended to limit the application scenarios of the embodiments of this disclosure.
[0038] In related technologies, electronic devices can download special effects resources from a server and then add the corresponding special effects to short videos. Currently, a server can encode multiple images in a special effects resource using a single encoding method to obtain a data packet corresponding to the special effects resource. When an electronic device requests to download the special effects resource, the server can send the data packet to the electronic device. The electronic device then decodes the data packet to obtain the multiple images corresponding to the special effects resource, thus obtaining the added special effects. However, with the diversification of short video special effects, special effects resources can include a large number of images, and the image types of these images are also diverse. When a server encodes multiple images of a special effects resource using a single encoding method, some image types may not match that encoding method, resulting in a large data size for the data packet corresponding to the special effects resource.
[0039] To address the technical problems in related technologies, this disclosure provides an image processing method. An electronic device can acquire special effects resources to be encoded and determine the image type of each first image in the special effects resources. For any given first image, if the image type is color mapping, the target encoding method for the first image is determined to be the lossless encoding method in the first encoding method. If the image type is static, the target encoding method corresponding to the first image is determined based on the first encoding method, the second encoding method, and the first image. If the first image type is a sequence frame type, the number of colors included in the first image is obtained, and the target encoding method corresponding to the first image is determined based on the number of colors. After obtaining the target encoding method corresponding to each first image, the terminal device can encode the special effects resources according to the target encoding method corresponding to each first image. In the above method, since the electronic device can determine the target encoding method corresponding to the first image by combining the image type of the first image in the special effects resources, and each type of image includes a corresponding target encoding method, each type of first image in the special effects resources can be matched with the corresponding target encoding method. This can improve the encoding quality of the first image, reduce the size of the encoded first image, and thus reduce the data volume of the data packet corresponding to the special effects resources.
[0040] The technical solutions of this disclosure and how they solve the aforementioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this disclosure will now be described with reference to the accompanying drawings.
[0041] Figure 2 This is a schematic flowchart illustrating an image processing method provided in an embodiment of this disclosure. Please refer to [link / reference]. Figure 2 The method may include:
[0042] S201. Obtain the special effects resources to be encoded.
[0043] The execution subject of this disclosure can be an electronic device or an image processing device installed in an electronic device. The image processing device can be implemented in software, or it can be implemented using a combination of software and hardware; this disclosure does not limit this. Optionally, the electronic device can be any device with on-device computing capabilities; for example, the electronic device can be a server, encoding device, computer, etc., and this disclosure does not limit this.
[0044] Among them, special effects resources can be resources for creating special effects shots. For example, if the special effects resource is a sticker effect resource, then when the electronic device performs post-production editing of the video or shoots a new video, the electronic device can add sticker effects to the video based on the special effects resource; if the special effects resource is a dynamic smoke effect resource, then when the electronic device performs post-production editing of the video or shoots a new video, the electronic device can add dynamic smoke effects to the video based on the special effects resource.
[0045] It should be noted that special effects resources can also be virtual headwear effects (such as headband effects, glasses effects, hat effects, etc.), filter effects, animation effects, etc., and this disclosure does not limit them.
[0046] Optionally, the special effects resource may include multiple first images. For example, if the special effects corresponding to the special effects resource are animation effects, then the special effects resource may include a set of images corresponding to the animation effects (i.e., multiple first images); if the special effects corresponding to the special effects resource are fireworks effects, then the special effects resource may include multiple images corresponding to the fireworks animation (i.e., multiple first images). For example, if the special effects corresponding to the special effects resource include sticker effects, filter effects, and fireworks effects, then the special effects resource may include images corresponding to sticker effects, images corresponding to filter effects, and images corresponding to fireworks effects.
[0047] Below, in conjunction with Figure 3 The special effects resources of the embodiments of this disclosure will be described.
[0048] Figure 3 This is a schematic diagram of a special effects resource provided in an embodiment of this disclosure. Please refer to [link / reference]. Figure 3This includes special effects resources. These resources can include images 1, 2, 3, 4, and 5. Each image can feature the same person; images 1 and 5 show the same action, while images 2, 3, and 4 show different actions. The images are arranged in the order of 1 to 5. Thus, the special effect corresponding to this resource is an animated sticker effect of a person waving. If a terminal device downloads and decodes the data packet of this special effects resource, it can add the animated sticker effect of a person waving to a video during recording.
[0049] Optionally, the electronic device can receive special effects resources to be encoded from other devices. For example, the other device can be a compilation device for the special effects resources. After the user completes the compilation of the special effects resources on the other device, the other device can send the special effects resources to the electronic device, which can then encode the special effects resources.
[0050] Optionally, the electronic device can retrieve the special effects resources to be encoded from a database. For example, the database can pre-store multiple special effects resources to be encoded. When the electronic device receives an encoding message for a special effects resource, it can retrieve these multiple resources from the database. For example, each of the multiple special effects resources pre-stored in the database includes a unique identifier. The electronic device can receive encoding messages for special effects resources sent by other devices. These encoding messages can include identifiers corresponding to multiple special effects resources. The electronic device can then retrieve the special effects resources to be encoded from the database based on these identifiers.
[0051] It should be noted that electronic devices can acquire special effects resources to be encoded in any feasible implementation method, and the embodiments disclosed herein do not limit this.
[0052] S202. Determine the image type of the first image.
[0053] The electronic device can determine the image type of each first image according to the following feasible implementation: performing gradient processing on the brightness value of the first image to obtain a second image, and determining the image type of the first image based on the number of frames associated with the second image and the first image. Optionally, the image type may include at least one of the following: color mapping type, static type, and sequence frame type.
[0054] In this context, the first image of a color mapping type can represent a set of color mapping relationships. For example, the first image of a color mapping type can be a Look-Up Table (LUT) image. A LUT image maps each pixel value of one image to the pixel value of another image. By using LUT images, various effects can be adjusted on other images (color correction, exposure adjustment, curve adjustment, etc.). For example, filter effects can use LUT images. If an electronic device obtains the mapping value corresponding to pure blue (RGB value 0, 0, 1), the electronic device can obtain the coordinates of pure blue on that LUT and determine the color at those coordinates as the mapped color of pure blue in that LUT image.
[0055] The first image of the static type can be the image corresponding to a static special effect. For example, the special effects corresponding to the special effects resource can include static sticker effects, and the image corresponding to the sticker can be a static image. For example, if the special effect downloaded to the electronic device is a static glasses effect, then the image type of the first image included in the special effects resource can be static.
[0056] In this context, the first image of a sequence frame type can be a set of images that make up a dynamic effect. For example, the special effects corresponding to the special effects resource may include a fireworks effect, which is composed of multiple consecutive images; therefore, these multiple consecutive images can be images of the sequence frame type. For example, in... Figure 3 In the illustrated embodiment, the special effects resources may include 5 images, which can form a dynamic special effect of a person waving. Therefore, all 5 images can be images of the sequence frame type.
[0057] The brightness value can be the brightness distribution information of the image. For example, the brightness value of the first image can be the brightness distribution information of the first image, that is, the brightness value of the first image can be the contrast of the first image, and the brightness value of the first image can indicate the brightness of the first image.
[0058] The gradient value of an image can indicate the degree of change in image brightness in the x and y directions. For example, the gradient value of an image can indicate the rate of change in image brightness, and it can also indicate the direction of the brightness change. Therefore, after the electronic device performs gradient processing on the brightness value of the first image, it can obtain the second image corresponding to the first image.
[0059] It should be noted that the electronic device can perform gradient processing on the brightness value of the first image according to any feasible implementation method, and the embodiments disclosed herein are not limited in this respect.
[0060] Specifically, the electronic device determines the image type of the first image based on the second image and the number of frames associated with the first image. This can be achieved by: performing binarization processing on the second image to obtain a binarized image of the second image; determining the first image as a color mapping type based on the number of image block repetition units in the binarized image of the second image; and determining the image type of the first image as a sequence frame type or a static type based on the number of frames associated with the first image.
[0061] Binarization is a method of transforming a first image into a visual effect consisting only of black and white. For example, an electronic device can set the grayscale value of the pixels in the first image to 0 or 255, thus making the first image contain only black and white. By performing binarization on the second image, a binarized image of the second image can be obtained.
[0062] Optionally, if the number of repeating image block units in the binarized image of the second image is greater than a preset value, then the type of the first image is determined to be a color mapping type. For example, if the binarized image of the second image includes multiple repeating image block units, then the image type of the first image corresponding to the second image is determined to be a color mapping type; if the binarized image of the second image does not include multiple repeating image block units, then the image type of the first image corresponding to the second image is determined to be a static type or a sequence frame type.
[0063] For example, if the electronic device binarizes the second image corresponding to the first image, and the resulting binarized image is composed of M*M repeated image block units, then the electronic device can determine that the first image corresponding to the second image is a LUT image. If the binarized image does not include M*M repeated image block units, then the electronic device can determine that the second image is a static image or a sequence frame image, where M is an integer greater than 1.
[0064] It should be noted that, based on the construction rules of LUT images, after performing gradient processing on the brightness values of the LUT image and binarizing the result of the gradient processing, the LUT image can be transformed into an image composed of 4*4 identical image blocks or 8*8 identical images. Therefore, electronic devices can accurately identify LUT images based on the binarized image of the second image.
[0065] Below, in conjunction with Figure 4 This section explains the process by which electronic devices determine the color mapping type of an image.
[0066] Figure 4 This is a schematic diagram of an image used to determine the color mapping type according to an embodiment of this disclosure. Please refer to [link / reference]. Figure 4This includes: a first image and a binarized image of a corresponding second image. The color-mapped image has the following characteristics: it consists of multiple grid cells (e.g., each edge of the image may include 4 or 8 grid cells), and the color change within each grid cell is smooth. Electronic devices ( Figure 4 (Not shown) Gradient processing can be performed on the brightness values of the first image, and the result of the gradient processing can be binarized to obtain a binarized image of the second image. Since the binarized image of the second image includes 8*8 repeating image blocks, the binarized image of the second image satisfies the judgment condition of the color mapping type image, and the electronic device can determine that the image type of the first image is a color mapping type (i.e., the first image is a LUT image).
[0067] Optionally, if the binarized image of the second image does not include M*M repeating image blocks, the electronic device can determine that the first image corresponding to the second image is a texture image, and the electronic device can further determine the image type of the texture image. Optionally, the electronic device can determine the image type of the first image as a sequence frame type or a static type based on the number of frames associated with the first image. For example, if the number of frames associated with the first image is 0, the electronic device can determine that the first image does not have any associated continuous images, and the electronic device can determine that the image type of the first image is a static type. If the number of frames associated with the first image is greater than 0, the electronic device can determine that the first image has associated continuous images, and the electronic device can determine that the image type of the first image is a sequence frame type.
[0068] Optionally, in practical applications, images of the sequence frame type may include the same identifier. If multiple consecutive images have the same identifier, the electronic device can identify the multiple consecutive images as images of the sequence frame type. If the identifiers of each of the multiple images are different, the electronic device can identify the multiple images as images of the static type.
[0069] It should be noted that the embodiments disclosed herein are merely illustrative of a method for an electronic device to determine a static image type and a sequence frame type image, and are not intended to limit the method for an electronic device to determine a static image type and a sequence frame type image. The electronic device may also determine the image type corresponding to the first image based on any feasible implementation method, and the embodiments disclosed herein do not limit this.
[0070] S203. For any first image, determine the target encoding method corresponding to the first image based on the image type of the first image.
[0071] The target encoding method can be the encoding method corresponding to the first image. The electronic device can encode the first image corresponding to the target encoding method according to the target encoding method. For example, in practical applications, the image type of the first image can be matched with the encoding method of the first image. This can improve the encoding effect of the first image, reduce the size of the encoded data packet, and improve the decoding efficiency.
[0072] It should be noted that after the electronic device acquires multiple first images from the special effects resources, it can determine the image type of each first image, and thus obtain the target encoding method corresponding to each first image.
[0073] The electronic device can determine the target encoding method corresponding to the first image based on the following feasible implementation method: obtain the first encoding method and the second encoding method, and determine the target encoding method corresponding to the first image based on the color mapping type, static type or sequence frame type respectively.
[0074] The first encoding method can include lossless encoding and quantization encoding. Optionally, the first encoding method can be a Portable Network Graphics (PNG) encoding method. The PNG encoding method can include PNG32 encoding (lossless encoding) and PNG index encoding (quantization encoding).
[0075] Optionally, the PNG32 encoding method uses 32 bits of data to represent each pixel when storing the RGBA data of an image. For example, PNG32 encoding can use 24 bits to identify a color, with each of the RGB values occupying 8 bits and the alpha transparency value being represented by 8 bits. In this way, this encoding method can support the encoding of more than 16 million colors and 256 levels of transparency, thus resulting in less information loss after image encoding.
[0076] Optionally, in PNG indexed encoding, each pixel can be represented by 8 bits of data when storing the RGBA data of an image. For example, PNG indexed encoding can use 8 bits to represent the RGB value of a pixel and 1 bit to represent transparency. Therefore, PNG indexed encoding can support encoding 256 colors and 2 levels of transparency (i.e., transparent or opaque). If the number of colors in an image is greater than 256, the colors need to be quantized, resulting in a loss of more image information.
[0077] Optionally, the second encoding method can be WebP encoding. For example, WebP encoding can be an image encoding method that supports both lossy and lossless compression. Since the first image is a static image, it only needs to be decoded once during loading. During encoding, an algorithm with a higher compression ratio can be referenced. When using WebP encoding, the WebP encoding parameter can be selected as 90.
[0078] It should be noted that the first encoding method and the second encoding method in the embodiments of this disclosure can also be other encoding methods, and the embodiments of this disclosure do not limit them.
[0079] The electronic device determines the target encoding method corresponding to the first image based on the color mapping type, static type, or sequence frame type, in either the first encoding method or the second encoding method, with the following three possibilities:
[0080] Case 1: The image type of the first image is a color mapping type.
[0081] If the first image is of color mapping type, then the lossless encoding method in the first encoding method is determined as the target encoding method corresponding to the first image. For example, after encoding the first image using the lossless encoding method of the first encoding method, the first image loses less information; after encoding the first image using the quantization encoding method of the first encoding method, the first image loses more information. Since the mapping relationship of the first image of color mapping type can be determined based on color, if the color loss is significant, the accuracy of color mapping will be low. Therefore, the electronic device can determine that the target encoding method of the first image of color mapping type is the lossless encoding method of the first encoding method (e.g., PNG32 encoding method).
[0082] It should be noted that when encoding the first image using the first encoding method, the lossless encoding method can accurately encode the first image with minimal loss of image information. However, the encoded first image has a larger file size and slower decoding speed. Conversely, the quantization encoding method in the first encoding method loses more image information, but the encoded first image has a smaller file size and faster decoding speed. Therefore, if the first image is a color mapping type, the electronic device can determine that the target encoding method for the first image is the lossless encoding method in the first encoding method. This ensures the accuracy of the encoded first image and avoids color mapping errors.
[0083] Case 2: The first image is of static type.
[0084] If the image type of the first image is static, the electronic device can determine the target encoding method corresponding to the first image based on the first encoding method, the second encoding method, and the first image.
[0085] Optionally, the electronic device can encode the first image based on a first encoding method and a second encoding method, and determine the corresponding encoding method for the first image based on the encoded result. For example, in practical applications, the encoded image needs to be decoded at the decoding end. Therefore, when encoding the first image, the decoding efficiency of the decoding end also needs to be considered. By comparing the encoding results of the first image using the two encoding methods, the electronic device can accurately determine the encoding method that matches the first image, thereby improving the encoding accuracy and encoding effect of the first image.
[0086] Case 3: The first image is a sequence frame type.
[0087] If the first image is a sequence frame type, the number of colors included in the first image is obtained, and the target encoding method corresponding to the first image is determined based on the number of colors. For example, since sequence frame type images require continuous decoding at the decoding end, which consumes a lot of time, the electronic device can encode the first image of sequence frame type based on the first encoding method. However, since the first encoding method also includes lossless encoding method and quantization encoding method, the electronic device can determine the target encoding method based on the number of colors in the first image.
[0088] For example, in practical applications, if the loss of image information after quantizing the first image has a small impact on the image quality, the electronic device can encode the first image based on the quantization encoding method, thereby reducing the size of the encoded first image and improving the decoding efficiency. If the loss of image information after quantizing the first image has a large impact on the image quality, the electronic device can encode the first image based on the lossless encoding method, thereby improving the integrity of the decoded first image and improving the display effect of the first image.
[0089] S204. Encode the special effects resources according to the target encoding method corresponding to each first image.
[0090] Optionally, the electronic device can encode multiple first images in the special effects resource according to the target encoding method corresponding to each first image, to obtain a data packet after encoding the special effects resource. For example, if the special effects resource includes image A, image B, and image C, and the target encoding method corresponding to image A is encoding method 1, and the target encoding method corresponding to image B and image C is encoding method 2, then the electronic device can encode image A based on encoding method 1, and encode image B and image C based on encoding method 2. After the encoding of image A, image B, and image C is completed, the electronic device can obtain the data packet corresponding to the special effects resource (i.e., the special effects resource encoding is complete).
[0091] Below, in conjunction with Figure 5 This section explains the process by which electronic devices encode special effects resources.
[0092] Figure 5 This is a schematic diagram illustrating the encoding process of a special effects resource provided in an embodiment of this disclosure. Please refer to [link / reference]. Figure 5 This includes: special effects resources. These resources may include Image 1, Image 2, Image 3, and Image 4. Image 1, Image 2, and Image 3 are of sequence frame type, while Image 4 is of static type. Electronic devices ( Figure 5 (Not shown) It can be determined that the encoding method corresponding to image 1, image 2 and image 3 is encoding method 1, and the encoding method corresponding to image 4 is encoding method 2. The electronic device can encode image 1, image 2 and image 3 based on encoding method 1, and encode image 4 based on encoding method 2. After the encoding is completed, the data packet corresponding to the special effects resource can be obtained.
[0093] Optionally, after the electronic device encodes the special effects resources, the above method may further include: receiving a special effects resource download request sent by another device, wherein the special effects resource download request may include an identifier of at least one special effects resource, and the electronic device may determine a target data packet from multiple data packets corresponding to multiple special effects resources based on the identifier of at least one special effects resource, and send the target data packet to other devices.
[0094] This disclosure provides an image processing method. An electronic device can acquire special effects resources to be encoded and determine the image type of each first image in the special effects resources. For any first image, if the image type of the first image is a color mapping type, the target encoding method of the first image is determined to be PNG32 encoding. If the image type of the first image is a static type, the target encoding method corresponding to the first image is determined according to PNG encoding, WebP encoding, and the first image. If the type of the first image is a sequence frame type, the number of colors included in the first image is obtained, and the target encoding method corresponding to the first image is determined according to the number of colors, between PNG32 encoding and PNG index encoding. After obtaining the target encoding method corresponding to each first image, the electronic device performs encoding processing on multiple first images in the special effects resources to obtain the data packet corresponding to the special effects resources. In the above method, since the electronic device can determine the target encoding method corresponding to the first image by combining the image type of the first image in the special effects resource, and each type of image includes a corresponding target encoding method, each type of first image in the special effects resource can be matched with the corresponding target encoding method. This can improve the encoding quality of the first image, reduce the size of the first image after encoding, and thus reduce the data volume of the data packet corresponding to the special effects resource.
[0095] exist Figure 2 Based on the embodiments shown, the following, in conjunction with Figure 6 The method for determining the target encoding method corresponding to a static first image based on a first encoding method, a second encoding method, and the first image itself is described in detail in the above image processing method.
[0096] Figure 6 This is a schematic diagram illustrating a method for determining a target encoding method provided in an embodiment of this disclosure. Please refer to [link / reference]. Figure 6 The method flow may include:
[0097] S601. According to the first encoding method, the first image is pre-encoded to obtain the first pre-encoding result corresponding to the first image.
[0098] The first precoding result can be the encoding result obtained by the electronic device after precoding the first image based on the first encoding method. For example, the electronic device can precode the first image based on the PNG32 encoding method to obtain the encoding result corresponding to the PNG32 encoding method, that is, the first precoding result. The electronic device can also precode the first image based on the PNG index encoding method to obtain the encoding result corresponding to the PNG index encoding method, that is, the first precoding result.
[0099] S602. According to the second encoding method, the second image is pre-encoded to obtain the second pre-encoding result corresponding to the first image.
[0100] The second precoding result can be the encoding result obtained after the electronic device precodes the first image based on the second encoding method. For example, the electronic device can encode the first image based on the WebP encoding method to obtain the encoding result corresponding to the WebP encoding method, that is, the second precoding result.
[0101] It should be noted that since both PNG and WebP encoding methods include lossless encoding and quantization encoding, if the first precoding result is obtained based on PNG32 encoding, the second precoding result can be obtained based on WebP lossless encoding. If the first precoding result is obtained based on PNG index encoding, the second precoding result can be obtained based on WebP quantization encoding.
[0102] S603. Determine the target encoding method corresponding to the first image based on the first precoding result and the second precoding result.
[0103] The electronic device can determine the target encoding method corresponding to the first image according to the following feasible implementation: if the ratio of the second precoding result to the first precoding result is greater than or equal to a first threshold, then the target encoding method corresponding to the first image is determined to be the second encoding method; if the ratio of the second precoding result to the first precoding result is less than the first threshold, then the target encoding method corresponding to the first image is determined to be the first encoding method. For example, if the ratio of the data size of the second precoding result to the data size of the first precoding result is greater than or equal to the first threshold, then the electronic device determines the target encoding method to be the WebP encoding method; if the ratio of the data size of the second precoding result to the data size of the first precoding result is less than the first threshold, then the target encoding method is determined to be the PNG encoding method.
[0104] It should be noted that the ratio of the second precoding result to the first precoding result is merely an exemplary illustration of a method for determining the target encoding method, and is not a limitation on the method for determining the target encoding method. Electronic devices can perform arbitrary operations on the second precoding result and the first precoding result, and determine the target encoding method based on the operation result. This disclosure does not limit this.
[0105] Optionally, since the first image of static type only needs to be decoded once during loading, when the electronic device encodes the first image of static type, it can determine the target encoding method corresponding to the first image by combining the decoding efficiency.
[0106] If the second encoding method is WebP encoding, then there is a corresponding relationship between the compression rate and decoding performance of WebP encoding. Below, we will discuss this in conjunction with... Figure 7 This correspondence will be explained.
[0107] Figure 7 This diagram illustrates the correspondence between compression ratio and decoding performance, as provided in an embodiment of this disclosure. Please refer to... Figure 7 This includes a coordinate system. The horizontal axis represents the relative compression ratio of WebP encoding compared to PNG encoding, where x = 0 indicates no size optimization for WebP encoding compared to PNG. The vertical axis represents the relative decoding time increment of WebP encoding compared to PNG encoding, where y > 0 indicates a degraded decoding time for WebP encoding compared to PNG (i.e., the portion above the dashed line), and y < 0 indicates an optimized decoding time for WebP encoding compared to PNG (i.e., the portion below the dashed line).
[0108] Please see Figure 7 The coordinate system also includes a linear relationship between relative compression ratio and relative decoding time enhancement. Under the same encoding parameters, the higher the compression ratio of WebP encoding, the smaller the increase in decoding time. Therefore, after the relative compression ratio of WebP encoding exceeds a certain threshold, the decoding time of WebP encoding can be better than that of PNG encoding. This threshold (i.e., the first threshold) can be the focus of the dashed and solid lines in the coordinate system, i.e., x = 0.78. If the compression ratio of WebP encoding is greater than or equal to 78% of the compression ratio of PNG encoding, the electronic device can determine that the target encoding method is WebP encoding. If the compression ratio of WebP encoding is less than 78% of the compression ratio of PNG encoding, the electronic device can determine that the target encoding method is PNG encoding.
[0109] In this way, the electronic device can determine the target decoding method corresponding to the first image from among multiple encoding methods based on the decoding time of the decoding end for the first image of static type, thereby improving the decoding efficiency of the decoding end for the first image of static type.
[0110] This disclosure provides a method for determining a target encoding method. An electronic device can pre-encode a first image according to a first encoding method to obtain a first pre-encoding result corresponding to the first image, and pre-encode a second image according to a second encoding method to obtain a second pre-encoding result corresponding to the first image. If the ratio of the second pre-encoding result to the first pre-encoding result is greater than or equal to a first threshold, the target encoding method is determined to be the second encoding method; if the ratio of the second pre-encoding result to the first pre-encoding result is less than the first threshold, the target encoding method is determined to be the first encoding method. In this way, the electronic device can determine the encoding method with the shorter decoding time from multiple encoding methods to encode a static first image, thereby improving the decoding efficiency of the first image.
[0111] exist Figure 2 Based on the embodiments shown, the following, in conjunction with Figure 8 The method for determining the target encoding method of the first image based on the number of colors in the above image processing method is described in detail.
[0112] Figure 8 This is a schematic diagram illustrating another method for determining a target encoding scheme provided in an embodiment of this disclosure. Please refer to... Figure 8 The method flow may include:
[0113] S801, Obtain the number of colors included in the first image.
[0114] Optionally, the electronic device may obtain the number of colors included in the first image according to the following feasible implementation: obtain the color histogram corresponding to the first image, and determine the number of colors included in the first image based on the color histogram.
[0115] Optionally, since a color histogram can indicate the proportion of different colors in the first image, the electronic device can obtain the number of colors included in the first image based on the color histogram. It should be noted that the electronic device can obtain the color histogram of the first image based on any feasible implementation method, and this disclosure does not limit this approach.
[0116] Optionally, the electronic device may also process the first image in any feasible manner to obtain the number of colors in the first image, and the embodiments of this disclosure are not limited in this respect.
[0117] S802. Determine the target encoding method corresponding to the first image based on the number of colors.
[0118] The electronic device determines the target encoding method corresponding to the first image based on the number of colors, and there are two cases:
[0119] Case 1: The number of colors is less than or equal to the second threshold.
[0120] If the number of colors is less than or equal to the second threshold, the electronic device can determine that the target encoding method is the lossless encoding method in the first encoding method. For example, if the number of colors is less than or equal to the second threshold, the electronic device can encode the first image using PNG index encoding. Furthermore, since the first image of the sequence frame type needs to be decoded continuously, the decoding efficiency of the first image of the sequence frame type can be improved by using PNG encoding.
[0121] Optionally, the second threshold can be 256. For example, if the number of colors contained in the first image is less than 256, then when the electronic device encodes the first image based on the PNG index encoding method, it does not need to quantize the colors of the first image (the PNG index encoding method can store a maximum of 256 colors). Therefore, after the electronic device encodes the first image based on the PNG index encoding method, the first image loses less image information, thus improving the encoding accuracy of the first image.
[0122] Case 2: The number of colors is greater than the second threshold.
[0123] If the number of colors exceeds the second threshold, the electronic device can cluster the multiple colors of the first image into N color classes and determine the clustering error corresponding to each color class. The electronic device can then determine the target encoding method based on the N clustering errors. Here, N can be an integer greater than 0 and less than 256.
[0124] For example, if the number of colors in the first image is greater than the second threshold, it means that the electronic device cannot store all the colors in the first image based on the PNG index encoding method. Therefore, during the encoding process of the first image, the electronic device can quantize the colors in the first image. If the image quality loss of the quantized first image is small, the PNG index encoding method can be determined as the target encoding method. If the image quality loss of the quantized first image is large, the PNG32 encoding method can be determined as the target encoding method.
[0125] Optionally, the electronic device may perform clustering processing on all colors in the first image based on a clustering algorithm to obtain N categories. The electronic device may also cluster all colors in the first image into N categories based on any other feasible implementation method. This embodiment of the present disclosure does not limit this.
[0126] Optionally, the electronic device can determine the clustering error for each color class according to the following feasible implementation: For any clustered color class, the electronic device can determine the clustering error according to the following formula:
[0127]
[0128] Among them, E k N represents the clustering error; k is the number of colors in this color class; i is the color index in this color class; This represents the value of the i-th color in that color class. Cluster centers (after the clustering algorithm clusters multiple colors, the electronic device can obtain the cluster centers corresponding to each color).
[0129] In this way, the electronic device can obtain the clustering error of each color in the N color categories according to the above formula, and then determine whether the quantization of the first image will result in a significant loss of image information based on the N clustering errors.
[0130] Specifically, the electronic device determines the target encoding method based on N clustering errors. This can be achieved by: obtaining the largest clustering error among the N clustering errors and the target number of clustering errors greater than the third threshold among the N clustering errors; and determining the target encoding method based on the largest clustering error and the target number.
[0131] For example, if an electronic device clusters multiple colors in a first image into 256 color classes, it can obtain the clustering error for each color class and identify the largest clustering error among the 256 errors. For instance, if the third threshold is 10, and 50 of the 256 clustering errors have an error greater than 10, the electronic device can determine that the target quantity is 50.
[0132] It should be noted that the electronic device can determine the third threshold based on any feasible implementation method, and the embodiments disclosed herein are not limited in this regard.
[0133] Optionally, the electronic device determines the target encoding method based on the maximum clustering error and the number of targets. Specifically, if the maximum clustering error is greater than the fourth threshold and the number of targets is greater than the fifth threshold, the target encoding method is determined to be the lossless encoding method in the first encoding method. If the maximum clustering error is less than or equal to the fourth threshold, or the number of targets is less than or equal to the fifth threshold, the target encoding method is determined to be the quantization encoding method in the first encoding method.
[0134] For example, if the maximum clustering error is greater than the fourth threshold and the number of targets is greater than the fifth threshold, it means that after the electronic device performs quantization processing on the first image, the first image will lose a lot of image information, which will affect the image quality after the first image is decoded. Therefore, the electronic device can encode the first image based on the lossless encoding method of the first encoding method (i.e., PNG32 encoding method).
[0135] It should be noted that the electronic device can determine the fourth and fifth thresholds according to any feasible implementation method, and the embodiments disclosed herein do not limit this.
[0136] For example, if the maximum clustering error is less than or equal to the fourth threshold, it indicates that the electronic device loses less image information after quantizing the first image, and has little impact on the image quality after decoding. Therefore, the electronic device can encode the first image based on the quantization encoding method (i.e., PNG index encoding method) in the first encoding method. In this way, the electronic device can not only ensure the image quality after decoding the first image, but also reduce the data volume of the data packet after encoding the first image.
[0137] Optionally, when encoding the first image based on the lossless encoding method in the first encoding method, the electronic device can also optimize the amount of encoded data. The following will combine... Figure 9 The encoding process of lossless encoding is explained.
[0138] Figure 9 This is a schematic diagram illustrating a lossless encoding method provided in an embodiment of this disclosure. Please refer to [link / reference]. Figure 9 It includes: pixel data of the first image, a filtering module (which can be a differential filter), and a compression module. The filtering module can include filter parameter 1, filter parameter 2, ..., filter parameter n, and the compression module can execute compression mode A and compression mode B.
[0139] Please see Figure 9 The filtering module can include multiple filtering parameters, and the compression module can include two compression modes. (Electronic devices...) Figure 9 (Not shown) can iterate through each combination parameter of the filtering module and the compression module, compress the pixel data of the first image into compressed data, and set the combination parameter corresponding to the smallest compressed data as the parameter of the filtering module and the compression module, thereby performing compression processing on the first image.
[0140] For example, in Figure 9 In the illustrated embodiment, the filtering module can filter the pixel data of the first image based on filtering parameter 1, and the compression module can compress the filtered data based on compression mode A to obtain compressed data A. The filtering module can also filter the pixel data of the first image based on filtering parameter 2, and the compression module can compress the filtered data based on compression mode B to obtain compressed data B. If compressed data A is less than compressed data B, the electronic device can determine that the filtering parameter of the filtering module is filtering parameter 1 and the compression mode of the compression module is compression mode A, and encode the first image based on the filtering module and the compression module. In this way, the amount of data after encoding the first image can be reduced.
[0141] Optionally, in the PNG32 encoding method, if the number of alpha channels in the RGBA of the first image is all 255, it means that the first image does not have transparent pixels. Therefore, when encoding the first image, there is no need to store the alpha channels, which can reduce the amount of data after encoding the first image.
[0142] Optionally, in the PNG32 encoding method, if the decoding end can render the special effects scene of alpha*RGB color data on the screen, then when the electronic device encodes the first image based on PNG32, the electronic device can store alpha*RGB color data, which will generate a large number of 0 values, improve encoding efficiency, reduce the amount of data after encoding the first image, and save computation when decoding the first image at the decoding end, thus improving decoding efficiency.
[0143] This disclosure provides a method for determining a target encoding method. An electronic device can obtain the number of colors included in a first image. If the number of colors is less than or equal to a second threshold, the electronic device can determine that the target encoding method is the lossless encoding method among the first encoding methods. If the number of colors is greater than the second threshold, the electronic device can cluster the various colors of the first image into N color classes and determine the clustering error corresponding to each color class. The electronic device can determine the target encoding method based on the N clustering errors. In this way, the electronic device can not only ensure the image quality after decoding the first image but also reduce the data volume of the data packets after encoding the first image.
[0144] Figure 10 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of this disclosure. Please refer to [link / reference]. Figure 10 The image processing device 100 includes an acquisition module 101, a first determination module 102, a second determination module 103, and an encoding module 104, wherein:
[0145] The acquisition module 101 is used to acquire special effects resources to be encoded, the special effects resources including multiple first images;
[0146] The first determining module 102 is used to determine the image type of the first image;
[0147] The second determining module 103 is used to determine the target encoding method corresponding to any one of the first images based on the image type of the first image;
[0148] The encoding module 104 is used to encode the special effects resources according to the target encoding method corresponding to each first image.
[0149] According to one or more embodiments of this disclosure, the first determining module 102 is specifically used for:
[0150] Gradient processing is applied to the brightness values of the first image to obtain the second image;
[0151] Based on the second image and the number of frames associated with the first image, the image type of the first image is determined, including color mapping type, static type, and sequence frame type.
[0152] According to one or more embodiments of this disclosure, the first determining module 102 is specifically used for:
[0153] The second image is binarized to obtain a binarized version of the second image;
[0154] Based on the number of image block repeating units in the binarized image of the second image, the first image is determined to be of color mapping type;
[0155] Based on the number of frames associated with the first image, the image type of the first image is determined to be either the sequence frame type or the static type.
[0156] According to one or more embodiments of this disclosure, the second determining module 103 is specifically used for:
[0157] Obtain a first encoding method and a second encoding method, wherein the first encoding method includes a lossless encoding method and a quantization encoding method;
[0158] Based on the color mapping type, static type, or sequence frame type, the target encoding method corresponding to the first image is determined in the first encoding method and the second encoding method, respectively.
[0159] According to one or more embodiments of this disclosure, the second determining module 103 is specifically used for:
[0160] If the first image type is a color mapping type, then the lossless encoding method in the first encoding method is determined as the target encoding method corresponding to the first image;
[0161] If the image type of the first image is static, then the target encoding method corresponding to the first image is determined based on the first encoding method, the second encoding method, and the first image.
[0162] If the image type of the first image is a sequence frame type, then the number of colors included in the first image is obtained, and the target encoding method corresponding to the first image is determined based on the number of colors.
[0163] According to one or more embodiments of this disclosure, the second determining module 103 is specifically used for:
[0164] Based on the first encoding method, the first image is pre-encoded to obtain the first pre-encoding result corresponding to the first image;
[0165] Based on the second encoding method, the first image is pre-encoded to obtain the second pre-encoding result corresponding to the first image;
[0166] If the ratio of the second precoding result to the first precoding result is greater than or equal to the first threshold, then the target encoding method corresponding to the first image is determined to be the second encoding method;
[0167] If the ratio of the second precoding result to the first precoding result is less than the first threshold, then the target encoding method corresponding to the first image is determined to be the first encoding method.
[0168] According to one or more embodiments of this disclosure, the second determining module 103 is specifically used for:
[0169] If the number of colors is less than or equal to the second threshold, then the target encoding method is determined to be the quantization encoding method in the first encoding method;
[0170] If the number of colors is greater than the second threshold, the multiple colors of the first image are clustered into N color classes, and the clustering error corresponding to each color class is determined. Based on the N clustering errors, the target encoding method is determined, where N is an integer greater than 0 and less than 256.
[0171] According to one or more embodiments of this disclosure, the second determining module 103 is specifically used for:
[0172] Obtain the target number of the largest clustering error among the N clustering errors, and the target number of clustering errors among the N clustering errors that are greater than the third threshold;
[0173] If the maximum clustering error is greater than the fourth threshold and the number of targets is greater than the fifth threshold, then the target encoding method is determined to be the lossless encoding method in the first encoding method;
[0174] If the maximum clustering error is less than or equal to the fourth threshold, or if the target number is less than or equal to the fifth threshold, then the target encoding method is determined to be the quantization encoding method in the first encoding method.
[0175] The image processing apparatus provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be repeated here.
[0176] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Please refer to [link / reference]. Figure 11 It shows a schematic diagram of the structure of an electronic device 1100 suitable for implementing the embodiments of the present disclosure. The electronic device 1100 can be any device with on-device computing capabilities. Figure 11 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0177] like Figure 11 As shown, electronic device 1100 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 1101, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1102 or a program loaded from storage device 1108 into random access memory (RAM) 1103. RAM 1103 also stores various programs and data required for the operation of electronic device 1100. The processing unit 1101, ROM 1102, and RAM 1103 are interconnected via bus 1104. Input / output (I / O) interface 1105 is also connected to bus 1104.
[0178] Typically, the following devices can be connected to I / O interface 1105: input devices 1106 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 1107 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1108 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1109. Communication device 1109 allows electronic device 1100 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 11 An electronic device 1100 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0179] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 1109, or installed from storage device 1108, or installed from ROM 1102. When the computer program is executed by processing device 1101, it performs the functions defined in the methods of embodiments of this disclosure.
[0180] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0181] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0182] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.
[0183] This disclosure provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the image processing methods described in the first aspect above and various possible aspects thereof.
[0184] This disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the image processing methods described in the first aspect above and various possible aspects of the first aspect.
[0185] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0186] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0187] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".
[0188] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0189] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0190] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0191] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0192] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0193] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the terminal device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0194] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the terminal device.
[0195] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0196] It is understood that the data involved in this technical solution (including but not limited to the data itself, its acquisition, or its use) shall comply with the requirements of relevant laws, regulations, and provisions. Data may include information, parameters, and messages, such as flow control instructions.
[0197] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0198] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0199] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
[0200] In a first aspect, this disclosure provides one or more embodiments of an image processing method, the method comprising:
[0201] Obtain special effects resources to be encoded, the special effects resources including multiple first images;
[0202] Determine the image type of the first image;
[0203] For the first image, the target encoding method corresponding to the first image is determined according to the image type of the first image;
[0204] The special effects resources are encoded according to the target encoding method corresponding to each first image.
[0205] According to one or more embodiments of this disclosure, determining the image type of the first image includes:
[0206] Gradient processing is applied to the brightness values of the first image to obtain the second image;
[0207] Based on the second image and the number of frames associated with the first image, the image type of the first image is determined, including color mapping type, static type, and sequence frame type.
[0208] According to one or more embodiments of this disclosure, determining the image type of the first image based on the number of frames associated with the second image and the first image includes:
[0209] The second image is binarized to obtain a binarized version of the second image;
[0210] Based on the number of image block repeating units in the binarized image of the second image, the first image is determined to be of color mapping type;
[0211] Based on the number of frames associated with the first image, the image type of the first image is determined to be either the sequence frame type or the static type.
[0212] According to one or more embodiments of this disclosure, determining the target encoding method corresponding to the first image based on the image type of the first image includes:
[0213] Obtain a first encoding method and a second encoding method, wherein the first encoding method includes a lossless encoding method and a quantization encoding method;
[0214] Based on the color mapping type, static type, or sequence frame type, the target encoding method corresponding to the first image is determined in the first encoding method and the second encoding method, respectively.
[0215] According to one or more embodiments of this disclosure, determining the target encoding method corresponding to the first image based on the color mapping type, static type, or sequence frame type, among the first encoding method and the second encoding method, includes:
[0216] If the first image type is a color mapping type, then the lossless encoding method in the first encoding method is determined as the target encoding method corresponding to the first image;
[0217] If the image type of the first image is static, then the target encoding method corresponding to the first image is determined based on the first encoding method, the second encoding method, and the first image.
[0218] If the image type of the first image is a sequence frame type, then the number of colors included in the first image is obtained, and the target encoding method corresponding to the first image is determined based on the number of colors.
[0219] According to one or more embodiments of this disclosure, determining a target encoding method corresponding to the first image based on the first encoding method, the second encoding method, and the first image includes:
[0220] Based on the first encoding method, the first image is pre-encoded to obtain the first pre-encoding result corresponding to the first image;
[0221] Based on the second encoding method, the first image is pre-encoded to obtain the second pre-encoding result corresponding to the first image;
[0222] If the ratio of the second precoding result to the first precoding result is greater than or equal to the first threshold, then the target encoding method corresponding to the first image is determined to be the second encoding method;
[0223] If the ratio of the second precoding result to the first precoding result is less than the first threshold, then the target encoding method corresponding to the first image is determined to be the first encoding method.
[0224] According to one or more embodiments of this disclosure, determining the target encoding method corresponding to the first image based on the number of colors includes:
[0225] If the number of colors is less than or equal to the second threshold, then the target encoding method is determined to be the quantization encoding method in the first encoding method;
[0226] If the number of colors is greater than the second threshold, the multiple colors of the first image are clustered into N color classes, and the clustering error corresponding to each color class is determined. Based on the N clustering errors, the target encoding method is determined, where N is an integer greater than 0 and less than 256.
[0227] According to one or more embodiments of this disclosure, determining the target encoding method based on N clustering errors includes:
[0228] Obtain the target number of the largest clustering error among the N clustering errors, and the target number of clustering errors among the N clustering errors that are greater than the third threshold;
[0229] If the maximum clustering error is greater than the fourth threshold and the number of targets is greater than the fifth threshold, then the target encoding method is determined to be the lossless encoding method in the first encoding method;
[0230] If the maximum clustering error is less than or equal to the fourth threshold, or if the target number is less than or equal to the fifth threshold, then the target encoding method is determined to be the quantization encoding method in the first encoding method.
[0231] In a second aspect, this disclosure provides one or more embodiments of an image processing apparatus, which includes an acquisition module, a first determination module, a second determination module, and an encoding module, wherein:
[0232] The acquisition module is used to acquire special effects resources to be encoded, the special effects resources including multiple first images;
[0233] The first determining module is used to determine the image type of the first image;
[0234] The second determining module is used to determine the target encoding method corresponding to any one of the first images based on the image type of the first image;
[0235] The encoding module is used to encode the special effects resources according to the target encoding method corresponding to each first image.
[0236] According to one or more embodiments of this disclosure, the first determining module is specifically used for:
[0237] Gradient processing is applied to the brightness values of the first image to obtain the second image;
[0238] Based on the second image and the number of frames associated with the first image, the image type of the first image is determined, including color mapping type, static type, and sequence frame type.
[0239] According to one or more embodiments of this disclosure, the first determining module is specifically used for:
[0240] The second image is binarized to obtain a binarized version of the second image;
[0241] Based on the number of image block repeating units in the binarized image of the second image, the first image is determined to be of color mapping type;
[0242] Based on the number of frames associated with the first image, the image type of the first image is determined to be either the sequence frame type or the static type.
[0243] According to one or more embodiments of this disclosure, the second determining module is specifically used for:
[0244] Obtain a first encoding method and a second encoding method, wherein the first encoding method includes a lossless encoding method and a quantization encoding method;
[0245] Based on the color mapping type, static type, or sequence frame type, the target encoding method corresponding to the first image is determined in the first encoding method and the second encoding method, respectively.
[0246] According to one or more embodiments of this disclosure, the second determining module is specifically used for:
[0247] If the first image type is a color mapping type, then the lossless encoding method in the first encoding method is determined as the target encoding method corresponding to the first image;
[0248] If the image type of the first image is static, then the target encoding method corresponding to the first image is determined based on the first encoding method, the second encoding method, and the first image.
[0249] If the image type of the first image is a sequence frame type, then the number of colors included in the first image is obtained, and the target encoding method corresponding to the first image is determined based on the number of colors.
[0250] According to one or more embodiments of this disclosure, the second determining module is specifically used for:
[0251] Based on the first encoding method, the first image is pre-encoded to obtain the first pre-encoding result corresponding to the first image;
[0252] Based on the second encoding method, the first image is pre-encoded to obtain the second pre-encoding result corresponding to the first image;
[0253] If the ratio of the second precoding result to the first precoding result is greater than or equal to the first threshold, then the target encoding method corresponding to the first image is determined to be the second encoding method;
[0254] If the ratio of the second precoding result to the first precoding result is less than the first threshold, then the target encoding method corresponding to the first image is determined to be the first encoding method.
[0255] According to one or more embodiments of this disclosure, the second determining module is specifically used for:
[0256] If the number of colors is less than or equal to the second threshold, then the target encoding method is determined to be the quantization encoding method in the first encoding method;
[0257] If the number of colors is greater than the second threshold, the multiple colors of the first image are clustered into N color classes, and the clustering error corresponding to each color class is determined. Based on the N clustering errors, the target encoding method is determined, where N is an integer greater than 0 and less than 256.
[0258] According to one or more embodiments of this disclosure, the second determining module is specifically used for:
[0259] Obtain the target number of the largest clustering error among the N clustering errors, and the target number of clustering errors among the N clustering errors that are greater than the third threshold;
[0260] If the maximum clustering error is greater than the fourth threshold and the number of targets is greater than the fifth threshold, then the target encoding method is determined to be the lossless encoding method in the first encoding method;
[0261] If the maximum clustering error is less than or equal to the fourth threshold, or if the target number is less than or equal to the fifth threshold, then the target encoding method is determined to be the quantization encoding method in the first encoding method.
[0262] Thirdly, embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the image processing methods described in the first aspect and various possible aspects thereof.
[0263] Fourthly, embodiments of this disclosure provide a computer program product, including a computer program that, when executed by a processor, implements the image processing methods described in the first aspect above and various possible aspects of the first aspect.
[0264] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0265] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0266] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. An image processing method, characterized in that, include: Obtain special effects resources to be encoded, the special effects resources including multiple first images; Gradient processing is applied to the brightness values of the first image to obtain the second image; The second image is binarized to obtain a binarized version of the second image; If the number of image block repeating units in the binarized image of the second image is greater than a preset value, then the image type of the first image is determined to be a color mapping type. If the binarized image of the second image does not include multiple repeating image block units, then the image type of the first image is determined to be either static or sequence frame type. For the first image, a first encoding method and a second encoding method are obtained, wherein the first encoding method includes a lossless encoding method and a quantization encoding method; Based on the color mapping type, static type, or sequence frame type, respectively, determine the target encoding method corresponding to the first image in the first encoding method and the second encoding method; The special effects resources are encoded according to the target encoding method corresponding to each first image.
2. The method according to claim 1, characterized in that, The step of determining the target encoding method corresponding to the first image based on the color mapping type, static type, or sequence frame type, respectively, among the first encoding method and the second encoding method, includes: If the first image type is a color mapping type, then the lossless encoding method in the first encoding method is determined as the target encoding method corresponding to the first image; If the image type of the first image is static, then the target encoding method corresponding to the first image is determined based on the first encoding method, the second encoding method, and the first image. If the image type of the first image is a sequence frame type, then the number of colors included in the first image is obtained, and the target encoding method corresponding to the first image is determined based on the number of colors.
3. The method according to claim 2, characterized in that, The step of determining the target encoding method corresponding to the first image based on the first encoding method, the second encoding method, and the first image includes: Based on the first encoding method, the first image is pre-encoded to obtain the first pre-encoding result corresponding to the first image; Based on the second encoding method, the first image is pre-encoded to obtain the second pre-encoding result corresponding to the first image; If the ratio of the second precoding result to the first precoding result is greater than or equal to the first threshold, then the target encoding method corresponding to the first image is determined to be the second encoding method; If the ratio of the second precoding result to the first precoding result is less than the first threshold, then the target encoding method corresponding to the first image is determined to be the first encoding method.
4. The method according to claim 2, characterized in that, Determining the target encoding method corresponding to the first image based on the number of colors includes: If the number of colors is less than or equal to the second threshold, then the target encoding method is determined to be the quantization encoding method in the first encoding method; If the number of colors is greater than the second threshold, the multiple colors of the first image are clustered into N color classes, and the clustering error corresponding to each color class is determined. Based on the N clustering errors, the target encoding method is determined, where N is an integer greater than 0 and less than 256.
5. The method according to claim 4, characterized in that, The step of determining the target encoding method based on N clustering errors includes: Obtain the target number of the largest clustering error among the N clustering errors, and the target number of clustering errors among the N clustering errors that are greater than the third threshold; If the maximum clustering error is greater than the fourth threshold and the number of targets is greater than the fifth threshold, then the target encoding method is determined to be the lossless encoding method in the first encoding method; If the maximum clustering error is less than or equal to the fourth threshold, or if the target number is less than or equal to the fifth threshold, then the target encoding method is determined to be the quantization encoding method in the first encoding method.
6. An image processing apparatus, characterized in that, It includes an acquisition module, a first determination module, a second determination module, and an encoding module, wherein: The acquisition module is used to acquire special effects resources to be encoded, the special effects resources including multiple first images; The first determining module is used to perform gradient processing on the brightness values of the first image to obtain a second image; The second image is binarized to obtain a binarized version of the second image; If the number of image block repeating units in the binarized image of the second image is greater than a preset value, then the image type of the first image is determined to be a color mapping type. If the binarized image of the second image does not include multiple repeating image block units, then the image type of the first image is determined to be either static or sequence frame type. The second determining module is used to obtain a first encoding method and a second encoding method for any one of the first images, wherein the first encoding method includes a lossless encoding method and a quantization encoding method; Based on the color mapping type, static type, or sequence frame type, respectively, the target encoding method corresponding to the first image is determined in the first encoding method and the second encoding method; The encoding module is used to encode the special effects resources according to the target encoding method corresponding to each first image.
7. An electronic device, characterized in that, include: Processor and memory; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the image processing method as described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the image processing method as described in any one of claims 1-5.
9. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the image processing method as described in any one of claims 1-5.
Citation Information
Patent Citations
Data coding method and device, computer equipment and storage medium
CN113792816A
Virtual gift generation method and device, equipment and medium
CN116233561A