CN115249276A - Image compression method, image compression device, electronic equipment and storage medium - Google Patents

Image compression method, image compression device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115249276A
CN115249276A CN202210934170.1A CN202210934170A CN115249276A CN 115249276 A CN115249276 A CN 115249276A CN 202210934170 A CN202210934170 A CN 202210934170A CN 115249276 A CN115249276 A CN 115249276A
Authority
CN
China
Prior art keywords
key information
information area
target
target image
compressed
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.)
Pending
Application number
CN202210934170.1A
Other languages
Chinese (zh)
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.)
China Telecom Corp Ltd
Original Assignee
China Telecom Corp 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 China Telecom Corp Ltd filed Critical China Telecom Corp Ltd
Priority to CN202210934170.1A priority Critical patent/CN115249276A/en
Publication of CN115249276A publication Critical patent/CN115249276A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6209Protecting access to data via a platform, e.g. using keys or access control rules to a single file or object, e.g. in a secure envelope, encrypted and accessed using a key, or with access control rules appended to the object itself

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • Multimedia (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

The application relates to an image compression method, an image compression device, an electronic device and a storage medium, wherein the image compression method comprises the following steps: acquiring a target image according to a preset image resolution; segmenting the target image according to a preset image segmentation rule to obtain a key information area and a non-key information area; encrypting the key information area based on a pixel color difference algorithm to obtain an encrypted key information area; and respectively compressing the encrypted key information area and the non-key information area to obtain a compressed target image. By classifying the target images, the utilization rate of the storage space is improved, and meanwhile, the information safety of a user is protected to a great extent.

Description

Image compression method, image compression device, electronic equipment and storage medium
Technical Field
The present application relates to the field of image processing, and in particular, to an image compression method and apparatus, an electronic device, and a storage medium.
Background
Due to the requirement of real name, all mobile communication users need to collect the identification card information, for example, collecting image information such as user identification card number, home address and the like and directly storing the image information can cause a large amount of storage space to be occupied.
In the prior art, acquired image information is compressed, however, a common technical means for image compression and storage is to compress and directly store an image by using a Run-Length Encoding (RLE) or Joint Photographic Experts Group (JPEG) algorithm, and the two methods can directly see all information when the acquired image information is viewed, which has an information security risk.
Disclosure of Invention
In view of the above problems, embodiments of the present application are proposed to provide an image compression method, apparatus, electronic device, and storage medium that overcome or at least partially solve the above problems.
According to a first aspect of the present application, there is provided an image compression method, the method comprising:
acquiring a target image according to a preset image resolution;
segmenting the target image according to a preset image segmentation rule to obtain a key information area and a non-key information area;
encrypting the key information area based on a pixel color difference algorithm to obtain an encrypted key information area;
and respectively compressing the encrypted key information area and the non-key information area to obtain a compressed target image.
Optionally, the key information area and the non-key information area respectively correspond to different address identifiers, and the compressing the encrypted key information area and the non-key information area respectively to obtain a compressed target image includes:
respectively compressing the encrypted key information area and the non-key information area to obtain a compressed encrypted key information area and a compressed non-key information area;
performing association processing on the compressed and encrypted key information area and the compressed non-key information area in the same target image according to the address identifier;
and under the condition that the compression encryption key information area is detected and the compression non-key information area is associated, packaging the compression encryption key information area and the compression non-key information area to generate a target image compression packet and a target compression address corresponding to the target image compression packet.
Optionally, the encrypting the key information area based on the pixel color difference algorithm to obtain an encrypted key information area includes:
acquiring a random character string, wherein an address identifier corresponding to the random character string and different address identifiers corresponding to the key information area and the non-key information area respectively exist in an association relationship, and the random character string and the address identifier corresponding to the random character string are stored in the target image compression packet;
analyzing the random character string to obtain a target code, wherein the target code comprises an image color change degree, a continuous color change area and an image color change adjustment value;
and performing color change processing on each target pixel in the key information area according to the image color change degree, the continuous color change area and the image color change adjusting value to obtain an encrypted key information area.
Optionally, after the step of segmenting the target image according to the preset image segmentation rule to obtain a key information area and a non-key information area, and before the step of compressing the encrypted key information area and the non-key information area respectively to obtain a compressed target image, the method further includes:
dividing the non-key information area into a preset number of target blocks;
performing difference processing on pixels corresponding to all the target blocks and pixels corresponding to each stock block in the stock block set to obtain a plurality of block differences, wherein the stock blocks are obtained based on historical target images;
and judging whether a target stock block similar to the target block exists in the stock block set or not according to the relation between each block difference value and a preset threshold value.
Optionally, different target blocks correspond to different address identifiers, and after the step of determining whether a duplicate block similar to the target block exists in the stock block according to the relationship between the block difference and a preset threshold, the method further includes:
under the condition that a target stock block similar to the target block exists in the stock block set, deleting the target block, taking the target stock block as the target block, and updating the non-key information area based on the target stock block;
and under the condition that a target stock block similar to the target block does not exist in the stock block set, updating the stock block set based on the target block, and keeping the non-key information area.
Optionally, the compressing the encrypted key information region and the non-key information region respectively to obtain a compressed confidential key information region, and compressing the non-key information region includes:
and respectively carrying out lossless compression processing on the encrypted key information areas, and carrying out lossy compression processing on the non-key information areas to obtain compressed confidential key information areas and compressed non-key information areas.
Optionally, after the step of compressing the encrypted key information area and the non-key information area respectively to obtain a compressed target image, the method further includes:
under the condition that a decompression request is received, verifying according to the level corresponding to the decompression request to obtain the target image decompression area;
and decompressing the compressed target image according to the target image decompression area.
Optionally, the decompressing request includes a target compression address corresponding to the target image, and the decompressing the compressed target image according to the target image decompressing area includes:
under the condition that the target image decompression area is detected to be the non-key information area, inquiring the target image compression packet based on the target compression address, and decompressing the compressed non-key information area in the target compression packet;
under the condition that the target image decompression area is detected to be the key information area, inquiring the target image compression packet based on the target compression address, and decompressing the compressed and encrypted key information area after decryption;
under the condition that the target image decompression area is detected to be the target image, inquiring the target image compression packet based on the target compression address, respectively decompressing the compression non-key information area in the target compression packet, decrypting the compression encryption key information area and decompressing to obtain the key information area and the non-key information area, and splicing the key information area and the non-key information area based on the address identification to obtain the decompressed target image.
Optionally, the decrypting and decompressing the encrypted key information region includes:
decrypting the compressed and encrypted key information area based on the random character string in the target image compressed packet to obtain a decrypted key information area;
and decompressing the decrypted key information area to obtain the key information area.
According to a second aspect of the present application, there is provided an image compression apparatus characterized by comprising:
the acquisition module is used for acquiring a target image according to a preset image resolution;
the segmentation module is used for segmenting the target image according to a preset image segmentation rule to obtain a key information area and a non-key information area;
the encryption module is used for encrypting the key information area based on a pixel color difference algorithm to obtain an encrypted key information area;
and the compression module is used for respectively compressing the encrypted key information area and the non-key information area to obtain a compressed target image.
According to a third aspect of the present application, an electronic device is provided, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for executing the program stored in the memory.
According to a fourth aspect of the present application, there is provided a computer-readable storage medium having a computer program stored thereon.
The method comprises the steps of obtaining a target image according to a preset image resolution; segmenting the target image according to a preset image segmentation rule to obtain a key information area and a non-key information area; encrypting the key information area based on a pixel color difference algorithm to obtain an encrypted key information area; and respectively compressing the encrypted key information area and the non-key information area to obtain a compressed target image. The method has the advantages that the collected target image resolution can be unified automatically by acquiring the target image through the preset image resolution, the image is not required to be processed manually by a user, the image can be rapidly processed in the follow-up process of compressing the image, the target image is classified into a key information area and a non-key information area, different compression methods are adopted for different areas, the occupation amount of a storage space is reduced to the maximum extent, the key information area is encrypted through a pixel color difference algorithm, and the information safety of the user is protected. The important information of the user is prevented from being leaked. According to the method and the device, the key information and the non-key information are classified, so that the utilization rate of the storage space is improved, and the information safety of the user is protected to a great extent.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application.
FIG. 1 is a flow diagram illustrating a method of image compression according to an exemplary embodiment;
FIG. 2 is a method flow diagram of step 104 of the flow diagram of a method of image compression shown in FIG. 1 according to an exemplary embodiment;
FIG. 3 is a method flow diagram of step 103 of the flow diagram of a method of image compression shown in FIG. 1 according to an exemplary embodiment;
FIG. 4 is a flow diagram illustrating another method of image compression according to an exemplary embodiment;
FIG. 5 is a flow diagram illustrating another method of image compression according to an exemplary embodiment;
FIG. 6 is a method flow diagram of step 1011 of the flow diagram of another method of image compression shown in FIG. 5 in accordance with an exemplary embodiment;
FIG. 7 illustrates a block diagram of an image compression apparatus according to an exemplary embodiment.
Detailed Description
Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The terms first, second and the like in the description and in the claims of the present application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the application are capable of operation in sequences other than those illustrated or described herein, and that the terms "first," "second," etc. are generally used in a generic sense and do not limit the number of terms, e.g., a first term can be one or more than one. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/" generally means that a preceding and succeeding related objects are in an "or" relationship.
The image compression method, the image compression apparatus, the electronic device, and the storage medium according to the embodiments of the present application are described in detail below with reference to the accompanying drawings.
It should be noted that the present application may be applied to an information collection terminal of an operator, or other information collection scenarios, for example, the operator collects identity information through a mobile terminal, and uses the identity information to newly handle a number card real name, so as to prevent lawless persons from fraudulently, but after collecting the identity information, a large number of user identity card images are stored, and occupy a large amount of storage space and are important information of users, and if a leakage result is very serious, the above problem may be solved, and the storage space may be greatly saved and the security of sensitive data may be improved through the image compression method provided in the embodiment of the present application.
A first embodiment of the present application relates to an image compression method, and fig. 1 is a flowchart illustrating an image compression method according to an exemplary embodiment, as shown in fig. 1, including the steps of:
step 101, acquiring a target image according to a preset image resolution.
It should be noted that, in the embodiment of the present application, since the id card images shot by different mobile phones have different resolutions according to different models, in order to facilitate subsequent unified compression management on the target image, the image resolution may be preset, and the resolution may be specifically consistent by specifying the width and height of the image.
In this embodiment of the application, the target image may be any image data that meets a preset image resolution, for example, an identity card image and the like, and may be acquired in real time or directly uploaded through a mobile terminal, so as to facilitate understanding of technical solutions of the application by those skilled in the art, the identity card image is taken as an example for description, but the application is not limited to be only applicable to compressing the acquired identity card image. Therefore, firstly, resolution of the acquired identification card images needs to be unified, for example, the resolution of the shot photos is automatically adjusted by the terminal to be 716 times 441, so that the resolutions of all the photos are the same, and it is ensured that no error occurs in the subsequent operation.
And 102, segmenting the target image according to a preset image segmentation rule to obtain a key information area and a non-key information area.
It should be noted that, after a target image is acquired, the target image is divided according to a preset image division rule, and the divided regions are divided into a key information region and a non-key information region, and the two different types of regions are stored in a classified manner, but not all of them are stored in one file path, where the image division rule may be that the regions are classified according to the importance of data content in the image, and the key information blocks are also divided according to specific information in the key information region, the remaining portions are non-key information regions, and the non-key information regions are also divided into a preset number of non-key information blocks according to a preset configuration.
And 103, encrypting the key information area based on a pixel color difference algorithm to obtain an encrypted key information area.
It should be noted that, in the embodiment of the present application, in order to ensure that the target image has independent encryption desensitization with different constants and achieve secure storage of information, the encryption processing is performed on the key information area through the pixel color difference algorithm, so as to obtain an encrypted key information area.
Further, as shown in fig. 3, fig. 3 is a method flowchart of step 103 of the flowchart of a method of image compression shown in fig. 1 according to an exemplary embodiment, step 103 comprising the steps of:
step 1031, acquiring a random character string, wherein an address identifier corresponding to the random character string, a key information area and a non-key information area respectively correspond to different address identifiers and have an association relationship, and the random character string and the address identifier corresponding to the random character string are stored in a target image compression packet;
step 1032, analyzing the random character string to obtain a target code, wherein the target code comprises an image color change degree, a continuous color change area and an image color change adjustment value;
and 1033, performing color change processing on each target pixel in the key information area according to the color change degree of the image, the continuous color change area and the color change adjustment value of the image to obtain an encrypted key information area.
The foregoing steps 1031 to 1032 are specific steps of a pixel color difference algorithm, specifically, a randomly generated random character string is obtained first, it should be noted that, in this embodiment of the present application, in addition to the address identifier corresponding to each block, the random character string confidential to the key information block is also stored independently, and there is an association relationship between the address identifier corresponding to the random character string and the different address identifiers corresponding to the key information area and the non-key information area, and the random character string and the address identifier corresponding to the random character string are stored in the target image compression packet, and the target image compression packet is elaborated in steps 1041 to 1043. Secondly, the random character string is analyzed to obtain a target code, it should be noted that in the embodiment of the present application, the character string may be analyzed to ASCII code, but the method is not limited to this analysis manner, as long as the random character string can be analyzed and the subsequent key information area is encrypted, the embodiment of the present application may be used, the data after the target code is analyzed may be 3 digits or other digits, the specific digits may be determined according to a digit adjustment algorithm, the present application is not specifically limited, the target code includes an image color change degree, a continuous color change area, and an image color change adjustment value, and each target pixel in the key information area is subjected to color change processing through these digits to obtain an encrypted key information area.
For example, a random 3-bit character string 3BQ is generated and analyzed as an ASCII code to obtain [51, 66, 81], the first bit of the character string represents the color change degree of RGB, the second bit represents a continuous color change area, the third bit represents an adjustment value of the next color change after the continuous color change is completed, the identification number is encrypted and desensitized through the code, a monochrome image is taken as an example, the first pixel RGB (FFFEFE) is subjected to color change to obtain RGB (CCCBCB), after 66 pixel points are continuously processed (the last line is automatically changed), color adjustment is performed, the 67 th pixel point starts to change color into RGB (7B 7A), RGB (2 a 2929) and RGB (D8D 7.) are sequentially obtained, the character string of each image is randomly generated, the purpose of independently encrypting each image is achieved, the key information area is encrypted based on a pixel color difference algorithm, the random character string can be upgraded to a higher level, and the security is improved.
And 104, respectively compressing the encrypted key information area and the non-key information area to obtain a compressed target image.
After the key information area is encrypted in step 103, different areas are compressed to obtain a compressed target image.
The key information area and the non-key information area correspond to different address identifiers respectively, for example, after the terminal acquires the identification card image, the image is uploaded to the server, the information data in the identification card image is divided before storage, the identification card number and the grid image are divided into key information areas, the rest other areas are non-key information areas, the non-key information areas are divided into 7 non-key information blocks, for example, 9 files are counted, address marks are distributed to 9 blocks respectively, for example, the identification card is divided into IMG001_1, IMG001_2, IMG001_3, IMG001_4, IMG001_5, IMG001_6, IMG001_7, IMG001_8 and IMG001_9 in sequence, wherein the IMG001_1 and IMG001_2 are grid image and identification card number codes respectively, and the IMG001_3, IMG _4, IMG001_5, IMG _ 001_6, IMG001_7, IMG001_8 and IMG001_9 are other blocks.
Specifically, as shown in fig. 2, fig. 2 is a method flowchart of step 104 of the flowchart of an image compression method shown in fig. 1 according to an exemplary embodiment, and step 104 includes the following steps:
step 1041, respectively compressing the encrypted key information area and the non-key information area to obtain a compressed encrypted key information area and a compressed non-key information area.
It should be noted that, in this embodiment of the present application, the compressing with the encrypted key information area and the encrypted non-key information area to obtain a compressed encrypted key information area and a compressed non-key information area, the compressing the encrypted key information area and the non-key information area to obtain a compressed confidential key information area, and the compressing the non-key information area includes: and respectively carrying out lossless compression processing on the encrypted key information areas, and carrying out lossy compression processing on the non-key information areas to obtain compressed confidential key information areas and compressed non-key information areas.
Specifically, in the embodiment of the present application, after the key information desensitization is completed, lossless compression of the key information area image may be completed through an RLE algorithm, and after pure color chart RGB (FFFEFE) desensitization is taken as an example, the lossless compression may be:
[ FFFEFE ]66[2 [7B ] CCCBCBCBCB ]66[2A2929]66[ 8D 7]66 ], in addition, for a non-key information area, since the information content is not critical, the processing can be carried out by using lossy compression, for example, JPEG algorithm is used to carry out lossy compression on the non-key information, and the processing is sequentially finished by color space conversion, reduced sampling, DCT transform, quantization and Huffman coding, and the concrete process can be as follows:
the method comprises the steps of firstly, performing color space conversion on a non-key information area, namely using a YUV algorithm, reserving Y latitude, discarding a large amount of information on UV dimensionality, secondly, performing reduction sampling on the non-key information area, namely deleting UV latitude data at intervals to realize data reduction, and thirdly, performing DCT (discrete cosine transformation) conversion on the non-key information area, namely in image coding, storing an image in a matrix form, wherein the image is a two-dimensional array, performing two-dimensional DCT on the image, converting a time domain image into a frequency domain energy distribution diagram, realizing energy concentration to remove spatial redundancy, and most of energy comprises a large amount of flat areas, so most of energy is concentrated in a low-frequency area, and the purpose of removing the spatial redundancy can be achieved; fourthly, quantizing the non-key information area, performing a large amount of lossy abandoning on the data with lower weight, and performing slightly lossy abandoning on the data with higher weight; and fifthly, carrying out Huffman coding on the non-key information area. After the above steps are performed with partial data discarding, only the preparation of data is completed, and the final lossless compression needs to be performed by using the huffman coding, so as to form a compressed file which is finally stored in the disk.
It should be noted that, the key information area has a higher requirement on resolution when used, and the non-key area has a low information utilization rate and has a lower requirement on resolution. Therefore, the key information area and the non-key information area are subjected to hierarchical compression processing. Lossless compression can be carried out on the image in the key information area, and the image is converted into a compressed character string to be independently stored (because the key information area needs to be encrypted and desensitized); lossy compression is performed on the non-key information area image. According to the method and the device, the storage space can be greatly reduced through partition processing, the space is more effectively compressed, and the storage cost of the server is saved for the storage of mass identity cards.
And 1042, performing association processing on the compressed and encrypted key information area and the compressed non-key information area in the same target image according to the address identifier.
After the target image is compressed and desensitized and encrypted, each block after the target image is divided is stored separately, and each block has its own corresponding address identifier, so that all blocks in the same target image can be associated based on the address identifiers to ensure consistent data during decompression.
And 1043, under the condition that the compressed and encrypted key information area is detected and the compressed and non-key information area is associated, performing packing processing on the compressed and encrypted key information area and the compressed and non-key information area to generate a target image compression packet and a target compression address corresponding to the target image compression packet.
Under the condition that the compressed and encrypted key information area is determined and the compressed non-key information area is associated, the compressed files are packaged, namely all compressed blocks corresponding to the same target image are unified to generate a target image compressed packet through the address identification, and the address identification corresponding to the target image compressed packet is the target compressed address.
Specifically, taking the identification card image as an example, the target compression address is IMG001, the key information area address identifier and the non-key information area address identifier are IMG001_1, IMG001_2, IMG001_3, IMG001_4, IMG001_5, IMG001_6, IMG001_7, IMG001_8, IMG001_9, and IMG001 xu 3bq, and after the addresses are determined, all files and addresses are sorted into a compression package to obtain the target image compression package as follows: the system comprises a main address directory, an IMG001, a grid illumination RLE code directory, an IMG001_1 desensitization identity card RLE code directory, an IMG001_2, a block information directory, an IMG001_3, an IMG001_4, an IMG001_5, an IMG001_6, an IMG001_7, an IMG001_8, an IMG001_9, a random string directory and an IMG001_3BQ.
According to the embodiment of the application, the target image is acquired through the preset image resolution, the uniform resolution of the acquired target image can be automatically realized, the image is not required to be manually processed by a user, the image is conveniently and rapidly processed in the follow-up process of compressing the image, different compression methods are adopted for different areas by classifying the target image into the key information area and the non-key information area, the occupation amount of a storage space is greatly reduced, the key information area is encrypted through a pixel color difference algorithm, and the information safety of the user is protected. And leakage of important information of the user is prevented. According to the method and the device, the key information and the non-key information are classified, so that the utilization rate of the storage space is improved, and the information safety of the user is protected to a great extent.
A second embodiment of the present application relates to an image compression method, and fig. 4 is a flowchart illustrating another image compression method according to an exemplary embodiment, as shown in fig. 4, including the steps of:
step 101, acquiring a target image according to a preset image resolution.
And 102, segmenting the target image according to a preset image segmentation rule to obtain a key information area and a non-key information area.
And 103, encrypting the key information area based on a pixel color difference algorithm to obtain an encrypted key information area.
The details of steps 101-103 are discussed with reference to the preamble and will not be described herein.
Step 105, dividing the non-key information area into a preset number of target blocks.
It should be noted that the specific preset number may be divided according to the information content of the non-key information area, for example, taking the id card image as an example, the non-key information area may be divided into 7 target blocks, and the specific number is not specifically limited in this application.
And 106, performing difference processing on the pixels corresponding to all the target blocks and the pixels corresponding to each stock block in the stock block set to obtain a plurality of block differences, wherein the stock blocks are obtained based on the historical target image.
It should be noted that, for stock blocks, the stock blocks are calculated blocks and may be acquired based on a history target image. After the target block is divided in step 105, the target block and the stock block need to be compared, for example, for a target block, the matrix content in formula 1 may be expressed in the form of a matrix in formula 1, where the matrix content in formula 1 represents RGB values corresponding to each pixel in each target block.
Figure BDA0003782850690000111
For a stock block, the matrix in formula 2 can be expressed in the form of a matrix, and the matrix content in formula 2 represents the RGB value corresponding to each pixel in each stock block.
Figure BDA0003782850690000112
The difference matrix can be obtained by subtracting the two matrices and taking the absolute value, as shown in formula 3, the content of the matrix in formula 3 represents the difference matrix obtained by subtracting the matrix in formula 1 from the matrix in formula 2 and taking the absolute value.
Figure BDA0003782850690000113
And step 107, judging whether a target stock block similar to the target block exists in the stock block set according to the relation between each block difference value and a preset threshold value.
And 108, under the condition that a target stock block similar to the target block exists in the stock block set, deleting the target block, taking the target stock block as the target block, and updating the non-key information area based on the target stock block.
And step 109, under the condition that the target stock block similar to the target block does not exist in the stock block set, updating the stock block set based on the target block and keeping the non-key information area.
It should be noted that, in the above steps 107-108, the target block and the stock block are compared, specifically, a difference value may be obtained by subtracting the RGB value of each pixel in each target block from the RGB value of each pixel in the corresponding stock block, for example, the difference value between the target block and the stock block may be obtained based on the above formula 3 as 18, at this time, if the set threshold is 20, the difference value may be considered acceptable, at this time, the target block may be deleted, or the target block may be automatically discarded, the stock block is directly used to replace the target block, if the threshold is 10, the difference value exceeds the threshold, and needs to be independently stored and used as the stock block for subsequent comparison, the target block is obtained by cutting a non-key information area, and the target block is compared with the stock block to determine whether to be multiplexed, so as to reduce the number of similar blocks, the storage is performed by using a multiplexing means, and the storage space is greatly reduced.
For steps 105 to 109 and step 103, there is no precedence order, and they can be performed simultaneously, and this embodiment of the present application is only an embodiment, and does not mean that steps 105 to 109 are necessarily performed after step 103.
And 104, respectively compressing the encrypted key information area and the non-key information area to obtain a compressed target image.
The details of step 104 are discussed with reference to the preamble and will not be described herein.
According to the embodiment of the application, the mobile terminal acquires the identity information of a user to obtain a target image, the key information area and the non-key information area are divided, different areas are subjected to grading processing, the key information area is subjected to lossless compression after being processed through a desensitization algorithm, the non-key information area is subjected to lossy compression, further, a plurality of target blocks are obtained by cutting the non-key information area, and the target blocks are compared with the stock blocks to determine whether to multiplex or not. The number of similar blocks (repeated blocks) can be reduced, the storage space is greatly reduced by adopting a multiplexing means for storage, and the information safety of a user is greatly protected while the utilization rate of the storage space is improved.
A third embodiment of the present application relates to an image compression method, and fig. 5 is a flowchart illustrating another image compression method according to an exemplary embodiment, as shown in fig. 5, including the steps of:
step 101, acquiring a target image according to a preset image resolution.
And 102, segmenting the target image according to a preset image segmentation rule to obtain a key information area and a non-key information area.
And 103, encrypting the key information area based on a pixel color difference algorithm to obtain an encrypted key information area.
And step 104, respectively compressing the encrypted key information area and the non-key information area to obtain a compressed target image.
The above steps 101-104 are discussed with reference to the preamble and will not be described further herein.
Step 1010, in the case of receiving a decompression request, performing verification processing according to a level corresponding to the decompression request to obtain a target image decompression area;
in step 1011, the compressed target image is decompressed according to the target image decompression area.
It should be noted that, in the above steps 1010-1011, the present application may further perform decryption and decompression on the image after performing encryption compression on the target image, and because of the manner in which different regions are stored separately in the present application, the present application may perform decompression on the target image to different degrees according to different requests.
And under the condition of receiving the decompression request, verifying according to the level corresponding to the decompression request to obtain a target image decompression area corresponding to the decompression request, and decompressing the compressed target image according to the decompression area corresponding to the target image.
Specifically, the decompression request includes a target compression address corresponding to the target image, that is, when a user or an operator needs to decompress and view the compressed target image, the transmitted decompression request carries the target compression address corresponding to the target image, so that the target image can be located quickly.
As shown in fig. 6, fig. 6 is a method flowchart of step 1011 of the flowchart of another image compression method shown in fig. 5 according to an exemplary embodiment, and step 1011 includes:
step 10111, under the condition that the target image decompression area is detected to be a non-key information area, inquiring the target image compression packet based on the target compression address, and decompressing the compressed non-key information area in the target compression packet.
Step 10112, under the condition that the target image decompression area is detected to be the key information area, inquiring a target image compression packet based on the target compression address, and decompressing the compressed and encrypted key information area after decryption.
Step 10113, under the condition that the target image decompression area is detected to be the target image, inquiring the target image compression packet based on the target compression address, respectively decompressing the compression non-key information areas in the target compression packet, decrypting the compression encryption key information areas and decompressing to obtain the key information areas and the non-key information areas, and splicing the key information areas and the non-key information areas based on the address identification to obtain the decompressed target image.
Specifically, the decrypting and decompressing the encrypted key information region in the above step specifically includes: decrypting the compressed and encrypted key information area based on the random character string in the target image compressed packet to obtain a decrypted key information area; and decompressing the decryption key information area to obtain the key information area.
In the above steps 10111-10113, different decompression areas are determined according to different requests, and when character key information such as an identification number is not needed, only a user portrait needs to be used for comparison, only the user portrait part is desensitized; when all key information is needed, performing grade verification and performing anti-desensitization; when the key information is not needed, only the non-key information is utilized, and only the non-key information needs to be decompressed.
If both the key information and the non-key information need to be decompressed, inquiring the target image compression packet based on a target compression address, respectively decompressing a compression non-key information region in the target compression packet, and decompressing a compression encryption key information region, for example, searching the compression packet through the address IMG001, obtaining the grid photograph IMG001_1 and decompressing, obtaining and decompressing the desensitization identification card IMG001_2, obtaining and decompressing the block information IMG001_3, IMG001_4, IMG001_5, IMG001_6, IMG001_7, IMG001_8 and IMG001_9, if the desensitization is not needed, directly splicing the image to obtain the desensitization identification card photo, if the desensitization is needed, obtaining the random string IMG001_3BQ first, obtaining an original image through random string desensitization, and re-splicing to obtain the original image.
According to the embodiment of the application, decompression of the target image in different degrees can be achieved based on different request levels, a large amount of storage space can be saved in an actual use scene, desensitized or non-desensitized images can be extracted and used according to needs, when operations such as half-body photograph manual auditing and customer data inquiring need to be performed, desensitized images are provided, non-desensitized images are provided when identity card information auditing needs to be performed, and therefore safe storage of user information is achieved.
A fourth embodiment of the present application relates to an image compression apparatus, and as shown in fig. 7, fig. 7 is a block diagram of an apparatus for image compression according to an exemplary embodiment, the apparatus including the following modules:
an obtaining module 701, configured to obtain a target image according to a preset image resolution;
a segmentation module 702, configured to segment the target image according to a preset image segmentation rule to obtain a key information region and a non-key information region;
the encryption module 703 is configured to encrypt the key information area based on a pixel color difference algorithm to obtain an encrypted key information area;
a compressing module 704, configured to compress the encrypted key information area and the non-key information area respectively, so as to obtain a compressed target image.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
Further, based on the same inventive concept, embodiments of the present application further provide an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the method steps in any of the above embodiments are implemented.
Based on the same inventive concept, in the specific embodiment of the present application, when the processor executes the computer program, any implementation manner of the method of the embodiment of the present application may be implemented.
Since the electronic device described in the embodiment of the present application is a device used for implementing the method of the embodiment of the present application, a person skilled in the art can understand the specific structure and the deformation of the device based on the method described in the embodiment of the present application, and thus details are not described herein. All the devices adopted in the method of the embodiment of the present application belong to the protection scope of the present application.
Based on the same inventive concept, the specific embodiment of the present application further provides a storage medium corresponding to the method in the embodiment: the present embodiment provides a computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, realizes the method steps of any of the above embodiments.
In the implementation, when the computer program is executed by a processor, any one of the methods of the embodiments of the present application may be implemented.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as methods, apparatus, storable media and processors. Accordingly, embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
In a typical configuration, the computer device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory. The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium. Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (fransitory media), such as modulated data signals and carrier waves.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all changes and modifications that fall within the true scope of the embodiments of the present application.
Finally, it should also be 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 terminal 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 terminal. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or terminal apparatus that comprises the element.
The foregoing detailed description is directed to an image compression method, an image compression apparatus, an electronic device, and a storage medium, which are provided by the present application, and specific examples are applied in the present application to explain the principles and embodiments of the present application, and the descriptions of the foregoing examples are only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (12)

