CN106780322B - Image compression method and device - Google Patents

Image compression method and device Download PDF

Info

Publication number
CN106780322B
CN106780322B CN201611049678.4A CN201611049678A CN106780322B CN 106780322 B CN106780322 B CN 106780322B CN 201611049678 A CN201611049678 A CN 201611049678A CN 106780322 B CN106780322 B CN 106780322B
Authority
CN
China
Prior art keywords
data
space structure
compressed
data space
cubes
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
CN201611049678.4A
Other languages
Chinese (zh)
Other versions
CN106780322A (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.)
Inspur Financial Information Technology Co Ltd
Original Assignee
Inspur Financial Information Technology Co Ltd
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 Inspur Financial Information Technology Co Ltd filed Critical Inspur Financial Information Technology Co Ltd
Priority to CN201611049678.4A priority Critical patent/CN106780322B/en
Publication of CN106780322A publication Critical patent/CN106780322A/en
Application granted granted Critical
Publication of CN106780322B publication Critical patent/CN106780322B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/40Scaling the whole image or part thereof

Abstract

The invention provides an image compression method and device, wherein the method comprises the following steps: acquiring original bitmap data of an image file to be compressed, which comprises at least one pixel point, and setting at least three corresponding data layers according to at least three types of data values of each pixel point; respectively setting a space geometry corresponding to each data value in each data layer to obtain a data space structure corresponding to the data layer; for each data space structure, compressing the associated space geometry in the data space structure; and outputting the compressed data space structure when the set image compression ratio is judged to correspond to the lossless compression, otherwise, performing erasing processing of a corresponding degree on the compressed data space structure according to the image compression ratio, and outputting the erased data space structure. Based on the set image compression rate, corresponding processing can be performed on the image file to achieve the effect of image compression. Therefore, the scheme can support the custom image compression rate.

Description

