Image compression method and device, electronic equipment and storage medium
By unifying image resolution and dividing it into regions, combined with pixel color difference algorithm encryption and compression methods for different regions, the problems of image storage security and space utilization are solved, achieving secure and efficient image compression.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA TELECOM CORP LTD
- Filing Date
- 2022-08-04
- Publication Date
- 2026-06-23
AI Technical Summary
In existing technologies, image compression methods pose information security risks, especially when mobile communication user ID information is collected and stored directly, which consumes a large amount of storage space and carries a high risk of information leakage.
The target image is acquired by pre-setting the image resolution, and then divided into key information regions and non-key information regions. The key information regions are encrypted using a pixel color difference algorithm, and lossless and lossy compression are performed on the encrypted key information regions and non-key information regions respectively to generate a target image compressed package.
It achieves secure storage of image information, reduces storage space usage, improves information security, and prevents the leakage of important information.
Smart Images

Figure CN115249276B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and more particularly to image compression methods, apparatus, electronic devices, and storage media. Background Technology
[0002] Due to real-name registration requirements, all mobile communication users need to have their ID card information collected. For example, directly storing image information such as user ID card number and home address will consume a lot of storage space.
[0003] In existing technologies, image information is compressed. However, common methods for image compression and storage include using Run-Length Encoding (RLE) or the Joint Photographic Experts Group (JPEG) algorithm to compress the image separately and then store it directly. Both of these methods allow all information to be viewed directly when the image information is viewed, which poses a risk to information security. Summary of the Invention
[0004] In view of the above problems, embodiments of this application are proposed to provide an image compression method, apparatus, electronic device and storage medium that overcomes or at least partially solves the above problems.
[0005] According to a first aspect of this application, an image compression method is provided, the method comprising:
[0006] Obtain the target image based on a pre-set image resolution;
[0007] The target image is segmented according to a pre-set image segmentation rule to obtain key information regions and non-key information regions;
[0008] The key information region is encrypted based on the pixel color difference algorithm to obtain the encrypted key information region.
[0009] The encrypted key information region and the non-key information region are compressed respectively to obtain the compressed target image.
[0010] Optionally, the key information region and the non-key information region each correspond to different address identifiers, and the step of compressing the encrypted key information region and the non-key information region respectively to obtain the compressed target image includes:
[0011] The encrypted key information region and the non-key information region are compressed respectively to obtain a compressed encrypted key information region and a compressed non-key information region.
[0012] Based on the address identifier, the compressed encrypted key information region and the compressed non-key information region in the same target image are associated.
[0013] Upon detecting that the compressed encrypted key information region and the compressed non-key information region have been associated, the compressed encrypted key information region and the compressed non-key information region are packaged to generate a target image compressed package and a target compressed address corresponding to the target image compressed package.
[0014] Optionally, the encryption process of the key information region based on the pixel color difference algorithm to obtain the encrypted key information region includes:
[0015] Obtain a random string, wherein there is an association between the address identifier corresponding to the random string and the address identifiers corresponding to the key information area and the non-key information area, respectively, and the random string and the address identifier corresponding to the random string are stored in the target image compressed package;
[0016] The random string is parsed to obtain the target code, wherein the target code includes the degree of image color change, the continuously color-changing area, and the image color change adjustment value;
[0017] Based on the degree of image color change, the continuously color-changing area, and the image color change adjustment value, each target pixel in the key information area is color-changed to obtain the encrypted key information area.
[0018] Optionally, after the step of segmenting the target image according to a pre-set image segmentation rule to obtain key information regions and non-key information regions, and before the step of compressing the encrypted key information regions and the non-key information regions respectively to obtain a compressed target image, the method further includes:
[0019] The non-critical information area is divided into a preset number of target blocks;
[0020] The pixels corresponding to all the target blocks are respectively processed with the pixels corresponding to each existing block in the existing block set to obtain several block differences, wherein the existing blocks are obtained based on historical target images;
[0021] Based on the relationship between the difference of each block and a preset threshold, it is determined whether there is a target existing block in the existing block set that is similar to the target block.
[0022] Optionally, different target blocks correspond to different address identifiers. After determining whether there is a target existing block similar to the target block in the existing block set based on the relationship between the difference of each block and a preset threshold, the method further includes:
[0023] If a target block similar to the target block is detected in the existing block set, the target block is deleted, the target block is used as the target block, and the non-critical information area is updated based on the target block.
[0024] If no target block similar to the target block is detected in the existing block set, the existing block set is updated based on the target block, while maintaining the non-critical information area.
[0025] Optionally, the compression of the encrypted critical information region and the non-critical information region to obtain the compressed encrypted critical information region, and the compression of the non-critical information region, include:
[0026] The encrypted key information area is subjected to lossless compression, and the non-key information area is subjected to lossy compression, to obtain the compressed encrypted key information area and the compressed non-key information area.
[0027] Optionally, after the step of compressing the encrypted key information region and the non-key information region respectively to obtain the compressed target image, the method further includes:
[0028] Upon receiving a decompression request, a verification process is performed based on the level corresponding to the decompression request to obtain the decompressed area of the target image.
[0029] The compressed target image is decompressed according to the decompression region of the target image.
[0030] Optionally, the decompression request includes the target compression address corresponding to the target image, and the decompression process of the compressed target image according to the decompression region of the target image includes:
[0031] If the target image decompression area is detected to be the non-critical information area, the target image compressed package is queried based on the target compression address, and the compressed non-critical information area in the target image compressed package is decompressed;
[0032] If the target image decompression area is detected to be the key information area, the target image compressed package is queried based on the target compression address, and the compressed encrypted key information area is decrypted and then decompressed;
[0033] When the target image decompression area is detected to be the target image, the target image compressed package is queried based on the target compression address. The compressed non-critical information area in the target image compressed package is decompressed, and the compressed encrypted critical information area is decrypted and then decompressed to obtain the critical information area and the non-critical information area. The critical information area and the non-critical information area are then concatenated based on the address identifier to obtain the decompressed target image.
[0034] Optionally, the decompression of the encrypted key information area includes:
[0035] Based on the random string in the target image compressed package, the compressed and encrypted key information area is decrypted to obtain the decrypted key information area;
[0036] The key information area is decompressed to obtain the key information area.
[0037] According to a second aspect of this application, an image compression apparatus is provided, characterized in that the apparatus comprises:
[0038] The acquisition module is used to acquire the target image according to a pre-set image resolution;
[0039] The segmentation module is used to segment the target image according to a pre-set image segmentation rule to obtain key information regions and non-key information regions;
[0040] An encryption module is used to encrypt the key information area based on a pixel color difference algorithm to obtain an encrypted key information area;
[0041] The compression module is used to compress the encrypted key information area and the non-key information area respectively to obtain the compressed target image.
[0042] According to a third aspect of this application, an electronic device is provided, characterized in that it includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus.
[0043] Memory, used to store computer programs;
[0044] A processor is used to execute programs stored in memory.
[0045] According to a fourth aspect of this application, a computer-readable storage medium is provided on which a computer program is stored.
[0046] This application acquires a target image according to a pre-set image resolution; segments the target image according to pre-set image segmentation rules to obtain key information regions and non-key information regions; encrypts the key information regions based on a pixel color difference algorithm to obtain encrypted key information regions; and compresses both the encrypted key information regions and the non-key information regions to obtain a compressed target image. Acquiring the target image using a pre-set image resolution automatically ensures uniform resolution, eliminating the need for manual image processing by the user and facilitating rapid compression later. By classifying the target image into key and non-key information regions and applying different compression methods to different regions, the storage space required is significantly reduced. Encrypting key information regions using a pixel color difference algorithm protects user information security and prevents the leakage of important user information. In short, this application improves storage space utilization while significantly protecting user information security by classifying key and non-key information.
[0047] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0048] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application.
[0049] Figure 1 This is a flowchart illustrating an image compression method according to an exemplary embodiment;
[0050] Figure 2 yes Figure 1 A flowchart illustrating step 104 of an image compression method according to an exemplary embodiment;
[0051] Figure 3 yes Figure 1 A flowchart illustrating step 103 of an image compression method according to an exemplary embodiment;
[0052] Figure 4 This is a flowchart illustrating another image compression method according to an exemplary embodiment;
[0053] Figure 5 This is a flowchart illustrating another image compression method according to an exemplary embodiment;
[0054] Figure 6 yes Figure 5 A flowchart of a method of step 1011 in another image compression method illustrated according to an exemplary embodiment;
[0055] Figure 7 A block diagram of an image compression apparatus is shown according to an exemplary embodiment. Detailed Implementation
[0056] Exemplary embodiments of the present application will now be described in more detail 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 implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the present application to those skilled in the art.
[0057] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0058] The image compression method, apparatus, electronic device, and storage medium provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.
[0059] It should be noted that this application can be applied to an information collection terminal of an operator, or other information collection scenarios, etc. For example, operators collect identity information through mobile terminals for purposes such as real-name registration of new SIM cards, thereby preventing fraudsters from committing fraud. However, after collecting identity information, a large number of user ID card images are stored. These images occupy a lot of storage space and contain important user information. If leakage occurs, the consequences will be very serious. Therefore, the image compression method provided by the embodiments of this application can solve the above problems, significantly save storage space, and improve the security of sensitive data.
[0060] The first embodiment of this application relates to an image compression method. Figure 1 This is a flowchart illustrating an image compression method according to an exemplary embodiment, such as... Figure 1 As shown, it includes the following steps:
[0061] Step 101: Obtain the target image according to the preset image resolution.
[0062] It should be noted that, in this embodiment of the application, since the ID card images taken by different mobile phones have different resolutions due to different models, the image resolution will be preset in order to facilitate the unified compression and management of the target image in the future. Specifically, the resolution can be made consistent by specifying the width and height of the image.
[0063] In this embodiment, the target image can be any image data that conforms to a preset image resolution, such as an ID card image. It can be captured in real time or directly uploaded via a mobile terminal. To facilitate understanding of the technical solution of this application by those skilled in the art, an ID card image is used as an example for illustration, but this does not limit this application to compressing only captured ID card images. Therefore, the resolution of the captured ID card images first needs to be standardized. For example, the resolution of the captured photos can be automatically adjusted by the terminal to a uniform 716 x 441, ensuring that all photos have the same resolution and preventing errors in subsequent operations.
[0064] Step 102: Segment the target image according to the pre-set image segmentation rules to obtain key information regions and non-key information regions.
[0065] It should be noted that after the target image is acquired, it will be segmented according to the pre-set image segmentation rules, and the segmented areas will be divided into key information areas and non-key information areas. Furthermore, the two different types of areas are stored separately, not all in one file path. The image segmentation rules can be based on the importance of the data content in the image, and key information areas will also be divided into key information blocks according to specific information. The remaining part is the non-key information area, which will also be divided into a preset number of non-key information blocks.
[0066] Step 103: Encrypt the key information area based on the pixel color difference algorithm to obtain the encrypted key information area.
[0067] It should be noted that, in this embodiment of the application, in order to ensure that the target image has independent encryption and desensitization with different constants and to achieve secure information storage, the key information area is encrypted by using a pixel color difference algorithm to obtain the encrypted key information area.
[0068] Furthermore, such as Figure 3 As shown, Figure 3 yes Figure 1A flowchart illustrating step 103 of an image compression method according to an exemplary embodiment, step 103 includes the following steps:
[0069] Step 1031: Obtain a random string, wherein there is a correlation between the address identifier corresponding to the random string and the different address identifiers corresponding to the key information area and the non-key information area, and the random string and the address identifier corresponding to the random string are stored in the target image compressed package;
[0070] Step 1032: Parse the random string to obtain the target code, wherein the target code includes the degree of image color change, the continuous color change area, and the image color change adjustment value;
[0071] Step 1033: Based on the degree of image color change, the continuous color change area, and the image color change adjustment value, perform color change processing on each target pixel in the key information area to obtain the encrypted key information area.
[0072] Steps 1031-1032 above are the specific steps of the pixel color difference algorithm. Specifically, firstly, a randomly generated random string is obtained. It should be noted that in this embodiment, in addition to the corresponding address identifier for each block, the random string for confidential key information blocks is also stored independently. Furthermore, there is a correlation between the address identifier corresponding to the random string and the different address identifiers corresponding to key information areas and non-key information areas. The random string and the address identifier corresponding to the random string are stored in the target image compressed package. The target image compressed package will be described in detail in steps 1041-1043. Secondly, the random string is parsed to obtain the target code. It should be noted that in this embodiment, the string can be parsed into ASCII code, but this is not the only parsing method. As long as the random string can be parsed and the subsequent key information area is encrypted, it can be used as one of the embodiments of this application. The data after parsing the target code can be 3 digits or other digits. The specific number of digits can be determined according to the digit adjustment algorithm. This application does not make a specific limitation. The target code includes the degree of image color change, the continuous color change area, and the image color change adjustment value. By using these values, each target pixel in the key information area is color-changed to obtain the encrypted key information area.
[0073] For example, generating a random 3-character string "3BQ" and parsing it into ASCII code yields [51, 66, 81]. The first character of the string represents the degree of RGB color change, the second character represents the continuously changing color area, and the third character represents the adjustment value for the next color change after the continuous color change is completed. This encoding is used to encrypt and desensitize ID card numbers. Taking a monochrome image as an example, the first pixel is RGB (FFFEFE), which is changed to RGB (CCCBCB). After processing 66 pixels continuously (automatically wrapping to the next pixel), color adjustment is performed. The 67th pixel begins to change to RGB (7B7A7A), and so on, resulting in RGB (2A2929), RGB (2A2929), RGB (D8D7D7)... The string for each image is randomly generated, achieving independent encryption for each image. Encrypting key information areas based on pixel color difference algorithms can upgrade the random string to a higher bit level, improving security.
[0074] Step 104: Compress the encrypted key information area and the non-key information area respectively to obtain the compressed target image.
[0075] It should be noted that after encrypting the key information area in step 103, the different areas are compressed separately to obtain the compressed target image.
[0076] Key information areas and non-key information areas correspond to different address identifiers. For example, after the terminal collects the ID card image and uploads it to the server, it needs to be segmented before storage. The information data in the ID card image is divided into key information areas, with the ID card number and grid image being designated as key information areas, and the remaining image areas as non-key information areas. The non-key information areas are further divided, for example, into 7 non-key information blocks, totaling 9 files. Address labels are assigned to each of the 9 blocks, for example, sequentially designated as IMG. 001_1, IMG001_2, IMG001_3, IMG001_4, IMG001_5, IMG001_6, IMG001_7, IMG001_8, and IMG001_9, where IMG001_1 and IMG001_2 are the grid photo and ID card number, respectively, and IMG001_3, IMG001_4, IMG001_5, IMG001_6, IMG001_7, IMG001_8, and IMG001_9 are other blocks.
[0077] Specifically, such as Figure 2 As shown, Figure 2 yes Figure 1 A flowchart illustrating step 104 of an image compression method according to an exemplary embodiment, step 104 includes the following steps:
[0078] Step 1041: Compress the encrypted key information area and the non-key information area respectively to obtain the compressed encrypted key information area and the compressed non-key information area.
[0079] It should be noted that, in this embodiment of the application, the encrypted key information area and the non-key information area are compressed to obtain a compressed encrypted key information area and a compressed non-key information area. The process of 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 includes: performing lossless compression processing on the encrypted key information area and performing lossy compression processing on the non-key information area to obtain a compressed encrypted key information area and a compressed non-key information area.
[0080] Specifically, in this embodiment, after desensitizing key information, lossless compression of the key information region image can be achieved using the RLE algorithm. Taking a pure color image RGB (FFFEFE) after desensitization as an example, it can be compressed to: [FFFEFE]66[CCCBCB]66[7B7A7A]66[2A2929]66[2A2929]66[D8D7D7]66... Furthermore, for non-key information regions, since the information content is not as important as the key information, lossy compression can be used. For example, using the JPEG algorithm, lossy compression of non-key information is performed through color space conversion, downsampling, DCT transformation, quantization, and Huffman coding in sequence. The specific process can be as follows:
[0081] The first step is to perform color space conversion on non-critical information regions using the YUV algorithm, preserving the Y dimension while discarding a large amount of information in the UV dimensions. The second step is to downsample non-critical information regions by intermittently deleting UV dimension data to reduce data size. The third step is to perform DCT transformation on non-critical information regions. In image encoding, images are stored as matrices (two-dimensional arrays). DCT transforms the time-domain image into a frequency-domain energy distribution map, concentrating energy and removing spatial redundancy. Most energy contains flat regions, thus concentrating energy in low-frequency areas, achieving the goal of removing spatial redundancy. The fourth step is to quantize non-critical information regions, discarding a large amount of low-weight data with lossy characteristics and discarding higher-weight data with slight lossy characteristics. The fifth step is to perform Huffman coding on non-critical information regions. These steps, after some data discarding, only complete the data preparation. Finally, Huffman coding is used for lossless compression to form the final compressed file stored on the disk.
[0082] It should be noted that critical information areas require higher resolution, while non-critical areas have lower information utilization and therefore lower resolution requirements. Therefore, a hierarchical compression process is applied to both critical and non-critical information areas. For critical information areas, lossless compression is performed, converting the image into a compressed string for independent storage (as critical information areas require encryption and desensitization). For non-critical information areas, lossy compression is used. This application significantly reduces storage space through partitioning, more effectively compressing space and saving server storage costs for massive ID card data storage.
[0083] Step 1042: Based on the address identifier, perform association processing on the compressed encrypted key information region and the compressed non-key information region in the same target image.
[0084] After the target image is compressed and desensitized and encrypted, each block of the target image is stored separately and each block has its own corresponding address identifier. Therefore, based on the address identifier, all blocks in the same target image can be associated to ensure data consistency during decompression.
[0085] Step 1043: After detecting that the compressed encrypted key information area and the compressed non-key information area have been associated, the compressed encrypted key information area and the compressed non-key information area are packaged to generate a target image compressed package and the target compressed address corresponding to the target image compressed package.
[0086] Once the critical information area for compression and encryption has been determined, and the non-critical information area for compression has been associated, these compressed files will be packaged. This means that all compressed blocks corresponding to the same target image will be generated into a single target image compressed package using address identifiers. The address identifier corresponding to this target image compressed package is the target compression address.
[0087] Specifically, taking an ID card image as an example, the target compression address is IMG001, and the address identifiers for the critical information area and the non-critical information area are IMG001_1, IMG001_2, IMG001_3, IMG001_4, IMG001_5, IMG001_6, IMG001_7, IMG001_8, IMG001_9, and IMG001_3BQ. After determining the address, compress all files and addresses... After processing the compressed package, the target image compressed package is as follows: Main address directory, IMG001, grid photo RLE code directory, IMG001_1 desensitized ID card RLE code directory, IMG001_2, block information directory, IMG001_3, IMG001_4, IMG001_5, IMG001_6, IMG001_7, IMG001_8, IMG001_9, random string directory, IMG001_3BQ.
[0088] This application embodiment automatically achieves uniform resolution of the acquired target image by pre-setting the image resolution, eliminating the need for manual image processing by the user and facilitating rapid subsequent image compression. By classifying the target image into critical and non-critical information regions and applying different compression methods to different regions, the storage space usage is greatly reduced. Furthermore, a pixel color difference algorithm is used to encrypt critical information regions, protecting user information security and preventing the leakage of important user information. In short, this application improves storage space utilization while significantly protecting user information security by classifying critical and non-critical information.
[0089] The second embodiment of this application relates to an image compression method. Figure 4 This is a flowchart illustrating another image compression method according to an exemplary embodiment, such as... Figure 4 As shown, it includes the following steps:
[0090] Step 101: Obtain the target image according to the preset image resolution.
[0091] Step 102: Segment the target image according to the pre-set image segmentation rules to obtain key information regions and non-key information regions.
[0092] Step 103: Encrypt the key information area based on the pixel color difference algorithm to obtain the encrypted key information area.
[0093] The specific details of steps 101-103 above are as discussed in the preceding paragraphs and will not be repeated here.
[0094] Step 105: Divide the non-critical information area into a preset number of target blocks.
[0095] It should be noted that the specific preset number can be divided according to the information content of the non-critical information area. For example, taking the ID card image as an example, the non-critical information area can be divided into 7 target blocks. The specific number is not specifically limited in this application.
[0096] Step 106: Perform difference processing on the pixels corresponding to all target blocks and the pixels corresponding to each existing block in the existing block set to obtain several block differences, wherein the existing blocks are obtained based on historical target images.
[0097] It should be noted that, for existing blocks, these are blocks that have already been calculated and can be obtained based on historical target images. After dividing the area into target blocks in step 105, the target blocks and existing blocks need to be compared. For example, a target block can be represented by a matrix in Formula 1, where the matrix content represents the RGB value of each pixel in each target block.
[0098] (1)
[0099] For a given stock block, it can be represented by a matrix in Formula 2, where the matrix content represents the RGB value of each pixel in each stock block.
[0100] (2)
[0101] The difference matrix is obtained by subtracting the two matrices and taking their absolute values, as shown in Formula 3. The matrix content in Formula 3 represents the difference matrix obtained by subtracting the matrix in Formula 1 and the matrix in Formula 2 and taking their absolute values.
[0102] (3)
[0103] Step 107: Based on the relationship between the difference of each block and the preset threshold, determine whether there is a target existing block in the existing block set that is similar to the target block.
[0104] Step 108: If a target existing block similar to the target block is detected in the existing block set, delete the target block, use the target existing block as the target block, and update the non-critical information area based on the target existing block.
[0105] Step 109: If no target block similar to the target block is detected in the existing block set, the existing block set is updated based on the target block, while maintaining non-critical information areas.
[0106] It should be noted that in steps 107-108 above, the target block and the existing block are compared. Specifically, the difference can be obtained by subtracting the RGB value of each pixel in the target block from the RGB value of the corresponding pixel in the existing block. For example, based on the above formula 3, the difference between the target block and the existing block is 18. If the threshold is set to 20, the difference can be considered acceptable, and the target block will be deleted. This can also be understood as automatically discarding the target block and directly replacing it with the existing block. If the threshold is 10, the difference exceeds the threshold and needs to be saved independently as an existing block for subsequent comparison. The target block is obtained by cutting non-critical information areas. The target block is compared with the existing block to determine whether it is reused, thereby reducing the number of similar blocks. The reuse method is used for storage, which greatly reduces storage space.
[0107] There is no specific order between steps 105-109 and step 103; they can be performed simultaneously. This embodiment is just one example and does not necessarily mean that steps 105-109 must follow step 103.
[0108] Step 104: Compress the encrypted key information area and the non-key information area respectively to obtain the compressed target image.
[0109] The specific details of step 104 above are as discussed previously and will not be repeated here.
[0110] This application embodiment collects user identity information through a mobile terminal to obtain a target image, divides it into key information regions and non-key information regions, and performs hierarchical processing on different regions. Key information regions are processed using a de-identification algorithm and then losslessly compressed, while non-key information regions undergo lossy compression. Furthermore, several target blocks are obtained by segmenting the non-key information regions, and these target blocks are compared with existing blocks to determine whether they can be reused. This application embodiment can reduce the number of similar blocks (duplicate blocks), employs reuse methods for storage, significantly reduces storage space, improves storage space utilization, and greatly protects user information security.
[0111] The third embodiment of this application relates to an image compression method. Figure 5 This is a flowchart illustrating another image compression method according to an exemplary embodiment, such as... Figure 5 As shown, it includes the following steps:
[0112] Step 101: Obtain the target image according to the preset image resolution.
[0113] Step 102: Segment the target image according to the pre-set image segmentation rules to obtain key information regions and non-key information regions.
[0114] Step 103: Encrypt the key information area based on the pixel color difference algorithm to obtain the encrypted key information area.
[0115] Step 104: Compress the encrypted key information area and the non-key information area respectively to obtain the compressed target image.
[0116] Steps 101-104 above are discussed in the preceding paragraphs and will not be repeated here.
[0117] Step 1010: Upon receiving a decompression request, perform verification processing according to the level corresponding to the decompression request to obtain the target image decompression area;
[0118] Step 1011: Decompress the compressed target image according to the decompression area of the target image.
[0119] It should be noted that in steps 1010-1011 above, after encrypting and compressing the target image, this application can also decrypt and decompress the image. Since different areas are stored separately in this application, this application can decompress the target image to different degrees for different requests.
[0120] Upon receiving a decompression request, a verification process is performed based on the level corresponding to the decompression request. This process determines the decompression area of the target image corresponding to the decompression request, and the compressed target image is then decompressed based on the decompression area corresponding to the target image.
[0121] Specifically, the decompression request includes the target compressed address corresponding to the target image. That is, when a user or operator needs to decompress and view the compressed target image, the decompression request sent carries the target compressed address corresponding to the target image, thus enabling quick location of the target image.
[0122] like Figure 6 As shown, Figure 6 yes Figure 5 A flowchart of a method for step 1011 in another image compression method illustrated according to an exemplary embodiment, step 1011 includes:
[0123] Step 10111: If the target image decompression area is detected to be a non-critical information area, query the target image compressed package based on the target compression address and decompress the compressed non-critical information area in the target image compressed package.
[0124] Step 10112: If the target image decompression area is detected to be the key information area, query the target image compressed package based on the target compression address, decrypt the compressed and encrypted key information area, and then decompress it.
[0125] Step 10113: When the target image decompression area is detected as the target image, the target image compressed package is queried based on the target compression address. The compressed non-critical information area in the target image compressed package is decompressed, and the compressed encrypted critical information area is decrypted and then decompressed to obtain the critical information area and the non-critical information area. The critical information area and the non-critical information area are spliced based on the address identifier to obtain the decompressed target image.
[0126] Specifically, the above steps of decrypting and decompressing the encrypted key information area include: decrypting the compressed encrypted key information area based on a random string in the target image compressed package to obtain the decrypted key information area; and decompressing the decrypted key information area to obtain the key information area.
[0127] In steps 10111-10113 above, different decompression areas are determined according to different requests. When key text information such as ID number is not needed, and only the user's image is used for comparison, only the desensitized user image part is desensitized.
[0128] When all critical information is required, desensitization is performed after the level verification is passed; when critical information is not required and only non-critical information is needed, only the non-critical information needs to be decompressed.
[0129] If both critical and non-critical information need to be decompressed, the target image compressed package is queried based on the target compressed address. The compressed non-critical information area in the target image compressed package is decompressed, and the compressed encrypted critical information area is decrypted and then decompressed. For example, the compressed package is searched by address IMG001, the grid photo IMG001_1 is obtained and decompressed, the desensitized ID card IMG001_2 is obtained and decompressed, and the block information IMG001_3, IMG001_4, IMG001_5, IMG001_6, IMG001_7, IMG001_8, and IMG001_9 are obtained and decompressed. If no desensitization is required, the images are directly stitched together to obtain the desensitized ID card photo. If desensitization is required, the random string IMG001_3BQ is obtained first, and the original image is obtained by desensitizing the random string. Then, the images are re-stitched to obtain the original ID card photo.
[0130] Through the embodiments of this application, target images can be decompressed to different degrees based on different request levels, which can save a lot of storage space in actual use scenarios. Furthermore, desensitized or undesensitized images can be extracted and used as needed. When manual review of half-body photos or customer information queries are required, desensitized images are provided, while undesensitized images are provided when ID card information verification is required, thereby achieving secure storage of user information.
[0131] The fourth embodiment of this application relates to an image compression device, such as... Figure 7 As shown, Figure 7 This is a block diagram of an image compression apparatus according to an exemplary embodiment, the apparatus comprising the following modules:
[0132] The acquisition module 701 is used to acquire the target image according to a preset image resolution;
[0133] The segmentation module 702 is used to segment the target image according to a preset image segmentation rule to obtain key information regions and non-key information regions;
[0134] The encryption module 703 is used to encrypt the key information area based on the pixel color difference algorithm to obtain the encrypted key information area;
[0135] The compression module 704 is used to compress the encrypted key information area and the non-key information area respectively to obtain the compressed target image.
[0136] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0137] Furthermore, based on the same inventive concept, a specific embodiment of this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method steps in any of the above embodiments.
[0138] Based on the same inventive concept, in specific embodiments of this application, the processor can implement any of the methods in the embodiments of this application when executing the computer program.
[0139] Since the electronic devices described in the specific embodiments of this application are devices used to implement the methods of the embodiments of this application, those skilled in the art can understand the specific structure and variations of the devices based on the methods described in the embodiments of this application, and therefore will not be described in detail here. All devices used in the methods of the embodiments of this application fall within the scope of protection of this application.
[0140] Based on the same inventive concept, this application also provides a storage medium corresponding to the method in the embodiment: This embodiment provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the method steps in any of the above embodiments.
[0141] In practice, when the computer program is executed by the processor, it can implement any of the methods in the specific embodiments of this application.
[0142] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0143] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, storable media, and processors. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0144] In a typical configuration, the computer device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory. Memory may include non-persistent memory in computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media. Computer-readable media includes both permanent and non-persistent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device. As defined in this article, computer-readable media do not include transient media, such as modulated data signals and carrier waves.
[0145] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0146] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0147] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0148] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0149] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0150] The above provides a detailed description of the image compression method, apparatus, electronic device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. An image compression method, characterized in that, The method includes: Obtain the target image based on a pre-set image resolution; The target image is segmented according to a pre-set image segmentation rule to obtain key information regions and non-key information regions; The key information region is encrypted based on the pixel color difference algorithm to obtain the encrypted key information region. The encrypted key information region and the non-key information region are compressed respectively to obtain the compressed target image; The key information region and the non-key information region each correspond to different address identifiers. The process of compressing the encrypted key information region and the non-key information region to obtain the compressed target image includes: The encrypted key information region and the non-key information region are compressed respectively to obtain a compressed encrypted key information region and a compressed non-key information region. Based on the address identifier, the compressed encrypted key information region and the compressed non-key information region in the same target image are associated. Upon detecting that the compressed encrypted key information region and the compressed non-key information region have been associated, the compressed encrypted key information region and the compressed non-key information region are packaged to generate a target image compressed package and a target compressed address corresponding to the target image compressed package.
2. The method according to claim 1, characterized in that, The encryption process for the key information region based on the pixel color difference algorithm yields the following encrypted key information regions: Obtain a random string, wherein there is an association between the address identifier corresponding to the random string and the address identifiers corresponding to the key information area and the non-key information area, respectively, and the random string and the address identifier corresponding to the random string are stored in the target image compressed package; The random string is parsed to obtain the target code, wherein the target code includes the degree of image color change, the continuously color-changing area, and the image color change adjustment value; Based on the degree of image color change, the continuously color-changing area, and the image color change adjustment value, each target pixel in the key information area is color-changed to obtain the encrypted key information area.
3. The method according to claim 1, characterized in that, After the step of segmenting the target image according to a pre-set image segmentation rule to obtain key information regions and non-key information regions, and before the step of compressing the encrypted key information regions and non-key information regions respectively to obtain a compressed target image, the method further includes: The non-critical information area is divided into a preset number of target blocks; The pixels corresponding to all the target blocks are respectively processed with the pixels corresponding to each existing block in the existing block set to obtain several block differences, wherein the existing blocks are obtained based on historical target images; Based on the relationship between the difference of each block and a preset threshold, it is determined whether there is a target existing block in the existing block set that is similar to the target block.
4. The method according to claim 3, characterized in that, Different target blocks correspond to different address identifiers. After determining whether there is a target existing block similar to the target block in the existing block set based on the relationship between the difference of each block and a preset threshold, the method further includes: If a target block similar to the target block is detected in the existing block set, the target block is deleted, the target block is used as the target block, and the non-critical information area is updated based on the target block. If no target block similar to the target block is detected in the existing block set, the existing block set is updated based on the target block, while maintaining the non-critical information area.
5. The method according to claim 1, characterized in that, The step of compressing the encrypted critical information region and the non-critical information region respectively to obtain the compressed encrypted critical information region, and compressing the non-critical information region includes: The encrypted key information area is subjected to lossless compression, and the non-key information area is subjected to lossy compression, to obtain the compressed encrypted key information area and the compressed non-key information area.
6. The method according to claim 1, characterized in that, After the step of compressing the encrypted key information region and the non-key information region respectively to obtain the compressed target image, the method further includes: Upon receiving a decompression request, a verification process is performed based on the level corresponding to the decompression request to obtain the decompressed area of the target image. The compressed target image is decompressed according to the decompression region of the target image.
7. The method according to claim 6, characterized in that, The decompression request includes the target compression address corresponding to the target image, and the decompression process of the compressed target image according to the decompression region of the target image includes: If the target image decompression area is detected to be the non-critical information area, the target image compressed package is queried based on the target compression address, and the compressed non-critical information area in the target image compressed package is decompressed; If the target image decompression area is detected to be the key information area, the target image compressed package is queried based on the target compression address, and the compressed encrypted key information area is decrypted and then decompressed; When the target image decompression area is detected to be the target image, the target image compressed package is queried based on the target compression address. The compressed non-critical information area in the target image compressed package is decompressed, and the compressed encrypted critical information area is decrypted and then decompressed to obtain the critical information area and the non-critical information area. The critical information area and the non-critical information area are then concatenated based on the address identifier to obtain the decompressed target image.
8. The method according to claim 7, characterized in that, The process of decrypting and decompressing the encrypted key information area includes: Based on the random string in the target image compressed package, the compressed and encrypted key information area is decrypted to obtain the decrypted key information area; The key information area is decompressed to obtain the key information area.
9. An image compression device, characterized in that, The device includes: The acquisition module is used to acquire the target image according to a pre-set image resolution; The segmentation module is used to segment the target image according to a pre-set image segmentation rule to obtain key information regions and non-key information regions; An encryption module is used to encrypt the key information area based on a pixel color difference algorithm to obtain an encrypted key information area; A compression module is used to compress the encrypted key information region and the non-key information region respectively to obtain a compressed target image; The key information region and the non-key information region each correspond to different address identifiers. The process of compressing the encrypted key information region and the non-key information region to obtain the compressed target image includes: The encrypted key information region and the non-key information region are compressed respectively to obtain a compressed encrypted key information region and a compressed non-key information region. Based on the address identifier, the compressed encrypted key information region and the compressed non-key information region in the same target image are associated. Upon detecting that the compressed encrypted key information region and the compressed non-key information region have been associated, the compressed encrypted key information region and the compressed non-key information region are packaged to generate a target image compressed package and a target compressed address corresponding to the target image compressed package.
10. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method of any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the method as described in any one of claims 1 to 8.