1. A method of image compression, the method comprising:
acquiring a target image according to a preset image resolution;
segmenting the target image according to a preset image segmentation rule to obtain a key information area and a non-key information area;
encrypting the key information area based on a pixel color difference algorithm to obtain an encrypted key information area;
and respectively compressing the encrypted key information area and the non-key information area to obtain a compressed target image.
2. The method according to claim 1, wherein the key information area and the non-key information area correspond to different address identifiers, and the compressing the encrypted key information area and the non-key information area to obtain the compressed target image comprises:
compressing the encrypted key information area and the non-key information area respectively to obtain a compressed encrypted key information area and a compressed non-key information area;
performing association processing on the compressed and encrypted key information area and the compressed non-key information area in the same target image according to the address identifier;
and under the condition that the compressed and encrypted key information area is detected and the compressed and non-key information area is associated, packaging the compressed and encrypted key information area and the compressed and non-key information area to generate a target image compression packet and a target compression address corresponding to the target image compression packet.
3. The method according to claim 2, wherein the encrypting the key information area based on the pixel color difference algorithm to obtain an encrypted key information area comprises:
acquiring a random character string, wherein an address identifier corresponding to the random character string and different address identifiers corresponding to the key information area and the non-key information area respectively exist in an association relationship, and the random character string and the address identifier corresponding to the random character string are stored in the target image compression packet;
analyzing the random character string to obtain a target code, wherein the target code comprises an image color change degree, a continuous color change area and an image color change adjustment value;
and performing color change processing on each target pixel in the key information area according to the image color change degree, the continuous color change area and the image color change adjusting value to obtain an encrypted key information area.
4. The method according to claim 1, wherein after the step of segmenting the target image according to the preset image segmentation rule to obtain a key information area and a non-key information area, and before the step of compressing the encrypted key information area and the non-key information area respectively to obtain a compressed target image, the method further comprises:
dividing the non-key information area into a preset number of target blocks;
performing difference processing on pixels corresponding to all the target blocks and pixels corresponding to each stock block in the stock block set to obtain a plurality of block differences, wherein the stock blocks are obtained based on historical target images;
and judging whether a target stock block similar to the target block exists in the stock block set or not according to the relation between each block difference value and a preset threshold value.
5. The method of claim 4, wherein different target blocks correspond to different address identifiers, and after the step of determining whether a duplicate block similar to the target block exists in the stock block according to the relationship between the block difference and a preset threshold, the method further comprises:
under the condition that a target stock block similar to the target block is detected to exist in the stock block set, deleting the target block, taking the target stock block as the target block, and updating the non-key information area based on the target stock block;
and under the condition that a target stock block similar to the target block does not exist in the stock block set, updating the stock block set based on the target block and keeping the non-key information area.
6. The method of claim 2, wherein the compressing the encrypted critical information area and the non-critical information area separately results in a compressed confidential critical information area, and compressing the non-critical information area comprises:
and respectively carrying out lossless compression processing on the encrypted key information areas, and carrying out lossy compression processing on the non-key information areas to obtain compressed confidential key information areas and compressed non-key information areas.
7. The method according to claim 1, wherein after the step of compressing the encrypted key information area and the non-key information area respectively to obtain compressed target images, the method further comprises:
under the condition that a decompression request is received, verifying according to the level corresponding to the decompression request to obtain the target image decompression area;
and decompressing the compressed target image according to the target image decompression area.
8. The method according to claim 7, wherein the decompression request includes a target compression address corresponding to the target image, and the decompressing the compressed target image according to the target image decompression area includes:
under the condition that the target image decompression area is detected to be the non-key information area, inquiring the target image compression packet based on the target compression address, and decompressing the compressed non-key information area in the target compression packet;
under the condition that the target image decompression area is detected to be the key information area, inquiring the target image compression packet based on the target compression address, and decompressing the compressed and encrypted key information area after decryption;
under the condition that the target image decompression area is detected to be the target image, inquiring the target image compression packet based on the target compression address, respectively decompressing the compression non-key information area in the target compression packet, decrypting the compression encryption key information area and decompressing to obtain the key information area and the non-key information area, and splicing the key information area and the non-key information area based on the address identification to obtain the decompressed target image.
9. The method of claim 8, wherein the decrypting the encrypted key information region and decompressing comprises:
decrypting the compressed and encrypted key information area based on the random character string in the target image compressed packet to obtain a decrypted key information area;
and decompressing the decrypted key information area to obtain the key information area.
10. An image compression apparatus, characterized in that the apparatus comprises:
the acquisition module is used for acquiring a target image according to a preset image resolution;
the segmentation module is used for segmenting the target image according to a preset image segmentation rule to obtain a key information area and a non-key information area;
the encryption module is used for encrypting the key information area based on a pixel color difference algorithm to obtain an encrypted key information area;
and the compression module is used for respectively compressing the encrypted key information area and the non-key information area to obtain a compressed target image.
11. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing the communication between the processor and the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method of any one of claims 1 to 9 when executing a program stored in the memory.
12. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 9.
CN202210934170.1A 2022-08-04 2022-08-04 Image compression method, image compression device, electronic equipment and storage medium Pending CN115249276A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210934170.1A CN115249276A (en) 2022-08-04 2022-08-04 Image compression method, image compression device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210934170.1A CN115249276A (en) 2022-08-04 2022-08-04 Image compression method, image compression device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115249276A true CN115249276A (en) 2022-10-28

