An image encoding method, device, and storage medium based on regions of interest
By performing the splitting of images and sorting of discrete cosine transform coefficients, the problem of not supporting cosmic cosine transform coefficients in the prior art is solved, and efficient image compression and coding are achieved.
Patent Information
- Application Number
- CN202210399776.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-15
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2042-04-15
AI Technical Summary
The existing JPEG compression algorithm does not support the coding processing of the region of interest (ROI), resulting in a low compression rate.
By obtaining the image to be encoded and the encoding strategy table, the images are split, the discrete cosine transform (DCT) coefficients of each image block are obtained, and the DCT coefficients are classified and processed and encoded based on the region of interest.
Selective encoding based on the region of interest is realized, and the compression rate and encoding efficiency of the image are improved.
Smart Images

Figure CN115002464B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image encoding method, apparatus, and storage medium based on a region of interest. Background Art
[0002] Currently, in image compression / encoding technology, with the continuous improvement of image resolution, how to further improve the image compression ratio has become an urgent problem to be solved; while the mainstream Joint Photographic Experts Group (JPEG) compression algorithm itself does not support the encoding process of the region of interest (ROI). Usually, through preprocessing operations, different processes are performed on the image within or outside the ROI region, and then the preprocessed image is encoded by JPEG. It is impossible to directly implement regional encoding, resulting in a low compression ratio. Summary of the Invention
[0003] This application provides an image encoding method, apparatus, and storage medium based on a region of interest, which can achieve selective encoding based on the region of interest and improve the image compression ratio.
[0004] To solve the above technical problems, the technical solution adopted by this application is: to provide an image encoding method based on a region of interest, the image encoding method includes: obtaining an image to be encoded and an encoding strategy table, and splitting the image to be encoded to obtain a plurality of image blocks; obtaining first discrete cosine transform coefficients, where the first discrete cosine transform coefficients are the discrete cosine transform coefficients of each image block; selecting a current encoding strategy from the encoding strategy table, and classifying the first discrete cosine transform coefficients based on the current encoding strategy and the region of interest to obtain classified discrete cosine transform coefficients; encoding the classified discrete cosine transform coefficients to generate encoded data of the image to be encoded.
[0005] To solve the above technical problems, another technical solution adopted by this application is: to provide an image encoding apparatus, the image encoding apparatus includes a memory and a processor connected to each other, where the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the image encoding method based on the region of interest in the above technical solution.
[0006] To solve the above technical problems, another technical solution adopted by this application is: to provide a computer-readable storage medium, which is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the image encoding method based on the region of interest in the above technical solution.
[0007] Through the above solution, the beneficial effects of this application are as follows: First, obtain the image to be encoded and the encoding strategy table; then split the image to be encoded to obtain multiple image blocks; then obtain the first discrete cosine transform coefficients corresponding to each image block; then select the current encoding strategy from the encoding strategy table, and classify the first discrete cosine transform coefficients based on the current encoding strategy and the ROI region to obtain the classified discrete cosine transform coefficients; then encode the classified discrete cosine transform coefficients to generate the encoded data of the image to be encoded. The solution provided by this application does not require preprocessing operations on the image to be encoded, can directly classify the discrete cosine transform coefficients of each image block, and then encode the classified discrete cosine transform coefficients to complete the encoding operation, which can improve the efficiency of image encoding; moreover, it can also select appropriate current encoding strategies and ROI regions to classify the discrete cosine transform coefficients of each image block respectively, realizing regional and selective encoding of the image to be encoded based on the ROI region, which can improve the image compression ratio and encoding efficiency; in addition, the encoding method provided by this application can also be applied to all encoding schemes that use the discrete cosine transform algorithm for image compression processing, and has a wide range of applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the technical solutions in the embodiments of this application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings. Among them:
[0009] Figure 1 is a flowchart of an embodiment of the image encoding method based on the region of interest provided by this application;
[0010] Figure 2 is a schematic diagram of the discrete cosine transform coefficients provided by this application;
[0011] Figure 3 is a schematic diagram of the conventional JPEG encoding provided by this application;
[0012] Figure 4 is a schematic diagram of the progressive JPEG encoding provided by this application;
[0013] Figure 5 is the image to be encoded provided by this application;
[0014] Figure 6 is the image that only encodes some DC component coefficients provided by this application;
[0015] Figure 7is an image encoding some DC component coefficients and some AC component coefficients provided by the present application;
[0016] Figure 8 is a schematic diagram of applying the image encoding method based on region of interest provided by the present application to progressive JPEG encoding;
[0017] Figure 9 is a schematic flowchart of another embodiment of the image encoding method based on region of interest provided by the present application;
[0018] Figure 10 is a schematic structural diagram of an embodiment of the image encoding device provided by the present application;
[0019] Figure 11 is a schematic structural diagram of an embodiment of the computer-readable storage medium provided by the present application. Detailed Embodiments
[0020] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be specifically noted that the following embodiments are only used to illustrate the present application, but do not limit the scope of the present application. Similarly, the following embodiments are only partial embodiments of the present application rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present application.
[0021] Referring to "embodiment" in the present application means that the specific features, structures or characteristics described in connection with the embodiment may be included in at least one embodiment of the present application. The phrase appears in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein may be combined with other embodiments.
[0022] It should be noted that the terms "first", "second", and "third" in the present application are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first", "second", and "third" may explicitly or implicitly include at least one of such features. In the description of the present application, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically defined. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices.
[0023] Please refer toFigure 1 , Figure 1 is a schematic flowchart of an embodiment of an image encoding method based on a region of interest provided by this application. The method includes:
[0024] Step 11: Obtain the image to be encoded and the encoding strategy table, and split the image to be encoded to obtain a plurality of image blocks.
[0025] The image to be encoded can be split into a plurality of image blocks, and then each image block is encoded separately. Specifically, generally, the size of the image block is selected as 8x8 or 16x16 to facilitate subsequent discrete cosine transform (Discrete Cosine Transform, DCT). The number and size of the image blocks can be set according to the actual situation and are not limited here.
[0026] Step 12: Obtain the first DCT coefficients.
[0027] The first DCT coefficients are the DCT coefficients of each image block, that is, the first DCT coefficients can include the DCT coefficients corresponding to each image block; specifically, when performing DCT transformation on each image block, the DCT coefficients as shown in Figure 2 can be obtained. The DCT coefficients can include a plurality of transformation coefficients (that is, the 64 transformation coefficients numbered "0" to "63" shown in Figure 2 ). Among them, in the process of encoding using the DCT coefficients, the transformation coefficient numbered "0" represents the DC component coefficient, and the transformation coefficients numbered "1" to "63" represent the AC component coefficients. Therefore, in the subsequent encoding process, encoding is performed using the DC component coefficient and the AC component coefficients.
[0028] It can be understood that the image encoding method in this embodiment can be applied to any encoding method that uses DCT transformation for image compression, which can include but is not limited to JPEG encoding. Here, the encoding process is introduced by taking conventional JPEG encoding and progressive JPEG encoding as examples:
[0029] 1) Conventional JPEG encoding
[0030] As shown in Figure 3 , in the process of conventional JPEG encoding, the encoder first performs DCT transformation on each image block in sequence, then quantizes the DCT coefficients according to the corresponding quantization table, and then encodes the quantized DCT coefficients according to the encoding table; among them, the algorithm used for encoding is usually Huffman encoding plus run-length encoding (Run Length Code) to obtain the encoded data.
[0031] 2) Progressive JPEG encoding
[0032] As shown inFigure 4 As shown, in the progressive JPEG encoding method, the encoder first performs DCT transformation on each image block in sequence; then quantizes the DCT coefficients according to the corresponding quantization table; then encodes the DC component coefficients and the AC component coefficients in sequence using different coding tables to obtain encoded data. By encoding the DC component coefficients and the AC component coefficients in sequence, a series of bitstream data from the low-precision part to the high-precision part can be obtained; then during decoding, after solving the image data of different precisions in sequence and superimposing them in sequence, an image meeting the precision requirements is finally obtained.
[0033] Please refer to Figures 5 to 7 the decoded image shown, where Figure 5 is the original image to be encoded. First, the high bits (such as the high 5 bits) of the DC component coefficients of all image blocks in the image to be decoded can be encoded, and then a relatively blurred image as shown in Figure 6 can be obtained at the decoding end. Then, the high bits of the AC component coefficients with earlier numbers (such as numbers "1" to "9") are encoded. Combining with the previously encoded DC component coefficients, a relatively clear image as shown in Figure 7 can be obtained at the decoding end. And so on, until all the remaining DCT coefficients are encoded, a complete and clear image can be obtained.
[0034] Step 13: Select the current coding strategy from the coding strategy table, and classify the first DCT coefficients based on the current coding strategy and the ROI region to obtain the classified DCT coefficients.
[0035] As Figure 8 shown, when the image coding method in this embodiment is applied to the progressive JPEG encoding process, after quantizing the DCT coefficients, a suitable coding strategy (i.e., the DCT classification strategy) can be selected, and then the quantized DCT coefficients are classified based on the coding strategy to obtain the classified DCT coefficients, so as to perform encoding using the classified DCT coefficients.
[0036] In a specific embodiment, the image to be encoded may include at least one ROI region, each ROI region may include at least one image block, and the ROI region may be manually divided; the coding strategy table may include multiple coding strategies, and one coding strategy can be selected from the coding strategy table as the current coding strategy, so as to encode the image block using the current coding strategy. It can be understood that the image to be encoded can be divided into multiple image blocks, and the coding strategies corresponding to each image block may be the same or different; in a specific implementation manner, the corresponding current coding strategy can be selected according to the precision requirements of the region where the current image block is located, so as to encode different image blocks using different current coding strategies to achieve different precisions of encoding in different regions.
[0037] Further, based on the current coding strategy and the ROI region, the first DCT coefficients can be classified to obtain the classified DCT coefficients. The first DCT coefficients include the DCT coefficients corresponding to each image block. The coding strategy corresponding to each image block can be used to classify the respective DCT coefficients, so as to obtain the classified DCT coefficients corresponding to each image block.
[0038] Step 14: Encode the classified DCT coefficients to generate the encoded data of the image to be encoded.
[0039] Encode the classified DCT coefficients to generate the encoded data of the image to be encoded. Specifically, the classified DCT coefficients corresponding to each image block can be encoded separately to obtain a plurality of sub-encoded data, and then the plurality of sub-encoded data are merged to generate the final encoded data of the image to be encoded; alternatively, the classified DCT coefficients of all image blocks can be merged and then encoded to generate the encoded data of the image to be encoded.
[0040] The technical solution adopted in this embodiment does not require preprocessing the image to be encoded. By directly classifying the DCT coefficients of each image block and then encoding the classified DCT coefficients, the encoding operation can be completed, which can improve the efficiency of image encoding; moreover, a suitable current coding strategy and the reference ROI region can be selected to classify the DCT coefficients of each image block respectively, realizing regional and selective encoding of the image to be encoded based on the ROI region, which can improve the image compression ratio and encoding efficiency; in addition, the encoding method in this embodiment can be applied to all encoding schemes that use the DCT algorithm for image compression processing, and has general applicability.
[0041] Please refer to Figure 9 , Figure 9 which is a schematic flowchart of another embodiment of the ROI-based image encoding method provided by this application. The method includes:
[0042] Step 91: Obtain the image to be encoded and the coding strategy table, and split the image to be encoded to obtain a plurality of image blocks.
[0043] Step 92: Obtain the first DCT coefficients.
[0044] Steps 91 to 92 are the same as steps 11 to 12 in the above embodiment, and will not be elaborated here.
[0045] Step 93: Determine whether the image block belongs to the ROI region.
[0046] By determining whether an image block belongs to the ROI region, a suitable encoding strategy can be selected for the image blocks within the ROI region and the image blocks outside the ROI region. Then, the corresponding encoding strategies are used to classify the respective first DCT coefficients differently, enabling regional encoding of the image to be encoded in different regions; specifically, since the accuracy requirement for the image within the ROI region is higher than that outside the ROI region, different encoding strategies can be selected according to different accuracy requirements, so that an image with different accuracy region distributions can be obtained through the encoding strategy corresponding to the accuracy requirement.
[0047] Specifically, the first DCT coefficients may include multiple transformation coefficients (i.e., Figure 2 the 64 transformation coefficients numbered "0" to "63" shown in ), each transformation coefficient corresponds to a number, and each transformation coefficient contains multiple sub-transformation coefficients; the accuracy of the encoded image is related to the number of the encoded transformation coefficient and the number of bits of the sub-transformation coefficient. Each transformation coefficient may contain 8 to 16 sub-transformation coefficients, and each bit of the sub-transformation coefficient may correspond to a different accuracy type. Among them, the transformation coefficient numbered "0" represents the DC component coefficient, and the transformation coefficients numbered "1 to 63" represent the AC component coefficients. The high-order sub-transformation coefficients in the DC component coefficient are the low-accuracy part of the DC component coefficient, the low-order sub-transformation coefficients in the DC component coefficient are the high-accuracy part of the DC component coefficient, the high-order sub-transformation coefficients in the AC component coefficient are the low-accuracy part of the AC component coefficient, and the low-order sub-transformation coefficients in the AC component coefficient represent the high-accuracy part of the AC component coefficient; different encoding strategies can be used to selectively encode the high / low accuracy parts of the DC component coefficient and / or the AC component coefficient corresponding to each image block, so as to achieve different encodings for different regions in the image to be encoded and obtain regional images with different accuracies.
[0048] Step 94: If the image block belongs to the ROI region, the first DCT coefficients are classified using the first preset encoding strategy to obtain second DCT coefficients; the image block is encoded based on the second DCT coefficients to obtain sub-encoded data.
[0049] The encoding strategy table may include a first preset encoding strategy and a second preset encoding strategy. The classified DCT coefficients include second DCT coefficients and third DCT coefficients. When the image block belongs to the ROI region, the first DCT coefficients can be classified using the first preset encoding strategy to obtain second DCT coefficients, and then the image block is encoded according to the second DCT coefficients to obtain sub-encoded data; specifically, the first preset encoding strategy may include the first number information of the transformation coefficient and the first sub-transformation coefficient information. Based on the first number information and the first sub-transformation coefficient information, the sub-transformation coefficients in the first DCT coefficients are screened to obtain the second DCT coefficients.
[0050] Further, the first numbering information may include a first preset numbering range and a second preset numbering range, the first sub-transformation coefficient information may include a first preset digit range and a second preset digit range, and the step of screening the sub-transformation coefficients in the first DCT coefficients may be: first, obtain the transformation coefficients corresponding to the first preset numbering range to obtain at least one first transformation coefficient, then screen the sub-transformation coefficients in the first transformation coefficient based on the first preset digit range to obtain a first candidate coefficient; then obtain the transformation coefficients corresponding to the second preset numbering range to obtain at least one second transformation coefficient; then screen the sub-transformation coefficients in the second transformation coefficient based on the second preset digit range to obtain a second candidate coefficient; finally, merge the first candidate coefficient and the second candidate coefficient to obtain the second DCT coefficient.
[0051] Specifically, the numbers in the first preset numbering range are generally smaller than the numbers in the second preset numbering range. For example, the numbers in the first preset numbering range may be from "0" to "5", and the numbers in the second preset numbering range may be from "6" to "55". Then, the first transformation coefficients with numbers from "0" to "5" and the second transformation coefficients with numbers from "6" to "55" can be obtained first, and then the sub-transformation coefficients corresponding to the corresponding digits in each first transformation coefficient are screened according to the first preset digit range, and the sub-transformation coefficients corresponding to the corresponding digits in each second transformation coefficient are screened according to the second preset digit range, so as to obtain the corresponding first candidate coefficient and second candidate coefficient, and then merge the first candidate coefficient and the second candidate coefficient to obtain the second DCT coefficient, and encode the image block based on the second DCT coefficient to obtain the sub-encoded data.
[0052] It can be understood that the first preset digit range and the second preset digit range included in the first sub-transformation coefficient information may be the same or different, and the preset numbering range may also be set to one, three or more than three. Correspondingly, the preset digit range may also be one, three or more than three, which is not limited herein, and the first numbering information and the first sub-transformation coefficient information in the first preset encoding strategy can be set according to the actual situation.
[0053] Step 95: If the image block does not belong to the ROI region, classify the first DCT coefficient using the second preset encoding strategy to obtain a third DCT coefficient; encode the image block based on the third DCT coefficient to obtain sub-encoded data.
[0054] If the image block does not belong to the ROI region, the first DCT coefficients are classified using a second preset coding strategy to obtain third DCT coefficients. Specifically, the second preset coding strategy may include second number information of transform coefficients and second sub-transform coefficient information. Based on the second number information and the second sub-transform coefficient information, the sub-transform coefficients in the first DCT coefficients are screened to obtain fourth DCT coefficients, and then the fourth DCT coefficients are assigned values to obtain third DCT coefficients.
[0055] Further, the second number information may include a third preset number range and a fourth preset number range, and the second sub-transform coefficient information includes a third preset digit range and a fourth preset digit range. The steps to obtain the third DCT coefficients may be: first, obtain the transform coefficients corresponding to the third preset number range to obtain at least one third transform coefficient, and then screen the sub-transform coefficients in the third transform coefficient based on the third preset digit range to obtain third candidate coefficients; obtain the transform coefficients corresponding to the fourth preset number range to obtain at least one fourth transform coefficient; screen the sub-transform coefficients in the fourth transform coefficient based on the fourth preset digit range to obtain fourth candidate coefficients; then merge the third candidate coefficients and the fourth candidate coefficients to obtain fourth DCT coefficients; and then set the sub-transform coefficients in the fourth DCT coefficients that meet the preset conditions to preset values to obtain third DCT coefficients.
[0056] In a specific implementation, the image to be encoded may include at least one ROI region, and different precision requirements may be set for each ROI region. Different preset coding strategies may be set for different ROI regions. The preset coding strategies included in the coding strategy table may be set according to different precision requirements. The coding strategy table may include the corresponding relationship between the precision requirements and the preset coding strategies. During the process of encoding the image, the corresponding first preset coding strategy / second preset coding strategy is selected by judging the precision requirements of the ROI region / non-ROI region of the image block.
[0057] Further, the setting rule of the preset coding strategy can be as follows: when the image block belongs to the ROI region, the higher the precision requirement, the larger the number in the first numbered information included in the first preset coding strategy, and the larger the number of digits in the second digit information; when the image block does not belong to the ROI region, the higher the precision requirement, the larger the number in the third numbered information included in the second preset coding strategy, and the larger the number of digits in the third digit information. Specific digits and numbers are not limited here and can be set according to the actual situation and precision requirements; it can be understood that the numbers in the third preset number range are generally smaller than the numbers in the fourth preset number range, and the third preset digit range and the fourth preset digit range included in the second sub-transform coefficient information can be the same or different. The preset number range can also be one, three, or more than three, and correspondingly, the preset digit range can also be one, three, or more than three.
[0058] For example, the preset value can be 0, that is, when the image block does not belong to the ROI region, by setting some sub-transform coefficients in the fourth DCT coefficient to 0 and discarding some sub-transform coefficients, the third DCT coefficient is obtained, and then the image block is encoded based on the third DCT coefficient to obtain sub-encoded data; further, the third preset digit range can include a first sub-range, and the fourth preset digit range can include a second sub-range. Whether to discard some sub-transform coefficients can be determined by judging whether the number of the transform coefficient corresponding to the sub-transform coefficient falls within the third preset number range and whether the position of the sub-transform coefficient in the transform coefficients falls within the first sub-range; if the number of the transform coefficient corresponding to the sub-transform coefficient falls within the third preset number range and the position of the sub-transform coefficient in the transform coefficients falls within the first sub-range, the sub-transform coefficient is set to the preset value; or, whether to discard some sub-transform coefficients can be determined by judging whether the number of the transform coefficient corresponding to the sub-transform coefficient falls within the fourth preset number range and whether the position of the sub-transform coefficient in the transform coefficients falls within the second sub-range; if the number of the transform coefficient corresponding to the sub-transform coefficient falls within the fourth preset number range and the position of the sub-transform coefficient in the transform coefficients falls within the second sub-range, the sub-transform coefficient is set to the preset value.
[0059] In a specific implementation, the second sub-range can also be the same as the fourth preset digit range. For example: the fourth preset digit range can be 0 to 8, and the second sub-range is also 0 to 8. Then all sub-transform coefficients in the transform coefficients within the fourth preset number range can be discarded at this time.
[0060] The discarded sub-transform coefficients can be high-precision partial coefficients. During the encoding process, the high-precision partial coefficients mainly affect the detailed parts of the image and have little impact on the overall clarity (i.e., precision) of the image. Therefore, by discarding the high-precision partial coefficients in the image blocks outside the ROI region and retaining the low-precision partial coefficients, selective encoding can be achieved, and at the same time, the change in the image after the loss of details is not perceptible to the human eye. The number of bits in the first sub-range and the number of bits in the second sub-range can be the low bits in the transform coefficients. Taking the transform coefficients including 8-bit sub-transform coefficients as an example, if the high-order sub-transform coefficients are the sub-transform coefficients in the positions from "3" to "7", that is, the high bits are from "3" to "7", then at this time, the low-order sub-transform coefficients can be the sub-transform coefficients in the "0" position, that is, the low bits are from "0" to "2".
[0061] Step 96: Generate encoded data based on the sub-encoded data.
[0062] The sub-encoded data of each image block can be merged to generate encoded data. Specifically, when the image block belongs to the ROI region, the sub-transform coefficients in the first preset bit range in the first transform coefficients can be determined as the first candidate coefficients; the first candidate coefficients are encoded to obtain the first sub-encoded data; the sub-transform coefficients in the second preset bit range in the second transform coefficients are determined as the second candidate coefficients; the second candidate coefficients are encoded to obtain the second sub-encoded data; the first sub-encoded data and the second sub-encoded data are merged to obtain the sub-encoded data.
[0063] When the image block does not belong to the ROI region, the sub-transform coefficients in the third preset bit range in the third transform coefficients are determined as the third candidate coefficients; the third candidate coefficients are encoded to obtain the third sub-encoded data; the sub-transform coefficients in the fourth preset bit range in the fourth transform coefficients are determined as the fourth candidate coefficients; the fourth candidate coefficients are encoded to obtain the fourth sub-encoded data; the third sub-encoded data and the fourth sub-encoded data are merged to obtain the sub-encoded data. It can be understood that the sub-transform coefficients in the third candidate coefficients and the fourth candidate coefficients that meet the preset conditions are preset values.
[0064] In other embodiments, when the image block belongs to the ROI region, the second DCT coefficients can also be directly encoded to obtain the sub-encoded data. When the image block does not belong to the ROI region, the third DCT coefficients can be directly encoded to obtain the sub-encoded data.
[0065] The following describes the image encoding method in this embodiment by taking the progressive JPEG encoding to encode the image to be processed, and the quantized DCT coefficients include 8-bit sub-transform coefficients as an example:
[0066] 1) Encode the high 7-bit sub-transform coefficients of the transform coefficients numbered "0" in all image blocks (including the ROI region and all image blocks outside the ROI region). At this time, a complete image with lower clarity can be obtained at the decoding end.
[0067] 2) Encode the high 7-bit sub-transform coefficients of the transform coefficients numbered "1" to "5" in all image blocks. At this time, a complete image with slightly higher clarity can be obtained at the decoding end.
[0068] 3) Set the lowest bit sub-transform coefficients of the transform coefficients numbered "0" to "5" in the image blocks outside the ROI region to 0, that is, discard the detail information of the high-precision part outside the ROI region.
[0069] 4) Set the transform coefficients numbered "6" to "63" in the image blocks outside the ROI region to 0, further discard the detail information outside the ROI region. After performing the above steps 3 and 4, the clarity of the image decoded at the decoding end can maintain the same clarity as the image obtained in step 2.
[0070] 5) Encode the lowest bit sub-transform coefficients of the transform coefficients numbered "0" to "5" in all image blocks after being processed by steps 3) and 4). At this time, since the corresponding lowest bit sub-transform coefficients outside the ROI region have been discarded in step 3 above, the clarity of the image outside the ROI region will not be improved, while the clarity of the image within the ROI region can be improved because the accuracy of the DCT coefficients is supplemented.
[0071] 6) Encode all sub-transform coefficients of the transform coefficients numbered "6" to "63" in all image blocks. At this time, since all the corresponding sub-transform coefficients outside the ROI region have been discarded in step 4, the clarity outside the ROI region will not be improved, while the clarity of the image within the ROI region can be improved because the high-frequency part (i.e., the detail part of the image) of the DCT coefficients is supplemented.
[0072] In this embodiment, by determining whether an image block belongs to the ROI region, a corresponding first preset coding strategy is selected for the image blocks within the ROI region, and a corresponding second preset coding strategy is selected for the image blocks outside the ROI region. Thus, the transform coefficients in the image blocks within / outside the ROI region are classified differently through different coding strategies, thereby controlling different precisions in different regions; by setting some sub-transform coefficients of the high-precision part in the image blocks outside the ROI region to 0 and discarding the detail part of the image to be encoded, it can be ensured that even without using the progressive coding method, after recombining the coefficients classified according to different strategies and directly performing conventional JPEG coding, the effect of region coding can be achieved, and at the same time, the storage space occupied by the coding data can be reduced, and the compression ratio of the image can be improved.
[0073] Please refer to Figure 10 , Figure 10 which is a schematic structural diagram of an embodiment of an image encoding device provided by the present application. The image encoding device 100 includes a memory 101 and a processor 102 connected to each other. The memory 101 is used to store a computer program, and when the computer program is executed by the processor 102, it is used to implement the region of interest-based image encoding method in the above embodiment.
[0074] Please refer to Figure 11 , Figure 11 which is a schematic structural diagram of an embodiment of a computer-readable storage medium provided by the present application. The computer-readable storage medium 110 is used to store a computer program 111, and when the computer program 111 is executed by a processor, it is used to implement the region of interest-based image encoding method in the above embodiment.
[0075] The computer-readable storage medium 110 can be various media that can store program codes, such as a server, a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk, or an optical disc.
[0076] In several implementation manners provided by the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation manners described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division manners. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0077] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this implementation manner.
[0078] In addition, each functional unit in various implementation manners of the present application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0079] The above are only embodiments of the present application, and do not thereby limit the patent scope of the present application. Any equivalent structural or equivalent process transformations made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, are similarly included in the patent protection scope of the present application.
Claims
1. An image coding method based on region of interest, characterized in that, comprising: Obtain the image to be coded and the coding strategy table, and split the image to be coded to obtain a plurality of image blocks; Obtain the first discrete cosine transform coefficients, where the first discrete cosine transform coefficients are the discrete cosine transform coefficients of each of the image blocks; Select the current coding strategy from the coding strategy table, and classify the first discrete cosine transform coefficients based on the current coding strategy and the region of interest to obtain the classified discrete cosine transform coefficients; Encode the classified discrete cosine transform coefficients to generate the coded data of the image to be coded; Wherein, the coding strategy table includes a first preset coding strategy and a second preset coding strategy, the classified discrete cosine transform coefficients include second discrete cosine transform coefficients and third discrete cosine transform coefficients, and the method further includes: Determine whether the image block belongs to the region of interest; If so, classify the first discrete cosine transform coefficients using the first preset coding strategy to obtain the second discrete cosine transform coefficients; Encode the image block based on the second discrete cosine transform coefficients to obtain sub-coded data; If not, classify the first discrete cosine transform coefficients using the second preset coding strategy to obtain the third discrete cosine transform coefficients; Encode the image block based on the third discrete cosine transform coefficients to obtain sub-coded data; Generate the coded data based on the sub-coded data.
2. The image coding method based on region of interest according to claim 1, characterized in that, The first discrete cosine transform coefficients include a plurality of transform coefficients, each transform coefficient corresponds to a number, and each transform coefficient includes multiple sub-transform coefficients; The first preset coding strategy includes the first number information and the first sub-transform coefficient information of the transform coefficients; The method further includes: Screen the sub-transform coefficients in the first discrete cosine transform coefficients based on the first number information and the first sub-transform coefficient information to obtain the second discrete cosine transform coefficients.
3. The image coding method based on region of interest according to claim 2, characterized in that, The first number information includes a first preset number range and a second preset number range, and the first sub-transform coefficient information includes a first preset digit range and a second preset digit range; The step of screening the sub-transform coefficients in the first discrete cosine transform coefficients based on the first number information and the first sub-transform coefficient information to obtain the second discrete cosine transform coefficients includes: Obtain the transform coefficients corresponding to the first preset number range to obtain at least one first transform coefficient; Screen the sub-transform coefficients in the first transform coefficient based on the first preset digit range to obtain a first candidate coefficient; Obtain the transform coefficients corresponding to the second preset number range to obtain at least one second transform coefficient; Based on the second preset digit range, screen the sub-transform coefficients in the second transform coefficient to obtain a second candidate coefficient; Merge the first candidate coefficient and the second candidate coefficient to obtain the second discrete cosine transform coefficient.
4. The method for image coding based on a region of interest according to claim 3, wherein, the second preset coding strategy includes second number information of the transform coefficients in the first discrete cosine transform coefficient and second sub-transform coefficient information; the step of classifying the first discrete cosine transform coefficient by using the second preset coding strategy to obtain the third discrete cosine transform coefficient includes: Based on the second number information and the second sub-transform coefficient information, screen the sub-transform coefficients in the first discrete cosine transform coefficient to obtain a fourth discrete cosine transform coefficient; Perform an assignment process on the fourth discrete cosine transform coefficient to obtain the third discrete cosine transform coefficient.
5. The method for image coding based on a region of interest according to claim 4, wherein, the second number information includes a third preset number range and a fourth preset number range, and the second sub-transform coefficient information includes a third preset digit range and a fourth preset digit range. The method further includes: Obtain the transform coefficients corresponding to the third preset number range to obtain at least one third transform coefficient; Based on the third preset digit range, screen the sub-transform coefficients in the third transform coefficient to obtain a third candidate coefficient; Obtain the transform coefficients corresponding to the fourth preset number range to obtain at least one fourth transform coefficient; Based on the fourth preset digit range, screen the sub-transform coefficients in the fourth transform coefficient to obtain a fourth candidate coefficient; Merge the third candidate coefficient and the fourth candidate coefficient to obtain the fourth discrete cosine transform coefficient; Set the sub-transform coefficients in the fourth discrete cosine transform coefficient that meet the preset conditions to a preset value to obtain the third discrete cosine transform coefficient.
6. The method for image coding based on a region of interest according to claim 5, wherein the third preset digit range includes a first sub-range, and the fourth preset digit range includes a second sub-range, wherein, the method further includes: Judge whether the number of the fourth transform coefficient corresponding to the sub-transform coefficient in the fourth discrete cosine transform coefficient falls within the third preset number range and whether the position of the sub-transform coefficient in the fourth discrete cosine transform coefficient in the fourth transform coefficient falls within the first sub-range; if so, set the sub-transform coefficient in the fourth discrete cosine transform coefficient to the preset value; or Judge whether the number of the fourth transform coefficient corresponding to the sub-transform coefficient in the fourth discrete cosine transform coefficient falls within the fourth preset number range and whether the position of the sub-transform coefficient in the fourth discrete cosine transform coefficient in the fourth transform coefficient falls within the second sub-range; if so, set the sub-transform coefficient in the fourth discrete cosine transform coefficient to the preset value.
7. The method for image coding based on region of interest according to claim 5, wherein, the method further includes: when the image block belongs to the region of interest, determining sub-transform coefficients within the first preset number-of-digits range in the first transform coefficients as the first candidate coefficients; coding the first candidate coefficients to obtain first sub-coded data; determining sub-transform coefficients within the second preset number-of-digits range in the second transform coefficients as the second candidate coefficients; coding the second candidate coefficients to obtain second sub-coded data; merging the first sub-coded data and the second sub-coded data to obtain the sub-coded data; when the image block does not belong to the region of interest, determining sub-transform coefficients within the third preset number-of-digits range in the third transform coefficients as the third candidate coefficients; coding the third candidate coefficients to obtain third sub-coded data; determining sub-transform coefficients within the fourth preset number-of-digits range in the fourth transform coefficients as the fourth candidate coefficients; coding the fourth candidate coefficients to obtain fourth sub-coded data; merging the third sub-coded data and the fourth sub-coded data to obtain the sub-coded data.
8. An image coding device, wherein, it includes a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the method for image coding based on region of interest according to any one of claims 1-7.
9. A computer-readable storage medium for storing a computer program, wherein, when the computer program is executed by a processor, it is used to implement the method for image coding based on region of interest according to any one of claims 1-7.
Citation Information
Patent Citations
Motion-constrained tile set for region of interest coding
CN105432082A
Image encoding / decoding method and device
CN107888917A