CN115514967B - Image compression method and image decompression method based on binary block bidirectional coding - Google Patents

Image compression method and image decompression method based on binary block bidirectional coding Download PDF

Info

Publication number
CN115514967B
CN115514967B CN202211382188.1A CN202211382188A CN115514967B CN 115514967 B CN115514967 B CN 115514967B CN 202211382188 A CN202211382188 A CN 202211382188A CN 115514967 B CN115514967 B CN 115514967B
Authority
CN
China
Prior art keywords
image block
image
processed
symbol
type
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211382188.1A
Other languages
Chinese (zh)
Other versions
CN115514967A (en
Inventor
花忠云
刘星雨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Graduate School Harbin Institute of Technology
Original Assignee
Shenzhen Graduate School Harbin Institute of Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Graduate School Harbin Institute of Technology filed Critical Shenzhen Graduate School Harbin Institute of Technology
Priority to CN202211382188.1A priority Critical patent/CN115514967B/en
Publication of CN115514967A publication Critical patent/CN115514967A/en
Application granted granted Critical
Publication of CN115514967B publication Critical patent/CN115514967B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/85Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

The invention discloses an image compression method and an image decompression method based on binary block bidirectional coding, wherein the image compression method comprises the following steps: acquiring a plurality of to-be-processed image blocks corresponding to an image to be compressed, and acquiring a type judgment threshold according to the size of the to-be-processed image blocks; acquiring a coding type judgment parameter according to a first symbol number and a second symbol number corresponding to the image block to be processed; determining the block type and the sign symbol of each image block to be processed according to the size relationship between the coding type judgment parameter and the type judgment threshold of each image block to be processed; according to the block type and the sign symbol of each image block to be processed, the number and the position of target coding symbols in each image block to be processed are coded through a preset image block coding step, and the coding result of each image block is obtained; and obtaining an image compression result according to all image block coding results corresponding to the image to be compressed. The invention is beneficial to improving the image compression processing efficiency.

Description

Image compression method and image decompression method based on binary block bidirectional coding
Technical Field
The invention relates to the technical field of image compression, in particular to an image compression method and an image decompression method based on binary block bidirectional coding.
Background
With the development of science and technology, the application of images is more and more extensive, and the number of images is also increasing rapidly, so in the processes of image storage, transmission and the like, image compression is required to reduce resources such as disk space required during image storage, bandwidth required during channel transmission and the like.
In the prior art, image compression is generally performed by adopting a Huffman coding mode. The problem in the prior art is that when image compression is performed by using huffman coding, statistics needs to be performed on symbols in the whole image and probability distribution needs to be determined, and then the whole image is directly compressed, so that time complexity is high during arithmetic compression, much time needs to be consumed, and efficiency and effect of image compression are not improved.
Thus, there is still a need for improvement and development of the prior art.
Disclosure of Invention
The invention mainly aims to provide an image compression method and an image decompression method based on binary block bidirectional coding, and aims to solve the problems that in the prior art, when image compression is carried out by using Huffman coding, statistics needs to be carried out on symbols in the whole image and probability distribution needs to be determined, then the whole image needs to be directly compressed, time complexity is high during arithmetic compression, more time needs to be consumed, and the efficiency of image compression is not improved.
In order to achieve the above object, a first aspect of the present invention provides an image compression method based on binary block bidirectional coding, wherein the image compression method based on binary block bidirectional coding comprises:
acquiring a plurality of to-be-processed image blocks corresponding to an image to be compressed, and acquiring a type judgment threshold of each to-be-processed image block according to the size of each to-be-processed image block, wherein each to-be-processed image block is a binary image block;
acquiring a coding type judgment parameter of each to-be-processed image block according to a first symbol number and a second symbol number corresponding to each to-be-processed image block, wherein the first symbol number is the number of symbols 0 in the to-be-processed image block, and the second symbol number is the number of symbols 1 in the to-be-processed image block;
determining the block type and the sign of each image block to be processed according to the size relationship between the coding type judgment parameter and the type judgment threshold of each image block to be processed, wherein the block type of one image block to be processed is one of a compressible type and an incompressible type;
according to the block type and the sign symbol of each to-be-processed image block, the number and the position of a target coding symbol in each to-be-processed image block are coded through a preset image block coding step, and an image block coding result of each to-be-processed image block is obtained, wherein the target coding symbol is an element symbol which is the same as the sign symbol in the to-be-processed image block;
and obtaining an image compression result corresponding to the image to be compressed according to the image block coding results of all the image blocks to be processed corresponding to the image to be compressed.
Optionally, the obtaining a plurality of to-be-processed image blocks corresponding to an image to be compressed, and obtaining a type determination threshold of each to-be-processed image block according to the size of each to-be-processed image block includes:
acquiring an image to be compressed, dividing the image to be compressed and acquiring a plurality of image blocks to be processed with the same size;
and obtaining the type judgment threshold corresponding to each image block to be processed through a preset threshold comparison table according to the size of each image block to be processed.
Optionally, the determining the coding type of each image block to be processed and the flag symbol according to the size relationship between the coding type determining parameter and the type determining threshold of each image block to be processed includes:
setting the block type of the to-be-processed image block with the coding type judgment parameter larger than the type judgment threshold value as an incompressible type, and setting the sign symbol of the to-be-processed image block to be absent;
and setting the block type of the image block to be processed of which the coding type judgment parameter is not greater than the type judgment threshold value as a compressible type, and setting the sign symbol of the image block to be processed as the symbol with less number in the image block to be processed.
Optionally, for any one of the to-be-processed image blocks, the preset image block encoding step includes:
when the block type of the image block to be processed is an incompressible type, splicing a first type symbol and an image block character string of the image block to be processed to obtain an encoding result of the image block to be processed, wherein the first type symbol is symbol 1, and the image block character string is a binary string obtained by scanning the image block to be processed in a raster scanning manner;
when the block type of the image block to be processed is a compressible type, judging parameters according to the coding type of the image block to be processed to obtain a parameter coding string of the image block to be processed, obtaining a symbol coding string of the image block to be processed according to the position of each target coding symbol in the character string of the image block to be processed, splicing a second type symbol, the parameter coding string of the image block to be processed, the symbol coding string of the image block to be processed and a sign symbol of the image block to be processed to serve as a coding result of the image block to be processed, wherein the second type symbol is symbol 0, and the parameter coding string and the symbol coding string are binary strings.
Optionally, the obtaining of the symbol encoding string of the to-be-processed image block according to the position of each target encoding symbol in the character string of the to-be-processed image block includes:
sequentially making i =1,2, \8230andz, respectively executing the following steps to obtain each symbol coding sub-string so as to connect and obtain the symbol coding string:
when i is an odd number, acquiring an ith coding character string and the length Len of the ith coding character string, traversing the ith coding character string from left to right until acquiring the position number of a first target coding symbol counted from left to right in the ith coding character string
Figure 128918DEST_PATH_IMAGE001
Calculating to obtain target digit according to target digit calculation formula
Figure 577217DEST_PATH_IMAGE002
Binary coding the target digit to obtain the ith symbol code sub-string, and deleting the first symbol from left to right in the ith code sub-string
Figure 153692DEST_PATH_IMAGE001
The symbol is used as the (i + 1) th coded character string;
when i is an even number, acquiring the ith code character string and the length Len of the ith code character string, and performing right-to-left pass on the ith code character stringThe position number of the first target code symbol counted from right to left in the ith code character string is obtained
Figure 283322DEST_PATH_IMAGE001
Calculating to obtain target digit according to the target digit calculation formula
Figure 894432DEST_PATH_IMAGE002
Binary coding the target digit to obtain the ith symbol code sub-string, and deleting the first part from right to left in the ith code sub-string
Figure 451315DEST_PATH_IMAGE001
The symbol is used as the (i + 1) th coded character string;
wherein, the 1 st encoding character string is the image block character string of the image block to be processed, z is the above encoding type judgment parameter, and the above position number
Figure 515086DEST_PATH_IMAGE001
The target digit is determined by the number of symbols passing through during traversal, and the target digit calculation formula is as follows:
Figure 448407DEST_PATH_IMAGE003
Figure 160361DEST_PATH_IMAGE004
is the target number of bits described above.
The second aspect of the present invention provides an image compression system based on binary block bidirectional coding, wherein the image compression system based on binary block bidirectional coding comprises:
the image block processing module is used for acquiring a plurality of to-be-processed image blocks corresponding to an image to be compressed and acquiring a type judgment threshold of each to-be-processed image block according to the size of each to-be-processed image block, wherein each to-be-processed image block is a binary image block;
a parameter obtaining module, configured to obtain a coding type determination parameter of each to-be-processed image block according to a first symbol number and a second symbol number corresponding to each to-be-processed image block, where the first symbol number is the number of symbols 0 in the to-be-processed image block, and the second symbol number is the number of symbols 1 in the to-be-processed image block;
a block type determining module, configured to determine a block type and a landmark of each to-be-processed image block according to a size relationship between a coding type determination parameter and a type determination threshold of each to-be-processed image block, where a block type of one to-be-processed image block is one of a compressible type and an incompressible type;
the encoding module is configured to encode, according to a block type and a sign of each to-be-processed image block, the number and the position of a target encoding symbol in each to-be-processed image block through a preset image block encoding step, and obtain an image block encoding result of each to-be-processed image block, where the target encoding symbol is an element symbol in the to-be-processed image block that is the same as the sign;
and the compression result acquisition module is used for acquiring the image compression result corresponding to the image to be compressed according to the image block coding results of all the image blocks to be processed corresponding to the image to be compressed.
A third aspect of the present invention provides an image decompression method, including:
acquiring an image compression result corresponding to an image to be decompressed;
obtaining an image block coding result corresponding to each image block to be decoded according to the image compression result, and obtaining the size of each image block to be decoded;
obtaining a block type of each image block to be decoded according to a type symbol value in each image block coding result, wherein the type symbol value is a value of a first bit in the image block coding result, and the block type of one image block to be decoded is one of a compressible type and an incompressible type;
decoding the number and the position of target decoding symbols corresponding to each image block to be decoded through a preset image block decoding step according to the size, the block type and the image block encoding result of each image block to be decoded, and obtaining the image block decoding result of each image block to be decoded, wherein the target decoding symbols are element symbols which are the same as the sign symbols of each image block to be decoded in the image block decoding result;
and obtaining a target decompressed image according to the decoding results of all the image blocks corresponding to the image to be decompressed.
Optionally, the preset image block decoding step includes:
when the block type of the image block to be decoded is an incompressible type, deleting a first bit of an image block encoding result of the image block to be decoded to serve as a target decoding character string of the image block to be decoded, placing the target decoding character string according to the size of the image block to be decoded in a raster scanning mode, and obtaining an image block decoding result of the image block to be decoded;
when the block type of the image block to be decoded is a compressible type, taking the last bit of the encoding result of the image block as a sign symbol of the image block to be decoded, obtaining a parameter encoding string in the encoding result of the image block to be decoded, obtaining a decoding type judgment parameter of the image block to be decoded according to the parameter encoding string, obtaining a character string to be decoded according to the encoding result of the image block, decoding the character string to be decoded according to the sign symbol and the decoding type judgment parameter of the image block to be decoded to obtain a target decoding character string of the image block to be decoded, placing the target decoding character string according to the size of the image block to be decoded in a raster scanning mode, and obtaining the decoding result of the image block to be decoded, wherein the character string to be decoded is a character string obtained after deleting the first bit, the last bit and the parameter encoding string from the encoding result of the image block.
Optionally, the decoding the character string to be decoded according to the sign symbol and the decoding type determination parameter of the image block to be decoded to obtain the target decoding character string of the image block to be decoded includes:
setting an initial decoding character string according to the flag symbol, wherein when the flag symbol is 0, the initial decoding character string is a character string with a length of S × S and each element is 1, when the flag symbol is 1, the initial decoding character string is a character string with a length of S × S and each element is 0, and S × S is equal to the size of the image block to be decoded;
when in use
Figure 216042DEST_PATH_IMAGE005
If =0, the initial decoding character string is used as the target decoding character string of the image block to be decoded, wherein,
Figure 32688DEST_PATH_IMAGE005
judging parameters of the decoding type of the image block to be decoded;
when in use
Figure 300858DEST_PATH_IMAGE005
Not equal to 0, setting the first calculated value rl =1, setting the second calculated value rh = S × S, sequentially making j =1,2, \\ 8230,
Figure 558664DEST_PATH_IMAGE005
executing the following steps to update the initial decoding character string and obtain a target decoding character string of the image block to be decoded: obtaining the jth character string and calculating the target length
Figure 519667DEST_PATH_IMAGE006
= rh-rl +1; calculating the jth decoded bit number
Figure 558030DEST_PATH_IMAGE007
(ii) a According to the 1 st bit in the j character string
Figure 567575DEST_PATH_IMAGE008
Obtaining the jth binary string from the sign of the bit, and converting the 1 st bit to the 1 st bit of the jth character string
Figure 7783DEST_PATH_IMAGE008
After symbol erasure of bitsObtaining a j +1 th character string; converting the jth binary string into decimal to obtain the jth number
Figure 874108DEST_PATH_IMAGE009
(ii) a When j is odd number, updating in sequence
Figure 337450DEST_PATH_IMAGE009
=rl+
Figure 213002DEST_PATH_IMAGE009
、rl=
Figure 445401DEST_PATH_IMAGE009
+1, when j is even number, updating in turn
Figure 13785DEST_PATH_IMAGE009
=rh-
Figure 698844DEST_PATH_IMAGE009
、rh=
Figure 378088DEST_PATH_IMAGE009
-1; the first character string from left to right
Figure 464992DEST_PATH_IMAGE009
Updating each element to the mark symbol; wherein, the 1 st character string is the character string to be decoded of the image block to be decoded.
A fourth aspect of the present invention provides an image decompression system, comprising:
the image compression result acquisition module is used for acquiring an image compression result corresponding to the image to be decompressed;
the image compression result processing module is used for acquiring image block coding results corresponding to all image blocks to be decoded according to the image compression results and acquiring the size of each image block to be decoded;
an image block coding result processing module, configured to obtain a block type of each to-be-decoded image block according to a type symbol value in each image block coding result, where the type symbol value is a value of a first bit in the image block coding result, and a block type of one to-be-decoded image block is one of a compressible type and an incompressible type;
a decoding module, configured to decode, according to the size, the block type, and the image block encoding result of each to-be-decoded image block, the number and the position of a target decoding symbol corresponding to each to-be-decoded image block through a preset image block decoding step, and obtain an image block decoding result of each to-be-decoded image block, where the target decoding symbol is an element symbol in the image block decoding result that is the same as a sign symbol of the to-be-decoded image block;
and the image decompression module is used for obtaining a target decompressed image according to all the image block decoding results corresponding to the image to be decompressed.
As can be seen from the above, in the scheme of the present invention, a plurality of to-be-processed image blocks corresponding to an image to be compressed are obtained, and a type determination threshold of each of the to-be-processed image blocks is obtained according to the size of each of the to-be-processed image blocks, where the to-be-processed image block is a binary image block; acquiring a coding type judgment parameter of each to-be-processed image block according to a first symbol number and a second symbol number corresponding to each to-be-processed image block, wherein the first symbol number is the number of symbols 0 in the to-be-processed image block, and the second symbol number is the number of symbols 1 in the to-be-processed image block; determining the block type and the sign of each image block to be processed according to the size relationship between the coding type judgment parameter and the type judgment threshold of each image block to be processed, wherein the block type of one image block to be processed is one of a compressible type and an incompressible type; according to the block type and the sign of each to-be-processed image block, the number and the position of target coding symbols in each to-be-processed image block are coded through a preset image block coding step, and an image block coding result of each to-be-processed image block is obtained, wherein the target coding symbols are the same element signs as the sign in the to-be-processed image block; and acquiring an image compression result corresponding to the image to be compressed according to the image block coding results of all the image blocks to be processed corresponding to the image to be compressed.
Compared with the scheme of image compression by using Huffman coding in the prior art, the method and the device do not need to count the probability distribution of the symbols in the image to be compressed, do not need to consume time for probability counting, and are beneficial to improving the efficiency of image compression. Meanwhile, the image compression is not directly performed on the whole image to be compressed, but the image to be compressed is divided into a plurality of small blocks, and only the number and the position of one element symbol (namely, a target coding symbol) in each image block to be processed are required to be coded and compressed, so that the effect of image compression is favorably improved. Meanwhile, after a plurality of to-be-processed image blocks corresponding to the to-be-compressed image are obtained, encoding is performed through a preset image block encoding step according to the block type and the sign of each to-be-processed image block to achieve image compression, time complexity during compression calculation is low, calculation difficulty is reduced, and image compression processing efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic flowchart of an image compression method based on binary block bidirectional coding according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of an image compression system based on bi-directional coding of binary blocks according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating an image decompression method according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of an image decompression system according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a to-be-processed image block according to an embodiment of the present invention;
fig. 6 is a schematic diagram of an image block to be processed according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a to-be-processed image block according to an embodiment of the present invention;
fig. 8 is a schematic diagram of a to-be-processed image block according to an embodiment of the present invention;
fig. 9 is a schematic diagram of a to-be-processed image block according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when 8230that is," or "once" or "in response to a determination" or "in response to a detection". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, but the present invention may be practiced in other ways than those specifically described and will be readily apparent to those of ordinary skill in the art without departing from the spirit of the present invention, and therefore the present invention is not limited to the specific embodiments disclosed below.
With the development of science and technology, the application of images is more and more extensive, and the number of images is also increasing rapidly, so in the processes of image storage, transmission and the like, image compression is required to reduce resources such as disk space required during image storage, bandwidth required during channel transmission and the like. Specifically, various imaging devices such as smart phones and digital cameras generate massive images, and with the rapid development of various applications of the internet of things, the growth rate of the images is also accelerated. The enormous number of images puts a great strain on image storage and transmission on image owners, so that the images must be compressed to represent one image with as few bits as possible.
The goal of image compression is to represent an image with the least number of bits without losing the basic information content therein, and compression techniques can be classified into lossless compression and lossy compression, wherein the lossy compression can sacrifice the accuracy of reconstructed images, and when the requirement on the accuracy of image reconstruction is high, lossless compression is generally used. Common lossless compression methods include huffman coding, arithmetic compression, run length coding, lossless predictive coding, and the like.
In the prior art, image compression is generally performed by adopting a Huffman coding mode. The problem in the prior art is that when image compression is performed by using huffman coding, statistics needs to be performed on symbols in the whole image and probability distribution needs to be determined, and then the whole image is directly compressed, so that time complexity is high during arithmetic compression, much time needs to be consumed, and efficiency and effect of image compression are not improved. Meanwhile, the run length code encodes the length of the continuous symbol from one end, and the compression ratio is lower when the length of the continuous symbol is smaller, which is not beneficial to improving the compression effect; lossless predictive coding requires a good predictor, has high requirements on the predictor, and is not beneficial to reducing the compression difficulty and improving the compression efficiency.
In order to solve at least one of the above problems, in the solution of the present invention, a plurality of to-be-processed image blocks corresponding to an image to be compressed are obtained, and a type determination threshold of each of the to-be-processed image blocks is obtained according to a size of each of the to-be-processed image blocks, where the to-be-processed image blocks are binary image blocks; acquiring a coding type judgment parameter of each to-be-processed image block according to a first symbol number and a second symbol number corresponding to each to-be-processed image block, wherein the first symbol number is the number of symbols 0 in the to-be-processed image block, and the second symbol number is the number of symbols 1 in the to-be-processed image block; determining the block type and the sign of each image block to be processed according to the size relationship between the coding type judgment parameter and the type judgment threshold of each image block to be processed, wherein the block type of one image block to be processed is one of a compressible type and an incompressible type; according to the block type and the sign symbol of each to-be-processed image block, the number and the position of a target coding symbol in each to-be-processed image block are coded through a preset image block coding step, and an image block coding result of each to-be-processed image block is obtained, wherein the target coding symbol is an element symbol which is the same as the sign symbol in the to-be-processed image block; and obtaining an image compression result corresponding to the image to be compressed according to the image block coding results of all the image blocks to be processed corresponding to the image to be compressed.
Compared with the scheme of image compression by using Huffman coding in the prior art, the method and the device do not need to count the probability distribution of the symbols in the image to be compressed, do not need to consume time for probability counting, and are beneficial to improving the efficiency of image compression. Meanwhile, in the invention, the image compression is not directly carried out on the whole image to be compressed, but the image to be compressed is divided into a plurality of small blocks, and the encoding compression is carried out only on the number and the position of one element symbol (namely, a target encoding symbol) in each image block to be processed respectively, which is beneficial to improving the effect of the image compression. Meanwhile, after a plurality of to-be-processed image blocks corresponding to the to-be-compressed image are obtained, encoding is performed through a preset image block encoding step according to the block type and the sign of each to-be-processed image block to achieve image compression, time complexity during compression calculation is low, calculation difficulty is reduced, and image compression processing efficiency is improved.
Specifically, in the scheme of the invention, when the image is coded during image compression, the image is directly partitioned according to the bit plane, the coding result is connected according to the block type to be the compression result, the probability distribution of known symbols is not needed, and the image compression efficiency is favorably improved. Meanwhile, the scheme of the invention can reduce the time complexity of compression, because the coding of the scheme is mainly carried out aiming at the position of the symbolic sign, only a small logarithm operation is needed, and the time complexity is favorably reduced compared with the arithmetic compression process.
Furthermore, the application range of the scheme of the invention is wider, when the run code compresses 0 and 1 bit strings, if 0 and 1 distribution is too disordered, the coding result is longer, even longer than the original length, and the compression effect is extremely poor. The scheme of the invention considers the original strings with the block level length and classifies whether the original strings are suitable for coding (classified into a compressible type and an incompressible type), thereby being beneficial to reducing additional unnecessary expenditure and improving the compression effect. It should be noted that, based on the solution of the present invention, an original image to be compressed (for example, the image to be compressed is used as a whole image block to be processed) may also be directly processed, and a predictor may be used to compress a prediction error, so that a good compression effect may also be achieved.
As shown in fig. 1, an embodiment of the present invention provides an image compression method based on binary block bidirectional coding, and specifically, the image compression method includes the following steps:
step S100, obtaining a plurality of to-be-processed image blocks corresponding to an image to be compressed, and obtaining a type judgment threshold of each to-be-processed image block according to the size of each to-be-processed image block, wherein each to-be-processed image block is a binary image block.
The image to be compressed is an image which needs to be compressed, the image blocks to be processed are obtained by dividing the image to be compressed into blocks, and the image blocks to be processed are not intersected with each other. In this embodiment, the image to be compressed is a binary image, and therefore, the image to be compressed is directly divided into mutually disjoint blocks of size S × S to obtain image blocks to be processed. In an application scenario, the image to be compressed may also be a grayscale image (e.g., an 8-bit grayscale image), and each bit plane may be coded according to a bit plane, and each bit plane is divided into to-be-processed blocks of S × S size. In this embodiment, an image to be compressed is taken as a binary image for example to be specifically described, but other images may also be converted into a binary image, and therefore, the present invention is not limited in particular.
Specifically, the obtaining a plurality of to-be-processed image blocks corresponding to an image to be compressed and obtaining a type determination threshold of each to-be-processed image block according to the size of each to-be-processed image block includes: acquiring an image to be compressed, dividing the image to be compressed and acquiring a plurality of image blocks to be processed with the same size; and obtaining the type judgment threshold corresponding to each image block to be processed through a preset threshold comparison table according to the size of each image block to be processed.
It should be noted that, in this embodiment, the size of each to-be-processed image block obtained by division is the same and is S × S, that is, each to-be-processed image block includes pixels in S rows and S columns, and a value (i.e., a numerical value symbol) at each pixel is 0 or 1.
Specifically, in this embodiment, the type determination threshold Na of each to-be-processed image block is determined according to the size sxs of each to-be-processed image block. It should be noted that, in this embodiment, the sizes of the to-be-processed image blocks are the same, and therefore the corresponding type determination thresholds are also the same. In an actual use process, the sizes of the to-be-processed image blocks may be different, for example, after the first division, a part of the image blocks is divided for the second time, because the encoding process in this embodiment is performed on the image blocks, the image blocks after the second division may be specifically encoded as smaller to-be-processed image blocks, and the specific process may still refer to the encoding process in this embodiment. Specifically, each to-be-processed image block obtained by division is a square image block.
In this embodiment, the type determination threshold Na is determined according to a preset threshold comparison table, where the block type threshold Na corresponding to the length (or width) S of each to-be-processed image block is stored in the threshold comparison table, for example, when the value of S is 4, 8, 16, 32, 64, 128, 256, and 512, the corresponding values of Na are 3, 9, 31, 102, 342, 1175, 4112, and 13604, respectively, and in an actual use process, when S takes another value, the corresponding value of Na may be pre-calculated and stored in the threshold comparison table so as to perform fast lookup, thereby improving image compression efficiency.
Step S200, obtaining a coding type decision parameter of each to-be-processed image block according to a first symbol number and a second symbol number corresponding to each to-be-processed image block, where the first symbol number is the number of symbols 0 in the to-be-processed image block, and the second symbol number is the number of symbols 1 in the to-be-processed image block.
Specifically, the encoding type determining parameter is a parameter used for comparing with the type determining threshold to determine the block type of each to-be-processed image block, the type determining threshold corresponding to each to-be-processed image block is the same, but the encoding type determining parameter z corresponding to each to-be-processed image block is determined according to the number of symbols 0 and 1 in each to-be-processed image block, and specifically, the encoding type determining parameter is the minimum value of the first number of symbols and the second number of symbols. In the present embodiment, z = min { n0, n1} will be described by taking the first symbol number as n0 and the second symbol number as n 1.
Step S300, determining a block type and a sign of each to-be-processed image block according to a size relationship between the encoding type determination parameter and the type determination threshold of each to-be-processed image block, where the block type of one to-be-processed image block is one of a compressible type and an incompressible type.
In this embodiment, the type determining threshold is a threshold for determining a block type of an image block to be processed, and the encoding type determining parameter is a parameter for comparing with the type determining threshold to determine a specific type of each image block to be processed.
Specifically, the determining the block type and the sign of each to-be-processed image block according to the size relationship between the coding type judgment parameter and the type judgment threshold of each to-be-processed image block includes: setting the block type of the to-be-processed image block with the coding type judgment parameter larger than the type judgment threshold value as an incompressible type, and setting the sign symbol of the to-be-processed image block to be absent; setting the block type of the image block to be processed with the coding type judgment parameter not greater than the type judgment threshold value as a compressible type, and setting the sign symbol of the image block to be processed as the symbol with less number in the image block to be processed.
Specifically, the sign symbol s may also be determined quickly by combining the first symbol number and the second symbol number, and when the block type of one to-be-processed image block is a compressible type, the sign symbol s of the to-be-processed image block is set to a symbol corresponding to a smaller one of n0 and n 1.
For example, for an image block to be processed, when z > Na, the block type of the corresponding image block to be processed is set to an incompressible type (which may be represented by type I), and the set flag s does not exist at this time. When z = n0 ≦ Na, the block type of the corresponding image block to be processed is set to the compressible type (which may be represented by type II), and the flag symbol s is set to 0 at this time. When z = n1 ≦ Na, the block type of the corresponding image block to be processed is set to the compressible type (which may be represented by type II), and the flag symbol s is set to 1 at this time. It should be noted that, during the encoding process, the above-mentioned sign s may be stored alone, or may be connected with a character string obtained by other encoding and stored as one bit (the last bit in this embodiment) in the image block encoding result. The flag symbol s is set to be absent, i.e. to represent that the corresponding storage bit is empty, or no additional 1 bit is required to store the flag symbol s (to further reduce the occupation of storage space).
When the symbolic sign s is used as the last bit in the image block coding result to be stored, the type of the block can be judged according to the first bit in the image block coding result in the decoding stage, the block is judged to be an I-type block, and the original block can be directly recovered according to the image block coding result; if the judgment result is the type II block, after the specific position of each target coding symbol (namely the same element as s in the original block) is decoded, the last bit of the coding result of the image block is read to obtain the sign symbol, so that the original block is obtained by decoding and recovering.
The sign s may be a value of another bit in the image encoding result, and is not particularly limited herein. For example, for class II blocks, the signpost s may also be the 2 nd bit in the image coding result.
Step S400, according to the block type and the sign of each to-be-processed image block, encoding the number and the position of a target encoding symbol in each to-be-processed image block through a preset image block encoding step, and obtaining an image block encoding result of each to-be-processed image block, where the target encoding symbol is an element symbol in the to-be-processed image block that is the same as the sign.
The preset image block encoding step is a preset step for encoding the number of target encoding symbols in each to-be-processed image block and the position of the target encoding symbol, where the target encoding symbol is an element symbol in the to-be-processed image block that is the same as the sign symbol, that is, a symbol with a smaller number ratio in the to-be-processed image block. For example, when the logo symbol of an image block to be processed is 1, the preset image block encoding step is a step of encoding the number of all symbols 1 and the positions where all symbols 1 appear in the image block to be processed.
The target encoding symbol (for example, symbol 1) is a symbol with fewer occurrences in the image block to be processed, so that the amount of calculation and the time complexity when encoding the number and the position of the target encoding symbol are small, which is beneficial to improving the image compression efficiency, and the character string after final encoding can be made shorter, which is beneficial to improving the compression rate. And accurate image restoration can be performed after the number and the position of each target coding symbol are decoded, namely lossless compression and decompression can be realized.
In this embodiment, for any one of the to-be-processed image blocks, the preset image block encoding step includes:
when the block type of the image block to be processed is an incompressible type, splicing a first type symbol and an image block character string of the image block to be processed to obtain an encoding result of the image block to be processed, wherein the first type symbol is symbol 1, and the image block character string is a binary string obtained by scanning the image block to be processed in a raster scanning manner;
when the block type of the image block to be processed is a compressible type, judging parameters according to the coding type of the image block to be processed to obtain a parameter coding string of the image block to be processed, obtaining a symbol coding string of the image block to be processed according to the position of each target coding symbol in the character string of the image block to be processed, splicing a second type symbol, the parameter coding string of the image block to be processed, the symbol coding string of the image block to be processed and a sign symbol of the image block to be processed to serve as a coding result of the image block to be processed, wherein the second type symbol is symbol 0, and the parameter coding string and the symbol coding string are binary strings.
It should be noted that the parameter coding string is used to record the number of the symbols (i.e., the target coding symbol, that is, the same element symbol as the sign symbol s) that occupy a smaller area in the image block to be processed, and the symbol coding string is used to record the position of the symbol that occupies a smaller area in the image block to be processed. During encoding, the positions of the target encoding symbols can be restored according to the two codes, so that lossless decompression is realized.
Specifically, in this embodiment, the obtaining of the symbol code string of the to-be-processed image block with the block type being a compressible type by sequentially connecting a plurality of symbol code substrings, where the number of the symbol code substrings is equal to the code type determination parameter of the to-be-processed image block, and the obtaining of the symbol code string of the to-be-processed image block according to the position of each target code symbol in the image block character string of the to-be-processed image block includes:
sequentially making i =1,2, \ 8230;, z, respectively executing the following steps to obtain each symbol coding sub-string so as to connect to obtain the symbol coding string:
when i is an odd number, acquiring an ith code character string and the length Len of the ith code character string, traversing the ith code character string from left to right until acquiring the position number of a first target code symbol counted from left to right in the ith code character string
Figure 204278DEST_PATH_IMAGE001
Calculating to obtain target digit according to target digit calculation formula
Figure 376633DEST_PATH_IMAGE002
Binary coding the target digit to obtain the ith symbol code sub-string, and deleting the first symbol from left to right in the ith code sub-string
Figure 596918DEST_PATH_IMAGE001
The symbols are used as the (i + 1) th coding character string;
when i is an even number, acquiring an ith code character string and the length Len of the ith code character string, traversing the ith code character string from right to left until acquiring the position number of a first target code symbol counted from right to left in the ith code character string
Figure 803908DEST_PATH_IMAGE001
Calculating to obtain target digit according to the target digit calculation formula, and comparing
Figure 714095DEST_PATH_IMAGE002
Binary coding the target digit to obtain the ith symbol code sub-string, and deleting the first part from right to left in the ith code sub-string
Figure 373747DEST_PATH_IMAGE001
The symbols are used as the (i + 1) th coding character string;
wherein, the 1 st encoding character string is the image block character string of the image block to be processed, z is the above encoding type judgment parameter, and the above position number
Figure 394793DEST_PATH_IMAGE001
The target digit is determined by the number of symbols passing through during traversal, and the target digit calculation formula is as follows:
Figure 190710DEST_PATH_IMAGE003
Figure 271799DEST_PATH_IMAGE004
is the target number of bits described above.
Specifically, in this embodiment, the encoding result of one to-be-processed image block is represented by BC, and when the to-be-processed image block is an incompressible type, BC =1| | Str, where the symbol | | | represents bit connection, and Str represents the image block character string of the to-be-processed image block (i.e., a binary string obtained by scanning the to-be-processed image block in a raster manner). Note that, at this time, the sign symbol s does not exist, so the encoding result BC is composed of only the first type symbol (i.e., symbol 1) and the image block character string by concatenation.
On the contrary, when the to-be-processed image block is of a compressible type, the sign symbol s is used to indicate a symbol with a small occurrence frequency in the image block character string Str of the to-be-processed image block, and the encoding result BC =0| | | BN | | | BD | | s of the to-be-processed image block, it should be noted that s may also be stored alone without being part of BC, which is not specifically limited herein.
Where BN is a parameter encoding string (a binary string) for indicating the value of the block type judgment parameter z (i.e., the number of symbols which appear less frequently in Str, which is a decimal number). For example, when the length S =4 of the to-be-processed image block and the type decision threshold Na =3, for the compressible type to-be-processed image block, z may all take values of 0, 1,2, and 3, and convert the values into binary parameter code strings, which may be represented by 0, 10, 110, and 111, respectively.
In an application scenario, a specified length may be preset for storing the parameter encoding string, so as to more conveniently know which part is the parameter encoding string. In this embodiment, the length of the parameter encoding string is not limited, and the value of z is represented by using the variable-length parameter encoding string, which is beneficial to further reducing the occupation of the storage space and improving the compression rate. Specifically, in an application scenario, the correspondence between the value of z and the parameter coding string BN may be preset and stored in a table. In this embodiment, after determining a possible z value according to Na, all possible values of BN may be set according to variable-length Huffman coding, and a corresponding parameter coding string BN may be determined according to an actual z value. Meanwhile, for a Na value, the probability of the occurrence of a smaller value of z is higher, so that the length of the parameter coding string BN corresponding to the smaller value of z is shorter. And because Huffman coding is prefix code, the starting point of the parameter coding string can be conveniently determined by combining the preset corresponding relation table of the block type judgment parameter and the parameter coding string in the decoding process, thereby realizing decoding. Alternatively, in another application scenario, the length of the BN may be additionally stored to achieve fast decoding, and is not limited in this respect.
BD is the symbol encoding string of the image block to be processed, which records the positions where all target encoding symbols appear in Str. When z =0, there is no BD (because the number of target encoding symbols is 0, there is no position). BD can be considered to be absent at this time because the position of the target encoding symbol does not need to be recorded and the length of Str is determined, all symbols therein are the same symbols at this time, and all symbols therein can be directly recovered at the time of decoding. On the contrary, when z ≠ 0, it indicates that there are z target code symbols in total in Str, and z calculations can be performed to find the positions of all the target code symbols and perform position coding.
Specifically, when z ≠ 0, i =1,2, \8230;, z may be sequentially encoded according to the following steps:
when i is an odd number, the first target coding symbol at the left end of the ith coding character string is coded, the length Len of the current ith coding character string is obtained, and then the position number of the first target coding symbol in the ith coding character string is obtained by traversing from left to right
Figure 418746DEST_PATH_IMAGE001
(is a decimal value indicating that the target code symbol is at the ith symbol position in the ith code string) because
Figure 243483DEST_PATH_IMAGE001
∈[1,Len-(z-i)]So that the formula can be calculated according to the target digit
Figure 159486DEST_PATH_IMAGE003
The target digit is obtained through calculation, and the compression rate can be further improved by using the variable target digit. Wherein the target number of bits may be sufficient to encode
Figure 145897DEST_PATH_IMAGE001
The shortest number of bits. In particular, the representation is represented using a binary of the target digit
Figure 780140DEST_PATH_IMAGE002
To obtain the ith symbol code sub-string
Figure 142989DEST_PATH_IMAGE010
. Then deleting the first coded string from left to right in the ith coded string
Figure 179078DEST_PATH_IMAGE001
The element symbols are used as the (i + 1) th encoding character string, so that the corresponding encoding character string is continuously deleted along with the increase of i, and the compression rate and the compression efficiency can be further improved.
When i is an even number, positions are encoded from right to left. Specifically, a first target coding symbol at the right end of the ith coding character string is coded, the length Len of the current ith coding character string is obtained, and then the position number of the first target coding symbol in the ith coding character string is obtained by traversing from right to left
Figure 336390DEST_PATH_IMAGE001
Calculating a formula according to the target digit
Figure 457929DEST_PATH_IMAGE003
To calculate a target digit, using the binary representation of the target digit
Figure 624469DEST_PATH_IMAGE002
To obtain the ith symbol code sub-string
Figure 249485DEST_PATH_IMAGE010
. Then deleting the ith code wordBefore the string from right to left
Figure 843277DEST_PATH_IMAGE001
The element symbols are combined to form the i +1 th encoding character string.
In this embodiment, a bidirectional encoding mode is used, that is, when i is an odd number and an even number, the encoding directions are different, so that the encoded character string can be deleted more quickly, and the encoded character string can be deleted more quickly
Figure 186534DEST_PATH_IMAGE004
Smaller, and thus, the compression ratio is improved.
Based on the steps, a plurality of symbol code substrings are obtained
Figure 156764DEST_PATH_IMAGE011
Figure 901866DEST_PATH_IMAGE012
,…,
Figure 666560DEST_PATH_IMAGE013
And connecting to obtain the symbol coding string BD of the image block to be processed.
In an application scenario, when x target code symbols are uniformly distributed in a binary block with size of sxs, the code symbols can be obtained by calculation according to the following formula (1)
Figure 497113DEST_PATH_IMAGE010
Binary digit of
Figure 5454DEST_PATH_IMAGE004
The value of (c):
Figure 605063DEST_PATH_IMAGE014
the uniform distribution means that each (S × S)/x middle position in the image block character string Str with the length of S × S corresponding to the binary block has one target coding symbol.
It should be noted that the type determination threshold Na in this embodiment is obtained by looking up a threshold comparison table, and in an application scenario, the corresponding relationship between S and Na may be obtained and stored in advance according to the following principle.
Specifically, if x target code symbols are uniformly distributed in an S × S block, the number of bits required for the position of each target code symbol can be known according to the formula (1), and the length of the corresponding code result BC when an image block to be processed is regarded as a compressible type should not be greater than the length of the corresponding code result BC when the image block is regarded as an incompressible type (otherwise, invalid compression is performed, but the occupied space is increased), so in the calculation of Na, the code lengths under two conditions that one block is regarded as a compressible type and an incompressible type need to be comprehensively considered to determine the critical value of the determination (i.e., the type determination threshold Na).
Specifically, in the pre-calculation process, an assumed uniformly distributed binary block is taken into consideration as a class I block and a class II block, and the maximum x, i.e., na value, is determined according to the following formula (2):
Figure 540658DEST_PATH_IMAGE015
wherein the content of the first and second substances,
Figure 858507DEST_PATH_IMAGE016
specifically, x bits are required at most to represent the value x, so the Na values corresponding to S can be obtained by calculation according to the above formula (2), for example, when S is 4, 8, 16, 32, 64, 128, 256, and 512, the Na values corresponding to S are 3, 9, 31, 102, 342, 1175, 4112, and 13604, respectively. Thus, assuming that x target code symbols are uniformly distributed in a block and the block satisfies the condition "there is a greater compression rate as a class II block", the maximum x value satisfying the condition is taken as the Na value, and correspondingly, a block with z ≦ Na is better considered as a class II block, and z ≦ Na>Na should be a class I block.
And step S500, acquiring an image compression result corresponding to the image to be compressed according to the image block coding results of all the image blocks to be processed corresponding to the image to be compressed.
Specifically, after the image block coding results of each to-be-processed image block are obtained, all the image block coding results can be spliced into a binary character string according to the sequence of image block division and used as the image compression result corresponding to the to-be-compressed image, so that image compression is realized. And all the image block coding results can be directly stored and then directly used as image compression results corresponding to the image to be compressed, splicing is not needed, and decoding and restoring are facilitated.
Therefore, in the embodiment, the probability distribution of the symbols in the image to be compressed does not need to be counted, the probability counting does not need to be performed with time, and the efficiency of image compression is favorably improved. Meanwhile, the image compression is not directly performed on the whole image to be compressed, but the image to be compressed is divided into a plurality of small blocks, and only the number and the position of one element symbol (namely, a target coding symbol) in each image block to be processed are required to be coded and compressed, so that the effect of image compression is favorably improved. Meanwhile, after a plurality of to-be-processed image blocks corresponding to the to-be-compressed image are obtained, encoding is performed through a preset image block encoding step according to the block type and the sign of each to-be-processed image block to achieve image compression, time complexity during compression calculation is low, calculation difficulty is reduced, and image compression processing efficiency is improved.
As shown in fig. 2, in correspondence to the image compression method based on bidirectional encoding of binary blocks, an embodiment of the present invention further provides an image compression system based on bidirectional encoding of binary blocks, where the image compression system based on bidirectional encoding of binary blocks includes:
the image block processing module 610 is configured to obtain a plurality of to-be-processed image blocks corresponding to an image to be compressed, and obtain a type determination threshold of each to-be-processed image block according to a size of each to-be-processed image block, where the to-be-processed image block is a binary image block;
a parameter obtaining module 620, configured to obtain a coding type determining parameter of each to-be-processed image block according to a first symbol number and a second symbol number corresponding to each to-be-processed image block, where the first symbol number is the number of symbols 0 in the to-be-processed image block, and the second symbol number is the number of symbols 1 in the to-be-processed image block;
a block type determining module 630, configured to determine a block type and a sign of each to-be-processed image block according to a size relationship between a coding type determination parameter and a type determination threshold of each to-be-processed image block, where a block type of one to-be-processed image block is one of a compressible type and an incompressible type;
the encoding module 640 is configured to encode, according to the block type and the sign of each to-be-processed image block, the number and the position of a target encoding symbol in each to-be-processed image block through a preset image block encoding step, and obtain an image block encoding result of each to-be-processed image block, where the target encoding symbol is an element symbol in the to-be-processed image block that is the same as the sign;
the compression result obtaining module 650 is configured to obtain an image compression result corresponding to the image to be compressed according to the image block encoding results of all the image blocks to be processed corresponding to the image to be compressed.
Specifically, in this embodiment, the specific functions of the image compression system based on the binary block bidirectional coding and the modules thereof may refer to the corresponding descriptions in the image compression method based on the binary block bidirectional coding, and are not described herein again.
The division method of each block of the image compression system based on the binary block bidirectional coding is not unique, and is not particularly limited herein.
As shown in fig. 3, corresponding to the image compression method based on binary block bidirectional coding, an embodiment of the present invention further provides an image decompression method for decompressing an image compression result compressed according to the image compression method based on binary block bidirectional coding and implementing image restoration. Specifically, in this embodiment, the image decompression method is implemented based on binary block decoding, and the image decompression method includes the following steps:
step A100, obtaining an image compression result corresponding to an image to be decompressed.
The image compression result obtained in step a100 is a result obtained by compressing according to any one of the image compression methods.
And step A200, acquiring an image block coding result corresponding to each image block to be decoded according to the image compression result, and acquiring the size of each image block to be decoded.
And one image block coding result is an image block coding result corresponding to one to-be-processed image block when image compression is performed according to any one of the image compression methods. It should be noted that, when the image block coding results are spliced in the image compression process, the length of each image block coding result may be recorded, so as to perform restoration in the image decompression process. The size of the image block to be decoded is the same as that of each image block to be processed in the image compression process, namely S multiplied by S, and the corresponding size can also be stored in advance in the image compression process. Specifically, when the length of the coding result of each block is not recorded, the coding results of all blocks are connected, and the image blocks can be restored in sequence, and when the length of the coding result of each block is recorded, the coding result of each block can be obtained more directly, but extra bits (i.e., storage space) are needed to store the corresponding length, and if the block is small, the extra bits are needed to be large, which is not beneficial to saving space. Therefore, in the actual use process, whether to store the length of each block of the encoding result may be determined according to actual requirements, and is not specifically limited herein.
Step a300, obtaining a block type of each to-be-decoded image block according to a type symbol value in each image block encoding result, where the type symbol value is a value of a first bit in the image block encoding result, and a block type of one to-be-decoded image block is one of a compressible type and an incompressible type.
Specifically, the type symbol value is the first bit in the encoding result of each image block, and its value may be 0 or 1, where when the type symbol value is 0, the corresponding block type is a compressible type, and when the type symbol value is 1, the corresponding block type is an incompressible type.
Step A400, decoding the number and the position of target decoding symbols corresponding to each to-be-decoded image block through a preset image block decoding step according to the size, the block type and the image block encoding result of each to-be-decoded image block, and obtaining the image block decoding result of each to-be-decoded image block, wherein the target decoding symbols are element symbols in the image block decoding result, and the element symbols are the same as the sign symbols of each to-be-decoded image block.
The image block decoding step is a decoding process corresponding to the image block encoding step in the image compression process, and is used for decoding the image block encoding result to obtain an image block decoding result, wherein the image block decoding result is equivalent to a binary image block obtained by restoring an image block character string Str of the image block to be processed in a raster scanning manner.
Specifically, for any one of the image blocks to be decoded, the preset image block decoding step includes:
when the block type of the image block to be decoded is an incompressible type, deleting a first bit of an image block encoding result of the image block to be decoded as a target decoding character string (which is equivalent to an image block character string Str of the image block to be processed in an image compression process) of the image block to be decoded, placing the target decoding character string according to the size of the image block to be decoded in a raster scanning manner, and obtaining an image block decoding result of the image block to be decoded;
when the block type of the image block to be decoded is a compressible type, the last bit of the encoding result of the image block is used as a sign symbol (equivalent to the sign symbol s in the compression process) of the image block to be decoded, and a parameter encoding string (equivalent to the sign symbol s in the compression process) in the encoding result of the image block to be decoded is obtainedBN), obtaining decoding type judgment parameters (using) of the image blocks to be decoded according to the parameter coding strings
Figure 904960DEST_PATH_IMAGE005
Representing the z) in the compression process, obtaining a character string to be decoded (equivalent to a BD in the compression process) according to the encoding result of the image block, decoding the character string to be decoded according to the logo and the decoding type judgment parameter of the image block to be decoded to obtain a target decoding character string of the image block to be decoded, placing the target decoding character string according to the size of the image block to be decoded in a raster scanning manner, and obtaining the image block decoding result of the image block to be decoded, wherein the character string to be decoded is a character string obtained after deleting the first bit, the last bit and the parameter encoding string from the encoding result of the image block.
It should be noted that the parameter encoding string may be marked in advance during the compression process to find its corresponding position. In this embodiment, because the parameter encoding string is a character string encoded by prefixes with different prefixes, the length of the parameter encoding string can be determined by directly looking up a table during traversal, and the corresponding parameter encoding string can be obtained.
Specifically, the decoding the character string to be decoded according to the logo and the decoding type determination parameter of the image block to be decoded to obtain the target decoding character string of the image block to be decoded includes:
setting an initial decoding character string according to the flag symbol, wherein when the flag symbol is 0, the initial decoding character string is a character string with a length of S × S and each element is 1, when the flag symbol is 1, the initial decoding character string is a character string with a length of S × S and each element is 0, and S × S is equal to the size of the image block to be decoded;
when in use
Figure 624654DEST_PATH_IMAGE005
If =0, the initial decoding character string is used as the target decoding character string of the image block to be decoded, wherein,
Figure 731151DEST_PATH_IMAGE005
judging parameters of the decoding type of the image block to be decoded;
when in use
Figure 536296DEST_PATH_IMAGE005
Not equal to 0, setting the first calculated value rl =1, setting the second calculated value rh = S × S, sequentially making j =1,2, \\ 8230,
Figure 406948DEST_PATH_IMAGE005
executing the following steps to update the initial decoding character string and obtain a target decoding character string of the image block to be decoded: obtaining the j-th character string and calculating the target length
Figure 981149DEST_PATH_IMAGE006
= rh-rl +1; calculating the jth decoded bit number
Figure 258546DEST_PATH_IMAGE007
(ii) a According to the 1 st bit in the j character string
Figure 285408DEST_PATH_IMAGE008
The sign of the bit is used to obtain the jth binary string and the 1 st bit to the 1 st bit of the jth character string
Figure 939243DEST_PATH_IMAGE008
Obtaining a j +1 th character string after deleting the symbol of the bit; converting the jth binary string into a decimal to obtain a jth number
Figure 367951DEST_PATH_IMAGE009
(ii) a When j is odd number, updating in sequence
Figure 816249DEST_PATH_IMAGE009
=rl+
Figure 595987DEST_PATH_IMAGE017
、rl=
Figure 787934DEST_PATH_IMAGE009
+1, when j is even number, updating in turn
Figure 71147DEST_PATH_IMAGE009
=rh-
Figure 955927DEST_PATH_IMAGE009
、rh=
Figure 957381DEST_PATH_IMAGE009
-1; the first character string from left to right
Figure 953019DEST_PATH_IMAGE009
Updating each element to the mark symbol; wherein, the 1 st character string is the character string to be decoded of the image block to be decoded.
Specifically, in this embodiment, in the process of decoding the image block to be decoded, the type of the image block to be decoded is determined according to the first bit in the encoding result of the image block, and if the type is an incompressible type, the target decoding character string is directly obtained and placed back into the block in a raster scanning manner, so that decoding can be completed. Wherein, the target decoding character string is from 2 nd bit to S × S +1 st bit in the image block coding result.
On the contrary, if the type is compressible, a character string (i.e. an initial decoding character string) is initialized for storing intermediate results in the decoding process and finally obtaining a decoded character string. When the flag symbol is 0, the initial decoding character string is a character string having a length of sxs and each element is 1, and when the flag symbol is 1, the initial decoding character string is a character string having a length of sxs and each element is 0, and sxs is equal to the size of the image block to be decoded.
Specifically, the decoding parameter code string obtains a decoding type judgment parameter
Figure 90739DEST_PATH_IMAGE005
When is coming into contact with
Figure 146420DEST_PATH_IMAGE005
If =0, directly using the initial decoding character string as the target decoding character string of the image block to be decoded, if yes
Figure 635170DEST_PATH_IMAGE005
When not equal to 0, decoding BD to obtain
Figure 168919DEST_PATH_IMAGE005
And the lossless decoding can be realized according to the position of the target decoding symbol. It should be noted that, for the same image block, in the encoding and decoding processes, z = c =
Figure 426725DEST_PATH_IMAGE005
Further, a decoding type judgment parameter is obtained from the decoding parameter coding string
Figure 653307DEST_PATH_IMAGE005
If Na =3 is compressed, and z is only 0, 1,2, or 3, the BN is 0, 10, 110, or 111, and the BN starts from the second bit of the BC, so that decoding can be performed by traversing from the second bit of the BC to the right to determine the BC and finally obtain the type judgment parameter
Figure 363774DEST_PATH_IMAGE005
In particular, type judgment parameters
Figure 701215DEST_PATH_IMAGE005
Is the minimum value between the number of consecutive 1 s traversing rightward from the second bit of BC and Na.
Deleting the first bit, the last bit and the part of the BN in the BC to obtain the character string to be decoded. In that
Figure 79107DEST_PATH_IMAGE005
When the value is not equal to 0, the decoding is required to obtain the position of each target decoding symbol (corresponding to the target coding symbol during the encoding) so as to complete the decoding.
In an application fieldIn the scene, decoding obtains the decimal position number of each target decoding symbol
Figure 211011DEST_PATH_IMAGE009
. Specifically, the initial decoding character string of the image block to be decoded can be set as
Figure 674353DEST_PATH_IMAGE018
Initialisation rl =1, rh = S × S, rl and rh being used to simulate that in the encoding process, currently
Figure 549905DEST_PATH_IMAGE018
Subscripts to the left and right ends of (a). Let j =1,2, \8230,
Figure 782303DEST_PATH_IMAGE005
executing the following steps to update the initial decoding character string and finally obtain the target decoding character string of the image block to be decoded: calculating a target length
Figure 85109DEST_PATH_IMAGE006
= rh-rl +1; calculating the jth decoded bit number
Figure 35747DEST_PATH_IMAGE007
Is provided with
Figure 714990DEST_PATH_IMAGE019
=BC[1:
Figure 801895DEST_PATH_IMAGE008
]Update BC = BC [ solution ] of
Figure 541181DEST_PATH_IMAGE008
+1:end](ii) a Will be provided with
Figure 713536DEST_PATH_IMAGE019
Conversion to decimal system to obtain
Figure 933820DEST_PATH_IMAGE009
(ii) a When j is odd number, updating in sequence
Figure 140811DEST_PATH_IMAGE009
=rl+
Figure 785419DEST_PATH_IMAGE009
、rl=
Figure 241808DEST_PATH_IMAGE009
+1, when j is even number, updating in turn
Figure 200537DEST_PATH_IMAGE009
=rh-
Figure 324351DEST_PATH_IMAGE009
、rh=
Figure 343122DEST_PATH_IMAGE009
-1; will be provided with
Figure 552387DEST_PATH_IMAGE018
From left to right as the first
Figure 49227DEST_PATH_IMAGE009
Each element is updated to a corresponding flag symbol (i.e., a target decoding symbol). Wherein, obtained
Figure 27547DEST_PATH_IMAGE009
Is a subscript representing the location, based on the parity and current of j
Figure 217220DEST_PATH_IMAGE018
The left and right end indices of (a) can recover the position of the corresponding jth target decoded symbol in the original Str.
And A500, obtaining a target decompressed image according to all the image block decoding results corresponding to the image to be decompressed.
Specifically, the decoding results of all the image blocks are restored according to the partitioning manner during the partitioning, so that the corresponding target decompressed image can be obtained.
As shown in fig. 4, in correspondence to the image decompression method, an embodiment of the present invention further provides an image decompression system, where the image decompression system includes:
an image compression result obtaining module 710, configured to obtain an image compression result corresponding to an image to be decompressed;
the image compression result processing module 720 is configured to obtain an image block encoding result corresponding to each to-be-decoded image block according to the image compression result, and obtain the size of each to-be-decoded image block;
an image block encoding result processing module 730, configured to obtain a block type of each to-be-decoded image block according to a type symbol value in each image block encoding result, where the type symbol value is a value of a first bit in the image block encoding result, and a block type of one to-be-decoded image block is one of a compressible type and an incompressible type;
a decoding module 740, configured to decode, according to the size, the block type, and the image block encoding result of each to-be-decoded image block, the number and the position of a target decoding symbol corresponding to each to-be-decoded image block through a preset image block decoding step, and obtain an image block decoding result of each to-be-decoded image block, where the target decoding symbol is an element symbol in the image block decoding result that is the same as a sign symbol of the to-be-decoded image block;
and the image decompression module 750 is configured to obtain a target decompressed image according to all the image block decoding results corresponding to the to-be-decompressed image.
In this embodiment, the image compression method and the image decompression method are further specifically described based on an image compression and decompression process in a specific application scenario, and fig. 5, fig. 6, fig. 7, fig. 8, and fig. 9 are schematic diagrams of 5 to-be-processed image blocks provided in the embodiment of the present invention, respectively, where gray squares represent a symbol 0, white squares represent a symbol 1, and S =4,na =3 corresponding to the to-be-processed image blocks in fig. 5 to fig. 9.
When image compression is performed, each to-be-processed image block is encoded, specifically, a type determination threshold Na (3 in this embodiment) is determined according to the size S × S of the to-be-processed image block, and a block type determination parameter z is determined according to the number of 0S and 1S in the to-be-processed image block, so that the type and sign of the block are determined, and encoding is implemented.
Specifically, for fig. 5 described above, s =4, na =3, n0=12, n1=4, z = min { n0, n1} = n1=4 is calculated. It can be seen that z is greater than Na, so that the image block to be processed is an incompressible block and there is no sign symbol s, and the image block encoding result BC =1| | Str =10001100000100100 corresponding to the image block to be processed.
For the above fig. 6, s =4, na =3, n0=0, n1=16, z = min { n0, n1} = n0=0 is calculated. It can be seen that z = n0 ≦ Na, which is a compressible type of block, and the flag symbol s is 0, since z =0, the corresponding image block encoding result BC =0| | | BN =00, where s can be stored separately.
For the above fig. 7, the steps may refer to the above fig. 6, and the image block encoding result BC =0| | BN =00, s is 1.
For the above fig. 8, s =4, na =3, n0=13, n1=3, z = min { n0, n1} = n1=3 is calculated. It can be seen that z = n1 ≦ Na, is a compressible type of block, and the notation s is 1, BN =111, bd = is known from z =3
Figure 913781DEST_PATH_IMAGE020
||
Figure 214312DEST_PATH_IMAGE021
||
Figure 781560DEST_PATH_IMAGE022
. Calculating out
Figure 204451DEST_PATH_IMAGE020
When i =1, encoding starts from the left. Str =0000000000110100, length Len =16,
Figure 325990DEST_PATH_IMAGE023
=11, use
Figure 226950DEST_PATH_IMAGE024
=4 bit representation
Figure 117546DEST_PATH_IMAGE025
-1, obtainingTo
Figure 711338DEST_PATH_IMAGE020
=1010, update Str =10100. Calculating out
Figure 54595DEST_PATH_IMAGE012
When i =2, encoding starts from the right. Str =10100, length Len =5,
Figure 24825DEST_PATH_IMAGE026
=3, use
Figure 769927DEST_PATH_IMAGE027
=2 bit representation
Figure 534621DEST_PATH_IMAGE028
-1, obtaining
Figure 161911DEST_PATH_IMAGE012
=10, update Str =10. Computing
Figure 342357DEST_PATH_IMAGE029
When i =3, encoding starts from the left. Str =10, length Len =2,
Figure 269862DEST_PATH_IMAGE030
=1, use
Figure 143140DEST_PATH_IMAGE031
=1 bit representation
Figure 523305DEST_PATH_IMAGE030
-1=0, to yield
Figure 507442DEST_PATH_IMAGE029
=0. BD =, therefore
Figure 286524DEST_PATH_IMAGE011
||
Figure 127441DEST_PATH_IMAGE012
||
Figure 932586DEST_PATH_IMAGE029
=1010100. The image block coding result BC =0| | | BN | | | BD =01111010100 is obtained, and the sign s =1.
For the above fig. 9, s =4, na =3, n0=2, n1=14, z = min { n0, n1} = n0=2 is calculated. It can be seen that z = n0 ≦ Na, is a compressible type of block, and the notation s is 0, and from z =2, BN =110, bd =
Figure 782730DEST_PATH_IMAGE011
||
Figure 356931DEST_PATH_IMAGE012
. Computing
Figure 634328DEST_PATH_IMAGE011
When i =1, encoding starts from the left. Str =1111111101111011, length Len =16,
Figure 661190DEST_PATH_IMAGE023
=9, use
Figure 315025DEST_PATH_IMAGE024
=4 bit representation
Figure 743733DEST_PATH_IMAGE032
To obtain
Figure 192032DEST_PATH_IMAGE033
(ii) a Update Str =1111011. Computing
Figure 971769DEST_PATH_IMAGE012
When i =2, encoding starts from the right. Str =1111011, length Len =7,
Figure 163716DEST_PATH_IMAGE026
=3, use
Figure 243667DEST_PATH_IMAGE027
=3 bit representation
Figure 66130DEST_PATH_IMAGE026
-1, obtaining
Figure 129901DEST_PATH_IMAGE012
=010. Hence BD =
Figure 797642DEST_PATH_IMAGE011
||
Figure 263259DEST_PATH_IMAGE012
=1000010, the obtained image block encoding result BC =0| | BN | | | BD =01101000010, and the sign s =0.
For the image decompression method in this embodiment, when decoding an image block to be decoded, the type of the image block to be decoded is determined for the first bit in the image block encoding result BC, and if the block is an incompressible block, the block can be directly decoded and placed back into the block in a raster scanning manner of the block. If the block is compressible, an initial decoding string is initialized for decoding, and the initial decoding string is decoded
Figure 256622DEST_PATH_IMAGE005
And after the position of each target decoding symbol is recovered in a lossless mode, obtaining a corresponding target decoding character string, and then putting back the target decoding character string in a raster scanning mode.
Specifically, when decoding the encoding result of fig. 8, the recovery condition is: it is known that S =4 corresponding to the block size, corresponding to the threshold Na =3, the image block coding result BC =01111010100, and the symbol S =1. According to BC [0 ] when decoding]If the block is compressible, initializing the initial decoding string
Figure 542110DEST_PATH_IMAGE018
= 000000000000. When decoding BN, from BC [2 ]]Begin traversing to the right, number of consecutive 1 s (including BC 2]) Is 4, so
Figure 279122DEST_PATH_IMAGE005
Min {4, na } =3, update BC =1010100 (i.e. character string to be decoded). By
Figure 599245DEST_PATH_IMAGE005
=3 know that decoding the updated BC may result in 3 positions, i.e.
Figure 497931DEST_PATH_IMAGE023
Figure 270715DEST_PATH_IMAGE026
Figure 608155DEST_PATH_IMAGE030
. Specifically, rl =1,rh = S × S =16 is initialized.
Computing
Figure 720468DEST_PATH_IMAGE023
J =1,rl =1,rh =16;
Figure 117951DEST_PATH_IMAGE006
=rh-rl+1=16;
Figure 315714DEST_PATH_IMAGE024
=4; BC =1010100, so
Figure 456846DEST_PATH_IMAGE011
=BC[1:
Figure 689244DEST_PATH_IMAGE034
]=1010, update BC = BC [ ([ solution ] ])
Figure 729400DEST_PATH_IMAGE034
+1:end]=100; will be provided with
Figure 742355DEST_PATH_IMAGE011
Conversion to decimal system to obtain
Figure 359281DEST_PATH_IMAGE023
=10; since j =1 is odd, update
Figure 508503DEST_PATH_IMAGE023
=rl+
Figure 919892DEST_PATH_IMAGE023
=11, update rl =
Figure 154565DEST_PATH_IMAGE023
+1=12, set
Figure 575182DEST_PATH_IMAGE018
[11]=1, obtained
Figure 578910DEST_PATH_IMAGE018
=0000000000100000。
Calculating out
Figure 426780DEST_PATH_IMAGE026
J =2,rl =12,rh =16;
Figure 148748DEST_PATH_IMAGE006
=rh-rl+1=5;
Figure 904215DEST_PATH_IMAGE027
=2; BC =100, so
Figure 965712DEST_PATH_IMAGE012
=BC[1:
Figure 46800DEST_PATH_IMAGE035
]=10, update BC = BC [ ([ solution ] ])
Figure 928169DEST_PATH_IMAGE035
+1:end]=0; will be provided with
Figure 752905DEST_PATH_IMAGE012
Conversion to decimal system to obtain
Figure 668909DEST_PATH_IMAGE026
=2; since j =2 is an even number, update
Figure 920898DEST_PATH_IMAGE026
=rh-
Figure 555142DEST_PATH_IMAGE026
=14, update rh =
Figure 917990DEST_PATH_IMAGE026
-1=13, set
Figure 485238DEST_PATH_IMAGE018
[14]=1, obtained
Figure 845812DEST_PATH_IMAGE018
=0000000000100100。
Computing
Figure 764089DEST_PATH_IMAGE030
J =3,rl =12,rh =13;
Figure 868312DEST_PATH_IMAGE006
=rh-rl+1=2;
Figure 821224DEST_PATH_IMAGE031
=1; BC =0, so
Figure 352700DEST_PATH_IMAGE029
=BC[1:
Figure 758273DEST_PATH_IMAGE036
]=0, will
Figure 400607DEST_PATH_IMAGE029
Converted to decimal system to obtain
Figure 208026DEST_PATH_IMAGE030
=0; since j =3 is odd, update
Figure 910403DEST_PATH_IMAGE030
=rl+
Figure 800343DEST_PATH_IMAGE030
=12, update rl =
Figure 246368DEST_PATH_IMAGE030
+1=13, set
Figure 908293DEST_PATH_IMAGE018
[12]=1, obtained
Figure 843888DEST_PATH_IMAGE018
=0000000000110100. Will be the final
Figure 896158DEST_PATH_IMAGE018
And restoring according to a raster scanning mode to finish the recovery of the binary block.
Thus, in this embodiment, the block type is determined according to the number of 0 and 1 in the binary block; efficient compression is achieved by encoding the blocks by classification. When 8 bit surfaces of 8-bit gray level images are directly compressed, a compression ratio better than that of run-length codes and arithmetic compression can be realized; and the coding method can also be matched with a predictor to carry out block compression on each bit plane of the prediction error of the image, and can also realize good compression effect. It should be noted that, after the predictor is matched, the occupied space after compression is smaller, because the prediction error mostly tends to 0, and the probability that all the blocks in the bit plane are 0 is larger, the total encoding result is shorter, thereby being beneficial to further improving the compression rate.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned functions may be distributed as different functional units and modules according to needs, that is, the internal structure of the system may be divided into different functional units or modules to implement all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the present invention. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art would appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed system/intelligent terminal and method may be implemented in other ways. For example, the above-described system/intelligent terminal embodiments are merely illustrative, and for example, the division of the above modules or units is only one logical function division, and the actual implementation may be implemented by another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed.
The integrated modules/units described above, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments described above may be implemented. The computer program includes computer program code, and the computer program code may be in a source code form, an object code form, an executable file or some intermediate form. The computer readable medium may include: any entity or system capable of carrying the above-described computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the contents contained in the computer-readable storage medium can be increased or decreased as required by legislation and patent practice in the jurisdiction.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art; the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein.