Family

ID=83700699

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210934170.1A Pending CN115249276A (en) 2022-08-04 2022-08-04 Image compression method, image compression device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115249276A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116204135A (en) * 2023-04-27 2023-06-02 中科信工创新技术(北京)有限公司 Data compression method, device, equipment and medium
CN116610646A (en) * 2023-07-20 2023-08-18 深圳市其域创新科技有限公司 Data compression method, device, equipment and computer readable storage medium
CN116781916A (en) * 2023-08-21 2023-09-19 北京中星微人工智能芯片技术有限公司 Vehicle image storage method, apparatus, electronic device, and computer-readable medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116204135A (en) * 2023-04-27 2023-06-02 中科信工创新技术(北京)有限公司 Data compression method, device, equipment and medium
CN116610646A (en) * 2023-07-20 2023-08-18 深圳市其域创新科技有限公司 Data compression method, device, equipment and computer readable storage medium
CN116610646B (en) * 2023-07-20 2024-04-02 深圳市其域创新科技有限公司 Data compression method, device, equipment and computer readable storage medium
CN116781916A (en) * 2023-08-21 2023-09-19 北京中星微人工智能芯片技术有限公司 Vehicle image storage method, apparatus, electronic device, and computer-readable medium
CN116781916B (en) * 2023-08-21 2023-11-17 北京中星微人工智能芯片技术有限公司 Vehicle image storage method, apparatus, electronic device, and computer-readable medium