Image compression method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an image compression method and apparatus.
Background
With the rapid development of internet technology, the formats of image files are becoming more abundant to meet the file transmission requirements of different users.
Currently, to reduce the file size for convenient transmission, the original file can be compressed losslessly into jpg format or losslessly into png format.
However, the existing image compression method can only support lossy compression or lossless compression singly, and cannot support the custom image compression rate.
Disclosure of Invention
The invention provides an image compression method and device, which can support user-defined image compression rate.
In order to achieve the purpose, the invention is realized by the following technical scheme:
in one aspect, the present invention provides an image compression method, including:
acquiring original bitmap data corresponding to an image file to be compressed, wherein the image file to be compressed comprises at least one pixel point;
setting at least three corresponding data layers according to at least three types of data values corresponding to each pixel point in the original bitmap data, wherein each data layer comprises a type of data value corresponding to each pixel point;
respectively setting a space geometry corresponding to each data value in each data layer to obtain a data space structure corresponding to the data layer;
for each of the data space structures, performing: when any at least two adjacent space geometric bodies in the data space structure are judged to be related, the related space geometric bodies are compressed to generate a compressed data space structure;
and judging whether the set image compression ratio corresponds to lossless compression, if so, outputting the compressed data space structure, otherwise, carrying out erasing processing of a corresponding degree on the compressed data space structure according to the image compression ratio, and outputting the erased data space structure.
Further, the at least three types of data values include: r (red), G (green), and B (blue) values, or R, G, B, and alpha channel values;
the spatial geometry is a cube, and the 8 vertices of the cube are sequentially marked with an eight-digit binary number of a data value corresponding to the cube.
Further, when it is determined that any at least two adjacent space geometries in the data space structure are associated, performing compression processing on the associated space geometries, including: and stacking any two adjacent space geometries positioned in the same row in the data space structure when judging that the two space geometries are the same, and fusing the two space geometries when judging that the geometry surfaces between any two adjacent space geometries positioned in the same row in the data space structure are the same.
Further, when it is determined that any at least two adjacent space geometries in the data space structure are associated, performing compression processing on the associated space geometries, including: and stacking any two adjacent space geometries in the same column in the data space structure when judging that the two space geometries are the same, and fusing the two space geometries when judging that the geometric surface between any two adjacent space geometries in the same column in the data space structure is the same.
Further, the image compression rate is any value from 1 to 100, wherein 100 corresponds to lossless compression, and any value from 1 to 99 corresponds to lossy compression;
compressing the related space geometric bodies to obtain corresponding compressed space geometric bodies;
correspondingly, the compressed data space structure includes a first number of the compressed space geometry and a second number of the uncompressed space geometry, and the first number and the second number are not 0 at the same time;
the erasing process of the corresponding degree is carried out on the compressed data space structure according to the image compression ratio, and the erasing process comprises the following steps: when the image compression rate is 99, erasing the uncompressed space geometry; when the image compression rate is any one target value of 1 to 98, erasing the uncompressed spatial geometry and a target compressed spatial geometry in the compressed spatial geometry, wherein the target compressed spatial geometry is obtained by compressing spatial geometries whose number is not more than a target value, and the target value is a difference value obtained by subtracting the target value from 100.
Further, for each layer of the data layer, the relative position of each pixel point in the image file and the relative position of the data value corresponding to the pixel point in the data layer are kept consistent; and the relative position of each data value in the data layer, and the relative position of the space geometry corresponding to the data value in the corresponding data space structure are kept consistent.
Further, the obtaining of the original bitmap data corresponding to the image file to be compressed, which includes at least one pixel point, includes: initializing a preset multidimensional image processing module, reading an image file to be compressed comprising at least one pixel point by using the multidimensional image processing module, and converting the image file according to an algorithm corresponding to the file format of the image file to acquire original bitmap data corresponding to the image file.
In another aspect, the present invention provides an image compression apparatus comprising:
the device comprises an acquisition unit, a compression unit and a compression unit, wherein the acquisition unit is used for acquiring original bitmap data corresponding to an image file to be compressed, which comprises at least one pixel point;
the data layer setting unit is used for setting at least three corresponding data layers according to at least three types of data values corresponding to each pixel point in the original bitmap data, wherein each data layer comprises one type of data value corresponding to each pixel point;
the data space structure setting unit is used for respectively setting a space geometry corresponding to each data value in each data layer so as to obtain a data space structure corresponding to the data layer;
a data space structure compression unit configured to, for each of the data space structures: when any at least two adjacent space geometric bodies in the data space structure are judged to be related, the related space geometric bodies are compressed to generate a compressed data space structure;
and the processing unit is used for judging whether the set image compression ratio corresponds to lossless compression or not, outputting the compressed data space structure if the set image compression ratio corresponds to lossless compression, and otherwise, performing erasure processing of a corresponding degree on the compressed data space structure according to the image compression ratio and outputting the erased data space structure.
Further, the data space structure compressing unit is specifically configured to stack any two adjacent space geometries in the same row in the data space structure when it is determined that the two space geometries are the same, and fuse the two space geometries when it is determined that the surfaces of the geometries between any two adjacent space geometries in the same row in the data space structure are the same.
Further, the data space structure compressing unit is specifically configured to stack any two adjacent space geometries in the same column in the data space structure when it is determined that the two space geometries are the same, and fuse the two space geometries when it is determined that the surfaces of the geometries between any two adjacent space geometries in the same column in the data space structure are the same.
Further, the image compression rate is any value from 1 to 100, wherein 100 corresponds to lossless compression, and any value from 1 to 99 corresponds to lossy compression;
the data space structure compression unit is specifically configured to perform compression processing on the associated space geometry to obtain a corresponding compressed space geometry;
correspondingly, the compressed data space structure includes a first number of the compressed space geometry and a second number of the uncompressed space geometry, and the first number and the second number are not 0 at the same time;
the processing unit is specifically configured to erase the uncompressed space geometry when the image compression rate is 99; when the image compression rate is any one target value of 1 to 98, erasing the uncompressed spatial geometry and a target compressed spatial geometry in the compressed spatial geometry, wherein the target compressed spatial geometry is obtained by compressing spatial geometries whose number is not more than a target value, and the target value is a difference value obtained by subtracting the target value from 100.
Further, the obtaining unit is specifically configured to initialize a preset multidimensional image processing module, read an image file to be compressed that includes at least one pixel point by using the multidimensional image processing module, and convert the image file according to an algorithm corresponding to a file format of the image file, so as to obtain original bitmap data corresponding to the image file.
The invention provides an image compression method and a device, which are used for acquiring original bitmap data of an image file to be compressed, wherein the original bitmap data comprises at least one pixel point, and setting at least three corresponding data layers according to at least three types of data values of each pixel point; respectively setting a space geometry corresponding to each data value in each data layer to obtain a data space structure corresponding to the data layer; for each data space structure, compressing the associated space geometry in the data space structure; and outputting the compressed data space structure when the set image compression ratio is judged to correspond to the lossless compression, otherwise, performing erasing processing of a corresponding degree on the compressed data space structure according to the image compression ratio, and outputting the erased data space structure. Based on the set image compression rate, corresponding processing can be performed on the image file to achieve the effect of image compression. Therefore, the invention can support the customized image compression rate.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flow chart of a method for compressing an image according to an embodiment of the present invention;
FIG. 2 is a schematic view of a spatial geometry volumetric stacking provided in accordance with an embodiment of the present invention;
FIG. 3 is a schematic diagram of a spatial geometry volumetric fusion provided in accordance with an embodiment of the present invention;
FIG. 4 is a flow chart of another image compression method according to an embodiment of the present invention;
fig. 5 is a schematic diagram of an image compression apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer and more complete, the technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention, and based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without creative efforts belong to the scope of the present invention.
As shown in fig. 1, an embodiment of the present invention provides an image compression method, which may include the following steps:
step 101: and acquiring original bitmap data corresponding to the image file to be compressed, which comprises at least one pixel point.
Step 102: and setting at least three corresponding data layers according to at least three types of data values corresponding to each pixel point in the original bitmap data, wherein each data layer comprises a type of data value corresponding to each pixel point.
Step 103: and respectively setting a space geometry corresponding to each data value in each data layer so as to obtain a data space structure corresponding to the data layer.
Step 104: for each of the data space structures, performing: and when any at least two adjacent space geometric objects in the data space structure are judged to be related, compressing the related space geometric objects to generate a compressed data space structure.
Step 105: and judging whether the set image compression ratio corresponds to lossless compression, if so, outputting the compressed data space structure, otherwise, carrying out erasing processing of a corresponding degree on the compressed data space structure according to the image compression ratio, and outputting the erased data space structure.
The embodiment of the invention provides an image compression method, which comprises the steps of obtaining original bitmap data of an image file to be compressed, wherein the original bitmap data comprises at least one pixel point, and setting at least three corresponding data layers according to at least three types of data values of each pixel point; respectively setting a space geometry corresponding to each data value in each data layer to obtain a data space structure corresponding to the data layer; for each data space structure, compressing the associated space geometry in the data space structure; and outputting the compressed data space structure when the set image compression ratio is judged to correspond to the lossless compression, otherwise, performing erasing processing of a corresponding degree on the compressed data space structure according to the image compression ratio, and outputting the erased data space structure. Based on the set image compression rate, corresponding processing can be performed on the image file to achieve the effect of image compression. Therefore, the embodiment of the invention can support the custom image compression rate.
In one embodiment of the invention, the at least three types of data values include: r, G, and B values, or R, G, B, and alpha channel values;
the spatial geometry is a cube, and the 8 vertices of the cube are sequentially marked with an eight-digit binary number of a data value corresponding to the cube.
In detail, the original bitmap data corresponding to the image file may include: the resolution of the image file, the RGB value of each pixel point in the image file, the alpha channel value of each pixel point and the like. Wherein the alpha channel is an 8-bit gray channel that records transparency information in an image with 256 levels of gray.
Assuming that the resolution of the image file to be compressed is 500 pixels × 500 pixels, it can be said that each row of the image file includes 500 pixels, each column includes 500 pixels, and the image file includes 250000 pixels in total. Wherein, each pixel point has a corresponding RGB value. Certainly, in a specific case, each pixel point may also have an alpha channel value.
In an embodiment of the present invention, when at least three types of data values of each pixel point include: and when the R value, the G value and the B value are obtained, the established three data layers can be an R data layer, a G data layer and a B data layer respectively. The R data layer comprises the R value of each pixel point, the G data layer comprises the G value of each pixel point, and the B data layer comprises the B value of each pixel point.
Correspondingly, when the at least three types of data values of each pixel point further include an alpha channel value, the established data layer may further include an alpha channel data layer, wherein the data layer includes the alpha channel value of each pixel point.
In detail, for the RGB value, or color value, a color value of a pixel point can be represented by 24 bits, wherein the color value includes three bytes and 8 bits. For example, writing a color value of pure red as binary is: 111111110000000000000000, writing a color value of pure green as binary is: 000000001111111100000000, writing a color value of pure blue in binary is: 000000000000000011111111.
for example, a certain pixel point in pure red is taken as an example, the R value is 11111111, the G value is 00000000, and the B value is 00000000, so the labeled values on 8 vertexes of the cube corresponding to the R value are all 1, the labeled values on 8 vertexes of the cube corresponding to the G value are all 0, and the labeled values on 8 vertexes of the cube corresponding to the B value are all 0.
In detail, for each layer of data layer, by setting a spatial geometry corresponding to each data value in the data layer, such as the above cube, a data spatial structure composed of spatial geometries corresponding to the data layer can be established.
Preferably, in an embodiment of the present invention, for each layer of the data layer, the relative position of each pixel point in the image file maintains consistent with the relative position of the data value corresponding to the pixel point in the data layer; and the relative position of each data value in the data layer, and the relative position of the space geometry corresponding to the data value in the corresponding data space structure are kept consistent.
For example, if the pixel point a1b2 in the first row and the second column of the image file is pure red, and the binary color value of the pixel point a1b2 is 111111110000000000000000, the data value a1b2 in the first row and the second column of the established data layer corresponding to the R value is 11111111111, and at the same time, 8 vertices of the spatial geometry a1b2 in the first row and the second column of the established data space mechanism corresponding to the data layer are all marked as 1.
In the embodiment of the invention, the relative position of any pixel point in the image file, the relative position of the data value of the pixel point in the corresponding data layer and the relative position of the space geometry corresponding to the data value in the corresponding data space structure are kept consistent, so that the recording of related data, the regular creation of each data layer and each data space structure, and the execution of the compression operation and the corresponding decompression operation in the compression processing process of the image file can be facilitated.
In an embodiment of the present invention, to describe a possible implementation manner of compressing a data space structure, when it is determined that any at least two adjacent space geometries in the data space structure are associated, the compressing any associated space geometry includes: and stacking any two adjacent space geometries positioned in the same row in the data space structure when judging that the two space geometries are the same, and fusing the two space geometries when judging that the geometry surfaces between any two adjacent space geometries positioned in the same row in the data space structure are the same.
In detail, for any image file, the condition that the RGB values of two adjacent pixels are the same is common. For two adjacent pixel points with the same RGB value, in the established data space structure, the two corresponding adjacent space geometric bodies are the same, so that the two adjacent space geometric bodies can be stacked. An implementation of this space geometry volumetric stacking may be as shown in fig. 2. In fig. 2, two identical spatial geometries may be stacked into the same spatial geometry.
Of course, any two adjacent space geometries can be stacked when they are the same, based on the same implementation principle. In this way, n consecutive adjacent space geometries are the same and can be stacked into one space geometry. Correspondingly, based on the recorded stack information, when decompressing the compressed image file, the stacked spatial geometries may be sequentially expanded according to the stack information.
Correspondingly, in the established data space structure, the geometric bodies between two adjacent space geometric bodies can be fused when the surfaces of the geometric bodies are the same. An implementation of this spatial-geometric volume fusion can be seen in fig. 3. In fig. 3, the 4 mark values on the geometric body surface between the left space geometric body and the right space geometric body are mirror-symmetric, so that the two can be fused. The marking values of the two space geometric bodies before fusion are 8, and the marking values of the space geometric bodies after fusion are 12, which are correspondingly reduced by 4 compared with the marking values before fusion.
Of course, based on the same implementation principle, any two adjacent space geometries can be fused when the surfaces of the geometries are the same. Thus, if the geometric bodies between any two adjacent spatial geometric bodies are the same in the n consecutive spatial geometric bodies, the n spatial geometric bodies can be fused into a whole spatial geometric body. Correspondingly, based on the recorded fusion information, when decompressing the compressed image file, the fused spatial geometry may be sequentially expanded according to the fusion information.
In detail, in order to facilitate recording of the stacking information and the fusion information and facilitate decompression of the image file, the stacked space geometry and the fused space geometry are decomposed quickly and accurately, and the stacking operation and the fusion operation are performed on the basis of the same row or the same column.
In the embodiment of the present invention, the possible implementation manner of compressing the data space structure is performed based on the same row.
In an embodiment of the present invention, based on the above, after compressing each row in the data space structure, each column of the compressed data space structure may be further compressed again by using the same implementation principle, that is, any two adjacent space geometries in the same column are the same, stacked, and the geometry surfaces between any two adjacent space geometries in the same column are the same, and fused.
Correspondingly, in an embodiment of the present invention, to illustrate another possible implementation manner of compressing a data space structure, when it is determined that any at least two adjacent space geometries in the data space structure are associated, the compressing any associated space geometry includes: and stacking any two adjacent space geometries in the same column in the data space structure when judging that the two space geometries are the same, and fusing the two space geometries when judging that the geometric surface between any two adjacent space geometries in the same column in the data space structure is the same.
In the embodiment of the present invention, the possible implementation manner of compressing the data space structure is executed based on the same row, and the corresponding execution process and the execution process based on the same row may be based on the same implementation principle, so repeated descriptions are not repeated here.
In an embodiment of the present invention, based on the above, after compressing each column in the data space structure, each row of the compressed data space structure may be further compressed again by using the same implementation principle, that is, any two adjacent space geometries in the same row are the same, stacked, and the geometry surfaces between any two adjacent space geometries in the same row are the same, and fused.
In the embodiment of the present invention, according to the implementation sequence of the compression process, when the corresponding decompression operation is performed, the decompression operation may be performed sequentially according to the sequence opposite to the implementation sequence, so as to obtain the original data space structure, and further obtain the original image file.
In an embodiment of the present invention, in order to describe a possible implementation manner of performing erasure processing on the compressed data space structure according to the image compression rate, the image compression rate is any one of values 1 to 100, where 100 corresponds to lossless compression and any one of values 1 to 99 corresponds to lossy compression;
compressing the related space geometric bodies to obtain corresponding compressed space geometric bodies;
correspondingly, the compressed data space structure includes a first number of the compressed space geometry and a second number of the uncompressed space geometry, and the first number and the second number are not 0 at the same time;
the erasing process of the corresponding degree is carried out on the compressed data space structure according to the image compression ratio, and the erasing process comprises the following steps: when the image compression rate is 99, erasing the uncompressed space geometry; when the image compression rate is any one target value of 1 to 98, erasing the uncompressed spatial geometry and a target compressed spatial geometry in the compressed spatial geometry, wherein the target compressed spatial geometry is obtained by compressing spatial geometries whose number is not more than a target value, and the target value is a difference value obtained by subtracting the target value from 100.
In detail, the compression processing of the associated spatial geometries requires that the number of the associated spatial geometries is at least two. If a spatial geometry is not associated with any neighboring spatial geometry, it cannot be compressed, and can be present in the compressed data space structure as an uncompressed spatial geometry.
In detail, the image compression rate is any one of 1 to 100, 100 corresponding to lossless compression, and 1 to 99 corresponding to lossy compression. Wherein, the higher the value, the less the erased compressed space geometry, and the lower the loss rate of the image file.
For example, if the determined image compression rate is 100, 100 corresponds to lossless compression, so no erasure process is performed and all the uncompressed spatial geometries, i.e., the single original spatial geometry, are retained.
If the determined image compression ratio is 99, all uncompressed spatial geometry can be erased.
If the determined image compression rate is 90, not only all the uncompressed spatial geometries can be erased, but also the compressed spatial geometries resulting from compression of not more than 10 spatial geometries can be erased. For example, if there are 9 adjacent spatial geometries associated, the 9 spatial geometries may be compressed into one compressed spatial geometry. The image compression ratio is 90 and the compressed spatial geometry needs to be erased.
Thus, in summary, if the determined image compression rate is any value X from 1 to 98, all uncompressed spatial geometries can be erased, and compressed spatial geometries resulting from compression of no more than Y spatial geometries can be erased. Wherein, Y is 100-X.
In an embodiment of the present invention, to describe a possible implementation manner of obtaining original bitmap data, therefore, the obtaining original bitmap data corresponding to an image file to be compressed, which includes at least one pixel point, includes: initializing a preset multidimensional image processing module, reading an image file to be compressed comprising at least one pixel point by using the multidimensional image processing module, and converting the image file according to an algorithm corresponding to the file format of the image file to acquire original bitmap data corresponding to the image file.
In detail, the multidimensional image processing module may be established in advance. When the original bitmap data needs to be acquired, the multidimensional image processing module is initialized firstly to read the image file to be compressed which needs to be processed. The initialization work may include creation of a data space, and initialization setting of related parameters, such as setting the size of the data space.
The file format of the image file can be determined by reading the image file, so that an algorithm corresponding to the file format can be selected to convert the image file into original bitmap data. In detail, different file formats may correspond to different algorithms.
As shown in fig. 4, an embodiment of the present invention provides another image compression method, which specifically includes the following steps:
step 401: initializing a preset multidimensional image processing module, and reading an image file to be compressed comprising at least one pixel point by using the multidimensional image processing module.
In detail, the initialization work may include creation of a data space, initialization setting of related parameters, such as setting the size of the data space, and the like.
Step 402: and converting the image file according to an algorithm corresponding to the file format of the image file to obtain original bitmap data corresponding to the image file.
In detail, the original bitmap data may include: the resolution of the image file, the RGB value of each pixel point in the image file, the alpha channel value of each pixel point and the like. For example, the original bitmap data in the embodiment of the present invention may include a resolution and an RGB value of each pixel.
In detail, different file formats typically correspond to different algorithms.
Step 403: and setting three corresponding data layers according to three types of data values corresponding to each pixel point in the original bitmap data, wherein each data layer comprises one type of data value corresponding to each pixel point.
In detail, the three types of data values corresponding to each pixel point may be R value, G value, and B value. Wherein, can set up one deck data layer according to the R value of each pixel, can set up another layer data layer according to the G value of each pixel, can set up another layer data layer according to the B value of each pixel.
Step 404: and respectively setting a space geometry corresponding to each data value in each layer of data layer to obtain a data space structure corresponding to the data layer.
In detail, the spatial geometry may be a cube, and the 8 vertices of the cube are sequentially labeled with eight-digit binary numbers of the data values corresponding to the cube.
In detail, for each layer of data layer, the relative position of each pixel point in the image file and the relative position of the data value corresponding to the pixel point in the data layer are kept consistent; and the relative position of each data value in the data layer, and the relative position of the space geometry corresponding to the data value in the corresponding data space structure are kept consistent.
Step 405: for each data space structure, performing: and when judging that the surfaces of the geometric objects between any two adjacent spatial geometric objects in the same row in the data space structure are the same, fusing the surfaces to generate a compressed data space structure, wherein the compressed data space structure comprises a first number of compressed spatial geometric objects and a second number of uncompressed spatial geometric objects.
In detail, by compressing the associated spatial geometry, the corresponding compressed spatial geometry can be obtained. Correspondingly, the compressed data space structure may include a first number of compressed space geometries and a second number of uncompressed space geometries, and the first number and the second number are not 0 at the same time.
Step 406: and judging whether the set image compression rate corresponds to lossless compression, if so, outputting a compressed data space structure, and otherwise, executing step 407.
In detail, the image compression rate may be any one of 1 to 100, where 100 corresponds to lossless compression and any one of 1 to 99 corresponds to lossy compression.
Step 407: when the image compression ratio is determined to be 99, erasing the second number of uncompressed space geometries, and when the image compression ratio is any one target value of 1 to 98, erasing the second number of uncompressed space geometries and the target compressed space geometries in the first number of compressed space geometries, and outputting the erased data space structure.
In detail, the target compressed space geometry may be obtained by compressing the space geometry whose number is not more than the target value, and the target value is 100 minus the target value.
In summary, the embodiments of the present invention can use multidimensional technology to achieve the purpose of compressing the image file by segmenting the image color segmentation information. The realization mode can not only improve the lossless compression ratio of the image file, but also flexibly select the quality of the output file according to the actual requirement, thereby ensuring the authenticity and integrity of the image content to the maximum extent when processing and storing various image files, such as certificate scanning files or related photos, and having great market value in related industries of finance, safety and the like.
As shown in fig. 5, an embodiment of the present invention provides an image compression apparatus including:
an obtaining unit 501, configured to obtain original bitmap data corresponding to an image file to be compressed, where the original bitmap data includes at least one pixel point;
a data layer setting unit 502, configured to set at least three corresponding data layers according to at least three types of data values corresponding to each pixel point in the original bitmap data, where each data layer includes a type of data value corresponding to each pixel point;
a data space structure setting unit 503, configured to set, for each data layer, a space geometry corresponding to each data value therein, respectively, so as to obtain a data space structure corresponding to the data layer;
a data space structure compressing unit 504, configured to perform, for each of the data space structures: when any at least two adjacent space geometric bodies in the data space structure are judged to be related, the related space geometric bodies are compressed to generate a compressed data space structure;
a processing unit 505, configured to determine whether a set image compression ratio corresponds to lossless compression, if so, output the compressed data space structure, otherwise, perform erasure processing of a corresponding degree on the compressed data space structure according to the image compression ratio, and output the erased data space structure.
In one embodiment of the invention, the at least three types of data values include: r, G, and B values, or R, G, B, and alpha channel values;
the spatial geometry is a cube, and the 8 vertices of the cube are sequentially marked with an eight-digit binary number of a data value corresponding to the cube.
In an embodiment of the present invention, for each layer of the data layer, the relative position of each pixel point in the image file, and the relative position of the data value corresponding to the pixel point in the data layer are kept consistent; and the relative position of each data value in the data layer, and the relative position of the space geometry corresponding to the data value in the corresponding data space structure are kept consistent.
In an embodiment of the present invention, the data space structure compressing unit 504 is specifically configured to stack any two adjacent space geometries in the same row in the data space structure when it is determined that the two space geometries are the same, and fuse the two space geometries when it is determined that the surfaces of the geometries between any two adjacent space geometries in the same row in the data space structure are the same.
In an embodiment of the present invention, the data space structure compressing unit 504 is specifically configured to stack any two adjacent space geometries in the same column in the data space structure when it is determined that the two space geometries are the same, and fuse the two space geometries when it is determined that the surfaces of the geometries between any two adjacent space geometries in the same column in the data space structure are the same.
In one embodiment of the present invention, the image compression rate is any one of 1 to 100, where 100 corresponds to lossless compression and any one of 1 to 99 corresponds to lossy compression;
the data space structure compressing unit 504 is specifically configured to perform compression processing on the associated space geometry to obtain a corresponding compressed space geometry;
correspondingly, the compressed data space structure includes a first number of the compressed space geometry and a second number of the uncompressed space geometry, and the first number and the second number are not 0 at the same time;
the processing unit 505 is specifically configured to erase the uncompressed space geometry when the image compression rate is 99; when the image compression rate is any one target value of 1 to 98, erasing the uncompressed spatial geometry and a target compressed spatial geometry in the compressed spatial geometry, wherein the target compressed spatial geometry is obtained by compressing spatial geometries whose number is not more than a target value, and the target value is a difference value obtained by subtracting the target value from 100.
In an embodiment of the present invention, the obtaining unit 501 is specifically configured to initialize a preset multidimensional image processing module, read an image file to be compressed, which includes at least one pixel point, by using the multidimensional image processing module, and convert the image file according to an algorithm corresponding to a file format of the image file, so as to obtain original bitmap data corresponding to the image file.
Because the information interaction, execution process, and other contents between the units in the device are based on the same concept as the method embodiment of the present invention, specific contents may refer to the description in the method embodiment of the present invention, and are not described herein again.
In summary, the embodiments of the present invention have at least the following advantages:
1. in the embodiment of the invention, original bitmap data of an image file to be compressed, which comprises at least one pixel point, is obtained, and at least three corresponding data layers are set according to at least three types of data values of each pixel point; respectively setting a space geometry corresponding to each data value in each data layer to obtain a data space structure corresponding to the data layer; for each data space structure, compressing the associated space geometry in the data space structure; and outputting the compressed data space structure when the set image compression ratio is judged to correspond to the lossless compression, otherwise, performing erasing processing of a corresponding degree on the compressed data space structure according to the image compression ratio, and outputting the erased data space structure. Based on the set image compression rate, corresponding processing can be performed on the image file to achieve the effect of image compression. Therefore, the embodiment of the invention can support the custom image compression rate.
2. In the embodiment of the invention, the multi-dimensional technology can be used for achieving the purpose of compressing the image file by segmenting the image color segmentation information. The realization mode can not only improve the lossless compression ratio of the image file, but also flexibly select the quality of the output file according to the actual requirement, thereby ensuring the authenticity and integrity of the image content to the maximum extent when processing and storing various image files, such as certificate scanning files or related photos, and having great market value in related industries of finance, safety and the like.
3. In the embodiment of the invention, the relative position of any pixel point in the image file, the relative position of the data value of the pixel point in the corresponding data layer and the relative position of the space geometry corresponding to the data value in the corresponding data space structure are kept consistent, so that the recording of related data, the regular creation of each data layer and each data space structure, and the execution of the compression operation and the corresponding decompression operation in the compression processing process of the image file can be facilitated.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the inclusion of an element by the phrase "comprising a" does not exclude the presence of other similar elements in a process, method, article, or apparatus that comprises the element.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it is to be noted that: the above description is only a preferred embodiment of the present invention, and is only used to illustrate the technical solutions of the present invention, and not to limit the protection scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (6)

