Image compression method and system based on sparse coding

By clustering image blocks and initializing the dictionary, a sparse matrix is ​​generated for image compression, which solves the problems of high computational complexity and low compression rate of sparse coding, and achieves a more efficient image compression effect.

CN118828022AActive Publication Date: 2024-10-22JIMEI UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410953079.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2024-10-22
Estimated Expiration
2044-07-16

AI Technical Summary

Technical Problem

The existing sparse coding image compression technology has high computational complexity and low compression rate, and it is difficult to determine the dictionary, which affects the compression effect.

Method used

By dividing the image to be compressed into image blocks of the same size, clustering according to the similarity of the image blocks, calculating the clustering complexity to determine the number of basis vectors of the dictionary, and using the image blocks in the cluster to initialize or extract the dictionary, generate Sparse matrices are compressed.

Benefits of technology

The compression rate is improved, the complexity of the sparse coding solution process is reduced, and the efficiency and quality of image compression are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118828022A_ABST
    Figure CN118828022A_ABST
Patent Text Reader

Abstract

The invention relates to the field of image compression, in particular to an image compression method and system based on sparse coding, and the method comprises the steps: segmenting each image in a group of to-be-compressed images into a plurality of image blocks with the same size, and carrying out the clustering of the image blocks according to the similarity of the image blocks, calculating the change condition of the points of the same gray scale of the image blocks in each cluster and the change condition of the points of different gray scales of the image blocks in the cluster center, determining the complexity of the cluster based on the change condition, and obtaining the number of base vectors of the dictionary corresponding to the cluster by using the complexity; if the dictionary is an over-complete dictionary, the dictionary is initialized by using the image blocks in the cluster, and the dictionary of the cluster and a sparse matrix of each image block are calculated based on the initialized dictionary; otherwise, extracting a dictionary from the image blocks in the cluster, and obtaining a sparse matrix of each image block based on the dictionary; in the image storage and sending process, the dictionary and the sparse matrix are stored and sent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image compression, and in particular to an image compression method and system based on sparse coding. Background Art

[0002] With the advent of the information age, the amount and size of image data have increased dramatically, and the storage and transmission of images face huge challenges. Image compression technology significantly reduces the size of image files by removing redundant information in image data, thereby saving storage space and bandwidth and improving transmission efficiency. On the Internet, image compression can speed up web page loading and improve user experience; on mobile devices, image compression can reduce storage usage and extend battery life. In satellite communications and remote detection, image compression can increase data transmission rate and effectiveness, ensuring that high-quality image data can be transmitted back to the ground in a timely manner. In addition, image compression also plays an irreplaceable role in multimedia communications, video conferencing, digital libraries, etc.

[0003] Compared with traditional compression methods (such as JPEG), sparse coding has the advantages of efficient representation, strong adaptability and strong noise resistance. In sparse coding, the image is decomposed into several small blocks, each of which is sparsely represented by a learned dictionary basis, storing only a small number of non-zero coefficients and basis vectors to achieve compression. This method can not only significantly reduce the storage and transmission costs of image data, but also maintain high-quality image reconstruction at low compression ratios, especially in retaining high-frequency details and edge information. However, sparse coding has high computational complexity, and the compression effect is closely related to the dictionary. Summary of the invention

[0004] In order to solve the above problem, the present invention provides an image compression method based on sparse coding, the method comprising the following steps: Each image in a group of images to be compressed is divided into multiple image blocks of the same size, and the image blocks are clustered according to their similarity. The change in the number of points of the same grayscale in the image blocks in each cluster and the change in the number of points of different grayscale in the cluster center image blocks are calculated. The complexity of the clustering is determined based on the change, and the number of basis vectors of the dictionary corresponding to the cluster is obtained using the complexity.

[0005] If the dictionary is an overcomplete dictionary, the dictionary is initialized using the image blocks in the cluster, and the dictionary of the cluster and the sparse matrix of each image block are calculated based on the initialized dictionary; otherwise, a dictionary is extracted from the image blocks in the cluster, and a sparse matrix of each image block is obtained based on the dictionary.