Claims (10)

1. A method for compressing an image based on bi-directional coding of binary blocks, the method comprising:
acquiring a plurality of to-be-processed image blocks corresponding to an image to be compressed, and acquiring a type judgment threshold of each to-be-processed image block according to the size of each to-be-processed image block, wherein each to-be-processed image block is a binary image block;
acquiring a coding type judgment parameter of each to-be-processed image block according to a first symbol number and a second symbol number corresponding to each to-be-processed image block, wherein the first symbol number is the number of symbols 0 in each to-be-processed image block, and the second symbol number is the number of symbols 1 in each to-be-processed image block;
determining the block type and the sign of each image block to be processed according to the size relationship between the coding type judgment parameter and the type judgment threshold of each image block to be processed, wherein the block type of one image block to be processed is one of a compressible type and an incompressible type;
according to the block type and the sign symbol of each to-be-processed image block, the number and the position of a target coding symbol in each to-be-processed image block are coded through a preset image block coding step, and an image block coding result of each to-be-processed image block is obtained, wherein the target coding symbol is an element symbol which is the same as the sign symbol in the to-be-processed image block;
and acquiring an image compression result corresponding to the image to be compressed according to the image block coding results of all the image blocks to be processed corresponding to the image to be compressed.
2. The image compression method based on bi-directional coding of binary blocks according to claim 1, wherein the obtaining a plurality of to-be-processed image blocks corresponding to an image to be compressed and obtaining the type determination threshold of each to-be-processed image block according to the size of each to-be-processed image block comprises:
acquiring an image to be compressed, dividing the image to be compressed and acquiring a plurality of image blocks to be processed with the same size;
and obtaining the type judgment threshold corresponding to each image block to be processed through a preset threshold comparison table according to the size of each image block to be processed.
3. The method according to claim 1, wherein the encoding type decision parameter is the minimum value between the first symbol number and the second symbol number, and the determining the block type and the flag symbol of each of the to-be-processed image blocks according to the size relationship between the encoding type decision parameter and the type decision threshold of each of the to-be-processed image blocks comprises:
setting the block type of the image block to be processed with the coding type judgment parameter larger than the type judgment threshold value as an incompressible type, and setting the symbolic sign of the image block to be processed as absent;
setting the block type of the image block to be processed with the coding type judgment parameter not greater than the type judgment threshold value as a compressible type, and setting the sign symbol of the image block to be processed as the symbol with less number in the image block to be processed.
4. The method according to any of claims 1-3, wherein for any of the tiles to be processed, the preset tile encoding step comprises:
when the block type of the image block to be processed is an incompressible type, splicing a first type symbol and an image block character string of the image block to be processed to obtain an encoding result of the image block to be processed, wherein the first type symbol is symbol 1, and the image block character string is a binary string obtained by scanning the image block to be processed in a raster scanning manner;
when the block type of the image block to be processed is a compressible type, judging parameters according to the coding type of the image block to be processed to obtain a parameter coding string of the image block to be processed, obtaining a symbol coding string of the image block to be processed according to the position of each target coding symbol in a character string of the image block to be processed, splicing a second type symbol, the parameter coding string of the image block to be processed, the symbol coding string of the image block to be processed and a sign symbol of the image block to be processed to serve as a coding result of the image block to be processed, wherein the second type symbol is symbol 0, and the parameter coding string and the symbol coding string are binary strings.
5. The image compression method based on binary block bidirectional coding according to claim 4, wherein the symbol code string of the to-be-processed image block whose block type is a compressible type is obtained by sequentially connecting a plurality of symbol code substrings, the number of the symbol code substrings is equal to the code type determination parameter of the to-be-processed image block, and the symbol code string of the to-be-processed image block is obtained according to the position of each target code symbol in the character string of the image block of the to-be-processed image block, comprising:
sequentially letting i =1,2, \ 8230;, z, respectively perform the following steps to obtain each symbol encoding sub-string to concatenate to obtain the symbol encoding string:
when i is an odd number, acquiring an ith coding character string and the length Len of the ith coding character string, traversing the ith coding character string from left to right until acquiring the position number of a first target coding symbol counted from left to right in the ith coding character string
Figure 774124DEST_PATH_IMAGE001
Calculating to obtain target digit according to target digit calculation formula
Figure 556135DEST_PATH_IMAGE002
Carrying out binary coding of target digit to obtain ith symbol code sub-string, and deleting the first symbol from left to right in the ith code sub-string
Figure 600314DEST_PATH_IMAGE001
The symbols are used as the (i + 1) th coding character string;
when i is an even number, acquiring an ith code character string and the length Len of the ith code character string, traversing the ith code character string from right to left until acquiring the position number of a first target code symbol in the ith code character string from right to left
Figure 199267DEST_PATH_IMAGE001
Calculating to obtain target digit according to the target digit calculation formula
Figure 987095DEST_PATH_IMAGE002
Carrying out binary coding of target digit to obtain ith symbol code sub-string, deleting right-hand code sub-string in ith code character stringFront to left
Figure 623612DEST_PATH_IMAGE003
The symbols are used as the (i + 1) th coding character string;
wherein, the 1 st coding character string is the image block character string of the image block to be processed, z is the coding type judgment parameter, and the position number
Figure 635431DEST_PATH_IMAGE001
The target digit is determined by the number of symbols passing through during traversal, and the target digit calculation formula is as follows:
Figure 927872DEST_PATH_IMAGE004
Figure 316128DEST_PATH_IMAGE005
is the target number of bits.
6. An image compression system based on bi-directional coding of binary blocks, the system comprising:
the image block processing module is used for acquiring a plurality of to-be-processed image blocks corresponding to an image to be compressed and acquiring the type judgment threshold of each to-be-processed image block according to the size of each to-be-processed image block, wherein each to-be-processed image block is a binary image block;
a parameter obtaining module, configured to obtain a coding type determination parameter of each to-be-processed image block according to a first symbol number and a second symbol number corresponding to each to-be-processed image block, where the first symbol number is the number of symbols 0 in the to-be-processed image block, and the second symbol number is the number of symbols 1 in the to-be-processed image block;
the block type determining module is used for determining the block type and the sign of each to-be-processed image block according to the size relationship between the coding type judgment parameter and the type judgment threshold of each to-be-processed image block, wherein the block type of one to-be-processed image block is one of a compressible type and an incompressible type;
the encoding module is used for encoding the number and the position of a target encoding symbol in each to-be-processed image block through a preset image block encoding step according to the block type and the sign symbol of each to-be-processed image block, and obtaining an image block encoding result of each to-be-processed image block, wherein the target encoding symbol is an element symbol which is the same as the sign symbol in the to-be-processed image block;
and the compression result acquisition module is used for acquiring the image compression result corresponding to the image to be compressed according to the image block coding results of all the image blocks to be processed corresponding to the image to be compressed.
7. A method of image decompression, the method comprising:
acquiring an image compression result corresponding to an image to be decompressed;
acquiring an image block coding result corresponding to each image block to be decoded according to the image compression result, and acquiring the size of each image block to be decoded;
obtaining the block type of each image block to be decoded according to the type symbol value in each image block coding result, wherein the type symbol value is the value of the first bit in the image block coding result, and the block type of one image block to be decoded is one of a compressible type and an incompressible type;
decoding the number and the position of target decoding symbols corresponding to each image block to be decoded through a preset image block decoding step according to the size, the block type and the image block encoding result of each image block to be decoded, and obtaining the image block decoding result of each image block to be decoded, wherein the target decoding symbols are element symbols which are the same as the sign symbols of each image block to be decoded in the image block decoding result;
and obtaining a target decompressed image according to all image block decoding results corresponding to the image to be decompressed.
8. The image decompression method according to claim 7, wherein for any one of the to-be-decoded image blocks, the preset image block decoding step comprises:
when the block type of the image block to be decoded is an incompressible type, deleting a first bit of an image block encoding result of the image block to be decoded to serve as a target decoding character string of the image block to be decoded, placing the target decoding character string according to the size of the image block to be decoded in a raster scanning mode, and obtaining an image block decoding result of the image block to be decoded;
when the block type of the image block to be decoded is a compressible type, taking the last bit of the image block coding result as a sign symbol of the image block to be decoded, obtaining a parameter coding string in the image block coding result of the image block to be decoded, obtaining a decoding type judgment parameter of the image block to be decoded according to the parameter coding string, obtaining a character string to be decoded according to the image block coding result, decoding the character string to be decoded according to the sign symbol and the decoding type judgment parameter of the image block to be decoded to obtain a target decoding character string of the image block to be decoded, placing the target decoding character string according to the size of the image block to be decoded in a raster scanning mode, and obtaining the image block decoding result of the image block to be decoded, wherein the character string to be decoded is a character string obtained after deleting the first bit, the last bit and the parameter coding string from the image block coding result.
9. The image decompression method according to claim 8, wherein the decoding the character string to be decoded according to the symbolic symbol and the decoding type determination parameter of the image block to be decoded to obtain the target decoded character string of the image block to be decoded comprises:
setting an initial decoding character string according to the sign symbol, wherein when the sign symbol is 0, the initial decoding character string is a character string with the length of S × S and each element is 1, when the sign symbol is 1, the initial decoding character string is a character string with the length of S × S and each element is 0, and S × S is equal to the size of the image block to be decoded;
when in use
Figure 10414DEST_PATH_IMAGE006
If =0, the initial decoding character string is used as the target decoding character string of the image block to be decoded, wherein,
Figure 458713DEST_PATH_IMAGE006
judging parameters of the decoding type of the image block to be decoded;
when in use
Figure 972871DEST_PATH_IMAGE006
Not equal to 0, setting the first calculated value rl =1, setting the second calculated value rh = S × S, sequentially making j =1,2, \\ 8230,
Figure 164818DEST_PATH_IMAGE007
executing the following steps to update the initial decoding character string and obtain a target decoding character string of the image block to be decoded: obtaining the jth character string and calculating the target length
Figure 713611DEST_PATH_IMAGE008
= rh-rl +1; calculating the jth decoded bit number
Figure 332811DEST_PATH_IMAGE009
(ii) a According to the 1 st bit in the jth character string
Figure 334265DEST_PATH_IMAGE010
The sign of the bit obtains the jth binary string and the 1 st bit to the 1 st bit of the jth character string
Figure 329903DEST_PATH_IMAGE010
Obtaining a j +1 th character string after deleting the symbol of the bit; converting the jth binary string to a decimal to obtain a jth number
Figure 529940DEST_PATH_IMAGE011
(ii) a When j is odd number, updating in sequence
Figure 257725DEST_PATH_IMAGE011
=rl+
Figure 808792DEST_PATH_IMAGE011
、rl=
Figure 545804DEST_PATH_IMAGE011
+1, when j is even number, updating in turn
Figure 865927DEST_PATH_IMAGE011
=rh-
Figure 764613DEST_PATH_IMAGE011
、rh=
Figure 802976DEST_PATH_IMAGE011
-1; the first character string from left to right
Figure 78099DEST_PATH_IMAGE011
Updating each element to the flag symbol; wherein, the 1 st character string is a character string to be decoded of the image block to be decoded.
10. An image decompression system, characterized in that the system comprises:
the image compression result acquisition module is used for acquiring an image compression result corresponding to the image to be decompressed;
the image compression result processing module is used for acquiring image block coding results corresponding to the image blocks to be decoded according to the image compression results and acquiring the size of each image block to be decoded;
the image block coding result processing module is used for acquiring the block type of each image block to be decoded according to a type symbol value in each image block coding result, wherein the type symbol value is the value of the first bit in the image block coding result, and the block type of one image block to be decoded is one of a compressible type and an incompressible type;
the decoding module is used for decoding the number and the position of a target decoding symbol corresponding to each image block to be decoded through a preset image block decoding step according to the size, the block type and the image block encoding result of each image block to be decoded, and obtaining the image block decoding result of each image block to be decoded, wherein the target decoding symbol is an element symbol which is the same as the sign symbol of each image block to be decoded in the image block decoding result;
and the image decompression module is used for obtaining a target decompressed image according to all the image block decoding results corresponding to the image to be decompressed.
CN202211382188.1A 2022-11-07 2022-11-07 Image compression method and image decompression method based on binary block bidirectional coding Active CN115514967B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211382188.1A CN115514967B (en) 2022-11-07 2022-11-07 Image compression method and image decompression method based on binary block bidirectional coding

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211382188.1A CN115514967B (en) 2022-11-07 2022-11-07 Image compression method and image decompression method based on binary block bidirectional coding

