Image processing method, storage medium, chip and electronic device
Patent Information
- Application Number
- CN202311136702.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-04
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-09-04
AI Technical Summary
[0003]本申请实施例的一个目的旨在提供一种图像处理方法、存储介质、芯片及电子设备,旨在改善现有图像处理方案中在CPU主频较低的情况下图像压缩处理的时间较长的问题
Smart Images

Figure CN117156145B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image coding technology, specifically to an image processing method, storage medium, chip, and electronic device. Background Technology
[0002] With the continuous development of technology, the demand for encoding efficiency in video image processing is also increasing. Most existing image encoding methods consume a large amount of CPU (Central Processing Unit) resources during compression calculations, especially on embedded platforms where the CPU clock speed is low. This further limits the calculation speed of existing image compression methods, resulting in longer image compression processing times. Summary of the Invention
[0003] One objective of this application is to provide an image processing method, storage medium, chip, and electronic device, which aims to improve the problem of long image compression processing time in existing image processing solutions when the CPU clock speed is low.
[0004] In a first aspect, embodiments of this application provide an image processing method, the image processing method comprising:
[0005] Obtain K pixel groups, each pixel group including a first pixel and a second pixel, wherein the first pixel is a pixel in the first row of the image to be encoded, and the second pixel is a pixel in the second row of the image to be encoded that is in the same column as the first pixel, wherein K is an integer greater than or equal to 1;
[0006] The K pixel groups are divided into one first pixel group and K-1 second pixel groups, wherein the first pixel group is the first pixel group among the K pixel groups, and the second pixel group is the pixel group among the K pixel groups excluding the first pixel group.
[0007] The pixel values of the first pixel group are encoded using preset first encoding information to obtain first encoded data;
[0008] The encoding information corresponding to each second pixel group is determined based on the first pixel parameter of the first pixel and the second pixel parameter of the second pixel in each second pixel group, so as to obtain the second encoding information set;
[0009] The pixel values of the corresponding second pixel group are encoded using the second encoding information in the second encoding information set to obtain the second encoding data corresponding to each of the K-1 second pixel groups.
[0010] In one possible implementation, the encoding process of the first pixel group using preset first encoding information to obtain first encoded data includes:
[0011] The first encoding type is determined based on the preset first encoding information;
[0012] The first pixel value of the first pixel in the first pixel group is encoded according to the encoding method indicated by the first encoding type to obtain the first sub-encoded data.
[0013] The second pixel value of the second pixel in the first pixel group is encoded according to the encoding method indicated by the first encoding type to obtain the second sub-encoded data;
[0014] The encoding value corresponding to the encoding type, the first sub-encoding data, and the second sub-encoding data are combined according to a preset combination method to obtain the first encoding data.
[0015] In one possible implementation, the second encoded information in the second encoded information set includes first sub-encoded information corresponding to the first pixel and second sub-encoded information corresponding to the second pixel. The step of determining the encoded information corresponding to each second pixel group based on the first pixel parameter of the first pixel and the second pixel parameter of the second pixel in each second pixel group to obtain the second encoded information set includes:
[0016] Based on the first pixel parameter of the first pixel in each second pixel group, determine the first sub-encoding information corresponding to the first pixel in each second pixel group;
[0017] Based on the second pixel parameters of the second pixel in each second pixel group, determine the second sub-encoding information corresponding to the second pixel in each second pixel group.
[0018] In one possible implementation, determining the first sub-encoding information corresponding to the first pixel in each second pixel group based on the first pixel parameter of the first pixel in each second pixel group includes:
[0019] If the first transparency channel value is different from the second transparency channel value, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset first encoding information;
[0020] If the first transparency channel value is the same as the second transparency channel value, then obtain the first channel difference between the first pixel in the i-th second pixel group and the first pixel in the (i-1)-th second pixel group;
[0021] The first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined based on the first channel difference.
[0022] Repeat the steps described above: obtaining the first transparency channel value from the first pixel parameter of the first pixel in the i-th second pixel group, obtaining the second transparency channel value from the first pixel parameter of the first pixel in the (i-1)-th second pixel group, and determining the first sub-encoding information corresponding to the first pixel in the i-th second pixel group based on the first channel difference, until the first sub-encoding information corresponding to the first pixel in the second to (K-1)-th second pixel groups is obtained respectively;
[0023] The first sub-encoding information corresponding to the first pixel in the first second pixel group is determined based on the first pixel parameter of the first pixel in the first second pixel group and the first pixel parameter of the first pixel in the first pixel group. The first second pixel group is the pixel group immediately following the first pixel group.
[0024] In one possible implementation, determining the first sub-encoding information corresponding to the first pixel in the first second pixel group based on the first pixel parameter of the first pixel in the first second pixel group and the first pixel parameter of the first pixel in the first pixel group includes:
[0025] Obtain the third transparency channel value from the first pixel parameter of the first pixel in the first pixel group, and obtain the fourth transparency channel value from the first pixel parameter of the first pixel in the first second pixel group;
[0026] If the third transparency channel value is different from the fourth transparency channel value, then the first sub-encoding information corresponding to the first pixel in the first second pixel group is determined to be the preset first encoding information;
[0027] If the third transparency channel value is the same as the fourth transparency channel value, then the second channel difference between the first pixel in the first second pixel group and the first pixel in the first pixel group is obtained;
[0028] The first sub-encoding information corresponding to the first pixel in the first second pixel group is determined based on the second channel difference.
[0029] In one possible implementation, determining the first sub-encoding information corresponding to the first pixel in the i-th second pixel group based on the first channel difference includes:
[0030] If the first channel difference belongs to the first preset channel difference range, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset differential encoding information;
[0031] If the first channel difference does not belong to the first preset channel difference range, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset source code encoding information.
[0032] If the difference between the first channels is zero, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset run-length encoding information.
[0033] In one possible implementation, the image processing method further includes:
[0034] The first encoded data is decoded to obtain the pixel values of the first pixel group;
[0035] Decode the K-1 second encoded data to obtain the pixel values corresponding to the K-1 second pixel groups respectively.
[0036] In one possible implementation, the decoding process of the first encoded data to obtain the pixel values of the first pixel group includes:
[0037] The encoded data of the first pixel and the encoded data corresponding to the second pixel in the first encoded data are decoded in parallel to obtain the pixel value of the first pixel and the pixel value of the second pixel.
[0038] In a second aspect, embodiments of this application provide a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the image processing method as described in any one of the first aspects.
[0039] In a third aspect, embodiments of this application provide a chip, comprising:
[0040] At least one processor; and,
[0041] A memory communicatively connected to the at least one processor; wherein,
[0042] The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the image processing method as described in any one of the first aspects.
[0043] In a fourth aspect, embodiments of this application provide an electronic device, including:
[0044] At least one processor; and,
[0045] A memory communicatively connected to the at least one processor; wherein,
[0046] The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the image processing method as described in any one of the first aspects.
[0047] In the image processing method provided in this application embodiment, K pixel groups are obtained, each pixel group including a first pixel and a second pixel. The first pixel is a pixel in the first row of the image to be encoded, and the second pixel is a pixel in the second row of the image to be encoded that is in the same column as the first pixel. K is an integer greater than or equal to 1. The K pixel groups are divided into one first pixel group and K-1 second pixel groups. The first pixel group is the first pixel group among the K pixel groups, and the second pixel groups are the pixel groups among the K pixel groups excluding the first pixel group. The pixel values of the first pixel group are encoded using preset first encoding information to obtain first encoded data. The encoding information corresponding to each second pixel group is determined based on the first pixel parameter of the first pixel and the second pixel parameter of the second pixel in each second pixel group to obtain a second encoding information set. The pixel values of the corresponding second pixel group are encoded using the second encoding information in the second encoding information set to obtain second encoded data corresponding to K-1 second pixel groups respectively. Thus, the pixel values of two rows of pixels in the image to be encoded can be encoded simultaneously, greatly improving the efficiency of encoding the image to be encoded. Attached Figure Description
[0048] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0049] Figure 1 A schematic flowchart of an image processing method provided in an embodiment of this application;
[0050] Figure 2 A schematic diagram of an image to be detected provided in an embodiment of this application;
[0051] Figure 3 This is a schematic diagram of the circuit structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0053] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than the module division in the device or the order in the flowchart. Moreover, the terms "first," "second," and "third" used in this application do not limit the data or execution order, but only distinguish identical or similar items with essentially the same function and effect.
[0054] To better understand the image processing method provided in this application, a brief introduction to existing image processing methods is given below. In existing solutions, image formats typically include RGBA8888, etc. When encoding images of such formats, single-line compression is usually used. Therefore, the CPU usage is usually high during compression. When encoding on embedded platforms with low CPU frequencies, the encoding process needs to be adapted to the CPU frequency, resulting in a longer encoding time and lower efficiency in image encoding.
[0055] This application aims to solve the above-mentioned problems and proposes an image processing method that can simultaneously encode the pixel values of two rows of pixels in an image, greatly improving the efficiency of image encoding while adapting to the CPU's main frequency. Specifically, compared to existing solutions that use single-row encoding, it can double the encoding speed.
[0056] This application provides an image processing method that can be applied to electronic devices or servers. The electronic devices can be, but are not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will now be described in detail through specific embodiments.
[0057] As another aspect of this application, this application provides an image processing method applied to an electronic device or server. Please refer to... Figure 1 Image processing methods include:
[0058] S101. Obtain K pixel groups, each pixel group including a first pixel and a second pixel, wherein the first pixel is a pixel in the first row of the image to be encoded, and the second pixel is a pixel in the second row of the image to be encoded that is in the same column as the first pixel, wherein K is an integer greater than or equal to 1.
[0059] Among them, such as Figure 2 The image shown illustrates the pixels in the first row and the second row of the image to be encoded, where the pixels in the first row are the first pixels and the pixels in the second row are the second pixels. The image format of the image to be encoded can be RGBA8888, RGB888, etc. Figure 2 The example shown illustrates a row of 8 pixels in the image to be encoded. This is for illustrative purposes only and is not a specific limitation. For instance, a pixel group includes the first pixel of the first row and the first pixel of the second row, specifically represented as (A1, B1), where A1 is the first pixel in the first row and B1 is the first pixel in the second row. Alternatively, it could be (A2, B2), where A2 is the second pixel in the first row and B2 is the second pixel in the second row. That is, A1 and B1 are in the first column of the image to be encoded, and A2 and B2 are in the second column. Specifically, the pixel values of the pixels in the first row can be:
[0060] [[128,128,128,255],[1,2,3,0],[128,240,128,0],[4,5,3,0],[4,5,3,0],[4,5,3,0],[4,5,3,0],[5,6,7,0]];
[0061] The pixel values of the pixels in the second row can be:
[0062] [[127,127,127,255],[1,2,3,0],[129,241,129,0],[5,6,7,0],[5,6,7,0],[5,6,7,0],[5,6,7,0],[5,6,7,0],[10,12,4,0]].
[0063] Of course, for the sake of convenience in this example, pixel groups are set up. In the actual encoding process, the pixels in the first row of the image to be encoded can be directly encoded using the following encoding method, and the pixels in the second row can be encoded directly.
[0064] S102. Divide the K groups of pixels into one first group of pixels and K-1 second groups of pixels, wherein the first group of pixels is the first group of pixels among the K groups of pixels, and the second group of pixels is the group of pixels among the K groups of pixels excluding the first group of pixels.
[0065] Specifically, this could be such as Figure 2 The pixel group in the first column shown is defined as the first pixel group, which includes the first pixel in the first column and the second pixel in the first column.
[0066] S103. The pixel values of the first pixel group are encoded using preset first encoding information to obtain first encoded data.
[0067] The preset first encoding information may include encoding information of RGBA original code encoding. Therefore, the first encoding type can be determined to be RGBA original code encoding type. When encoding in RGBA original code, its encoding structure is 1 byte encoding attribute and 4 bytes of RGBA original code. The 1 byte encoding attribute includes 3 bits of encoding type + 5 bits of reserved bits. The 3 bits of encoding type are fixed to 0b110.
[0068] S104. Determine the encoding information corresponding to each second pixel group based on the first pixel parameter of the first pixel and the second pixel parameter of the second pixel in each second pixel group, so as to obtain the second encoding information set.
[0069] The second encoding information includes first sub-encoding information and second sub-encoding information. Specifically, it can be as follows: for the first pixel parameter of the first pixel in each of the K-1 second pixel point groups, determine the first sub-encoding information corresponding to the first pixel; and based on the second pixel parameter of the second pixel in each of the K-1 second pixel point groups, determine the second sub-encoding information corresponding to the second pixel in each second pixel point group. This first sub-encoding information and the second sub-encoding information are then defined as the second encoding information.
[0070] The second pixel group includes the first pixel and the second pixel corresponding to the first pixel.
[0071] The first pixel can be a pixel in the first row, and the second pixel can be a pixel in the second row. For example, in the second pixel group (A2, B2), A2 is the first pixel, and B2 is the second pixel.
[0072] The first pixel parameter may include the pixel table value of the first pixel in the corresponding image format. For example, in RGBA format, its pixel representation value can be (R, G, B, A). Here, R is the brightness value of red, G is the brightness value of green, B is the brightness value of blue, and A is the alpha channel value. Therefore, the corresponding first sub-encoding information can be determined based on the alpha channel value and RGB values, etc. The method for determining the second sub-encoding information can refer to the aforementioned method for determining the first sub-encoding information, and will not be repeated here.
[0073] S105. The pixel values of the corresponding second pixel group are encoded using the second encoding information in the second encoding information set to obtain the second encoding data corresponding to each of the K-1 second pixel groups.
[0074] When encoding the pixel values of the corresponding second pixel group using the second encoding information, a general encoding method corresponding to the second encoding information can be used to obtain the second encoded data corresponding to the second pixel group.
[0075] After encoding the pixel values of the first and second rows of pixels in the image to be encoded, the pixel values of the third and fourth rows can be encoded, and so on, until the entire image is encoded. If the image to be encoded has an odd number of rows, the pixel values of the last row can be encoded separately. This encoding method can use a general encoding method or the method used to encode the pixel values of the first row mentioned above; no specific limitation is made here.
[0076] In this example, by obtaining K pixel groups, each pixel group includes a first pixel and a second pixel. The first pixel is a pixel in the first row of the image to be encoded, and the second pixel is a pixel in the second row of the image to be encoded. The first pixel and the second pixel are in the same column. The pixel values of the first pixel group are encoded using preset first encoding information to obtain first encoded data. The first pixel group is the first pixel group among the K pixel groups. Based on the first pixel parameter and the second pixel parameter of the first pixel in each of the K-1 second pixel groups, encoding information corresponding to each second pixel group is determined to obtain a second encoding information set. The second pixel groups are the pixel groups other than the first pixel group among the K pixel groups. The pixel values of the corresponding second pixel groups are encoded using the second encoding information in the second encoding information set to obtain second encoded data corresponding to each of the K-1 second pixel groups. Thus, the pixel values of the two rows of pixels in the image to be encoded can be encoded simultaneously, greatly improving the efficiency of encoding the image to be encoded. Specifically, compared to the existing scheme that uses single-line encoding, it can improve the encoding speed by 100%.
[0077] In one possible implementation, a method for encoding a first group of pixels using preset first encoding information to obtain first encoded data includes:
[0078] A1. Determine the first encoding type based on the preset first encoding information;
[0079] A2. Encode the first pixel value of the first pixel in the first pixel group according to the encoding method indicated by the first encoding type to obtain the first sub-encoded data;
[0080] A3. Encode the second pixel value of the second pixel in the first pixel group according to the encoding method indicated by the first encoding type to obtain the second sub-encoded data;
[0081] A4. Combine the encoding value corresponding to the encoding type, the first sub-encoding data, and the second sub-encoding data according to a preset combination method to obtain the first encoding data.
[0082] The preset first encoding information may include encoding information such as RGBA original code encoding, and may also include an identification information used to indicate the RGBA original code encoding information. Therefore, the first encoding type can be determined based on the preset first encoding information, specifically, the first encoding type can be RGBA original code encoding type.
[0083] The first pixel value can be encoded using a common encoding method for RGBA original code to obtain the first sub-encoded data. Similarly, the second pixel value can be encoded using a common encoding method for RGBA original code to obtain the second sub-encoded data.
[0084] In a specific example, the method for combining the encoded value corresponding to the encoding type, the first sub-encoded data, and the second sub-encoded data according to a preset combination method to obtain the first encoded data can be as follows:
[0085] If the first pixel value is [128,128,128,255] and the second pixel value is [127,127,127,255], then the first encoded data can be:
[0086] [0xc1,0xc1,0x80,0x80,0x80,0xff,0x7f,0x7f,0x7f,0xff]
[0087] The first 0xc1 is the encoding attribute of the first pixel in the first row, the second 0xc1 is the encoding attribute of the first pixel in the second row, [0x80,0x80,0x80,0xff] is the encoding data of the first pixel in the first row, and [0x7f,0x7f,0x7f,0xff] is the encoding data of the first pixel in the second row.
[0088] In this example, the encoding method indicated by the first encoding type can be determined by the preset encoding first encoding information to encode the first pixel and the second pixel respectively, thereby eliminating the need to determine the encoding method corresponding to the first pixel group through other methods, which improves the efficiency of subsequent encoding.
[0089] In one possible implementation, the second encoded information in the second encoded information set includes first sub-encoded information corresponding to the first pixel and second sub-encoded information corresponding to the second pixel. A method for determining the encoded information corresponding to each second pixel group based on the first pixel parameter of the first pixel and the second pixel parameter of the second pixel in each second pixel group to obtain the second encoded information set includes:
[0090] B1. Determine the first sub-encoding information corresponding to the first pixel in each second pixel group based on the first pixel parameter of the first pixel in each second pixel group;
[0091] B2. Determine the second sub-encoding information corresponding to the second pixel in each second pixel group based on the second pixel parameter of the second pixel in each second pixel group.
[0092] The first pixel parameter may include the pixel table value of the first pixel in the corresponding image format. For example, in RGBA format, its pixel representation value may be (R, G, B, A). Here, R is the brightness value of red, G is the brightness value of green, B is the brightness value of blue, and A is the alpha channel value. Therefore, the corresponding first sub-encoding information can be determined based on the alpha channel value and RGB values. The method for determining the second sub-encoding information can refer to the method for determining the first sub-encoding information described above, and will not be repeated here.
[0093] In one possible implementation, a method for determining first sub-encoding information corresponding to a first pixel in each second pixel group based on a first pixel parameter of a first pixel in each second pixel group includes:
[0094] C1. Obtain the first transparency channel value from the first pixel parameter of the first pixel in the i-th second pixel group, and obtain the second transparency channel value from the first pixel parameter of the first pixel in the (i-1)-th second pixel group, where i is an integer greater than or equal to 2;
[0095] C2. If the first transparency channel value is different from the second transparency channel value, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset first encoding information.
[0096] C3. If the first transparency channel value is the same as the second transparency channel value, then obtain the first channel difference between the first pixel in the i-th second pixel group and the first pixel in the (i-1)-th second pixel group;
[0097] C4. Determine the first sub-encoding information corresponding to the first pixel in the i-th second pixel group based on the first channel difference;
[0098] C5. Repeat the above steps of obtaining the first transparency channel value from the first pixel parameter of the first pixel in the i-th second pixel group, and obtaining the second transparency channel value from the first pixel parameter of the first pixel in the (i-1)-th second pixel group, and determining the second encoding information of the i-th second pixel group based on the channel difference, until the first sub-encoding information corresponding to the first pixel in the second to the (K-1)-th second pixel groups is obtained;
[0099] C6. Determine the first sub-encoding information corresponding to the first pixel in the first second pixel group based on the first pixel parameter of the first pixel in the first second pixel group and the first pixel parameter of the first pixel in the first pixel group. The first second pixel group is the pixel group immediately following the first pixel group.
[0100] If the first transparency channel value is different from the second transparency channel value, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset first encoding information, that is, the first sub-encoding information can be determined to be encoding information including RGBA original code encoding.
[0101] If the first transparency channel value is the same as the second transparency channel value, a specific example of obtaining the first channel difference between the first pixel in the i-th second pixel group and the first pixel in the (i-1)-th second pixel group can be as follows: For example, if the second second pixel group is ([128,240,128,0], [129,241,129,0]) and the first second pixel group is ([1,2,3,0], [[1,2,3,0]), then the first transparency channel value is the same as the second transparency channel value, and the first channel difference is [127,238,125]. The second channel difference between the second pixels is [128,239,126].
[0102] After obtaining the first channel difference, the first channel difference is compared with the first preset channel difference range. The first sub-encoding information is determined based on whether the first channel difference falls within the first preset channel difference range.
[0103] After obtaining the first sub-encoding information of the first pixel in the i-th second pixel group, repeat the above steps until the first sub-encoding information corresponding to the first pixel in the second to K-1 second pixel groups is obtained.
[0104] Of course, since i is an integer greater than or equal to 2, the first sub-encoding information of the first pixel in the first second pixel group cannot be obtained by the above method. Therefore, the first sub-encoding information corresponding to the first pixel in the first second pixel group can be determined according to the first pixel parameter of the first pixel in the first second pixel group and the first pixel parameter of the first pixel in the first pixel group. The first second pixel group is the pixel group immediately following the first pixel group.
[0105] In this example, the first sub-encoding information corresponding to the first pixel is determined by the transparency channel value and channel difference in the first pixel parameter of the first pixel. This can quickly and accurately determine the first sub-encoding information and improve the efficiency of obtaining the first sub-encoding information.
[0106] In one possible implementation, a method for determining first sub-encoding information corresponding to a first pixel in the first second pixel group based on a first pixel parameter in the first second pixel group and the first pixel parameter of the first pixel in the first pixel group includes:
[0107] D1. Obtain the third transparency channel value from the first pixel parameter of the first pixel in the first pixel group, and obtain the fourth transparency channel value from the first pixel parameter of the first pixel in the first second pixel group.
[0108] D2. If the third transparency channel value is different from the fourth transparency channel value, then the first sub-encoding information corresponding to the first pixel in the first second pixel group is determined to be the preset first encoding information.
[0109] D3. If the third transparency channel value is the same as the fourth transparency channel value, then obtain the second channel difference between the first pixel in the first second pixel group and the first pixel in the first pixel group.
[0110] D4. Determine the first sub-encoding information corresponding to the first pixel in the first second pixel group based on the second channel difference.
[0111] The methods for obtaining the third and fourth transparency channel values can be the same as those for obtaining the first transparency channel value, and will not be repeated here.
[0112] The method for determining the first sub-encoding information corresponding to the first pixel in the first second pixel group based on the second channel difference can refer to the method for determining the first sub-encoding information corresponding to the first pixel in the i-th second pixel group based on the first channel difference in the foregoing embodiment, and will not be repeated here.
[0113] In one possible implementation, a method for determining the first sub-encoding information corresponding to the first pixel in the i-th second pixel group based on the first channel difference includes:
[0114] E1. If the first channel difference belongs to the first preset channel difference range, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset differential encoding information.
[0115] E2. If the first channel difference does not belong to the first preset channel difference range, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset source code encoding information.
[0116] E3. If the difference of the first channel is zero, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset run length encoding information.
[0117] The preset differential encoding information indicates that the encoding structure of the differential encoding method can be: 1 bit encoding attribute + 15 bits of difference. The 1 bit encoding type is fixed as 0b0. The bit width of the differential encoding attribute is set to 1 bit, which increases the bit width of the difference. Therefore, differential encoding can compress wider data, thereby improving the compression ratio. Here, the 15-bit bit width can represent the difference between the three channels of RBG. Each channel has a depth of 5 bits, so the range of the difference that can be represented is ±2^4, which is ±16. Therefore, the first preset channel difference interval is [±16, ±16, ±16]. The first channel difference belonging to the first preset channel difference interval can be understood as the first channel difference belonging to each interval within the preset channel difference interval. For example, if the first channel difference is [11, 10, 8], then it belongs to the first preset channel difference interval. For another example, if the first channel difference is [20, 10, 8], then it does not belong to the first preset channel difference interval.
[0118] The default source code encoding information can be RGB source code encoding information. Its encoding structure is: 1 byte encoding attribute + 3 bytes of RGB source code, where the 1 byte encoding attribute includes 3 bits of encoding type + 5 bits of run length, and the 3 bits of encoding type is fixed to 0b101.
[0119] The preset run length encoding information indicates the encoding structure as follows: 1 byte encoding attribute + 3 bytes of RGB original code, where the 1 byte encoding attribute includes 3 bits of encoding type + 5 bits of run length, and the 3 bits of encoding type are fixed to 0b100.
[0120] Therefore, the first sub-encoding information can be quickly determined by whether the difference of the first channel belongs to the first preset channel difference range, thus improving the efficiency of obtaining the first sub-encoding information.
[0121] In a specific example, the pixel values of the pixels in the first row of the image to be encoded can be:
[0122] [[128,128,128,255],[1,2,3,0],[128,240,128,0],[4,5,3,0],[4,5,3,0],[4,5,3,0],[4,5,3,0],[5,6,7,0]];
[0123] The pixel values of the pixels in the second row of the image to be encoded can be:
[0124] [[127,127,127,255],[1,2,3,0],[129,241,129,0],[5,6,7,0],[5,6,7,0],[5,6,7,0],[5,6,7,0],[5,6,7,0],[10,12,4,0]].
[0125] The encoded data after encoding using the above image processing method is as follows:
[0126] The image structure is: [[0xc1,0xc1,0x80,0x80,0x80,0xff,0x7f,0x7f,0x7f,0xff],[0xc1,0xc1,0x1,0x2,0x3,0x0,0x1,0x2,0x3,0x0],[0xa1,0x80,0xf0,0x80,0xa1,0x81,0xf1,0x81],[0xa1,0x4,0x5,0x3,0xa1,0x5,0x6,0x7],[0x83,0x83],[0x34,0x46,0xcd,0x56]]. Before encoding, the total length of the pixel values in the first and second rows is 64 bytes; after encoding, the total length is 42 bytes. Meanwhile, its encoding speed can be doubled on SIMD architecture CPUs and GPUs. Of course, the pixel group in the above method can also include a first pixel, a second pixel, a third pixel, and a fourth pixel, wherein the first pixel is a pixel in the first row of the image to be encoded, the second pixel is a pixel in the second row of the image to be encoded, the third pixel is a pixel in the third row of the image to be encoded, and the fourth pixel is a pixel in the fourth row of the image to be encoded, with the first, second, third, and fourth pixels in the same column. In the foregoing embodiments, the method for encoding the second pixel in the second pixel group is the same as the method for encoding the first pixel, and will not be repeated here.
[0127] In one possible implementation, the encoded data can also be decoded, as follows:
[0128] F1. Decode the first encoded data to obtain the pixel values of the first pixel group;
[0129] F2. Decode the K-1 second encoded data to obtain the pixel values corresponding to the K-1 second pixel groups respectively.
[0130] When decoding the first encoded data, it can be read by reading data blocks (2 bytes), with a bit width of 16 bits. After obtaining the data, it is decoded using the corresponding decoding method to obtain the pixel values of the first pixel group.
[0131] The same method can be used to decode the K-1 second encoded data to obtain the pixel values corresponding to the K-1 second pixel groups.
[0132] During decoding, data blocks cannot be read in parallel, but other decoding operations can be performed in parallel to improve decoding efficiency. Other decoding operations can be understood as decoding the encoded data of the first row of pixels and decoding the encoded data of the second row of pixels.
[0133] It should be noted that in the above embodiments, there is no necessarily a certain order between the steps. Those skilled in the art can understand from the description of the embodiments of this application that the above steps may have different execution orders in different embodiments, that is, they may be executed in parallel or in turn, etc.
[0134] Please see Figure 3 , Figure 3 This is a schematic diagram of the circuit structure of an electronic device provided in an embodiment of this application. Figure 3 As shown, the electronic device 300 includes one or more processors 301 and a memory 302. The processors 301 and the memory 302 are communicatively connected.
[0135] The memory 302, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the image processing method in the embodiments of this application. The processor 301 executes the functions of the image processing method provided in the above-described method embodiments by running the non-volatile software programs, instructions, and modules stored in the memory 302.
[0136] Memory 302 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 302 may optionally include memory remotely located relative to processor 301, and these remote memories may be connected to processor 301 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0137] The program instructions / modules are stored in the memory 302 and, when executed by one or more processors 301, perform the image processing method in any of the above method embodiments.
[0138] This application also provides a computer-readable storage medium storing computer-executable instructions that are executed by one or more processors, for example... Figure 3 One of the processors 301 can enable the one or more processors to execute the image processing method in any of the above method embodiments.
[0139] This application also provides a chip, which includes at least one processor and a memory communicatively connected to the at least one processor. The memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the image processing method in any of the above method embodiments.
[0140] This application also provides a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium. The computer program includes program instructions that, when executed by an electronic device, cause the electronic device to perform any of the image processing methods described above.
[0141] The device or equipment embodiments described above are merely illustrative. The unit modules described as separate components may or may not be physically separate. The components shown as module units may or may not be physical units; that is, they may be located in one place or distributed across multiple network module units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0142] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0143] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above, which are not provided in detail for the sake of brevity; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. An image processing method, characterized in that, The image processing method includes: Obtain K pixel groups, each pixel group including a first pixel and a second pixel, wherein the first pixel is a pixel in the first row of the image to be encoded, and the second pixel is a pixel in the second row of the image to be encoded that is in the same column as the first pixel, wherein K is an integer greater than or equal to 1; The K pixel groups are divided into one first pixel group and K-1 second pixel groups, wherein the first pixel group is the first pixel group among the K pixel groups, and the second pixel group is the pixel group among the K pixel groups excluding the first pixel group. The pixel values of the first pixel group are encoded using preset first encoding information to obtain first encoded data; The encoding information corresponding to each second pixel group is determined based on the first pixel parameter of the first pixel and the second pixel parameter of the second pixel in each second pixel group, so as to obtain the second encoding information set; The pixel values of the corresponding second pixel group are encoded using the second encoding information in the second encoding information set to obtain the second encoding data corresponding to each of the K-1 second pixel groups.
2. The image processing method according to claim 1, characterized in that, The step of encoding the first pixel group with preset first encoding information to obtain first encoded data includes: The first encoding type is determined based on the preset first encoding information; The first pixel value of the first pixel in the first pixel group is encoded according to the encoding method indicated by the first encoding type to obtain the first sub-encoded data. The second pixel value of the second pixel in the first pixel group is encoded according to the encoding method indicated by the first encoding type to obtain the second sub-encoded data; The encoding value corresponding to the encoding type, the first sub-encoding data, and the second sub-encoding data are combined according to a preset combination method to obtain the first encoding data.
3. The image processing method according to claim 2, characterized in that, The second encoded information in the second encoded information set includes first sub-encoded information corresponding to the first pixel and second sub-encoded information corresponding to the second pixel. The step of determining the encoded information corresponding to each second pixel group based on the first pixel parameter and the second pixel parameter of the second pixel in each second pixel group to obtain the second encoded information set includes: Based on the first pixel parameter of the first pixel in each second pixel group, determine the first sub-encoding information corresponding to the first pixel in each second pixel group; Based on the second pixel parameters of the second pixel in each second pixel group, determine the second sub-encoding information corresponding to the second pixel in each second pixel group.
4. The image processing method according to claim 3, characterized in that, The step of determining the first sub-encoding information corresponding to the first pixel in each second pixel group based on the first pixel parameter of the first pixel in each second pixel group includes: The first transparency channel value is obtained from the first pixel parameter of the first pixel in the i-th second pixel group, and the second transparency channel value is obtained from the first pixel parameter of the first pixel in the (i-1)-th second pixel group, where i is an integer greater than or equal to 2; If the first transparency channel value is different from the second transparency channel value, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset first encoding information; If the first transparency channel value is the same as the second transparency channel value, then obtain the first channel difference between the first pixel in the i-th second pixel group and the first pixel in the (i-1)-th second pixel group; The first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined based on the first channel difference. Repeat the steps described above: obtaining the first transparency channel value from the first pixel parameter of the first pixel in the i-th second pixel group, obtaining the second transparency channel value from the first pixel parameter of the first pixel in the (i-1)-th second pixel group, and determining the first sub-encoding information corresponding to the first pixel in the i-th second pixel group based on the first channel difference, until the first sub-encoding information corresponding to the first pixel in the second to (K-1)-th second pixel groups is obtained respectively; The first sub-encoding information corresponding to the first pixel in the first second pixel group is determined based on the first pixel parameter of the first pixel in the first second pixel group and the first pixel parameter of the first pixel in the first pixel group. The first second pixel group is the pixel group immediately following the first pixel group.
5. The image processing method according to claim 4, characterized in that, The step of determining the first sub-encoding information corresponding to the first pixel in the first second pixel group based on the first pixel parameter of the first pixel in the first second pixel group and the first pixel parameter of the first pixel in the first pixel group includes: Obtain the third transparency channel value from the first pixel parameter of the first pixel in the first pixel group, and obtain the fourth transparency channel value from the first pixel parameter of the first pixel in the first second pixel group; If the third transparency channel value is different from the fourth transparency channel value, then the first sub-encoding information corresponding to the first pixel in the first second pixel group is determined to be the preset first encoding information; If the third transparency channel value is the same as the fourth transparency channel value, then the second channel difference between the first pixel in the first second pixel group and the first pixel in the first pixel group is obtained; The first sub-encoding information corresponding to the first pixel in the first second pixel group is determined based on the second channel difference.
6. The image processing method according to claim 4 or 5, characterized in that, The step of determining the first sub-encoding information corresponding to the first pixel in the i-th second pixel group based on the first channel difference includes: If the first channel difference belongs to the first preset channel difference range, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset differential encoding information; If the first channel difference does not belong to the first preset channel difference range, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset source code encoding information. If the difference between the first channels is zero, then the first sub-encoding information corresponding to the first pixel in the i-th second pixel group is determined to be the preset run-length encoding information.
7. The image processing method according to claim 6, characterized in that, The image processing method further includes: The first encoded data is decoded to obtain the pixel values of the first pixel group; Decode the K-1 second encoded data to obtain the pixel values corresponding to the K-1 second pixel groups respectively.
8. The image processing method according to claim 7, characterized in that, The step of decoding the first encoded data to obtain the pixel values of the first pixel group includes: The encoded data of the first pixel and the encoded data corresponding to the second pixel in the first encoded data are decoded in parallel to obtain the pixel value of the first pixel and the pixel value of the second pixel.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the image processing method as described in any one of claims 1 to 8.
10. A chip, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the image processing method as described in any one of claims 1 to 8.
11. An electronic device, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the image processing method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Voice wake-up mode adjusting method, storage medium and electronic equipment
CN113889109A
Coding prediction method and device and computer storage medium
CN116456082A