[0006] In image storage or transmission, the sparse matrix of each image block and the dictionary of each cluster are stored or transmitted to achieve data compression.

[0007] Preferably, the calculation of the change in the number of points of the same grayscale in each cluster and the change in the number of points of different grayscales in the cluster center image block is performed, the complexity of the cluster is determined based on the change, and the number of basis vectors of the dictionary corresponding to the cluster is obtained using the complexity, specifically: Calculate the standard deviation of the number of pixels of all grayscale values ​​of the image blocks in the cluster.

[0008] The standard deviation of all gray values ​​is accumulated to obtain the cumulative result.

[0009] The complexity of clustering is obtained according to the accumulation result and the standard deviation of the number of points of different gray values ​​of the image block corresponding to the cluster center.

[0010] The complexity interval is determined, and the number of basis vectors of the dictionary is determined according to the interval.

[0011] Preferably, the initializing the dictionary using the image blocks in the cluster is specifically: The average value of all image blocks in the cluster is calculated, the image block formed by the average value is used as a dictionary initialization image block, and the dictionary is initialized based on the dictionary initialization image block.

[0012] Alternatively, the grayscale change of each image block in the cluster is calculated, the image block with the largest change is used as the dictionary initialization image block, and the dictionary is initialized based on the dictionary initialization image block.

[0013] Preferably, the initializing the dictionary based on the dictionary initialization image block is specifically: Performing DCT transformation on the dictionary initialization image block to obtain a complete dictionary, sorting the image blocks according to the grayscale change of each image block in the cluster, selecting at least one image block from the sorted image blocks, flattening the at least one image block into a one-dimensional vector, and concatenating the complete dictionary and the one-dimensional vector corresponding to the at least one image block to obtain an initialized dictionary.

[0014] Preferably, extracting a dictionary from the image blocks in the cluster is specifically: If the number of basis vectors is equal to the dimension of the basis vectors, a complete dictionary obtained by performing DCT transformation on the image block corresponding to the center of the cluster is used as the extracted dictionary.

[0015] If the number of basis vectors is less than the dimension of the basis vectors, a DCT transform is performed on the image block corresponding to the center of the cluster to obtain a complete dictionary, and columns of the number of basis vectors are selected from the complete dictionary to form a dictionary, and the formed dictionary is used as the extracted dictionary.

[0016] In addition, the present invention also provides an image compression system based on sparse coding, the system comprising the following modules: The dictionary determination module is used to divide each image in a group of images to be compressed into multiple image blocks of the same size, cluster the image blocks according to their similarity, calculate the change in the number of points of the same grayscale in the image blocks in each cluster and the change in the number of points of different grayscale in the cluster center image block, determine the complexity of the clustering based on the change, and use the complexity to obtain the number of basis vectors of the dictionary corresponding to the cluster.

[0017] The image sparse coding module, if the dictionary is an overcomplete dictionary, uses the image blocks in the cluster to initialize the dictionary, and calculates the dictionary of the cluster and the sparse matrix of each image block based on the initialized dictionary; otherwise, extracts the dictionary from the image blocks in the cluster, and obtains the sparse matrix of each image block based on the dictionary.

[0018] The compression module is used to store or send the sparse matrix of each image block and the dictionary of each cluster to achieve data compression during image storage or transmission.

[0019] Preferably, the calculation of the change in the number of points of the same grayscale in each cluster and the change in the number of points of different grayscales in the cluster center image block is performed, the complexity of the cluster is determined based on the change, and the number of basis vectors of the dictionary corresponding to the cluster is obtained using the complexity, specifically: Calculate the standard deviation of the number of pixels of all grayscale values ​​of the image blocks in the cluster.

[0020] The standard deviation of all gray values ​​is accumulated to obtain the cumulative result.