Similar Documents

Publication Publication Date Title
CN115249276A (en) Image compression method, image compression device, electronic equipment and storage medium
US7167988B2 (en) Information processing method and information processing apparatus
RU2613031C2 (en) Data encoding method, data decoding method, encoder, decoder and codec
Mansour et al. Reversible data hiding for electronic patient information security for telemedicine applications
CN104980278A (en) Method and device for verifying usability of biological characteristic image
Srivastava et al. Computationally efficient joint imperceptible image watermarking and JPEG compression: a green computing approach
WO2004075556A1 (en) Image compression device, image compression method, image compression program, compression/encoding method, compression/encoding device, compression/encoding program, decoding method, decoding device, and decoding program
FR2787604A1 (en) Insertion of secret mark and authentication of compressed digital image
CN112261038A (en) Big data acquisition method and system, computer equipment and storage medium thereof
Hu et al. Tamper detection and image recovery for BTC-compressed images
Xiao et al. High-capacity separable data hiding in encrypted image based on compressive sensing
Li et al. Encrypted jpeg image retrieval using histograms of transformed coefficients
CN110971581B (en) Encrypted data processing method and device
Chen et al. Recursive code construction for reversible data hiding in DCT domain
CN113779075B (en) Differential privacy-based data query method, device, equipment and storage medium
Iida et al. Robust image identification with dc coefficients for double-compressed jpeg images
Rashid et al. Deduplication practices for multimedia data in the cloud
Iida et al. Robust image identification with secure features for jpeg images
Iida et al. Robust image identification for double-compressed and resized JPEG images
CN112905575A (en) Data acquisition method, system, storage medium and electronic equipment
US11494866B2 (en) Video watermarking
Dawood et al. Secure video data deduplication in the cloud storage using compressive sensing
CN108347451B (en) Picture processing system, method and device
EP3928515A1 (en) Compression across multiple images
US20240179144A1 (en) Secure transmitting and receiving method for real time data

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