1. An image compression method, comprising:
acquiring original bitmap data corresponding to an image file to be compressed, wherein the image file to be compressed comprises at least one pixel point;
setting at least three corresponding data layers according to at least three types of data values corresponding to each pixel point in the original bitmap data, wherein each data layer comprises a type of data value corresponding to each pixel point;
respectively setting a cube corresponding to each data value in each data layer to obtain a data space structure corresponding to the data layer;
for each of the data space structures, performing: when any at least two adjacent cubes in the data space structure are judged to be associated, the associated cubes are compressed to generate a compressed data space structure;
judging whether the set image compression ratio corresponds to lossless compression, if so, outputting the compressed data space structure, otherwise, carrying out erasing processing of a corresponding degree on the compressed data space structure according to the image compression ratio, and outputting the erased data space structure;
when it is determined that any at least two adjacent cubes in the data space structure are associated, compressing the associated cubes, including:
stacking any two cubes in the data space structure, which are positioned in the same row, when judging that the cubes in the data space structure are the same, and fusing the two cubes when judging that the cube surfaces in the data space structure, which are positioned in the same row, are the same;
or the like, or, alternatively,
stacking any two cubes in the same column in the data space structure when judging that the two cubes are the same, and fusing the two cubes when judging that the cube surfaces between any two adjacent cubes in the same column in the data space structure are the same;
the image compression rate is any one of 1 to 100, wherein 100 corresponds to lossless compression and any one of 1 to 99 corresponds to lossy compression;
compressing the related cube to obtain a corresponding compressed cube;
correspondingly, the compressed data space structure includes a first number of the compressed cubes and a second number of the uncompressed cubes, and the first number and the second number are not 0 at the same time;
the erasing process of the corresponding degree is carried out on the compressed data space structure according to the image compression ratio, and the erasing process comprises the following steps: when the image compression rate is 99, erasing the uncompressed cube; erasing the uncompressed cube and a target compressed cube of the compressed cubes when the image compression rate is any target value of 1 to 98, wherein the target compressed cube is obtained by compressing cubes with a number not more than a target value, and the target value is a difference obtained by subtracting the target value from 100.
2. The method of claim 1,
the at least three types of data values include: a red value R value, a green value G value and a blue value B value, or an R value, a G value, a B value and an alpha channel value;
the cube is a cube, and the 8 vertices of the cube are sequentially marked with an eight-digit binary number of a data value corresponding to the cube.
3. The method of claim 1,
for each data layer, the relative position of each pixel point in the image file and the relative position of the data value corresponding to the pixel point in the data layer are kept consistent; and the relative position of each data value in the data layer is consistent with the relative position of the cube corresponding to the data value in the corresponding data space structure.
4. The method according to any one of claims 1 to 3,
the acquiring of the original bitmap data corresponding to the image file to be compressed, which comprises at least one pixel point, comprises: initializing a preset multidimensional image processing module, reading an image file to be compressed comprising at least one pixel point by using the multidimensional image processing module, and converting the image file according to an algorithm corresponding to the file format of the image file to acquire original bitmap data corresponding to the image file.
5. An image compression apparatus, comprising:
the device comprises an acquisition unit, a compression unit and a compression unit, wherein the acquisition unit is used for acquiring original bitmap data corresponding to an image file to be compressed, which comprises at least one pixel point;
the data layer setting unit is used for setting at least three corresponding data layers according to at least three types of data values corresponding to each pixel point in the original bitmap data, wherein each data layer comprises one type of data value corresponding to each pixel point;
the data space structure setting unit is used for respectively setting a cube corresponding to each data value in each data layer so as to obtain a data space structure corresponding to the data layer;
a data space structure compression unit configured to, for each of the data space structures: when any at least two adjacent cubes in the data space structure are judged to be associated, the associated cubes are compressed to generate a compressed data space structure;
the processing unit is used for judging whether the set image compression ratio corresponds to lossless compression or not, if so, outputting the compressed data space structure, otherwise, carrying out erasing processing of a corresponding degree on the compressed data space structure according to the image compression ratio and outputting the erased data space structure;
the data space structure compression unit is specifically configured to stack any two cubes located in the same row in the data space structure when it is determined that the two cubes are the same, and fuse the two cubes when it is determined that the surfaces of the cubes located in the same row in the data space structure are the same;
or the like, or, alternatively,
stacking any two cubes in the same column in the data space structure when judging that the two cubes are the same, and fusing the two cubes when judging that the cube surfaces between any two adjacent cubes in the same column in the data space structure are the same;
the image compression rate is any one of 1 to 100, wherein 100 corresponds to lossless compression and any one of 1 to 99 corresponds to lossy compression;
the data space structure compression unit is specifically configured to perform compression processing on the associated cube to obtain a corresponding compressed cube;
correspondingly, the compressed data space structure includes a first number of the compressed cubes and a second number of the uncompressed cubes, and the first number and the second number are not 0 at the same time;
the processing unit is specifically configured to erase the uncompressed cube when the image compression rate is 99; erasing the uncompressed cube and a target compressed cube of the compressed cubes when the image compression rate is any target value of 1 to 98, wherein the target compressed cube is obtained by compressing cubes with a number not more than a target value, and the target value is a difference obtained by subtracting the target value from 100.
6. The image compression apparatus according to claim 5,
the acquiring unit is specifically configured to initialize a preset multidimensional image processing module, read an image file to be compressed including at least one pixel point by using the multidimensional image processing module, and convert the image file according to an algorithm corresponding to a file format of the image file, so as to acquire original bitmap data corresponding to the image file.
CN201611049678.4A 2016-11-14 2016-11-14 Image compression method and device Active CN106780322B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611049678.4A CN106780322B (en) 2016-11-14 2016-11-14 Image compression method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611049678.4A CN106780322B (en) 2016-11-14 2016-11-14 Image compression method and device

Publications (2)

Publication Number Publication Date
CN106780322A CN106780322A (en) 2017-05-31
CN106780322B true CN106780322B (en) 2020-04-07

Family

ID=58912882

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611049678.4A Active CN106780322B (en) 2016-11-14 2016-11-14 Image compression method and device

Country Status (1)

Country Link
CN (1) CN106780322B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107809613B (en) * 2017-10-18 2020-09-01 浪潮金融信息技术有限公司 Video index creation method and device, computer readable storage medium and terminal

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1367613A (en) * 2000-12-01 2002-09-04 艾迪斯株式会社 Image compression device and its method
US7801365B2 (en) * 2003-07-03 2010-09-21 Canadian Space Agency Method of coding a continuous data flow using vector quantization
CN103763566A (en) * 2014-01-07 2014-04-30 西安建筑科技大学 Color halftone image compressing method based on three-dimensional matrix WDCT transformation

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1367613A (en) * 2000-12-01 2002-09-04 艾迪斯株式会社 Image compression device and its method
US7801365B2 (en) * 2003-07-03 2010-09-21 Canadian Space Agency Method of coding a continuous data flow using vector quantization
CN103763566A (en) * 2014-01-07 2014-04-30 西安建筑科技大学 Color halftone image compressing method based on three-dimensional matrix WDCT transformation

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于混合预测高光谱图像无损压缩;李媛媛等;《长春理工大学学报(自然科学版)》;20160229;第77-81页 *