Publications (2)

Publication Number Publication Date
CN115514967A CN115514967A (en) 2022-12-23
CN115514967B true CN115514967B (en) 2023-03-21

Family

ID=84511596

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211382188.1A Active CN115514967B (en) 2022-11-07 2022-11-07 Image compression method and image decompression method based on binary block bidirectional coding

Country Status (1)

Country Link
CN (1) CN115514967B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114222129A (en) * 2022-01-27 2022-03-22 深圳市爱协生科技有限公司 Image compression encoding method, image compression encoding device, computer equipment and storage medium
CN114640857A (en) * 2022-05-06 2022-06-17 江苏游隼微电子有限公司 Image compression method and 3D noise reduction method based on improved Huffman coding

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
RU2354073C2 (en) * 2002-01-22 2009-04-27 Нокиа Корпорейшн Conversion factor coding in image and videodata coders and/or decoders
EP2154894A1 (en) * 2008-08-15 2010-02-17 Thomson Licensing Video coding with coding of the locations of significant coefficients in a block of coefficients
WO2015115644A1 (en) * 2014-02-03 2015-08-06 三菱電機株式会社 Image encoding device, image decoding device, encoded stream conversion device, image encoding method, and image decoding method
US9712830B1 (en) * 2016-09-15 2017-07-18 Dropbox, Inc. Techniques for image recompression
CN111787335B (en) * 2020-07-08 2022-04-22 绍兴聚量数据技术有限公司 Reversible information hiding method based on AMBTC compression technology and Huffman coding
CN112188198B (en) * 2020-09-24 2022-08-02 湖南遥昇通信技术有限公司 Image data compression and decompression method and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114222129A (en) * 2022-01-27 2022-03-22 深圳市爱协生科技有限公司 Image compression encoding method, image compression encoding device, computer equipment and storage medium
CN114640857A (en) * 2022-05-06 2022-06-17 江苏游隼微电子有限公司 Image compression method and 3D noise reduction method based on improved Huffman coding