[0021] The complexity of clustering is obtained according to the accumulation result and the standard deviation of the number of points of different gray values ​​of the image block corresponding to the cluster center.

[0022] The complexity interval is determined, and the number of basis vectors of the dictionary is determined according to the interval.

[0023] Preferably, the initializing the dictionary using the image blocks in the cluster is specifically: Calculating the average value of all image blocks in the cluster, using the image block formed by the average value as the dictionary initialization image block, and initializing the dictionary based on the dictionary initialization image block; Alternatively, the grayscale change of each image block in the cluster is calculated, the image block with the largest change is used as the dictionary initialization image block, and the dictionary is initialized based on the dictionary initialization image block.

[0024] Preferably, the initializing the dictionary based on the dictionary initialization image block is specifically: Performing DCT transformation on the dictionary initialization image block to obtain a complete dictionary, sorting the image blocks according to the grayscale change of each image block in the cluster, selecting at least one image block from the sorted image blocks, flattening the at least one image block into a one-dimensional vector, and concatenating the complete dictionary and the one-dimensional vector corresponding to the at least one image block to obtain an initialized dictionary.

[0025] Preferably, extracting a dictionary from the image blocks in the cluster is specifically: If the number of basis vectors is equal to the dimension of the basis vectors, a complete dictionary obtained by performing DCT transformation on the image block corresponding to the center of the cluster is used as the extracted dictionary.

[0026] If the number of basis vectors is less than the dimension of the basis vectors, a DCT transform is performed on the image block corresponding to the center of the cluster to obtain a complete dictionary, and columns of the number of basis vectors are selected from the complete dictionary to form a dictionary, and the formed dictionary is used as the extracted dictionary.

[0027] Finally, the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method described above is implemented.

[0028] In order to solve the problems of low compression rate and difficulty in determining the dictionary in sparse coding in the prior art, the present invention compresses a group of similar images and clusters all image blocks in a group of images, determines the number of basis vectors in the dictionary and initializes the dictionary according to the situation of the image blocks in the cluster, thereby improving the compression rate and reducing the complexity of the sparse coding solution process. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 This is a flow chart of Embodiment 1; Figure 2 Schematic diagram of image compression for sparse coding; Figure 3 This is a structural diagram of the second embodiment. DETAILED DESCRIPTION

[0030] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0031] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0032] Embodiment 1, the present invention provides an image compression method based on sparse coding, such as Figure 1 As shown, the method comprises the following steps: S1, divide each image in a group of images to be compressed into multiple image blocks of the same size, cluster the image blocks according to their similarity, calculate the change in the number of points of the same grayscale in the image blocks in each cluster and the change in the number of points of different grayscale in the cluster center image blocks, determine the complexity of the clustering based on the change, and use the complexity to obtain the number of basis vectors of the dictionary corresponding to the cluster.

[0033] In the past, image compression was usually performed on a single image, and the similar areas in a single image were limited, resulting in limited compression effect. The present invention compresses a group of images to be compressed, and this group of images to be compressed are similar images, including but not limited to several consecutive frames of images in a video, multiple images taken in similar scenes or locations, etc.

[0034] For each of the images to be compressed in the group that are divided into multiple image blocks of the same size, each image will be divided into multiple image blocks, and all image blocks are clustered, and similar image blocks are clustered into one category. Since the image blocks are similar, when they are subsequently compressed, not only can the number of basis vectors in the dictionary be reduced, but also the compression rate can be improved. The number of points with the same grayscale is the number of points with the same grayscale value. For example, if the number of points with a pixel value or grayscale value of 127 in an image block is 5, then the number of grayscale points is 5. The change in the number of points with the same grayscale in the image blocks in the cluster is the change in the same grayscale value in different image blocks. For example, the number of points with a grayscale value of 127 in image block 1 is 6, and the number of points with a grayscale value of 127 in image block 2 is 8, then the change is an increase of 2. In a more specific embodiment, the change of the number of points with the same grayscale in each cluster is calculated, specifically: the standard deviation of the number of pixels of all grayscale values ​​in the cluster is calculated. For example, there are 5 image blocks in the cluster, and the number of pixels with grayscale value of 0 in these 5 image blocks are 1, 4, 2, 5, and 1 respectively, then the standard deviation is 1.6248; similarly, the standard deviation corresponding to the grayscale value of 1 in these 5 image blocks can be calculated. The standard deviation of all grayscale values ​​is accumulated to obtain the accumulated result, and the accumulated result is used as the change of the number of points with the same grayscale in each cluster.

[0035] The change in the number of points of different grayscales in the cluster center image block is to calculate the change in the number of points of different grayscales in the image block corresponding to the cluster center position. In a specific embodiment, the standard deviation is used as the change. For example, the image block corresponding to the cluster center is image block 4. There are 2 grayscale values ​​of 19 in image block 4, 3 grayscale values ​​of 67, and 4 grayscale values ​​of 212. The calculated standard deviation is 0.8165.

[0036] The greater the difference between different image blocks in a cluster, the greater the cumulative result, and the greater the standard deviation of the image block corresponding to the cluster center, the more complex the image block itself is, which requires more basis vectors to meet the requirements of sparse coding for image compression. If all image blocks in a cluster are the same, and the image block pixels do not change much, only a small number of basis vectors are needed, otherwise more basis vectors are needed. In a specific embodiment, the complexity of the cluster is obtained according to the cumulative result and the standard deviation of the number of points with different gray values ​​of the image block corresponding to the cluster center; the interval in which the complexity is located is determined, and the number of basis vectors of the dictionary is determined according to the interval. In a more specific embodiment, the average value of the cumulative result is calculated, and then the average value and the standard deviation of the number of points with different gray values ​​of the image block corresponding to the cluster center are weighted, and the weighted sum result is used as the complexity of the cluster, and the interval in which the complexity is located is determined. Each interval corresponds to a number of basis vectors, and then the number of basis vectors in the dictionary is determined. The number of basis vectors is greater than, equal to, or less than the number of pixel points in the image block.

[0037] The dictionary includes at least one basis vector, which is also called the atom of the dictionary. In a more specific embodiment, the dimension of the basis vector is the same as the number of pixels in the image block. For example, if there are N pixels in the image block, the basis vector has N elements.

[0038] S2: if the dictionary is an overcomplete dictionary, initialize the dictionary using the image blocks in the cluster, and calculate the dictionary of the cluster and the sparse matrix of each image block based on the initialized dictionary; otherwise, extract the dictionary from the image blocks in the cluster, and obtain the sparse matrix of each image block based on the dictionary.

[0039] In sparse coding for image compression, the quality of the dictionary directly affects the compression efficiency and compression speed. A good dictionary can obtain a sparser sparse matrix and converge quickly. After obtaining the number of basis vectors of the dictionary, the size of the dictionary is obtained. In sparse coding for image compression, the dictionary needs to be initialized, and the initialization will also affect the convergence speed. Common dictionary initialization methods include random initialization, sample-based initialization, etc. These methods either affect the convergence speed or are computationally complex. In a specific embodiment, when the dictionary is an overcomplete dictionary, the dictionary is initialized using clustered image blocks. Specifically, PCA is used to initialize the dictionary.

[0040] In another embodiment, the average value of all image blocks in the cluster is calculated, and the image block composed of the average value is used as the dictionary initialization image block, and the dictionary is initialized based on the dictionary initialization image block; or the grayscale change of each image block in the cluster is calculated, and the image block with the largest change is used as the dictionary initialization image block, and the dictionary is initialized based on the dictionary initialization image block. Wherein, calculating the average value of all image blocks in the cluster is to calculate the average value of the pixel values ​​at the same position of all image blocks, and use this average value as the pixel value of the position of the dictionary initialization image block. Since each channel is compressed in image compression, the pixel value of each channel is also the grayscale value. Unless otherwise specified, in the present invention, grayscale value and pixel value have the same meaning, and image compression is also to compress each channel separately. The grayscale change of each image block in the cluster is to calculate the change of the number of points of different grayscales for an image block. Preferably, the standard deviation is used as the measurement indicator of the change, of course, it is not limited to the standard deviation, and variance can also be used.

[0041] The dictionary-initialized image block can represent the characteristics of the image blocks in the cluster. In a specific embodiment, the dictionary-initialized image block is subjected to discrete cosine transform DCT to obtain a complete dictionary. The DCT transform obtains the frequency domain information of the image block. In order to obtain the spatial domain information of the image block, several image blocks are selected from the image blocks in the cluster and further spliced ​​with the complete dictionary to obtain the initialized dictionary.

[0042] In a more specific embodiment, the image blocks are sorted according to the grayscale change of each image block in the cluster, at least one image block is selected from the sorted image blocks, the at least one image block is flattened into a one-dimensional vector, and the complete dictionary and the one-dimensional vector corresponding to the at least one image block are spliced ​​to obtain an initialized dictionary. For example, the standard deviation of the number of different grayscales is used as an indicator of the grayscale change of the image blocks, the image blocks are sorted according to the size of the indicator, at least one image block is selected from the sorted image blocks, the image blocks are flattened into one dimension, and the image blocks are spliced ​​to the complete dictionary to obtain an initialized dictionary. Assume that the image block size is 4×4, the number of basis vectors obtained by S1 is 24, and the complete dictionary is 16×16. The complete dictionary contains 16 basis vectors, and the length of each basis vector is 16. Since 24 basis vectors are needed, 8 need to be selected from the sorted image blocks. If there are 32 image blocks in the cluster, 8 image blocks are extracted at equal intervals from the sorted image blocks, and then the image blocks are flattened into one-dimensional vectors, and the initialization dictionary is obtained by column splicing with the previous complete dictionary. In this way, the initialization dictionary contains not only the frequency information of typical image blocks in the cluster, but also spatial domain information. Among them, the process of performing DCT on the image block to obtain the complete dictionary is specifically to obtain the size of the image block n×n, generate n one-dimensional DCT basis functions, and then obtain the two-dimensional DCT basis function through the Kronecker product, flatten the two-dimensional DCT basis function into a vector, and splice the vector n 2 ×n 2 A matrix where each column is a flattened two-dimensional DCT basis function. This matrix is ​​the complete dictionary.

[0043] If the image blocks in the cluster are similar and the image blocks themselves do not change much, only a small number of basis vectors are needed. The dictionary is extracted from the image blocks in the cluster as follows: If the number of basis vectors is equal to the dimension of the basis vectors, a complete dictionary obtained by performing DCT transformation on the image block corresponding to the center of the cluster is used as the extracted dictionary.

[0044] If the number of basis vectors is less than the dimension of the basis vectors, a DCT transform is performed on the image block corresponding to the center of the cluster to obtain a complete dictionary, and columns of the number of basis vectors are selected from the complete dictionary to form a dictionary, and the formed dictionary is used as the extracted dictionary.

[0045] Among them, the basis vector dimension is the number of elements contained in the basis vector. When the number of basis vectors and the basis vector dimension are the same, the dictionary formed by the basis vectors is a complete dictionary. If the number of basis vectors is less than the basis vector dimension, the dictionary formed by the basis vectors is an incomplete dictionary or an undercomplete dictionary. When the number of basis vectors is equal to the basis vector dimension, the complete field obtained by DCT transforming the image block corresponding to the cluster center is used as the extracted dictionary. The process of obtaining a complete dictionary using DCT transform has been described above and will not be repeated here. If the number of basis vectors is less than the basis vector dimension, the columns of the number of basis vectors are selected from the complete dictionary obtained by DCT transform to form a dictionary. There are many ways to select, including but not limited to random selection, selection based on correlation, etc.