Also Published As

Publication number Publication date
CN106780322A (en) 2017-05-31

Similar Documents

Publication Publication Date Title
Holub et al. Random projections of residuals for digital image steganalysis
CN101331480B (en) Compressing images in documents
US8548241B2 (en) Enhanced multilayer compression of image files using OCR systems
JP4236659B2 (en) Image encoding apparatus, image encoding method, image encoding program, and recording medium
US8395822B2 (en) Image processing method combining compression and watermark techniques
CN101163188B (en) Image processing apparatus, image reading apparatus, image forming apparatus, image processing method
JP2006134337A (en) Method and apparatus for decoding mixed code, and recording medium
US7085423B2 (en) Apparatus and method for filing and reproducing images
KR102049078B1 (en) Image analysis
JP3923796B2 (en) Two-dimensional code, two-dimensional code creation method, two-dimensional code decoding method, apparatus for executing the method, program for executing the method on a computer, and computer-readable recording medium recording the program
CN106780322B (en) Image compression method and device
KR20070036991A (en) System and method for image forming
US9681013B2 (en) Methods and systems facilitating generation of digital representations of objects
US9781419B2 (en) Compressing image data
CN111212322A (en) Video compression method based on multi-video de-duplication splicing
CN1333575C (en) Image encoding device and method, and encoded image decoding device and method
JP2006246374A (en) Image compressor, image compression method, and image compression program
CN112187284A (en) Encoding method, encoding pattern reading method, and imaging device
CN104112100A (en) Data hiding method and device based on bitmap
JP3062224B2 (en) Image coding method
CN102521635B (en) Decoding method for continuous multi-system bar code
JP6481301B2 (en) Image processing apparatus and image processing program
KR102317205B1 (en) Method and apparatus for estimating parameters of compression algorithm
JP4878040B2 (en) Image encoding apparatus, image encoding method, image encoding program, and recording medium
CN109949382B (en) Method for realizing high-density compression and decompression of pictures based on machine learning

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
CB02 Change of applicant information

Address after: Wusong Industrial Park, Wuzhong Development District of Suzhou City, Jiangsu province 215100 Wusong Road No. 818

Applicant after: Tide Financial Information Technology Co Ltd

Address before: Wuzhong Economic Development Zone in Suzhou City, Jiangsu Province, the River Street 215104 tower rhyme Road No. 178 Building 2 layer 1

Applicant before: Tide (Suzhou) Financial Technology Service Co., Ltd.

GR01 Patent grant
GR01 Patent grant