Image compression method and device based on random singular value decomposition, equipment and medium
By performing blocking and parallel processing of the image matrix and multi-threaded singular value decomposition, the problem of traditional singular value decomposition is solved, the calculation efficiency is improved and the image compression effect is optimized.
Patent Information
- Application Number
- CN202510587853.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-07-25
AI Technical Summary
Traditional singular value decomposition is inefficient when dealing with complex problems and cannot fully utilize the performance of the central processors in different architectures of computers.
By performing block-parallel processing of the image matrix to be compressed, the task scheduler is used to perform multi-threaded execution based on the load balancing strategy, including preprocessing, orthogonal processing, numerical stability optimization and singular value decomposition, and setting preset end conditions to improve efficiency.
The efficiency of singular value decomposition is improved, the computational complexity and spatial complexity are reduced, the main features of the image are retained, and the storage space is saved.
Smart Images

Figure CN120378636A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image compression, and particularly to an image compression method, device, equipment and medium based on random singular value decomposition. Background Art
[0002] Nowadays, singular value decomposition is widely used in numerical calculations, scientific engineering fields, and the current popular large model fields, and plays an important role in many fields such as numerical calculations of large-scale matrices, data compression, image processing, signal processing, and machine learning. However, with the gradual complication of problems in various fields in recent years, the efficiency of traditional singular value decomposition has become gradually low, and the performance of central processing units with different architectures of computers cannot be well utilized. Therefore, how to make full use of the performance of central processing units with different architectures of computers and improve the efficiency of singular value decomposition is a problem to be solved at present. Summary of the Invention
[0003] In view of this, the purpose of the present application is to provide an image compression method, device, equipment and medium based on random singular value decomposition, which can perform block parallel processing on each matrix, and all parallel calculations are executed in multiple threads by a task scheduler based on a load balancing strategy, so as to make full use of the performance of central processing units with different architectures of computers and improve the efficiency of singular value decomposition. The specific solutions are as follows:
[0004] In a first aspect, the present application provides an image compression method based on random singular value decomposition, including:
[0005] Converting the image to be compressed into an original image matrix to obtain a current image matrix, and in the iterative process of the current image matrix, performing a preprocessing operation for extracting the main features of the matrix in parallel on each first current sub-block after the current image matrix is divided into blocks, so as to obtain a current target matrix;
[0006] Using each second current sub-block after the current target matrix is divided into blocks to update each sub-block after the current first matrix is divided into blocks in parallel, so as to obtain an updated current first matrix; the current first matrix is a matrix determined based on each historical target matrix;
[0007] Updating each first current sub-block in parallel according to each second current sub-block to obtain an updated current image matrix, and when the current iterative process meets a preset end condition, ending the iterative process, so as to perform singular value decomposition in parallel on each sub-block after the latest current first matrix is divided into blocks, so as to obtain a decomposition matrix, and determining a compressed image corresponding to the image to be compressed based on some singular values among the singular values corresponding to the decomposition matrix;
[0008] Among them, the parallel computing for each sub-block after matrix partitioning is executed in multiple threads by the task scheduler based on the load balancing strategy.
[0009] Optionally, the preprocessing operation for extracting the main features of the matrix is performed in parallel on each first current sub-block after partitioning the current image matrix, so as to obtain a current target matrix, including:
[0010] Determine a first intermediate matrix based on each sub-block after partitioning the Gaussian distribution matrix and each first current sub-block after partitioning the current image matrix, and perform orthogonalization processing on each sub-block after partitioning the first intermediate matrix to obtain a current orthogonal matrix;
[0011] Perform numerical stability optimization processing on each third current sub-block after partitioning the current orthogonal matrix to obtain a new current orthogonal matrix, and use each sub-block after partitioning the new current orthogonal matrix to perform main feature extraction on each first current sub-block in parallel to obtain a current target matrix.
[0012] Optionally, the performing numerical stability optimization processing on each third current sub-block after partitioning the current orthogonal matrix to obtain a new current orthogonal matrix includes:
[0013] Determine the target projection of the current orthogonal matrix on the column space of the current second matrix based on each sub-block after partitioning the current second matrix and each third current sub-block after partitioning the current orthogonal matrix; the current second matrix is a matrix determined based on each historical orthogonal matrix;
[0014] Subtract the target projection from each third current sub-block, and perform orthogonalization processing on each third current sub-block after subtracting the target projection in parallel to obtain a new current orthogonal matrix.
[0015] Optionally, the image compression method based on random singular value decomposition further includes:
[0016] Use each sub-block after partitioning the new current orthogonal matrix to update each sub-block after partitioning the current second matrix in parallel to obtain an updated current second matrix;
[0017] Correspondingly, the performing singular value decomposition on each sub-block after partitioning the latest current first matrix to obtain a decomposition matrix includes:
[0018] Use each sub-block after partitioning the latest current second matrix to perform singular value decomposition on each sub-block after partitioning the latest current first matrix in parallel to obtain a decomposition matrix.
[0019] Optionally, the step of updating each of the first current sub - blocks in parallel according to each of the second current sub - blocks to obtain an updated current image matrix includes:
[0020] Determining a second intermediate matrix based on each sub - block after partitioning the new current orthogonal matrix and each of the second current sub - blocks, and updating each of the first current sub - blocks in parallel according to each sub - block after partitioning the second intermediate matrix to obtain an updated current image matrix.
[0021] Optionally, the preset end condition includes that the current error value is not greater than a preset error, and / or the current rank reaches a preset rank;
[0022] Wherein, the current error value is a difference determined based on a first value and a second value; the first value is a value determined based on the norms of each of the first current sub - blocks when the current image matrix is the original image matrix; the second value is a value determined based on the norms of each sub - block after partitioning the updated current first matrix and the norms of each of the second current sub - blocks;
[0023] And, the current rank is a rank obtained by adding a preset matrix partitioning value to the rank at the previous moment; wherein, when the rank at the previous moment is the rank at the first moment, the rank at the previous moment is zero.
[0024] Optionally, the step of determining the compressed image corresponding to the image to be compressed based on some singular values in the singular values corresponding to the decomposition matrix includes:
[0025] Selecting some singular values from the singular values corresponding to the decomposition matrix, and determining a sub - matrix corresponding to the some singular values from the decomposition matrix, so as to use the sub - matrix to determine the compressed image corresponding to the image to be compressed;
[0026] Wherein, the some singular values are a preset number of singular values selected from the singular values corresponding to the decomposition matrix in the order from front to back of the singular values, or the some singular values are a preset number of singular values with the largest values among the singular values corresponding to the decomposition matrix.
[0027] In a second aspect, the present application provides an image compression device based on random singular value decomposition, including:
[0028] A matrix acquisition module, configured to convert an image to be compressed into an original image matrix to obtain a current image matrix, and during the iterative process of the current image matrix, perform a pre - processing operation for extracting the main features of the matrix on each of the first current sub - blocks after partitioning the current image matrix in parallel to obtain a current target matrix;
[0029] A matrix update module, configured to use each second current sub-block after the current target matrix is partitioned to update each sub-block after the current first matrix is partitioned in parallel, so as to obtain an updated current first matrix; the current first matrix is a matrix determined based on each historical target matrix;
[0030] An image compression module, configured to update each first current sub-block in parallel according to each second current sub-block, so as to obtain an updated current image matrix, and when the current iteration process meets a preset end condition, end the iteration process, and perform singular value decomposition on each sub-block after the latest current first matrix is partitioned in parallel, so as to obtain a decomposition matrix, and determine a compressed image corresponding to the image to be compressed based on some singular values among the singular values corresponding to the decomposition matrix;
[0031] Wherein, the parallel calculation for each sub-block after the matrix is partitioned is executed through a multi-threaded task scheduler based on a load balancing strategy.
[0032] In a third aspect, the present application provides an electronic device, including:
[0033] A memory, configured to store a computer program;
[0034] A processor, configured to execute the computer program to implement the foregoing image compression method based on random singular value decomposition.
[0035] In a fourth aspect, the present application provides a computer-readable storage medium, configured to store a computer program, wherein the computer program, when executed by a processor, implements the foregoing image compression method based on random singular value decomposition.
[0036] In the present application, the image to be compressed is converted into an original image matrix to obtain a current image matrix, and in the iteration process of the current image matrix, a preprocessing operation for extracting the main features of the matrix is performed on each first current sub-block after the current image matrix is partitioned in parallel, so as to obtain a current target matrix; each second current sub-block after the current target matrix is partitioned is used to update each sub-block after the current first matrix is partitioned in parallel, so as to obtain an updated current first matrix; the current first matrix is a matrix determined based on each historical target matrix; each first current sub-block is updated in parallel according to each second current sub-block, so as to obtain an updated current image matrix, and when the current iteration process meets a preset end condition, end the iteration process, and perform singular value decomposition on each sub-block after the latest current first matrix is partitioned in parallel, so as to obtain a decomposition matrix, and determine a compressed image corresponding to the image to be compressed based on some singular values among the singular values corresponding to the decomposition matrix; wherein, the parallel calculation for each sub-block after the matrix is partitioned is executed through a multi-threaded task scheduler based on a load balancing strategy.
[0037] As can be seen from the above, in this application, by performing block parallel processing on each matrix, the parallelism of singular value decomposition is fully exploited. All parallel computations are executed through a task scheduler in a multi-threaded manner based on a load balancing strategy, so as to give full play to the performance of central processing units with different architectures in a computer and improve the efficiency of singular value decomposition. Moreover, by extracting the main features of the current image matrix, this application can appropriately reduce the amount of computation and lower the computational complexity and space complexity of singular value decomposition. Further, by setting a preset end condition, when the iteration process of the current image matrix meets the end condition, singular value decomposition is performed, thereby ensuring the accuracy of singular value decomposition. In addition, after singular value decomposition, based on some of the singular values corresponding to the decomposed matrix, the compressed image corresponding to the image to be compressed is determined. This not only retains the main features of the image to be compressed, but also improves the compression ability of image compression and saves the storage space required for compressed images. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on the provided drawings.
[0039] Figure 1 It is a flowchart of an image compression method based on random singular value decomposition disclosed in the present application;
[0040] Figure 2 It is a schematic diagram of column storage disclosed in the present application;
[0041] Figure 3 It is a schematic diagram of block storage disclosed in the present application;
[0042] Figure 4 It is a schematic diagram of the structure of an image compression device based on random singular value decomposition disclosed in the present application;
[0043] Figure 5 It is a structural diagram of an electronic device disclosed in the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0044] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0045] Nowadays, singular value decomposition is widely used in numerical computing, scientific engineering fields, and the current popular large model fields. It plays an important role in many fields such as numerical computing of large-scale matrices, data compression, image processing, signal processing, and machine learning. However, with the gradual complication of problems in various fields in recent years, the efficiency of traditional singular value decomposition has become gradually low, and it cannot make good use of the performance of central processing units with different architectures in computers. For this reason, this application provides an image compression method based on random singular value decomposition. By performing block parallel processing on each matrix, all parallel computations are executed in multiple threads by a task scheduler based on a load balancing strategy to make full use of the performance of central processing units with different architectures in computers, thereby improving the efficiency of singular value decomposition.
[0046] See Figure 1 As shown, an embodiment of the present invention discloses an image compression method based on random singular value decomposition, including:
[0047] Step S11: Convert the image to be compressed into an original image matrix to obtain the current image matrix, and during the iteration process of the current image matrix, perform a preprocessing operation for extracting the main features of the matrix in parallel on each first current sub-block after the current image matrix is blocked, so as to obtain the current target matrix.
[0048] In this embodiment, when the image to be compressed is a grayscale image, the image to be compressed can be converted into a numerical matrix as the original image matrix. When the image to be compressed is an RGB (Red, Green, Blue) image, the image to be compressed can be converted into three numerical matrices as the original image matrices respectively.
[0049] After converting the image to be compressed into the original image matrix and using the original image matrix as the current image matrix, it is necessary to enter the iteration process of the current image matrix. During the iteration process of the current image matrix, first, the current image matrix needs to be blocked, and a preprocessing operation for extracting the main features of the matrix is performed in parallel on each first current sub-block obtained after blocking, so as to obtain the current target matrix.
[0050] For the current target matrix, first, a Gaussian distribution matrix can be randomly generated, and then a first intermediate matrix is determined based on each sub-block after the Gaussian distribution matrix is blocked and each first current sub-block after the current image matrix is blocked. Orthogonalization processing is performed in parallel on each sub-block after the first intermediate matrix is blocked to obtain the current orthogonal matrix. Then, numerical stability optimization processing is performed in parallel on each third current sub-block after the current orthogonal matrix is blocked to obtain a new current orthogonal matrix, and the main features are extracted from each first current sub-block in parallel using each sub-block after the new current orthogonal matrix is blocked, so as to obtain the current target matrix.
[0051] Among them, the Gaussian distribution matrix can be generated using RandBLAS (Random Basic Linear Algebra Subprograms), that is, filling a random dense matrix with the RandBLAS library to obtain the Gaussian distribution matrix. The first intermediate matrix is specifically a matrix determined based on the product between the Gaussian distribution matrix and the current image matrix.
[0052] For the numerical stability optimization process, first, based on each sub-block after partitioning the current second matrix and each third current sub-block after partitioning the current orthogonal matrix, determine the target projection of the current orthogonal matrix on the column space of the current second matrix. Then, subtract the target projection from each third current sub-block after partitioning the current orthogonal matrix, and perform orthogonalization processing on each third current sub-block after subtracting the target projection in parallel to obtain a new current orthogonal matrix. Among them, the current second matrix is a matrix determined based on each historical orthogonal matrix; for example, the current orthogonal matrix is , and the historical orthogonal matrices are and . At this time, the current second matrix is .
[0053] Among them, the numerical stability optimization process can be specifically expressed by the following formula:
[0054] ;
[0055] ;
[0056] represents the current orthogonal matrix, represents the current second matrix, T represents the transpose operation of the matrix, and orth represents the orthogonalization process.
[0057] It should be noted that subtracting the target projection from the current orthogonal matrix above aims to remove the components collinear with the current second matrix in the current orthogonal matrix, so that the current orthogonal matrix after subtracting the target projection is orthogonal to the current second matrix. After performing the orthogonalization process on the current orthogonal matrix after subtracting the target projection, it can be ensured that the new current orthogonal matrix obtained after the orthogonalization process is orthogonal to the current second matrix; among them, the orthogonalization process usually involves normalizing the current orthogonal matrix after subtracting the target projection, that is, dividing the current orthogonal matrix after subtracting the target projection by its norm to ensure that its length is 1.
[0058] In numerical calculations, due to the precision limitations of floating-point numbers, directly performing Householder reflection may lead to numerical instability. In this embodiment, by first subtracting the target projection and then performing orthogonalization processing, the non-orthogonality caused by numerical errors can be reduced, thereby improving the numerical stability and enhancing the stability and reliability of singular value decomposition.
[0059] After obtaining the new current orthogonal matrix, transpose the new current orthogonal matrix, and partition the transposed current orthogonal matrix. Use each sub-block obtained after partitioning to perform principal feature extraction on each first current sub-block after partitioning the current image matrix in parallel to obtain the current target matrix. For example, the current target matrix can be a matrix determined based on the product between the current image matrix and the transposed current orthogonal matrix.
[0060] Furthermore, after obtaining the new current orthogonal matrix, it is also necessary to use each sub-block after partitioning the new current orthogonal matrix to update each sub-block after partitioning the current second matrix in parallel to obtain the updated current second matrix. Among them, the updated current second matrix can be expressed as ; represents the current orthogonal matrix, represents the current second matrix; that is, the current second matrix can be updated by splicing the current second matrix and the new current orthogonal matrix to obtain the updated current second matrix.
[0061] Step S12: Use each second current sub-block after partitioning the current target matrix to update each sub-block after partitioning the current first matrix in parallel to obtain the updated current first matrix; the current first matrix is a matrix determined based on each historical target matrix.
[0062] In this embodiment, after obtaining the current target matrix, it is necessary to use each second current sub-block after partitioning the current target matrix to update each sub-block after partitioning the current first matrix in parallel to obtain the updated current first matrix. Among them, the updated current first matrix can be expressed as ; represents the current first matrix, represents the current target matrix; that is, the current first matrix can be updated by splicing the current first matrix and the current target matrix to obtain the updated current first matrix.
[0063] It should be noted that the current first matrix before update is a matrix determined based on each historical target matrix; for example, the current target matrix is , the historical target matrices are and , and the current first matrix before update is , the updated current first matrix is . It should be noted that the superscript T in this application represents the transpose operation of the matrix.
[0064] Step S13: Update each of the first current sub-blocks in parallel according to each of the second current sub-blocks to obtain an updated current image matrix, and when the current iteration process satisfies a preset end condition, end the iteration process, and perform singular value decomposition on each sub-block after partitioning the latest current first matrix in parallel to obtain a decomposition matrix, and determine the compressed image corresponding to the image to be compressed based on some of the singular values corresponding to the decomposition matrix.
[0065] In this embodiment, each of the first current sub-blocks after partitioning the current image matrix is updated in parallel according to each of the second current sub-blocks after partitioning the current target matrix to obtain an updated current image matrix; if the iteration process of the current image matrix satisfies a preset end condition at this time, end the iteration process of the current image matrix, and perform singular value decomposition on each sub-block after partitioning the latest current first matrix in parallel to obtain a decomposition matrix, and then determine the compressed image corresponding to the image to be compressed based on some of the singular values corresponding to the decomposition matrix.
[0066] Among them, for the updated current image matrix, a second intermediate matrix can be first determined based on each sub-block after partitioning the new current orthogonal matrix and each of the second current sub-blocks after partitioning the current target matrix, and each of the first current sub-blocks after partitioning the current image matrix is updated in parallel according to each sub-block after partitioning the second intermediate matrix to obtain an updated current image matrix. For example, the current image matrix is updated to obtain an updated current image matrix by subtracting the second intermediate matrix from the current image matrix.
[0067] For the determination of the second intermediate matrix, first, the current target matrix needs to be transposed, and the transposed current target matrix is partitioned, and the second intermediate matrix is determined by using each sub-block obtained after partitioning and each sub-block after partitioning the new current orthogonal matrix. For example, the second intermediate matrix can be a matrix determined based on the product between the transposed current target matrix and the new current orthogonal matrix.
[0068] It should be noted that the preset end conditions in this embodiment include but are not limited to that the current error value is not greater than a preset error, and / or the current rank reaches a preset rank. The rank refers to the rank of the matrix; and, the preset rank is less than the minimum of the number of rows and the number of columns of the original image matrix.
[0069] Wherein, the current error value is the difference determined based on a first value and a second value; the first value is the value determined based on the norms of the respective first current sub-blocks after partitioning the current image matrix when the current image matrix is the original image matrix; the second value is the value determined based on the norms of the sub-blocks after partitioning the updated current first matrix and the norms of the respective second current sub-blocks after partitioning the current target matrix. The formulas involved are as follows:
[0070] ;
[0071] ;
[0072] ;
[0073] represents the first value, A represents the original image matrix, represents the Frobenius norm, represents the second value, represents the current target matrix, represents the current first matrix, B represents the transposed current first matrix, and TOL represents the current error value.
[0074] Wherein, the current rank is the rank obtained by accumulating a preset matrix partitioning value to the rank at the previous moment; it should be noted that when the rank at the previous moment is the rank at the first moment, the rank at the previous moment is zero. The formulas involved are as follows: k = k + block_size; k represents the rank, block_size represents the preset matrix partitioning value, and the preset matrix partitioning value is the value determined based on the number of rows and columns of the original image matrix and the preset memory capacity allocated for each sub-block.
[0075] When the iteration process of the current image matrix meets the preset end condition, it is necessary to perform singular value decomposition on the respective sub-blocks of the latest current first matrix in parallel using the respective sub-blocks of the latest current second matrix to obtain a decomposition matrix, and select some singular values from the singular values corresponding to the decomposition matrix, so as to determine a sub-matrix corresponding to the selected singular values from the decomposition matrix, thereby determining the compressed image corresponding to the image to be compressed using the sub-matrix.
[0076] For the decomposition matrix, specifically, first perform singular value decomposition on the latest current first matrix to obtain a first decomposition matrix, a second decomposition matrix, and a decomposition matrix to be transformed, and then determine a third decomposition matrix based on the product between the latest current second matrix and the decomposition matrix to be transformed. The formulas involved are as follows:
[0077] ;
[0078] Let \(A\) represent the current first matrix, \(V\) represent the first decomposition matrix, and \(S\) represent the second decomposition matrix. Let \(X\) represent the decomposition matrix to be transformed. Let \(X^T\) represent the transpose matrix of the decomposition matrix to be transformed, \(Q\) represent the current second matrix, and \(U\) represent the third decomposition matrix.
[0079] For some singular values, a preset number of singular values can be selected from the singular values corresponding to the decomposition matrix in the order from front to back of the singular values as the partial singular values; alternatively, a preset number of singular values with the largest numerical values in the singular values corresponding to the decomposition matrix can be used as the partial singular values. In this way, by constructing a submatrix by selecting partial singular values to determine the compressed image, not only the main features of the image are retained, so that there is not much loss of clarity or details in the compressed image, but also the image compression ability is improved, and the storage space required for the compressed image is reduced.
[0080] It should be noted that for the matrices involved in this embodiment, a corresponding storage space needs to be allocated for each matrix, and each matrix is stored in blocks. At the same time, for the calculation of each matrix, it is a parallel calculation for each sub-block after the matrix is divided into blocks; among them, for the parallel calculation, it can be realized by the scheduling of OpenMP (Open Multi-Processing, used to support multi-threaded parallel programming) based on the load balancing strategy to achieve task-level parallelism of multiple threads. In this way, through matrix block parallel processing and task-level parallelism of multiple threads, the efficiency of singular value decomposition can be improved, and then the efficiency of image compression can be improved.
[0081] And, the prior art stores matrices in the Figure 2 LAPACK (Linear Algebra PACKage) column storage format shown, while this embodiment stores matrices in the Figure 3 matrix block storage format shown. It can be found that in this embodiment, the large matrix is first cut into each sub-block on the basis of the LAPACK column storage format, and then each sub-block is stored in column-major order. Among them, since all matrix calculations are for each sub-block, the finer the block is divided, the finer the parallel granularity is, and correspondingly, the higher the parallelism can be.
[0082] For example, first allocate a storage space for each of the \(A\) matrix and the \(B\) matrix, and store the \(A\) matrix and the \(B\) matrix in blocks in their respective storage spaces in the LAPACK column storage format. For the calculation between the \(A\) matrix and the \(B\) matrix, the parallel calculation is performed on each sub-block after the \(A\) matrix is divided into blocks and each sub-block after the \(B\) matrix is divided into blocks, and then the sub-calculation results between each sub-block are combined to obtain the final calculation result of the \(A\) matrix and the \(B\) matrix.
[0083] As can be seen from the above, in this application, by performing block parallel processing on each matrix, the parallelism of singular value decomposition is fully exploited. All parallel computations are executed in multiple threads by a task scheduler based on a load balancing strategy, so as to give full play to the performance of central processing units with different architectures of a computer and improve the efficiency of singular value decomposition. Moreover, in this application, by extracting main features from the current image matrix, the amount of computation can be appropriately reduced, and the computational complexity and space complexity of singular value decomposition can be decreased. Further, in this application, by setting a preset end condition, when the iteration process of the current image matrix meets the end condition, singular value decomposition is performed, thus ensuring the accuracy of singular value decomposition. In addition, after singular value decomposition in this application, based on some of the singular values corresponding to the decomposed matrix, the compressed image corresponding to the image to be compressed is determined. This not only retains the main features of the image to be compressed, but also improves the compression ability of image compression and saves the storage space required for compressing the image.
[0084] See Figure 4 As shown, an image compression device based on randomized singular value decomposition according to an embodiment of this application includes:
[0085] A matrix acquisition module 11, configured to convert an image to be compressed into an original image matrix to obtain a current image matrix, and during the iteration process of the current image matrix, perform a preprocessing operation for extracting main features of the matrix in parallel on each first current sub-block after the current image matrix is blocked, so as to obtain a current target matrix;
[0086] A matrix update module 12, configured to use each second current sub-block after the current target matrix is blocked to update each sub-block after the current first matrix is blocked in parallel, so as to obtain an updated current first matrix; the current first matrix is a matrix determined based on each historical target matrix;
[0087] An image compression module 13, configured to use each second current sub-block to update each first current sub-block in parallel to obtain an updated current image matrix, and when the current iteration process meets a preset end condition, end the iteration process, and perform singular value decomposition in parallel on each sub-block after the latest current first matrix is blocked to obtain a decomposed matrix, and determine the compressed image corresponding to the image to be compressed based on some of the singular values corresponding to the decomposed matrix; wherein, the parallel computation for each sub-block after the matrix is blocked is executed in multiple threads by a task scheduler based on a load balancing strategy.
[0088] As can be seen from the above, in this application, by performing block parallel processing on each matrix, the parallelism of singular value decomposition is fully exploited. All parallel computations are executed in multiple threads by the task scheduler based on the load balancing strategy, so that the performance of central processing units with different architectures of the computer can be fully utilized, and the efficiency of singular value decomposition can be improved. Moreover, by extracting the main features of the current image matrix, this application can appropriately reduce the amount of computation and lower the computational complexity and space complexity of singular value decomposition. Further, by setting a preset end condition, when the iteration process of the current image matrix meets the end condition, singular value decomposition is performed, thereby ensuring the accuracy of singular value decomposition. In addition, after singular value decomposition, based on some of the singular values corresponding to the decomposed matrix, the compressed image corresponding to the image to be compressed is determined. This not only retains the main features of the image to be compressed, but also improves the compression ability of image compression and saves the storage space required for compressing the image.
[0089] In some specific embodiments, the matrix acquisition module 11 includes:
[0090] The first matrix determination unit is configured to determine a first intermediate matrix based on each sub-block after the Gaussian distribution matrix is partitioned and each first current sub-block after the current image matrix is partitioned, and perform orthogonalization processing on each sub-block after the first intermediate matrix is partitioned in parallel to obtain a current orthogonal matrix;
[0091] The matrix processing sub-module is configured to perform numerical stability optimization processing on each third current sub-block after the current orthogonal matrix is partitioned in parallel to obtain a new current orthogonal matrix, and perform main feature extraction on each of the first current sub-blocks in parallel by using each sub-block after the new current orthogonal matrix is partitioned to obtain a current target matrix.
[0092] In some specific embodiments, the matrix processing sub-module includes:
[0093] The projection determination unit is configured to determine a target projection of the current orthogonal matrix on the column space of the current second matrix based on each sub-block after the current second matrix is partitioned and each third current sub-block after the current orthogonal matrix is partitioned; the current second matrix is a matrix determined based on each historical orthogonal matrix;
[0094] The matrix processing unit is configured to subtract the target projection from each of the third current sub-blocks, and perform orthogonalization processing on each of the third current sub-blocks after subtracting the target projection in parallel to obtain a new current orthogonal matrix.
[0095] In some specific embodiments, the image compression device based on randomized singular value decomposition may further include:
[0096] A first update unit, configured to update each sub-block obtained by partitioning the current second matrix in parallel by using each sub-block obtained by partitioning the new current orthogonal matrix, so as to obtain an updated current second matrix;
[0097] Correspondingly, the image compression module 13 includes:
[0098] A singular value decomposition unit, configured to perform singular value decomposition on each sub-block obtained by partitioning the latest current first matrix in parallel by using each sub-block obtained by partitioning the latest current second matrix, so as to obtain a decomposition matrix.
[0099] In some specific embodiments, the image compression module 13 includes:
[0100] A second update unit, configured to determine a second intermediate matrix based on each sub-block obtained by partitioning the new current orthogonal matrix and each second current sub-block, and update each first current sub-block in parallel according to each sub-block obtained by partitioning the second intermediate matrix, so as to obtain an updated current image matrix.
[0101] In some specific embodiments, the preset end condition includes that the current error value is not greater than a preset error, and / or the current rank reaches a preset rank;
[0102] Wherein, the current error value is a difference value determined based on a first value and a second value; the first value is a value determined based on the norms of each first current sub-block when the current image matrix is the original image matrix; the second value is a value determined based on the norms of each sub-block obtained by partitioning the updated current first matrix and the norms of each second current sub-block;
[0103] And, the current rank is a rank obtained by adding a preset matrix partition value to the rank at the previous moment; wherein, when the rank at the previous moment is the rank at the first moment, the rank at the previous moment is zero.
[0104] In some specific embodiments, the image compression module 13 includes:
[0105] A second matrix determination unit, configured to select some singular values from the singular values corresponding to the decomposition matrix, and determine a sub-matrix corresponding to the some singular values from the decomposition matrix, so as to determine a compressed image corresponding to the image to be compressed by using the sub-matrix;
[0106] Wherein, the some singular values are a preset number of singular values selected from the singular values corresponding to the decomposition matrix in the order from front to back of the singular values, or, the some singular values are a preset number of singular values with the largest values among the singular values corresponding to the decomposition matrix.
[0107] Furthermore, an embodiment of the present application also discloses an electronic device, Figure 5 which is a structural diagram of an electronic device 20 shown according to an exemplary embodiment. The content in the figure should not be considered as any limitation on the scope of use of the present application.
[0108] Figure 5 FIG. 6 is a schematic structural diagram of an electronic device 20 provided by an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the image compression method based on random singular value decomposition disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0109] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows is any communication protocol applicable to the technical solution of the present application, and no specific limitation is imposed on it here; the input / output interface 25 is used to obtain external input data or output data to the outside, and its specific interface type can be selected according to specific application needs, and no specific limitation is made here.
[0110] In addition, as a carrier for resource storage, the memory 22 may be a read-only memory, a random access memory, a magnetic disk, or an optical disc, etc. The resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage method may be short-term storage or permanent storage.
[0111] Among them, the operating system 221 is used to manage and control each hardware device and the computer program 222 on the electronic device 20, and it may be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the image compression method based on random singular value decomposition executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program that can be used to complete other specific tasks.
[0112] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the image compression method based on random singular value decomposition disclosed above. For the specific steps of this method, reference may be made to the corresponding content disclosed in the foregoing embodiments, and details are not described herein again.
[0113] In this specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method section.
[0114] Those skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0115] The steps of the methods or algorithms described in combination with the embodiments disclosed herein can be directly implemented by hardware, software modules executed by a processor, or a combination of both. The software modules can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.
[0116] Finally, it should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.
[0117] The above has introduced the technical solutions provided by this application in detail. Specific examples are used herein to elaborate on the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application; at the same time, for those of ordinary skill in the art, according to the idea of this application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to this application.
Claims
1. An image compression method based on random singular value decomposition, characterized in that Including: Converting the image to be compressed into an original image matrix to obtain a current image matrix, and during the iteration process of the current image matrix, performing a preprocessing operation for extracting the main features of the matrix on each first current sub-block after the current image matrix is partitioned in parallel to obtain a current target matrix; Using each second current sub-block after the current target matrix is partitioned to update each sub-block after the current first matrix is partitioned in parallel to obtain an updated current first matrix; The current first matrix is a matrix determined based on each historical target matrix; According to each second current sub-block, updating each first current sub-block in parallel to obtain an updated current image matrix, and when the current iteration process satisfies a preset end condition, ending the iteration process, and performing singular value decomposition on each sub-block after the latest current first matrix is partitioned in parallel to obtain a decomposition matrix, and determining the compressed image corresponding to the image to be compressed based on some singular values among the singular values corresponding to the decomposition matrix; Wherein, the parallel calculation for each sub-block after the matrix is partitioned is all performed through a task scheduler in multiple threads based on a load balancing strategy.
2. The image compression method based on random singular value decomposition according to claim 1, characterized in that The performing a preprocessing operation for extracting the main features of the matrix on each first current sub-block after the current image matrix is partitioned in parallel to obtain a current target matrix includes: Determining a first intermediate matrix based on each sub-block after the Gaussian distribution matrix is partitioned and each first current sub-block after the current image matrix is partitioned, and performing orthogonalization processing on each sub-block after the first intermediate matrix is partitioned in parallel to obtain a current orthogonal matrix; Performing numerical stability optimization processing on each third current sub-block after the current orthogonal matrix is partitioned in parallel to obtain a new current orthogonal matrix, and using each sub-block after the new current orthogonal matrix is partitioned to extract the main features of each first current sub-block in parallel to obtain a current target matrix.
3. The image compression method based on random singular value decomposition according to claim 2, wherein The performing numerical stability optimization processing on each third current sub-block after the current orthogonal matrix is partitioned in parallel to obtain a new current orthogonal matrix includes: Determining the target projection of the current orthogonal matrix on the column space of the current second matrix based on each sub-block after the current second matrix is partitioned and each third current sub-block after the current orthogonal matrix is partitioned; the current second matrix is a matrix determined based on each historical orthogonal matrix; Subtracting the target projection from each third current sub-block, and performing orthogonalization processing on each third current sub-block after subtracting the target projection in parallel to obtain a new current orthogonal matrix.
4. The image compression method based on random singular value decomposition according to claim 3, wherein Also including: Using each sub-block after the new current orthogonal matrix is partitioned to update each sub-block after the current second matrix is partitioned in parallel to obtain an updated current second matrix; Correspondingly, the performing singular value decomposition on each sub-block after the latest current first matrix is partitioned in parallel to obtain a decomposition matrix includes: Performing singular value decomposition on each sub-block after the latest current first matrix is partitioned by using each sub-block after the latest current second matrix is partitioned to obtain a decomposition matrix.
5. The image compression method based on random singular value decomposition according to claim 2, characterized in that, Updating each of the first current sub - blocks in parallel according to each of the second current sub - blocks to obtain an updated current image matrix includes: Determining a second intermediate matrix based on each sub - block after partitioning of the new current orthogonal matrix and each of the second current sub - blocks, and updating each of the first current sub - blocks in parallel according to each sub - block after partitioning of the second intermediate matrix to obtain an updated current image matrix.
6. The image compression method based on random singular value decomposition according to claim 1, characterized in that The preset end condition includes that the current error value is not greater than a preset error, and / or the current rank reaches a preset rank; Wherein, the current error value is a difference determined based on a first value and a second value; the first value is a value determined based on the norms of each of the first current sub - blocks when the current image matrix is the original image matrix; the second value is a value determined based on the norms of each sub - block after partitioning of the updated current first matrix and the norms of each of the second current sub - blocks; And, the current rank is a rank obtained by adding a preset matrix partitioning value to the rank at the previous moment; wherein, when the rank at the previous moment is the rank at the first moment, the rank at the previous moment is zero.
7. The method for image compression based on random singular value decomposition according to any one of claims 1 to 6, characterized in that, Determining the compressed image corresponding to the image to be compressed based on some of the singular values in the decomposition matrix includes: Selecting some singular values from the singular values corresponding to the decomposition matrix, and determining the sub - matrices corresponding to the some singular values from the decomposition matrix, so as to determine the compressed image corresponding to the image to be compressed by using the sub - matrices; Wherein, the some singular values are a preset number of singular values selected from the singular values corresponding to the decomposition matrix in the order from the front to the back of the singular values, or, the some singular values are a preset number of singular values with the largest values among the singular values corresponding to the decomposition matrix.
8. An image compression device based on random singular value decomposition, characterized in that, It includes: A matrix acquisition module, configured to convert the image to be compressed into an original image matrix to obtain a current image matrix, and during the iterative process of the current image matrix, perform a pre - processing operation for extracting the main features of the matrix on each of the first current sub - blocks after partitioning of the current image matrix in parallel to obtain a current target matrix; A matrix update module, configured to update each sub - block after partitioning of the current first matrix in parallel by using each of the second current sub - blocks after partitioning of the current target matrix to obtain an updated current first matrix; The current first matrix is a matrix determined based on each historical target matrix; An image compression module, configured to update each of the first current sub - blocks in parallel according to each of the second current sub - blocks to obtain an updated current image matrix, and when the current iterative process satisfies a preset end condition, end the iterative process, perform singular value decomposition on each sub - block after partitioning of the latest current first matrix in parallel to obtain a decomposition matrix, and determine the compressed image corresponding to the image to be compressed based on some of the singular values in the decomposition matrix; Wherein, the parallel calculation for each sub - block after matrix partitioning is performed in multiple threads by a task scheduler based on a load - balancing strategy.
9. An electronic device, characterized in that, It includes: A memory, configured to store a computer program; A processor for executing the computer program to implement the image compression method based on random singular value decomposition according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, For storing a computer program which, when executed by a processor, implements the image compression method based on random singular value decomposition according to any one of claims 1 to 7.
Citation Information
Cited By
Edge computing-oriented AI gateway video efficient compression method
CN120676183A
High-efficiency video compression method for AI gateways in edge computing
CN120676183B