[0046] After obtaining the initialized dictionary, the dictionary can be used to perform sparse representation on the image block or image. The sparse representation of the image is as follows: Figure 2 As shown, in Figure 2 In , the image blocks in a cluster can be obtained by multiplying the dictionary and the sparse matrix. Figure 2 The image block on the left is the vector obtained by flattening the image block.

[0047] After obtaining the initialized dictionary, the dictionary learning method or other methods are used to solve the clustered dictionary and the sparse matrix of each image block. There are many ways to solve the dictionary and the sparse matrix, including but not limited to the greedy algorithm, the convex optimization algorithm, the dictionary learning algorithm, etc. This is not the focus of the present invention and will not be described here. For a non-overcomplete dictionary, the above method can also be used to solve the dictionary. Generally speaking, if it is a non-overcomplete dictionary, the clustered image blocks do not change much. At this time, the dictionary can be obtained by parsing the image blocks, and then the sparse matrix of the image blocks can be calculated.

[0048] S3, during image storage or transmission, the sparse matrix of each image block and the dictionary of each cluster are stored or transmitted to achieve data compression.

[0049] After S2, each cluster corresponds to a dictionary, and each image block corresponds to a sparse matrix. In data storage or transmission, only the dictionary and sparse matrix need to be stored or sent. Figure 2 The image blocks can be restored. Of course, since there are many image blocks and more than one cluster, it is necessary to record the relationship between the dictionary, sparse matrix, and image blocks, as well as the location information of the image blocks in the image.

[0050] Assuming that there are 1000 8×8 image blocks in a cluster, there are 64,000 pixels in total. If one pixel occupies 1 byte, the required storage space is 64,000 bytes. These 1000 image blocks share a dictionary of 64×100, which is 6400 values, or 6400 bytes. Each image block corresponds to a sparse vector of dimension 100. If the number of non-zero sparse vectors is 10, plus the position information of these 10 non-zero sparse vectors, the space occupied by the sparse vector corresponding to each image block is 100×20, or 2000 bytes. After sparse coding of this cluster, even with the dictionary information, the space occupied is 8400 bytes. It can be seen that the original 64,000 bytes of this cluster are compressed to 8400 bytes.

[0051] Embodiment 2, the present invention also provides an image compression system based on sparse coding, such as Figure 3 As shown, the system includes the following modules: The dictionary determination module is used to divide each image in a group of images to be compressed into multiple image blocks of the same size, cluster the image blocks according to their similarity, calculate the change in the number of points of the same grayscale in the image blocks in each cluster and the change in the number of points of different grayscale in the cluster center image block, determine the complexity of the clustering based on the change, and use the complexity to obtain the number of basis vectors of the dictionary corresponding to the cluster.

[0052] The image sparse coding module, if the dictionary is an overcomplete dictionary, uses the image blocks in the cluster to initialize the dictionary, and calculates the dictionary of the cluster and the sparse matrix of each image block based on the initialized dictionary; otherwise, extracts the dictionary from the image blocks in the cluster, and obtains the sparse matrix of each image block based on the dictionary.

[0053] The compression module is used to store or send the sparse matrix of each image block and the dictionary of each cluster to achieve data compression during image storage or transmission.

[0054] Preferably, the calculation of the change in the number of points of the same grayscale in each cluster and the change in the number of points of different grayscales in the cluster center image block is performed, the complexity of the cluster is determined based on the change, and the number of basis vectors of the dictionary corresponding to the cluster is obtained using the complexity, specifically: Calculate the standard deviation of the number of pixels of all grayscale values ​​of the image blocks in the cluster.

[0055] The standard deviation of all gray values ​​is accumulated to obtain the cumulative result.

[0056] The complexity of clustering is obtained according to the accumulation result and the standard deviation of the number of points of different gray values ​​of the image block corresponding to the cluster center.

[0057] The complexity interval is determined, and the number of basis vectors of the dictionary is determined according to the interval.