Also Published As

Publication number Publication date
CN115514967A (en) 2022-12-23

Similar Documents

Publication Publication Date Title
US7365658B2 (en) Method and apparatus for lossless run-length data encoding
CN101243611B (en) Efficient coding and decoding of transform blocks
US5818877A (en) Method for reducing storage requirements for grouped data values
KR101678223B1 (en) Multimedia signature coding and decoding
US20110033126A1 (en) Method for improving the performance of embedded graphics coding
JP4801778B2 (en) Video compression / encoding device, video restoration device, video compression program, and video restoration program
JP6070568B2 (en) Feature coding apparatus, feature coding method, and program
JP2006129467A (en) Lossless adaptive encoding/decoding of integer data
KR100382649B1 (en) Methods and apparatuses for compressing and recovering data for hard copy apparatus
US8305244B2 (en) Coding data using different coding alphabets
US20140015698A1 (en) System and method for fixed rate entropy coded scalar quantization
CN110021368B (en) Comparison type gene sequencing data compression method, system and computer readable medium
CN115514967B (en) Image compression method and image decompression method based on binary block bidirectional coding
CN116582689A (en) Lossless compression for low-latency video transmission in resource-constrained coding environments
Kumar et al. Vector quantization with codebook and index compression
CN110545437A (en) coefficient encoding method, coefficient decoding method, electronic device, and medium
CN117440154B (en) Depth map sequence compression method considering floating point digital splitting
JP4743884B2 (en) Image coding apparatus and control method thereof
JP4936574B2 (en) Encoding apparatus and control method thereof
Kamal et al. Iteration free fractal compression using genetic algorithm for still colour images
CN109698704B (en) Comparative gene sequencing data decompression method, system and computer readable medium
JP2755464B2 (en) Image data compression method
He et al. How Can Spiral Architecture Improve Image Compression?
Alsous et al. Developing a High Performance Adjustable Quality Data Compression Scheme for Multimedia Messaging
CN114079774A (en) Method and device for encoding and decoding inter-frame prediction information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant