An image encoding method, apparatus, and readable storage medium
By generating an encoding sequence based on continuous pixel fields and pixel difference columns, and combining it with encoding alignment processing of semantic segmentation result maps, the problem of poor image compression effect in existing technologies is solved, and efficient lossless image encoding is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-23
- Publication Date
- 2026-03-10
AI Technical Summary
Existing image compression technologies suffer from poor compression performance, especially lossy encoding methods which lead to a decrease in image quality, while lossless encoding methods have a relatively low compression rate.
By generating encoded sequences based on pixel values and pixel difference columns in a continuous pixel domain, and combining this with encoding alignment processing of the semantic segmentation result image, efficient image encoding information is generated.
Without losing image information, the compression rate of the image is improved, the effect of lossless coding is enhanced, and the amount of information required to encode the image is reduced.
Smart Images

Figure CN116614628B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to an image encoding method, device and readable storage medium. BACKGROUND
[0002] With the continuous development of technology, the processing and transmission of images are more and more frequent, so higher requirements are put forward for the amount of information and the volume of images that can be carried by images, hoping that image files carry more content but have smaller volume.
[0003] In the prior art image encoding, the image is usually re-encoded to reduce the storage space occupied by the image and improve the transmission and storage efficiency. The image is usually encoded in a lossy encoding format such as jpg, so as to compress the image volume. In addition, a small number of pixel points can be encoded by a down-sampling encoding method to obtain an encoded image containing a small number of pixels, so as to achieve the purpose of reducing the image volume. The image can also be encoded by a lossless encoding format.
[0004] However, the lossy encoding method in the prior art not only reduces the image volume but also loses the content of the image, which easily leads to poor quality of the encoded image. The compression ratio of the image is usually small when the lossless encoding method in the prior art is used, so the compression effect of the image compression technology in the prior art is poor. SUMMARY
[0005] One of the purposes of the present application is to provide an image encoding method to solve the problem of poor image compression technology in the prior art. The second purpose is to provide an image encoding device. The third purpose is to provide a readable storage medium. The fourth purpose is to provide an electronic device.
[0006] In order to achieve the above purposes, the technical solution adopted by the present application is as follows:
[0007] An image encoding method, the method comprising:
[0008] generating a first encoding sequence corresponding to a first pixel column in the target image according to pixel values of a continuous pixel domain of the first pixel column and the number of terminal pixel rows of the continuous pixel domain; wherein the continuous pixel domain is composed of pixels with the same pixel value and continuous distribution;
[0009] generating a pixel difference column according to pixel difference values between a second pixel column in the target image and a front pixel column of the second pixel column; wherein a rear pixel column of the first pixel column is the second pixel column;
[0010] generating a second encoding sequence corresponding to the second pixel column according to pixel values of a continuous pixel domain of the pixel difference column and the number of terminal pixel rows.
[0011] combining the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain the first image encoding information corresponding to the target image.
[0012] Further, the generating the first encoding sequence corresponding to the first pixel column according to the pixel value of the continuous pixel domain of the first pixel column in the target image and the end pixel row number of the continuous pixel domain comprises:
[0013] traversing the pixels in the first pixel column to determine the continuous pixel domain of the first pixel column;
[0014] for each of the continuous pixel domains, generating an encoding pair corresponding to the continuous pixel domain based on the end pixel row number of the continuous pixel domain and the pixel value of the continuous pixel domain;
[0015] combining the encoding pairs corresponding to the continuous pixel domains in the distribution order of the continuous pixel domains in the first pixel column to obtain the first encoding sequence corresponding to the first pixel column.
[0016] Further, the generating the encoding pair corresponding to the continuous pixel domain based on the end pixel row number of the continuous pixel domain and the pixel value of the continuous pixel domain comprises:
[0017] calculating the product of the end pixel row number of the continuous pixel domain and a preset negative value to obtain a transformed end pixel row number, and combining the end pixel row number and the pixel value to obtain the encoding pair,
[0018] or, calculating the product of the pixel value of the continuous pixel domain and the preset negative value to obtain a transformed pixel value, and combining the transformed pixel value and the end pixel row number to obtain the encoding pair.
[0019] Further, the generating the pixel difference column according to the pixel difference value between the second pixel column in the target image and the front pixel column of the second pixel column comprises:
[0020] determining the pixel difference value of the pixels located at the same pixel row in the second pixel column and the front pixel column;
[0021] arranging the pixel difference values based on the pixel row number corresponding to the pixel difference values to obtain the pixel difference column; wherein the pixel value of the pixel difference column is the pixel difference value.
[0022] Further, the combining the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain the first image encoding information corresponding to the target image comprises:
[0023] combining a first encoding sequence corresponding to a first pixel column and a second encoding sequence corresponding to all second pixel columns distributed continuously after the first pixel column, to obtain local first image encoding information corresponding to the first pixel column;
[0024] generating a two-dimensional array according to the local first image encoding information corresponding to each first pixel column;
[0025] combining the two-dimensional array and resolution information of the target image to obtain the first image encoding information.
[0026] Further, the combining the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain the first image encoding information corresponding to the target image comprises:
[0027] converting each encoding in the first encoding sequence corresponding to the first pixel column into a binary number to obtain a first binary sequence corresponding to the first pixel column;
[0028] converting each encoding in the second encoding sequence corresponding to the second pixel column into a binary number to obtain a second binary sequence corresponding to the second pixel column;
[0029] combining the first binary sequence and the second binary sequence to obtain a first target binary sequence;
[0030] generating a second target binary sequence according to the resolution of the target image, and combining the first target binary sequence and the second target binary sequence to obtain the first image encoding information.
[0031] Further, the target image comprises a semantic segmentation result image, and the method further comprises:
[0032] obtaining a semantic segmentation reference image corresponding to the semantic segmentation result image; wherein the semantic segmentation result image is obtained by performing semantic segmentation on an original image by a semantic segmentation model;
[0033] encoding the semantic segmentation reference image into second image encoding information;
[0034] aligning encoding pairs in the first image encoding information and encoding pairs in the second image encoding information to obtain first aligned encoding information corresponding to the first image encoding information and second aligned encoding information corresponding to the second image encoding information; wherein the encoding pairs in the first aligned encoding information have a one-to-one correspondence with the encoding pairs in the first aligned encoding information;
[0035] Aligning the encoding pairs in the first alignment encoding information and the second alignment encoding information obtains an evaluation index of the semantic segmentation result graph.
[0036] Further, the aligning the encoding pairs in the first image encoding information and the second image encoding information obtains the first alignment encoding information corresponding to the first image encoding information and the second alignment encoding information corresponding to the second image encoding information, including:
[0037] From the same position in the first image encoding information and the second image encoding information, a first end pixel row number and a second end pixel row number are respectively obtained;
[0038] In the case that the first end pixel row number is greater than the second end pixel row number, a first encoding pair is inserted in the first image encoding information to obtain the first alignment encoding information; wherein the first encoding pair is composed of the second end pixel row number and a pixel value of a previous bit of the first end pixel row number;
[0039] In the case that the first end pixel row number is less than the second end pixel row number, a second encoding pair is inserted in the second image encoding information to obtain the second alignment encoding information; wherein the second encoding pair is composed of the first end pixel row number and a pixel value of a previous bit of the second end pixel row number.
[0040] Further, the aligning the encoding pairs in the first alignment encoding information and the second alignment encoding information obtains the evaluation index of the semantic segmentation result graph, including:
[0041] Generating a confusion matrix based on the first alignment encoding information and the second alignment encoding information;
[0042] Calculating the evaluation index based on the confusion matrix.
[0043] Further, the generating the confusion matrix based on the first alignment encoding information and the second alignment encoding information, including:
[0044] Constructing an initial matrix; wherein the number of rows and the number of columns of the initial matrix are equal to the number of pixel values in the second alignment encoding information;
[0045] Determining a target matrix position according to the pixel values at the same position in the first alignment encoding information, the second alignment encoding information, and a pixel value position index;
[0046] Adding a target element value at the target matrix position of the initial matrix to obtain the confusion matrix; wherein the target element value is determined based on the target position index and element values in the second alignment encoding information.
[0047] An image encoding device, the device comprising:
[0048] A first encoding sequence module configured to generate a first encoding sequence corresponding to a first pixel column in a target image according to pixel values of a continuous pixel domain of the first pixel column and a number of terminal pixel rows of the continuous pixel domain; wherein the continuous pixel domain is composed of pixels with the same pixel value and continuous distribution;
[0049] A pixel difference value column module configured to generate a pixel difference value column according to pixel difference values between a second pixel column in the target image and a front pixel column of the second pixel column; wherein a back pixel column of the first pixel column is the second pixel column;
[0050] A second encoding sequence module configured to generate a second encoding sequence corresponding to the second pixel column according to pixel values of a continuous pixel domain of the pixel difference value column and a number of terminal pixel rows of the continuous pixel domain;
[0051] A first image encoding module configured to combine the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain first image encoding information corresponding to the target image.
[0052] Further, the first encoding sequence module comprises:
[0053] A continuous pixel domain submodule configured to traverse pixels in the first pixel column to determine a continuous pixel domain of the first pixel column;
[0054] An encoding pair submodule configured to generate an encoding pair corresponding to the continuous pixel domain based on a number of terminal pixel rows of the continuous pixel domain and pixel values of the continuous pixel domain for each continuous pixel domain;
[0055] A first encoding sequence submodule configured to combine the encoding pairs corresponding to the continuous pixel domains in a distribution order of the continuous pixel domains in the first pixel column to obtain the first encoding sequence corresponding to the first pixel column.
[0056] Further, the encoding pair submodule is further configured to calculate a product of the number of terminal pixel rows of the continuous pixel domain and a preset negative value to obtain a transformed number of terminal pixel rows, and combine the number of terminal pixel rows and the pixel values to obtain the encoding pair, or calculate a product of the pixel values of the continuous pixel domain and the preset negative value to obtain a transformed pixel value, and combine the transformed pixel value and the number of terminal pixel rows to obtain the encoding pair.
[0057] Further, the pixel difference column module comprises:
[0058] a pixel difference sub-module, configured to determine a pixel difference between the second pixel column and a pixel in the front pixel column located at a same pixel row;
[0059] a difference column sub-module, configured to arrange the pixel differences based on the pixel rows corresponding to the pixel differences, to obtain the pixel difference column; wherein a pixel value of the pixel difference column is the pixel difference.
[0060] Further, the group first image encoding module comprises:
[0061] a local first image encoding information sub-module, configured to combine a first encoding sequence corresponding to a first pixel column, and a second encoding sequence corresponding to all second pixel columns distributed continuously after the first pixel column, to obtain local first image encoding information corresponding to the first pixel column;
[0062] a two-dimensional array sub-module, configured to generate a two-dimensional array according to the local first image encoding information corresponding to each first pixel column;
[0063] an array image encoding information sub-module, configured to combine the two-dimensional array and resolution information of the target image, to obtain the first image encoding information.
[0064] Further, the first image encoding module comprises:
[0065] a first binary sequence sub-module, configured to convert each encoding in the first encoding sequence corresponding to the first pixel column into a binary number, to obtain a first binary sequence corresponding to the first pixel column;
[0066] a second binary sequence sub-module, configured to convert each encoding in the second encoding sequence corresponding to the second pixel column into a binary number, to obtain a second binary sequence corresponding to the second pixel column;
[0067] a first target binary sequence sub-module, configured to combine the first binary sequence and the second binary sequence, to obtain a first target binary sequence;
[0068] a binary image encoding information sub-module, configured to generate a second target binary sequence according to the resolution of the target image, and combine the first target binary sequence and the second target binary sequence, to obtain the first image encoding information.
[0069] Further, the target image comprises a semantic segmentation result image, and the device further comprises:
[0070] The semantic segmentation reference map module is used to obtain the semantic segmentation reference map corresponding to the semantic segmentation result map; wherein, the semantic segmentation result map is obtained by semantic segmentation of the original image by a semantic segmentation model;
[0071] The second image encoding module is used to encode the semantic segmentation reference image into second image encoding information;
[0072] An alignment module is used to align the encoding pairs in the first image encoding information and the encoding pairs in the second image encoding information to obtain first aligned encoding information corresponding to the first image encoding information and second aligned encoding information corresponding to the second image encoding information; wherein, there is a one-to-one correspondence between the encoding pairs in the first aligned encoding information and the encoding pairs in the second aligned encoding information.
[0073] The evaluation module is used to compare the encoding pairs in the first alignment encoding information and the second alignment encoding information to obtain the evaluation index of the semantic segmentation result map.
[0074] Furthermore, the alignment module includes:
[0075] The pixel row acquisition submodule is used to acquire the first end pixel row number and the second end pixel row from the same position in the first image encoding information and the second image encoding information, respectively;
[0076] The first encoding pair insertion submodule is used to insert a first encoding pair into the first image encoding information when the number of the first end pixel rows is greater than the number of the second end pixel rows, to obtain the first alignment encoding information; wherein, the first encoding pair is composed of the number of the second end pixel rows and the pixel value of the position preceding the number of the first end pixel rows;
[0077] The second encoding pair insertion submodule is used to insert a second encoding pair into the second image encoding information when the number of the first end pixel rows is less than the number of the second end pixel rows, so as to obtain the second alignment encoding information; wherein the second encoding pair is composed of the number of the first end pixel rows and the pixel value of the position preceding the number of the second end pixel rows.
[0078] Furthermore, the evaluation module includes:
[0079] The confusion matrix submodule is used to generate a confusion matrix based on the first alignment encoding information and the second alignment encoding information;
[0080] An evaluation submodule is used to calculate the evaluation index based on the confusion matrix.
[0081] Furthermore, the confusion matrix submodule includes:
[0082] An initial matrix sub-unit is used to construct an initial matrix; wherein the number of rows and columns of the initial matrix are both equal to the number of pixel values in the second alignment encoding information;
[0083] The target matrix position subunit is used to determine the target matrix position based on the pixel values at the same position in the first alignment encoding information and the second alignment encoding information, as well as the pixel value position index.
[0084] An element value addition sub-unit is used to add a target element value at the target matrix position in the initial matrix to obtain the confusion matrix; wherein, the target element value is determined based on the element value in the second alignment encoding information collected from the target position index.
[0085] A readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the aforementioned image encoding method.
[0086] An electronic device includes: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the aforementioned image encoding method.
[0087] The beneficial effects of this invention are as follows: Compared with existing image encoding methods, this invention can generate a first encoding sequence corresponding to the first pixel column based on the pixel values of the continuous pixel fields of the first pixel column in the target image and the number of the last pixel rows of the continuous pixel fields; wherein, the continuous pixel fields represent pixels with the same pixel value and continuous distribution; a pixel difference column is generated based on the pixel difference between the second pixel column and the preceding pixel column in the target image; wherein, the following pixel column of the first pixel column is the second pixel column; a second encoding sequence corresponding to the second pixel column is generated based on the pixel values of the continuous pixel fields of the pixel difference column and the number of the last pixel rows; and the first encoding sequence corresponding to each first pixel column and the second encoding sequence corresponding to each second pixel column are combined to obtain the first image encoding information corresponding to the target image. It is possible to encode a portion of a pixel column using pixel differences. Since the actual content in an image is continuous, the pixel differences between corresponding pixels in adjacent pixel columns are usually small and have high repetition. Thus, the pixel differences between adjacent columns can be described with less information, allowing the portion of the pixel column to encode the complete pixel information of the pixel column with less data. This reduces the amount of information required to encode the image and improves the compression rate of the image without losing any image information, thereby improving the effect of lossless encoding of the image. Attached Figure Description
[0088] Figure 1This is a flowchart illustrating the steps of an image encoding method provided in this embodiment;
[0089] Figure 2 A schematic diagram of a target image provided in an embodiment of this application;
[0090] Figure 3 This is a schematic diagram of a first image encoding information provided in an embodiment of this application;
[0091] Figure 4 An image evaluation method provided in this application embodiment;
[0092] Figure 5 This application provides a schematic diagram of an alignment process.
[0093] Figure 6 A flowchart for generating a confusion matrix is provided in an embodiment of this application;
[0094] Figure 7 An image encoding device is provided in this embodiment;
[0095] Figure 8 This is a schematic diagram of the structure of an electronic device provided in this embodiment. Detailed Implementation
[0096] The embodiments of the present invention will be described below with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention and not for limiting the scope of protection of the present invention.
[0097] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0098] This embodiment proposes an image encoding method, such as... Figure 1 As shown, Figure 1 This embodiment illustrates a flowchart of an image encoding method, the method comprising:
[0099] Step 101: Generate a first encoding sequence corresponding to the first pixel column based on the pixel values of the continuous pixel fields of the first pixel column in the target image and the number of the last pixel rows of the continuous pixel fields; wherein, the continuous pixel fields are composed of pixels with the same pixel values and continuously distributed.
[0100] In this embodiment of the application, the target image may be an image composed of single-value pixels, such as a grayscale image or a semantic segmentation image.
[0101] For example, Table 1 below shows a simplified target image:
[0102] Column 1 Column 2 Column 3 Column 4 Row 1 1 1 1 2 Row 2 1 1 2 2 Row 3 1 2 2 2 Row 4 2 2 2 2
[0103] Table 1
[0104] In Table 1 above, if the method of determining continuous pixel fields from pixel columns (i.e., determining continuous pixel fields vertically) is adopted, then the first three consecutive pixels with a value of "1" in the first column can form a continuous pixel field; the last pixel with a value of "2" in the first column can form a continuous pixel field; the first two pixels with a value of "1" in the second column form a continuous pixel field; the last two pixels with a value of "2" in the second column form a continuous pixel field, and so on.
[0105] In the embodiments of this application, each consecutive pixel field can be encoded into a corresponding encoding pair. The encoding pair can consist of two numbers, one of which represents the pixel value of the pixel in the consecutive pixel field, and the other number is used to characterize the number of pixels contained in the consecutive pixel field.
[0106] For example, in Table 1 above, the first three consecutive pixels with a value of "1" in the first column can form a consecutive pixel field 1, and the last pixel with a value of "2" in the first column can form a consecutive pixel field 2. Then the encoding pair corresponding to the consecutive pixel field 1 can be represented as [1,3], and the encoding pair corresponding to the consecutive pixel field 2 can be represented as [2,1].
[0107] In this embodiment, a first pixel column and a second pixel column can be set. The first pixel column can be directly encoded, and the first pixel column and the second pixel column are distributed alternately, that is, any two first pixel columns are not adjacent. For example, the first column of pixels in the target image can be set as the first pixel column, the second to tenth columns can be set as the second pixel column, the eleventh column can be set as the first pixel column, the twelfth to twentieth columns can be set as the second pixel column, and so on.
[0108] Specifically, the first pixel column can be encoded based on the pixel values of the continuous pixel fields of the first pixel column in the target image and the number of the last pixel rows of the continuous pixel fields to generate the first encoding sequence corresponding to the first pixel column.
[0109] Optionally, step 101 may include:
[0110] Sub-step 1011: Traverse the pixels in the first pixel column to determine the continuous pixel field of the first pixel column.
[0111] Reference Figure 2 , Figure 2 This illustration shows a target image provided in an embodiment of the present application, such as... Figure 2 As shown, the target image contains pixel values of three semantic categories: 1, 2, and 3. The first column (21 pixels) can be defined as the first pixel column, and the pixels in columns 2 through 5 can be defined as the second pixel column. The first column contains 7 pixels. Traversing these 7 pixels from top to bottom, three consecutive pixel domains can be identified: consecutive pixel domain A (containing the first pixel of the first column), consecutive pixel domain B (containing the second to fifth pixels of the first column), and consecutive pixel domain C (containing the sixth and seventh pixels of the first column).
[0112] Sub-step 1012: For each of the continuous pixel fields, generate an encoding pair corresponding to the continuous pixel field based on the number of the last pixel rows of the continuous pixel field and the pixel value of the continuous pixel field.
[0113] like Figure 2 As shown, continuous pixel field A contains pixel values of 1, and the number of pixel rows at the end of continuous pixel field A is 1, so the encoding pair corresponding to continuous pixel field A can be represented as (1,1); continuous pixel field B contains pixel values of 2, and the number of pixel rows at the end of continuous pixel field A is 5, so the encoding pair corresponding to continuous pixel field A can be represented as (2,5); continuous pixel field C contains pixel values of 3, and the number of pixel rows at the end of continuous pixel field A is 7, so the encoding pair corresponding to continuous pixel field A can be represented as (3,7).
[0114] Optionally, sub-step 1012 may include:
[0115] Calculate the product of the number of end pixel rows in the continuous pixel field and a preset negative value to obtain the transformed end pixel row number, and combine the end pixel row number and the pixel value to obtain the encoding pair; or, calculate the product of the pixel value in the continuous pixel field and the preset negative value to obtain the transformed pixel value, and combine the transformed pixel value and the end pixel row number to obtain the encoding pair.
[0116] In this embodiment, to overcome the problem that a column of pixels cannot be restored when the encoding corresponding to a single pixel is partially damaged (e.g., if one bit of data is lost in the encoding sequence, the subsequent encoded pairs identified in sequence will be incorrect), a preset negative value can be multiplied by the pixel value or the last pixel row before saving it as an encoded pair. This allows the encoded pairs to be distinguished by the sign, and when a column of data is partially damaged, the subsequent encoded pairs can be located by the sign without affecting the restoration of other encoded pairs in that column, thus reducing the impact of data corruption. The preset negative value can be flexibly set by a technician; for example, the preset negative value can be "-1". It should be noted that during the data decoding stage, the same preset negative value as in the encoding stage can be used to perform a division operation on the transformed last pixel row number or transformed pixel value to obtain the correct last pixel row number or pixel value.
[0117] For example, the first encoding sequence [1,1,2,5,3,7] in the subsequent sub-step 1013, if the pixel values in it are converted using a preset negative value "-1" during the generation process, the resulting first encoding sequence is [-1,1,-2,5,-3,7].
[0118] In the embodiments of this application, a preset negative value can be used during the generation of the encoding sequence to convert the number of end pixel rows into a negative form of the transformed end pixel row number, or to convert the pixel value into a negative form of the transformed pixel value. Thus, the type of each encoded value in the encoding sequence can be determined by the sign of the encoding. Even if the encoded value is lost or incorrect, the subsequent encoded values can still be correctly identified, which can improve the robustness of the encoding sequence and help improve the anti-interference ability of the encoding sequence.
[0119] Sub-step 1013: According to the distribution order of the continuous pixel fields in the first pixel column, combine the coding pairs corresponding to each continuous pixel field to obtain the first coding sequence corresponding to the first pixel column.
[0120] The encoded pairs corresponding to consecutive pixel fields A, B, and C in the above example can be combined according to their distribution order in the first pixel column to obtain... Figure 2 The first encoded sequence [1,1,2,5,3,7] corresponding to the first column (i.e., a first pixel column).
[0121] In this embodiment, the first pixel column can be encoded based on the number of end pixel rows and the pixel value of the continuous pixel field. Compared with the encoding method based on the number of pixels in the continuous pixel field, when the data of one encoding pair is wrong, it will only affect the next encoding pair and will not cause the impact to spread further and affect more encoding pairs. It has higher robustness and security.
[0122] Step 102: Generate a pixel difference column based on the pixel difference between the second pixel column and the preceding pixel column in the target image; wherein the following pixel column of the first pixel column is the second pixel column.
[0123] In this embodiment, the first pixel column can be called the key column, which can be directly encoded using the original pixel information; the second pixel column can be called the non-key column. In order to further increase the compression rate of the encoding process, the second pixel column can be encoded using the difference between the second pixel column and the first column.
[0124] Optionally, step 102 may include:
[0125] Sub-step 1021: Determine the pixel difference between the second pixel column and the pixels in the same pixel row in the preceding pixel column.
[0126] In this embodiment, a pixel difference column can be generated first based on the pixel difference between the second pixel column and the preceding pixel column in the target image. The preceding pixel column of a second pixel column is the column before that second pixel column. The pixel difference for each row of pixels can be obtained by subtracting the pixel values corresponding to the positions in the second pixel column and its preceding pixel column.
[0127] Sub-step 1022: Arrange the pixel differences based on the number of pixel rows corresponding to the pixel differences to obtain the pixel difference column; wherein, the pixel values of the pixel difference column are the pixel differences.
[0128] In this embodiment of the application, after obtaining the pixel difference value corresponding to each row, the pixel difference values can be arranged based on the number of pixel rows corresponding to the pixel difference values to obtain the pixel difference value column corresponding to the second pixel column. It should be noted that the pixel difference value column can be a sequence or array composed of pixel differences.
[0129] For example, such as Figure 2 As shown, if columns 2 to 4 are the second pixel columns 1 to 3 respectively, the difference between the second pixel column 1 [1, 2, 2, 2, 3, 3, 3] and its preceding pixel column (the first pixel column [1, 2, 2, 2, 2, 3, 3]) can be used to obtain pixel difference column 1 [0, 0, 0, 0, 1, 0, 0]; the difference between the second pixel column 2 [1, 1, 2, 2, 3, 3, 3] and its preceding pixel column (the second pixel column 1 [1, 2, 2, 2, 3, 3, 3]) can be used to obtain pixel difference column 2 [0, 1, 0, 0, 0, 0, 0]; the difference between the second pixel column 3 [1, 1, 2, 2, 3, 3, 3] and its preceding pixel column (the second pixel column 2 [1, 1, 2, 2, 3, 3, 3]) can be used to obtain pixel difference column 3 [0, 0, 0, 0, 0, 0, 0].
[0130] Step 103: Generate a second encoding sequence corresponding to the second pixel column based on the pixel values of the continuous pixel fields of the pixel difference column and the number of the last pixel rows.
[0131] In this embodiment, the pixel difference column can be encoded to obtain a second encoding sequence corresponding to the second pixel column. Specifically, the pixel value and the number of the last pixel row of each consecutive pixel field in the pixel difference column can be obtained, and encoding pairs corresponding to each consecutive pixel field in the pixel difference column can be generated based on the pixel value and the number of the last pixel row. Combining these encoding pairs yields the second encoding sequence. It should be noted that the method of encoding the pixel difference column is consistent with the method of encoding the first pixel column described above, and will not be repeated in this embodiment.
[0132] For example, after encoding the pixel difference sequence 1 [0, 0, 0, 0, 1, 0, 0] in the above example, the second encoding sequence 1 [0, 4, 1, 5, 0, 7] can be obtained; after encoding the pixel difference sequence 2 [0, 1, 0, 0, 0, 0, 0], the second encoding sequence 2 [0, 1, 1, 2, 0, 7] can be obtained; after encoding the pixel difference sequence 3 [0, 0, 0, 0, 0, 0, 0], the second encoding sequence 3 [0, 7].
[0133] Step 104: Combine the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain the first image encoding information corresponding to the target image.
[0134] In this embodiment, the first image encoding information represents the sequence obtained after encoding the target image, which is composed of encoding pairs corresponding to each consecutive pixel field in the target image. A consecutive pixel field refers to a vertically or horizontally consecutive combination of pixels with the same semantic category in the semantic segmentation image. Since semantic categories are usually identified using numbers in the target image, a consecutive pixel field can also represent a combination of pixels with the same pixel value in the semantic segmentation image. It should be noted that the number of pixels in a consecutive pixel field is greater than or equal to 1 and less than or equal to the total number of pixels in each column or row.
[0135] After determining the first encoding sequence corresponding to each first pixel column and the second encoding sequence corresponding to each second pixel column in the target image, the first encoding sequence and the second encoding sequence can be combined according to the arrangement order of the first pixel column and the second pixel column in the target image to obtain the first image encoding information.
[0136] In this embodiment, the pixel columns in the semantic segmentation image can be divided into a first pixel column and a second pixel column, and different encoding methods can be used for different types of pixel columns. While fully preserving the complete image information of the semantic segmentation image, the second pixel column can be encoded by pixel difference, which can significantly compress the information amount of the second encoding sequence of the second pixel column, reduce the size of the image encoding sequence, improve the information compression rate of the semantic segmentation image, and help improve the efficiency of subsequent processing and transmission of the first image encoding information.
[0137] Optionally, step 104 may include:
[0138] Sub-step 1041: Combine the first encoding sequence corresponding to a first pixel column and the second encoding sequences corresponding to all the second pixel columns that are continuously distributed after the first pixel column to obtain the local first image encoding information corresponding to the first pixel column.
[0139] In this embodiment of the application, since the information of the first pixel column preceding the second pixel column is required when restoring the second pixel column through the second encoding sequence, a first pixel column and all adjacent second pixel columns can be used as a local image. The first encoding sequence of the first pixel column and the second encoding sequences corresponding to all the continuously distributed second pixel columns thereafter are combined to obtain the local first image encoding information corresponding to the first pixel column.
[0140] Sub-step 1042: Generate a two-dimensional array based on the local first image encoding information corresponding to each first pixel column.
[0141] In this embodiment of the application, after obtaining the local first image encoding information corresponding to each first pixel column, each first image encoding information can be treated as a one-dimensional array and combined to obtain a two-dimensional array.
[0142] For example, as can be seen from the discussion in the above examples, Figure 2In the target image shown, columns 1 to 4 form a local image, where column 1 is the first pixel column 1, column 2 is the second pixel column 1, column 3 is the second pixel column 2, and column 4 is the second pixel column 3. The first encoding sequence of the first pixel column 1 is [1, 1, 2, 5, 3, 7], the second encoding sequence of the second pixel column 1 is [0, 4, 1, 5, 0, 7], the second encoding sequence of the second pixel column 2 is [0, 1, 1, 2, 0, 7], and the second encoding sequence of the second pixel column 3 is... The code sequence 3 [0, 7], when combined, yields the local first image encoding information corresponding to the first pixel column 1 as [1, 1, 2, 5, 3, 7, 0, 4, 1, 5, 0, 7, 0, 1, 1, 2, 0, 7, 0, 7]. Based on this local first image encoding information corresponding to the first pixel column, a two-dimensional array [[1, 1, 2, 5, 3, 7, 0, 4, 1, 5, 0, 7, 0, 1, 1, 2, 0, 7, 0, 7], [...]...] can be generated, where [...] represents... Figure 2 The local first image encoding information corresponding to the 5th column.
[0143] Sub-step 1043: Combine the resolution information of the two-dimensional array and the target image to obtain the first image encoding information.
[0144] In this embodiment of the application, in order to successfully decode the corresponding target image based on the first image encoding information, the resolution information of the target image may also be included in the first image encoding information. The resolution information may include the number of pixel columns and the number of pixel rows in the target image.
[0145] For example, a possible first image encoding information can be represented as: {"resolution": 1920x7, "segmentation": [[1, 1, 2, 5, 3, 7, 0, 4, 1, 5, 0, 7, 0, 1, 1, 2, 0, 7, 0, 7], [...]...]}; where resolution represents the resolution and segmentation represents a two-dimensional array.
[0146] In this embodiment of the application, since the first image encoding information can be text information, such as text encoded in UTF-8 in JSON format, lossless text compression can also be used on the first image encoding information to further compress the storage space it occupies and improve the compression rate of the target image.
[0147] Optionally, step 104 may also include:
[0148] Sub-step 1044: Convert each code in the first encoding sequence corresponding to the first pixel column into a binary number to obtain the first binary sequence corresponding to the first pixel column.
[0149] In this embodiment, each code in the first encoding sequence corresponding to the first pixel column can be converted into a binary number to obtain the first binary sequence corresponding to the first pixel column, thereby further compressing the storage space required for the first encoding sequence. In other words, the first encoding sequence can be stored directly using binary bits, avoiding the need to store it in a large character format.
[0150] Sub-step 1045: Convert each code in the second encoding sequence corresponding to the second pixel column into a binary number to obtain the second binary sequence corresponding to the second pixel column.
[0151] Sub-step 1046: Combine the first binary sequence and the second binary sequence to obtain the first target binary sequence.
[0152] It should be noted that during the combination process, the pixels can be combined according to their distribution order in the target image so that the first target binary sequence can be read efficiently.
[0153] Sub-step 1047: Generate a second target binary sequence based on the resolution of the target image, and combine the first target binary sequence and the second target binary sequence to obtain the first image encoding information.
[0154] Reference Figure 3 , Figure 3 This illustration shows a schematic diagram of a first image encoding information provided in an embodiment of this application, such as... Figure 3 As shown, when the target image resolution is less than 2048x2048, the first 11 bits in the File Header can store the image width information, and the second 11 bits can store the image height information. Chunk1 represents the binary sequence of pixels from the first key column to the second key column, i.e., the binary sequence of a local image in sub-step C1 above. It should be noted that since the 11 bits of normal encoding are usually greater than 0, each chunk can be separated by...
[0155] 8 bits [00000000] + 11 bits [00000000000] represent the separator.
[0156] This application provides an image encoding method, comprising: generating a first encoding sequence corresponding to a first pixel column based on the pixel values of continuous pixel fields in a first pixel column of a target image and the number of end pixel rows in the continuous pixel fields; wherein, the continuous pixel fields represent pixels with the same pixel value and continuously distributed; generating a pixel difference column based on the pixel difference between a second pixel column and a preceding pixel column in the target image; wherein, the following pixel column of the first pixel column is the second pixel column; generating a second encoding sequence corresponding to the second pixel column based on the pixel values of continuous pixel fields in the pixel difference column and the number of end pixel rows; and combining the first encoding sequences corresponding to each first pixel column and the second encoding sequences corresponding to each second pixel column to obtain first image encoding information corresponding to the target image. It is possible to encode a portion of a pixel column using pixel differences. Since the actual content in an image is continuous, the pixel differences between corresponding pixels in adjacent pixel columns are usually small and have high repetition. Thus, the pixel differences between adjacent columns can be described with less information, allowing the portion of the pixel column to encode the complete pixel information of the pixel column with less data. This reduces the amount of information required to encode the image and improves the compression rate of the image without losing any image information, thereby improving the effect of lossless encoding of the image.
[0157] This embodiment proposes an image comparison method, such as... Figure 4 As shown, Figure 4 An image evaluation method provided by an embodiment of this application is illustrated, the method comprising:
[0158] Step 201: Generate a first encoding sequence corresponding to the first pixel column based on the pixel values of the continuous pixel fields of the first pixel column in the semantic segmentation result image and the number of the last pixel rows of the continuous pixel fields; wherein, the continuous pixel fields are composed of pixels with the same pixel values and continuously distributed.
[0159] This step can be referred to step 101 above, and will not be repeated in this embodiment.
[0160] Step 202: Generate a pixel difference column based on the pixel difference between the second pixel column and the preceding pixel column in the semantic segmentation result image; wherein the following pixel column of the first pixel column is the second pixel column.
[0161] This step can be referred to step 102 above, and will not be repeated in this embodiment.
[0162] Step 203: Generate a second encoding sequence corresponding to the second pixel column based on the pixel values of the continuous pixel fields of the pixel difference column and the number of the last pixel rows.
[0163] This step can be referred to step 103 above, and will not be repeated in this embodiment.
[0164] Step 204: Combine the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain the first image encoding information corresponding to the semantic segmentation result image.
[0165] This step can be referred to step 104 above, and will not be repeated in this embodiment.
[0166] Step 205: Obtain the semantic segmentation reference map corresponding to the semantic segmentation result map; wherein, the semantic segmentation result map is obtained by semantic segmentation of the original image by the semantic segmentation model.
[0167] In this embodiment, the original image can be a to-be-processed image used for semantic segmentation, typically containing multiple target or scene elements, such as an environmental image of a vehicle. By performing semantic segmentation on the original image, specific target or scene elements can be identified from the image. The semantic segmentation result image can be the result image obtained after semantic segmentation of the original image using a semantic segmentation model (e.g., an artificial neural network). The pixel value of each pixel in the semantic segmentation result image represents the category of the target or scene element in that pixel; that is, in the semantic segmentation result image, each pixel is labeled with a corresponding semantic category, such as car, pedestrian, etc. The semantic segmentation reference image, also known as the ground truth or labeled image, is a standard image used to evaluate the performance of the semantic segmentation model. The reference image is usually manually drawn by professional annotators to represent the correct distribution of each category in the real scene. Semantic segmentation is a task in computer vision that aims to divide an image into regions with different semantic categories. For example, an image of a road scene may contain multiple categories such as cars, pedestrians, and buildings.
[0168] Semantic segmentation models are deep learning-based algorithms, typically employing a convolutional neural network (CNN) structure. The model is trained on a large amount of labeled training data, learning to extract features from input images and assign pixels to different categories. After training, the original image is input into the trained model to obtain a semantic segmentation result image. This result image is then compared with a corresponding semantic segmentation reference image to evaluate the model's performance.
[0169] For example, suppose we have an original image of a road scene, including multiple targets such as cars, pedestrians, and buildings. This image is input into a trained semantic segmentation model. The model processes the original image, assigning a corresponding semantic category label to each pixel; for example, pixels in the car region are labeled "1," and pixels in the pedestrian region are labeled "2," etc. This yields a semantic segmentation result image. Professional annotators then label the regions where each target in the original image is located based on the real-world scene, thus obtaining a semantic segmentation reference image that reflects the actual situation.
[0170] Step 206: Encode the semantic segmentation reference image into second image encoding information.
[0171] In this embodiment of the application, the semantic segmentation result image can be encoded into first image encoding information and the semantic segmentation reference image can be encoded into second image encoding information using the above encoding method. This embodiment of the application will not be described in detail.
[0172] Step 207: Align the encoding pairs in the first image encoding information and the encoding pairs in the second image encoding information to obtain first aligned encoding information corresponding to the first image encoding information and second aligned encoding information corresponding to the second image encoding information; wherein, there is a one-to-one correspondence between the encoding pairs in the first aligned encoding information and the encoding pairs in the second aligned encoding information.
[0173] In this embodiment, the first image encoding information and the second image encoding information are generated based on different semantic segmentation images, resulting in differences in the number of encoding pairs and the pixel positions encoded by encoding pairs at the same location. To compare the encoding pairs in the first and second image encoding information, alignment processing can be performed to ensure that both contain the same number of encoding pairs and have a one-to-one correspondence, facilitating subsequent comparison. The alignment method can be selected according to actual needs, such as aligning according to the starting position of the encoding pair or the number of pixels. During the alignment process, the encoding sequences can be supplemented, cropped, or adjusted to ensure that the two sequences have the same length and structure. Corresponding encoding pairs can encode pixels at the same position, thus facilitating subsequent comparison of the two encoding pairs.
[0174] Specifically, if the first image encoding information contains 2 encoding pairs for the first column of pixels and 4 encoding pairs for the second column of pixels; and the second image encoding information contains 4 encoding pairs for the first column of pixels and 2 encoding pairs for the second column of pixels, then the encoding pairs for the first column of pixels in the first image encoding information can be increased to 4 to obtain the first alignment encoding information, and the encoding pairs for the second column of pixels in the second image encoding information can be increased to 4 to obtain the second alignment encoding information, thus completing the alignment operation between the two.
[0175] Optionally, step 207 may include:
[0176] Sub-step 2071: Obtain the first end pixel row number and the second end pixel row from the same position in the first image encoding information and the second image encoding information, respectively.
[0177] Reference Figure 5 , Figure 5 This illustration shows a schematic diagram of an alignment process provided in an embodiment of this application, such as... Figure 5 As shown, the first image encoding information (pre) and the second image encoding information (gt) corresponding to the same column can be read; the index i = 1 is initialized; it is determined whether i is greater than or equal to the length of the second image encoding information. If i is less than the length of the second image encoding information, it means that all the data that needs to be traversed in the second image encoding information has not yet been traversed, and the subsequent loop continues. The number of the last pixel row at the i-th position is obtained from the first image encoding information as the first last pixel row number i, and the number of the last pixel row at the i-th position is obtained from the second image encoding information as the second last pixel row number i.
[0178] Sub-step 2072: When the number of the first end pixel rows is greater than the number of the second end pixel rows, insert a first code pair into the first image encoding information to obtain the first alignment encoding information; wherein, the first code pair is composed of the number of the second end pixel rows and the pixel value of the position preceding the number of the first end pixel rows.
[0179] like Figure 5As shown, after obtaining the first end pixel row number i and the second end pixel row number i from position i in the first image encoding information and the second image encoding information respectively, the size relationship between the first end pixel row number and the second end pixel row number is determined. If the first end pixel row number i is greater than the second end pixel row number i, a first encoding pair consisting of the second end pixel row number and the pixel value of the position preceding the first end pixel row number is inserted into the first image encoding information to obtain the first alignment encoding information. That is, the pixel value of the (i-1)th position of the first image encoding information is inserted before the position of the i-th position of the first image encoding information (since the pixel value and the end pixel row number are arranged alternately in the encoding sequence, the (i-1)th position is the pixel value in the case of the i-th end pixel row number). Then, the end pixel row number of the second image encoding information at position i is inserted into the first image encoding information at position i.
[0180] Sub-step 2073: When the number of the first end pixel rows is less than the number of the second end pixel rows, insert a second encoding pair into the second image encoding information to obtain the second alignment encoding information; wherein, the second encoding pair is composed of the number of the first end pixel rows and the pixel value of the position preceding the number of the second end pixel rows.
[0181] like Figure 5 As shown, after obtaining the first end pixel row number i and the second end pixel row number i from position i in the first image encoding information and the second image encoding information respectively, the size relationship between the first end pixel row number and the second end pixel row number is determined. If the first end pixel row number i is less than the second end pixel row number i, a second encoding pair consisting of the first end pixel row number and the pixel value of the position preceding the second end pixel row number is inserted into the second image encoding information to obtain the first alignment encoding information. That is, the pixel value of the (i-1)th position of the second image encoding information is inserted before the position i of the second image encoding information. Then, the end pixel row number of the first image encoding information at position i is inserted into the position i of the second image encoding information.
[0182] like Figure 5 As shown, after inserting the first encoding pair into the first image encoding information or the second encoding pair into the second image encoding information, "i+=2" is executed, that is, i is incremented by 2, and it is re-determined whether i is greater than or equal to the length of the second image encoding information. This process is repeated until i is greater than or equal to the length of the second image encoding information, at which point the loop ends, and the encoding sequences of the next column of the semantic segmentation result image and the semantic segmentation reference image are aligned. It should be noted that in the above loop, if the number of rows of pixels at the first end is equal to the number of rows of pixels at the second end, it means that the encoding pair at that position has been aligned, and "i+=2" can be executed directly.
[0183] It should be noted that, as Figure 5As shown, after determining that i is greater than or equal to the length of the second image encoding information, it can be determined whether the traversed pixel column is the first pixel column. If it is the first pixel column, the type of the corresponding encoding sequence in the first alignment encoding information and the second alignment encoding information is marked as the first pixel column; if it is not the first pixel column, the type of the corresponding encoding sequence in the first alignment encoding information and the second alignment encoding information is marked as the second pixel column, so as to perform subsequent calculations.
[0184] In this embodiment, the first image encoding information and the second image encoding information can be aligned using the above method. The alignment operation can be completed in just one traversal, which has high alignment efficiency and accuracy.
[0185] Step 208: Compare the encoding pairs in the first alignment encoding information and the second alignment encoding information to obtain the evaluation index of the semantic segmentation result map.
[0186] In the embodiments of this application, the evaluation metric can represent an indicator that can be used to measure the difference between the semantic segmentation result map and the semantic segmentation reference map, such as pixel-level accuracy, recall, intersection of union (IoU), etc.; wherein, the IoU score is a standard performance metric for object class segmentation problems.
[0187] Specifically, based on the one-to-one correspondence between the first and second aligned encoding information, we can compare the encoding pairs one by one. The comparison method can be selected according to actual needs, such as comparing the number of pixels or category labels in the encoding pairs. By calculating the difference between the two aligned sequences, an evaluation metric can be obtained, thereby evaluating the performance of the semantic segmentation model.
[0188] For example, if the first and second coding sequences are as follows: First aligned coding information: [(1,3), (2,4), (2,7), (3,8)]; Second aligned coding information: [(1,3), (3,4), (2,7), (4,8)]. Then, the coding pair (1,3) in the first aligned coding information and the coding pair (1,3) in the second aligned coding information can be compared. Similarly, by using coding pairs as comparison units, the comparison operation between the semantic segmentation result map and the semantic segmentation reference map is completed.
[0189] Optionally, step 208 may include:
[0190] Sub-step 2081: Generate a confusion matrix based on the first alignment encoding information and the second alignment encoding information.
[0191] In this embodiment, a confusion matrix can be generated to compare the code pairs in the first and second aligned coding information. The confusion matrix (CM), also known as the error matrix, is a specific table layout used to visualize and understand the performance of a classification model. Each row represents the actual class, and each column represents the predicted class. This matrix is primarily used to display and analyze the performance of binary or multi-class classification problems.
[0192] For the first alignment encoding information and the second alignment encoding information generated in the embodiments of this application, the following method can be used to generate the confusion matrix to improve the efficiency of generating the confusion matrix:
[0193] Optionally, sub-step 2081 may include:
[0194] Sub-step A1: Construct an initial matrix; wherein the number of rows and columns of the initial matrix are both equal to the number of pixel values in the second alignment encoding information.
[0195] In this embodiment of the application, an initial matrix MXM can be constructed, where M represents the number of pixel values in the first alignment encoding information or the second alignment encoding information, i.e., the number of encoding pairs.
[0196] Reference Figure 6 , Figure 6 This application provides a flowchart for generating a confusion matrix, as illustrated in an embodiment. Figure 6 As shown, an initial matrix is first constructed, and the pixel column encoding sequence of a pixel column in the first alignment encoding information and the second alignment encoding information is obtained, so as to confuse the pixel column encoding sequence in subsequent steps.
[0197] Sub-step A2: Determine the target matrix position based on the pixel values at the same positions in the first alignment encoding information and the second alignment encoding information, as well as the pixel value position index.
[0198] like Figure 6 As shown, the pixel value position index idx is initialized to 0, and then the target matrix position is determined according to the pixel value position index idx. The target matrix position includes the target matrix x-coordinate and the target matrix y-coordinate. The target matrix x-coordinate is determined based on the following formula 1:
[0199] i = -1 × gt[idx] Formula 1
[0200] Where i represents the x-coordinate of the target matrix, and gt[idx] represents the idx-th bit encoding (pixel value) in a pixel column encoding sequence in the second alignment encoding information.
[0201] The x-coordinate of the target matrix is determined based on the following formula 2:
[0202] j = -1 × pre[idx] Formula 2
[0203] Where j represents the x-coordinate of the target matrix, and pre[idx] represents the idx-th bit encoding (pixel value) in the pixel column encoding sequence of the first alignment encoding information.
[0204] Sub-step A3: Add the target element value at the target matrix position of the initial matrix to obtain the confusion matrix; wherein the target element value is determined based on the element value in the second alignment encoding information collected from the target position index.
[0205] like Figure 6 As shown, after determining the target matrix position, it is determined whether idx is 0. If idx is 0, the value of gt[idx-1] (i.e., the row number of the last pixel before the idx position in the pixel column encoding sequence of the second alignment encoding information) is used as the target element value and added to the target matrix position of the confusion matrix. If idx is not 0, the value of gt[idx+1]-gt[idx-1] is used as the target element value and added to the target matrix position of the confusion matrix. Then, idx is incremented by 2, the target matrix position is redefined, and the corresponding target element value is added to the redefined target matrix position until a pixel column confusion matrix for one pixel column is generated. Then, the next pixel column is selected to generate the corresponding pixel column confusion matrix. Finally, all pixel column confusion matrices are merged to obtain the complete confusion matrix.
[0206] Furthermore, in this embodiment, since the first alignment encoding information and the second alignment encoding information contain pixel row encoding sequences of the first pixel row and the second pixel row, the pixel differences in the pixel row encoding sequence of the second pixel row can be restored to their true pixel values based on the pixel row encoding sequence of the first pixel row. That is, the encoding method of the encoding sequence corresponding to the second pixel row can be adjusted to match the encoding method of the encoding sequence corresponding to the first pixel row. Then, a confusion matrix is generated from the adjusted first alignment encoding information and the second alignment encoding information. Since the adjusted first alignment encoding information and the second alignment encoding information use the same encoding method, confusion using the same confusion algorithm can yield a highly consistent confusion result, thereby improving the accuracy of the confusion matrix and the accuracy of subsequent performance evaluation based on the confusion matrix.
[0207] Sub-step 2082: Calculate the evaluation index based on the confusion matrix.
[0208] In the embodiments of this application, the accuracy of semantic categories can be calculated using the following formula 3:
[0209]
[0210] Where ACC(n) represents the accuracy of semantic category n, TP represents the element value of the nth column and nth row in the confusion matrix, and CUML(n) represents the sum of all element values in the nth column of the confusion matrix.
[0211] The semantic category IoU can also be calculated using the following formula 4:
[0212]
[0213] Where IoU(n) represents the IoU of semantic category n, TP represents the element value of the nth column and nth row in the confusion matrix, CUML(n) represents the sum of all element values in the nth column of the confusion matrix, and CUMH(n) represents the sum of all element values in the nth row of the confusion matrix.
[0214] In addition, technicians may choose appropriate methods to calculate other evaluation indicators through confusion matrices, and the embodiments of this application do not impose specific limitations.
[0215] This application provides an image comparison method, comprising: generating a first encoding sequence corresponding to a first pixel column based on the pixel values of continuous pixel fields in a first pixel column of a target image and the number of end pixel rows in the continuous pixel fields; wherein, continuous pixel fields represent pixels with the same pixel value and continuously distributed; generating a pixel difference column based on the pixel difference between a second pixel column and a preceding pixel column in the target image; wherein, the following pixel column of the first pixel column is the second pixel column; generating a second encoding sequence corresponding to the second pixel column based on the pixel values of continuous pixel fields in the pixel difference column and the number of end pixel rows; combining the first encoding sequences corresponding to each first pixel column and the second encoding sequences corresponding to each second pixel column to obtain first image encoding information corresponding to the target image; obtaining a semantic segmentation reference image corresponding to the semantic segmentation result image; encoding the semantic segmentation reference image into second image encoding information; aligning the encoding pairs in the first image encoding information and the encoding pairs in the second image encoding information to obtain first aligned encoding information corresponding to the first image encoding information and second aligned encoding information corresponding to the second image encoding information; comparing the encoding pairs in the first aligned encoding information and the second aligned encoding information to obtain an evaluation index of the semantic segmentation result image. It can perform lossless encoding with high compression rate on the semantic segmentation result image and the corresponding semantic segmentation reference image to obtain the first image encoding information and the second image encoding sequence. Then, it performs image comparison based on the encoding pairs in the first image encoding information and the second image encoding sequence, and calculates the corresponding evaluation index. In the evaluation process, it only needs to compare the encoding pairs as units, and can compare multiple pixels at once, thereby reducing the number of comparisons required and helping to improve the comparison efficiency. Moreover, due to the use of high compression rate encoding method, it can also reduce the amount of image information data and data transmission time in the image comparison process to a certain extent, thus further improving the efficiency of evaluating the semantic segmentation result image.
[0216] Figure 7 This embodiment provides an image encoding device, such as... Figure 7 As shown, the device 50 includes:
[0217] The first encoding sequence module 501 is used to generate a first encoding sequence corresponding to the first pixel column based on the pixel values of the continuous pixel fields of the first pixel column in the target image and the number of the last pixel rows of the continuous pixel fields; wherein, the continuous pixel fields are composed of pixels with the same pixel values and continuously distributed.
[0218] The pixel difference column module 502 is used to generate a pixel difference column based on the pixel difference between the second pixel column and the preceding pixel column in the target image; wherein the following pixel column of the first pixel column is the second pixel column;
[0219] The second encoding sequence module 503 is used to generate a second encoding sequence corresponding to the second pixel column based on the pixel values of the continuous pixel fields of the pixel difference column and the number of the last pixel rows.
[0220] The first image encoding module 504 is used to combine the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain the first image encoding information corresponding to the target image.
[0221] Further, the first encoding sequence module includes:
[0222] The continuous pixel field submodule is used to traverse the pixels in the first pixel column and determine the continuous pixel field of the first pixel column;
[0223] The encoding pair submodule is used to generate an encoding pair corresponding to each consecutive pixel field based on the number of the last pixel rows of the consecutive pixel field and the pixel value of the consecutive pixel field.
[0224] The first encoding sequence submodule is used to combine the encoding pairs corresponding to each of the consecutive pixel fields according to the distribution order of the consecutive pixel fields in the first pixel column to obtain the first encoding sequence corresponding to the first pixel column.
[0225] Furthermore, the encoding pair submodule is also used to calculate the product of the number of end pixel rows in the continuous pixel field and a preset negative value to obtain the transformed end pixel row number, and combine the end pixel row number and the pixel value to obtain the encoding pair; or, calculate the product of the pixel value in the continuous pixel field and the preset negative value to obtain the transformed pixel value, and combine the transformed pixel value and the end pixel row number to obtain the encoding pair.
[0226] Furthermore, the pixel difference column module includes:
[0227] A pixel difference submodule is used to determine the pixel difference between the second pixel column and the pixel in the same pixel row in the preceding pixel column;
[0228] The difference column submodule is used to arrange the pixel differences based on the number of pixel rows corresponding to the pixel differences to obtain the pixel difference column; wherein, the pixel value of the pixel difference column is the pixel difference.
[0229] Furthermore, the first image encoding module of the group includes:
[0230] The local first image coding information submodule is used to combine the first coding sequence corresponding to a first pixel column and the second coding sequences corresponding to all the second pixel columns that are continuously distributed after the first pixel column to obtain the local first image coding information corresponding to the first pixel column.
[0231] The two-dimensional array submodule is used to generate a two-dimensional array based on the local first image encoding information corresponding to each first pixel column;
[0232] The array image encoding information submodule is used to combine the resolution information of the two-dimensional array and the target image to obtain the first image encoding information.
[0233] Furthermore, the first image encoding module includes:
[0234] The first binary sequence submodule is used to convert each code in the first encoding sequence corresponding to the first pixel column into a binary number to obtain the first binary sequence corresponding to the first pixel column.
[0235] The second binary sequence submodule is used to convert each code in the second encoding sequence corresponding to the second pixel column into a binary number to obtain the second binary sequence corresponding to the second pixel column.
[0236] The first target binary sequence submodule is used to combine the first binary sequence and the second binary sequence to obtain the first target binary sequence;
[0237] The binary image encoding information submodule is used to generate a second target binary sequence according to the resolution of the target image, and combine the first target binary sequence and the second target binary sequence to obtain the first image encoding information.
[0238] Furthermore, the target image includes a semantic segmentation result map, and the apparatus further includes:
[0239] The semantic segmentation reference map module is used to obtain the semantic segmentation reference map corresponding to the semantic segmentation result map; wherein, the semantic segmentation result map is obtained by semantic segmentation of the original image by a semantic segmentation model;
[0240] The second image encoding module is used to encode the semantic segmentation reference image into second image encoding information;
[0241] An alignment module is used to align the encoding pairs in the first image encoding information and the encoding pairs in the second image encoding information to obtain first aligned encoding information corresponding to the first image encoding information and second aligned encoding information corresponding to the second image encoding information; wherein, there is a one-to-one correspondence between the encoding pairs in the first aligned encoding information and the encoding pairs in the second aligned encoding information.
[0242] The evaluation module is used to compare the encoding pairs in the first alignment encoding information and the second alignment encoding information to obtain the evaluation index of the semantic segmentation result map.
[0243] Furthermore, the alignment module includes:
[0244] The pixel row acquisition submodule is used to acquire the first end pixel row number and the second end pixel row from the same position in the first image encoding information and the second image encoding information, respectively;
[0245] The first encoding pair insertion submodule is used to insert a first encoding pair into the first image encoding information when the number of the first end pixel rows is greater than the number of the second end pixel rows, to obtain the first alignment encoding information; wherein, the first encoding pair is composed of the number of the second end pixel rows and the pixel value of the position preceding the number of the first end pixel rows;
[0246] The second encoding pair insertion submodule is used to insert a second encoding pair into the second image encoding information when the number of the first end pixel rows is less than the number of the second end pixel rows, so as to obtain the second alignment encoding information; wherein the second encoding pair is composed of the number of the first end pixel rows and the pixel value of the position preceding the number of the second end pixel rows.
[0247] Furthermore, the evaluation module includes:
[0248] The confusion matrix submodule is used to generate a confusion matrix based on the first alignment encoding information and the second alignment encoding information;
[0249] An evaluation submodule is used to calculate the evaluation index based on the confusion matrix.
[0250] Furthermore, the confusion matrix submodule includes:
[0251] An initial matrix sub-unit is used to construct an initial matrix; wherein the number of rows and columns of the initial matrix are both equal to the number of pixel values in the second alignment encoding information;
[0252] The target matrix position subunit is used to determine the target matrix position based on the pixel values at the same position in the first alignment encoding information and the second alignment encoding information, as well as the pixel value position index.
[0253] An element value addition sub-unit is used to add a target element value at the target matrix position in the initial matrix to obtain the confusion matrix; wherein, the target element value is determined based on the element value in the second alignment encoding information collected from the target position index.
[0254] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0255] The image encoding device described above has the same advantages over the prior art as the image encoding method described in the foregoing embodiments, and will not be repeated here.
[0256] The present invention provides a readable storage medium that, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to perform the aforementioned image encoding method.
[0257] This invention provides an electronic device, see [link to relevant documentation]. Figure 8 The electronic device 60 includes a processor 601, a memory 602, and a computer program 6021 stored in the memory 602 and executable on the processor 601. When the processor 601 executes the program, it implements the image encoding method of the foregoing embodiments.
[0258] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. The structure required to construct such a system is readily apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0259] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0260] Similarly, it should be understood that, in order to simplify the invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.
[0261] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0262] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention can also be implemented as a device or apparatus program for performing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0263] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0264] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0265] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
[0266] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
[0267] It should be noted that the various data-related processes in the embodiments of the present invention are carried out in compliance with the relevant data protection laws and policies of the country where the location is located, and with the authorization granted by the owner of the corresponding device.
[0268] The above embodiments are merely preferred embodiments provided to fully illustrate the present invention, and the scope of protection of the present invention is not limited thereto. Equivalent substitutions or modifications made by those skilled in the art based on the present invention are all within the scope of protection of the present invention.
Claims
1. An image coding method characterized by, The method comprises: According to the pixel value of the continuous pixel field of the first pixel column in the target image and the number of terminal pixel rows of the continuous pixel field, a first encoding sequence corresponding to the first pixel column is generated; wherein the continuous pixel field is composed of pixels with the same pixel value and continuous distribution; According to the pixel difference value between the second pixel column in the target image and the front pixel column of the second pixel column, a pixel difference value column is generated; wherein the back pixel column of the first pixel column is the second pixel column; According to the pixel value and the number of terminal pixel rows of the continuous pixel field of the pixel difference value column, a second encoding sequence corresponding to the second pixel column is generated; Combining the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column, the first image encoding information corresponding to the target image is obtained.
2. The method of claim 1, wherein, According to the pixel value of the continuous pixel field of the first pixel column in the target image and the number of terminal pixel rows of the continuous pixel field, a first encoding sequence corresponding to the first pixel column is generated, comprising: Traverse the pixels in the first pixel column to determine the continuous pixel field of the first pixel column; For each continuous pixel field, generate the encoding pair corresponding to the continuous pixel field based on the number of terminal pixel rows of the continuous pixel field and the pixel value of the continuous pixel field; According to the distribution order of the continuous pixel field in the first pixel column, combine the encoding pairs corresponding to each continuous pixel field to obtain the first encoding sequence corresponding to the first pixel column.
3. The method of claim 2, wherein, For each continuous pixel field, generate the encoding pair corresponding to the continuous pixel field based on the number of terminal pixel rows of the continuous pixel field and the pixel value of the continuous pixel field, comprising: Calculate the product of the number of terminal pixel rows of the continuous pixel field and a preset negative value to obtain a transformed number of terminal pixel rows, and combine the transformed number of terminal pixel rows and the pixel value to obtain the encoding pair, Or, calculate the product of the pixel value of the continuous pixel field and the preset negative value to obtain a transformed pixel value, and combine the transformed pixel value and the number of terminal pixel rows to obtain the encoding pair.
4. The method of claim 1, wherein, According to the pixel difference value between the second pixel column in the target image and the front pixel column of the second pixel column, a pixel difference value column is generated, comprising: Determine the pixel difference value of the pixels located at the same pixel row in the second pixel column and the front pixel column; Arrange the pixel difference value based on the number of pixel rows corresponding to the pixel difference value to obtain the pixel difference value column; wherein the pixel value of the pixel difference value column is the pixel difference value.
5. The method of claim 1, wherein, Combining the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain the first image encoding information corresponding to the target image, comprising: Combining the first encoding sequence corresponding to a first pixel column and the second encoding sequence corresponding to all second pixel columns continuously distributed after the first pixel column to obtain the local first image encoding information corresponding to the first pixel column; According to the local first image encoding information corresponding to each first pixel column, a two-dimensional array is generated; Combine the resolution information of the two-dimensional array and the target image to obtain the first image encoding information.
6. The method of claim 1, wherein, The combining the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain the first image encoding information corresponding to the target image comprises: Converting each encoding in the first encoding sequence corresponding to the first pixel column into a binary number to obtain a first binary sequence corresponding to the first pixel column; Converting each encoding in the second encoding sequence corresponding to the second pixel column into a binary number to obtain a second binary sequence corresponding to the second pixel column; Combining the first binary sequence and the second binary sequence to obtain a first target binary sequence; Generating a second target binary sequence according to the resolution of the target image, and combining the first target binary sequence and the second target binary sequence to obtain the first image encoding information.
7. The method of claim 1, wherein, The target image comprises a semantic segmentation result image, and the method further comprises: Obtaining a semantic segmentation reference image corresponding to the semantic segmentation result image; wherein the semantic segmentation result image is obtained by performing semantic segmentation on an original image by a semantic segmentation model; Encoding the semantic segmentation reference image into second image encoding information; Aligning the encoding pairs in the first image encoding information and the encoding pairs in the second image encoding information to obtain first aligned encoding information corresponding to the first image encoding information and second aligned encoding information corresponding to the second image encoding information; wherein the encoding pairs in the first aligned encoding information have a one-to-one correspondence with the encoding pairs in the first aligned encoding information; Comparing the encoding pairs in the first aligned encoding information and the second aligned encoding information to obtain an evaluation index of the semantic segmentation result image.
8. The method of claim 7, wherein, The aligning the encoding pairs in the first image encoding information and the encoding pairs in the second image encoding information to obtain first aligned encoding information corresponding to the first image encoding information and second aligned encoding information corresponding to the second image encoding information comprises: Obtaining a first end pixel row number and a second end pixel row number from the same positions in the first image encoding information and the second image encoding information, respectively; In the case that the first end pixel row number is greater than the second end pixel row number, inserting a first encoding pair in the first image encoding information to obtain the first aligned encoding information; wherein the first encoding pair is composed of the second end pixel row number and a pixel value of a position one bit before the first end pixel row number; In the case that the first end pixel row number is less than the second end pixel row number, inserting a second encoding pair in the second image encoding information to obtain the second aligned encoding information; wherein the second encoding pair is composed of the first end pixel row number and a pixel value of a position one bit before the second end pixel row number.
9. The method of claim 7, wherein, The comparing the encoding pairs in the first aligned encoding information and the second aligned encoding information to obtain an evaluation index of the semantic segmentation result image comprises: generate a confusion matrix based on the first alignment encoding information and the second alignment encoding information; calculate the evaluation index based on the confusion matrix.
10. The method of claim 9, wherein, The generating a confusion matrix based on the first alignment encoding information and the second alignment encoding information comprises: constructing an initial matrix; wherein the number of rows and the number of columns of the initial matrix are equal to the number of pixel values in the second alignment encoding information; determining a target matrix position according to the pixel values at the same positions in the first alignment encoding information and the second alignment encoding information, and a pixel value position index; adding a target element value at the target matrix position of the initial matrix to obtain the confusion matrix; wherein the target element value is determined based on the target position index and the element values in the second alignment encoding information.
11. An image coding apparatus characterized by comprising: The apparatus comprises: a first encoding sequence module configured to generate a first encoding sequence corresponding to a first pixel column in a target image according to pixel values of a continuous pixel field of the first pixel column and a number of terminal pixel rows of the continuous pixel field; wherein the continuous pixel field is composed of pixels with the same pixel value and continuous distribution; a pixel difference value column module configured to generate a pixel difference value column according to pixel difference values between a second pixel column in the target image and a front pixel column of the second pixel column; wherein a rear pixel column of the first pixel column is the second pixel column; a second encoding sequence module configured to generate a second encoding sequence corresponding to the second pixel column according to pixel values of a continuous pixel field of the pixel difference value column and a number of terminal pixel rows; a first image encoding module configured to combine the first encoding sequence corresponding to the first pixel column and the second encoding sequence corresponding to the second pixel column to obtain first image encoding information corresponding to the target image.
12. A readable storage medium, characterized by, When instructions in the storage medium are executed by a processor of an electronic device, the electronic device performs an image encoding method as claimed in any one of claims 1-10.
Citation Information
Patent Citations
Embedding method and extracting method of reversible watermarks
CN102044061A
Lossless compression method of pixel values of CMOS image sensor
CN103533260A