[0058] Preferably, the initializing the dictionary using the image blocks in the cluster is specifically: Calculating the average value of all image blocks in the cluster, using the image block formed by the average value as the dictionary initialization image block, and initializing the dictionary based on the dictionary initialization image block; Alternatively, the grayscale change of each image block in the cluster is calculated, the image block with the largest change is used as the dictionary initialization image block, and the dictionary is initialized based on the dictionary initialization image block.

[0059] Preferably, the initializing the dictionary based on the dictionary initialization image block is specifically: Performing DCT transformation on the dictionary initialization image block to obtain a complete dictionary, sorting the image blocks according to the grayscale change of each image block in the cluster, selecting at least one image block from the sorted image blocks, flattening the at least one image block into a one-dimensional vector, and concatenating the complete dictionary and the one-dimensional vector corresponding to the at least one image block to obtain an initialized dictionary.

[0060] Preferably, extracting a dictionary from the image blocks in the cluster is specifically: If the number of basis vectors is equal to the dimension of the basis vectors, a complete dictionary obtained by performing DCT transformation on the image block corresponding to the center of the cluster is used as the extracted dictionary.

[0061] If the number of basis vectors is less than the dimension of the basis vectors, a DCT transform is performed on the image block corresponding to the center of the cluster to obtain a complete dictionary, and columns of the number of basis vectors are selected from the complete dictionary to form a dictionary, and the formed dictionary is used as the extracted dictionary.

[0062] Embodiment 3, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method described in embodiment 1 is implemented.

[0063] Embodiment 4, the present invention further provides a computer device, the computer device comprising at least a memory and a processor, a computer program is stored in the memory, and the computer program implements the method described in embodiment 1 when executed by the processor.

[0064] Through the description of the above implementation methods, technicians in this field can clearly understand that each implementation method can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in 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 codes.

[0065] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it, and other embodiments may also be used. Although the present invention has been described in detail with reference to the aforementioned embodiments, ordinary technicians in this field should understand that they can still modify the technical solutions recorded in the aforementioned embodiments, or replace some of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An image compression method based on sparse coding, characterized in that: The method comprises the following steps: Each image in a group of images to be compressed is divided into a plurality of image blocks of the same size, the image blocks are clustered according to the similarity of the image blocks, the change of the number of points of the same grayscale of the image blocks in each cluster and the change of the number of points of different grayscales of the cluster center image block are calculated, the complexity of the clustering is determined based on the change, and the number of basis vectors of the dictionary corresponding to the cluster is obtained using the complexity; If the dictionary is an overcomplete dictionary, the dictionary is initialized using the image blocks in the cluster, and the dictionary of the cluster and the sparse matrix of each image block are calculated based on the initialized dictionary; otherwise, a dictionary is extracted from the image blocks in the cluster, and a sparse matrix of each image block is obtained based on the dictionary; In image storage or transmission, the sparse matrix of each image block and the dictionary of each cluster are stored or transmitted to achieve data compression.

2. The method according to claim 1, characterized in that The calculation of the change in the number of points of the same grayscale in each cluster and the change in the number of points of different grayscales in the cluster center image block is performed, the complexity of the cluster is determined based on the change, and the number of basis vectors of the dictionary corresponding to the cluster is obtained by using the complexity, specifically: Calculate the standard deviation of the number of pixels of all gray values ​​of the image blocks in the cluster; Accumulate the standard deviation of all gray values ​​to get the cumulative result; Obtaining the complexity of clustering according to the accumulation result and the standard deviation of the number of points of different gray values ​​of the image block corresponding to the cluster center; The complexity interval is determined, and the number of basis vectors of the dictionary is determined according to the interval.

3. The method according to claim 1, characterized in that The initializing the dictionary using the image blocks in the cluster is specifically: Calculate the average value of all image blocks in the cluster, use the image block formed by the average value as the dictionary initialization image block, and initialize the dictionary based on the dictionary initialization image block; or The grayscale change of each image block in the cluster is calculated, the image block with the largest change is used as the dictionary initialization image block, and the dictionary is initialized based on the dictionary initialization image block.

4. The method according to claim 3, characterized in that Initializing the dictionary based on the dictionary initialization image block is specifically: Performing DCT transformation on the dictionary initialization image block to obtain a complete dictionary, sorting the image blocks according to the grayscale change of each image block in the cluster, selecting at least one image block from the sorted image blocks, flattening the at least one image block into a one-dimensional vector, and concatenating the complete dictionary and the one-dimensional vector corresponding to the at least one image block to obtain an initialized dictionary.

5. The method according to claim 1, characterized in that The step of extracting a dictionary from the image blocks in the cluster is specifically as follows: If the number of basis vectors is equal to the dimension of the basis vectors, a complete dictionary obtained by performing DCT transformation on the image block corresponding to the center of the cluster is used as the extracted dictionary; If the number of basis vectors is less than the dimension of the basis vectors, a DCT transform is performed on the image block corresponding to the center of the cluster to obtain a complete dictionary, and columns of the number of basis vectors are selected from the complete dictionary to form a dictionary, and the formed dictionary is used as the extracted dictionary.

6. An image compression system based on sparse coding, characterized in that: The system includes the following modules: a dictionary determination module, for dividing each image in a group of images to be compressed into a plurality of image blocks of the same size, clustering the image blocks according to the similarity of the image blocks, calculating the change in the number of points of the same grayscale in the image blocks in each cluster and the change in the number of points of different grayscales in the cluster center image blocks, determining the complexity of the clustering based on the change, and obtaining the number of basis vectors of the dictionary corresponding to the clustering using the complexity; An image sparse coding module, if the dictionary is an overcomplete dictionary, initializes the dictionary using the image blocks in the cluster, and calculates the dictionary of the cluster and the sparse matrix of each image block based on the initialized dictionary; Otherwise, extracting a dictionary from the image blocks in the cluster, and obtaining a sparse matrix of each image block based on the dictionary; The compression module is used to store or send the sparse matrix of each image block and the dictionary of each cluster to achieve data compression during image storage or transmission.

7. The system according to claim 6, characterized in that The calculation of the change in the number of points of the same grayscale in each cluster and the change in the number of points of different grayscales in the cluster center image block is performed, the complexity of the cluster is determined based on the change, and the number of basis vectors of the dictionary corresponding to the cluster is obtained by using the complexity, specifically: Calculate the standard deviation of the number of pixels of all gray values ​​of the image blocks in the cluster; Accumulate the standard deviation of all gray values ​​to get the cumulative result; Obtaining the complexity of clustering according to the accumulation result and the standard deviation of the number of points of different gray values ​​of the image block corresponding to the cluster center; The complexity interval is determined, and the number of basis vectors of the dictionary is determined according to the interval.

8. The system according to claim 6, characterized in that The initializing the dictionary using the image blocks in the cluster is specifically: Calculate the average value of all image blocks in the cluster, use the image block formed by the average value as the dictionary initialization image block, and initialize the dictionary based on the dictionary initialization image block; or The grayscale change of each image block in the cluster is calculated, the image block with the largest change is used as the dictionary initialization image block, and the dictionary is initialized based on the dictionary initialization image block.

9. The system according to claim 8, characterized in that Initializing the dictionary based on the dictionary initialization image block is specifically: Performing DCT transformation on the dictionary initialization image block to obtain a complete dictionary, sorting the image blocks according to the grayscale change of each image block in the cluster, selecting at least one image block from the sorted image blocks, flattening the at least one image block into a one-dimensional vector, and concatenating the complete dictionary and the one-dimensional vector corresponding to the at least one image block to obtain an initialized dictionary.

10. A computer storage device, wherein a computer program is stored on the storage device, characterized in that: When the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Partitioning compressive sensing reconstruction method based on image block clustering and sparse dictionary learning

    CN104036519A

  • Image compression method and device, server and storage medium

    CN111400528A

  • Image processing apparatus and method for interactive device, and the interactive device

    JP2016085579A