Disclosure of Invention
The invention provides an image compression and reconstruction method based on sparse representation on the basis of JPEG2000 compression standard, aiming at improving the image compression ratio and simultaneously guaranteeing the subjective quality of decompressed images.
In order to achieve the technical purpose, the invention adopts the following technical scheme:
s1, downsampling an original high-resolution image X to be compressed to obtain a downsampled low-resolution image Y L ;
S2, for the low resolution image Y L Upsampling to obtain Y of the same resolution as X H Image Y is divided by using quadtree block division method H Block division is performed to divide the image Y H Dividing into image blocks of 64×64, 32×32 and 16×16, for image block of 16×16, further dividing into image block of 4*4 and extracting features to obtain low resolution image feature block F L ;
S3, utilizing the one-to-one correspondence of the high-low resolution image blocks and Y H Corresponding division is carried out on the high-resolution image X to obtain a high-resolution image block X after block division H ;
S4, respectively training the high-resolution image blocks X by using K-SVD (K times singular value decomposition) H And a low resolution image feature block F L Corresponding dictionary D H And D L ;
S5, coding the low-resolution image Y at the coding end L Through JPEG2000 standard compressionShrinking to obtain Y L And a high-low resolution dictionary D H And D L Packaging and transmitting to a decoding end;
s6, firstly de-multiplexing the code stream at the decoding end to obtain a low-resolution image Y L Compressed code stream and high-low resolution dictionary D of (2) H And D L ;
S7, pair Y L The compressed code stream of (2) is decoded by JPEG2000 standard to obtain low resolution image Y' L Then for Y' L Upsampling to obtain an image Y 'with the same resolution as the original image' H ;
S8, for the image Y' H Performing the same block division as in step S2, and extracting the characteristics of the 4*4 image block to obtain corresponding image characteristic block F' L ;
S9, after block division is completed, the block divided by 64 x 64 and 32 x 32 is directly adopted as a reconstruction block by the up-sampling result in the step S7; for image feature block F' L Using sparse representation method and high-low resolution dictionary D H And D L Performing super-resolution reconstruction to obtain a reconstructed image block X' H ;
S10, splicing all reconstructed image blocks to corresponding positions to obtain a reconstructed high-resolution image X 0 Then, the iterative back projection technology is utilized for X 0 Global optimization is carried out to obtain a final reconstructed image X * 。
As one of the preferred embodiments of the present invention, the downsampling method in step S1 may be any of a variety of existing downsampling methods, such as a bicubic downsampling method, a simple extraction method, and the like.
As one of the preferred embodiments of the present invention, the upsampling method of step S2 is a bicubic upsampling method.
Step S2 is to divide the image Y by using a quadtree block H The specific implementation mode of the division is as follows:
s2.1 image Y H Divided into a plurality of mutually non-overlapping image blocks of size 64 x 64, called CTU for short, which is Y H A divided basic unit;
s2.2 each CTU mayThree sub-picture blocks (CUs) are selected and divided into 64X 64, 32X 32 and 16X 16, wherein the CUs with the sizes of 64X 64 and 32X 32 correspond to Y H Is a smooth region of CU size 16 x 16 corresponds to Y H Is not smooth.
S2.3, determining a threshold T of block division, wherein the specific method is as follows:
for an image Y of size m x n H The average value of the gray differences between the adjacent pixels in the ith row and the jth column is respectivelyAnd->The calculation formula is as follows:
the threshold T of the block division is defined by the whole m x n image Y H The average value of the gray differences between adjacent pixels is determined, namely:
s2.4 for each CTU of 64 x 64, the block partitioning procedure is as follows:
s2.4.1 the average value T of the gray differences between adjacent pixels of each CTU is calculated in the same manner as S2.3 CTU And compared with a blocking threshold T. When T is CTU >T, dividing the CTU into four CUs of 32×32, and executing step S2.4.2; otherwise, the CTU does not continue to divide, i.e. the size of 64×64;
s2.4.2 calculates the average value T of the gray differences between adjacent pixels of 4 32X 32CU sequentially according to the same method as S2.3 CU And compared with a blocking threshold T. When T is CU >T, the CU isDividing into 4 CUs 16×16; otherwise, the CU does not continue to partition, i.e. the size is 32 x 32.
The step S2 is further divided into image blocks of size 4*4 for the image blocks of size 16×16, and features are extracted to obtain a low resolution image feature block F L The specific method of (2) is as follows:
s2.5 for a CU 16 x 16, it is further divided into a plurality of 4*4 tiles, adjacent 4*4 tiles having k (0 < k < 4) pixels overlapping.
S2.6 the following 4 one-dimensional filters are used for extracting features of the image block of 4*4.
f 1 =[-1,0,1],f 2 =f 1 T ,f 3 =[1,0,-2,0,1],f 4 =f 3 T Where T represents the transpose. Applying the four filters to obtain 4 eigenvectors of each image block, and connecting the 4 eigenvectors into a 64 x 1 eigenvector, denoted as image eigenvector F L 。
As one of the preferable schemes of the invention, the step S4 is to train by using K-SVD to obtain the low-resolution image characteristic block F L Corresponding dictionary D L The specific implementation mode of the method is as follows:
s4.1 with all F L A sample dataset matrix F is composed.
S4.2 matrix F may be derived from dictionary matrix D L And coefficient matrix A, the aim of dictionary training is to find dictionary matrix D L And a coefficient matrix a. The linearity is expressed as:
F≈D L A
the dictionary training process described above may be translated into solving the following optimization problem:
epsilon is the maximum allowed by the reconstruction error.
S4.3, solving the optimization problem as follows:
s4.3.1 the Image super-resolution via sparse represen by YangDictionary published in the station paper as initial D L 。
S4.3.2 in the known D L Under the condition, the sparse coefficient of each sample is obtained to obtain the D L A corresponding coefficient matrix A;
s4.3.3 under the condition of knowing A, updating D by adopting K-SVD method L ;
S4.3.4 steps S4.3.2 and S4.3.3 are repeated until the reconstruction error meets the requirements, at which point D L Namely F L A corresponding training dictionary.
As one of the preferable schemes of the invention, the step S4 trains the high resolution image block X by using K-SVD H Corresponding dictionary D H In the process of (a), an image block X with a size of 4*4 is processed H Converted into a column vector of 16X 1, all X H Forming a matrix of sample data sets, and dictionary D L The dictionary D is obtained by using K-SVD as in the training process H 。
As one of the preferable schemes of the invention, the step S9 utilizes a sparse representation method and a high-low resolution dictionary D H And D L The super-resolution reconstruction process comprises the following specific steps:
s9.1 for each image feature block F' L Using dictionary D L The corresponding sparse coefficient alpha can be solved, and the calculation formula is as follows:
F′ L =D L α ||α|| 0 ≤N
wherein alpha is E R N N is the number of atoms in the sparse dictionary.
S9.2 corresponding reconstructed high resolution image block X' H Can use dictionary D H And the solved sparse coefficient alpha are linearly combined to represent:
X′ H =D H α ||α 0 ≤N
as one of the preferable schemes of the invention, the step 10 uses the iterative back projection method to perform the X 0 The specific steps for global optimization are as follows:
s10.1 reconstruction of high resolution image X 0 Downsampling D and blurringH, simulating a high-resolution image degradation process, and solving a degraded image X' t And a low resolution image Y L Error of (2) to reconstruct high resolution image X t And performing iterative updating. The calculation formula of the iterative back projection method is as follows:
X t+1 =X t +((Y L -X′ t )↑s)*p
wherein X 'is' t =DHX t ,X t For the t iteration process high resolution image, p is a back projection filter, ∈r is upsampling, and S is an upsampling factor.
S10.2 As final reconstructed high resolution image X * Stopping iterative updating when the reconstruction constraint is met, wherein the reconstruction constraint formula is as follows:
compared with the prior art, the invention has the following advantages:
(1) The invention adopts the quadtree idea to divide the image into blocks, divides the smooth area of the low-resolution image into image blocks with the sizes of 64 x 64 and 32 x 32, and divides the non-smooth image area containing detail information into image blocks with the size of 4*4, thereby shortening the dictionary training time by reducing the number of training samples on the basis of ensuring the accuracy of the dictionary training;
(2) When the decoding end reconstructs a decoded image, the smooth image block is directly reconstructed by using a bicubic interpolation mode, and the image feature block containing detail information is reconstructed by using a sparse representation mode, so that the high-resolution image reconstruction time is shortened on the premise of ensuring the subjective quality of image reconstruction;
(3) The invention carries out joint dictionary training on high-resolution image blocks and low-resolution image feature blocks, adds additional information contained in images into an initial dictionary trained by an external image library, updates the training dictionary and obtains a training dictionary D corresponding to the corresponding high-resolution image blocks H Corresponding to low resolution image feature blocksTraining dictionary D L Features contained in the dictionary are more in line with the image reconstruction requirements, and the image reconstruction quality is further improved.
Detailed Description
The invention is further explained with reference to the drawings and examples, wherein fig. 1 is a block diagram of image compression and reconstruction based on sparse representation, and the main steps include:
step 1: taking 640X 640 images as high-resolution images X to be compressed, and performing 4 times downsampling on the high-resolution images X to obtain images Y with spatial resolution of 160X 160 L ;
Step 2: for image Y L Performing bicubic upsampling with a sampling factor of 4 to obtain an image Y with a resolution of 640 x 640 H ;
Further, for image Y H The concrete operation of block division by using the quadtree idea is as follows:
image Y H The CTU is a basic unit of image block division, and each CTU can be selectively divided into three sub-image blocks (CUs) of 64 x 64, 32 x 32 and 16 x 16, and fig. 2 is a schematic diagram of quadtree block division. The threshold T of block division is defined by the whole 640 x 640 image Y H The average value of the gray differences between adjacent pixels is determined, namely:
in the aboveAnd->Respectively are images Y H The average value of the gray differences between the i-th row and j-th column adjacent pixels is calculated as follows:
for each 64×64ctu, the block partitioning procedure is as follows:
(1) Calculating the average value T of gray differences between adjacent pixels of each CTU CTU And compared with a blocking threshold T. When T is CTU >T, dividing the CTU into four CUs of 32×32, and executing step (2); otherwise, the CTU does not continue to divide, i.e. the size of 64×64;
(2) Sequentially calculating the average value T of gray differences between 4 adjacent pixels of 32X 32CU CU And compared with a blocking threshold T. When T is CU >T, dividing the CU into 4 16 x 16 CUs; otherwise, the CU does not continue to partition, i.e. the size is 32 x 32.
FIG. 3 is a schematic diagram showing the division result of the image quadtree blocks. For Y H After the above division of all CTUs, Y H Is divided into CUs of sizes 64 x 64 and 32 x 32, and the non-smooth region is divided into CUs of 16 x 16.
Further, for the image blocks with the size of 16×16, the image blocks are further divided into a plurality of image blocks with the size of 4*4, and k (0 < k < 4) pixels are overlapped on adjacent image blocks. When k=1, that is, adjacent image blocks overlap by one pixel, the image block division result is that as shown in fig. 4, an image block with a size of 16×16 is divided into 25 image blocks 4*4. The following 4 one-dimensional filters are used for the image block of 4*4 to extract its features:
f 1 =[-1,0,1],f 2 =f 1 T ,f 3 =[1,0,-2,0,1],f 4 =f 3 T where T represents the transpose. Applying the four filters to obtain 4 eigenvectors of each image block, and connecting the 4 eigenvectors into a 64 x 1 eigenvector, denoted as image eigenvector F L 。
Step 3: original high resolution image block X to be compressed H Dividing:
utilizing a low resolution image Y according to a one-to-one correspondence of high-low resolution image blocks H Corresponding division is made for the high resolution image X, the smooth region is divided into 64X 64 and 32X 32 image blocks, the non-smooth region is divided into a plurality of 4*4 image blocks, and the adjacent image blocks have k (0<k<4) Overlap of the individual pixels.
Step 4: training high resolution image blocks X separately using K-SVD (K-th singular value decomposition) H And a low resolution image feature block F L Corresponding dictionary D H And D L 。
Further, for the low resolution image feature block F L Corresponding dictionary D L Is trained as follows:
obtaining the low-resolution image characteristic block F from the step 2 L As dictionary D L Training samples, all samples are formed into a sample dataset matrix F. The sample dataset matrix F may be composed of a dictionary matrix D L And coefficient matrix A, the aim of dictionary training is to find dictionary matrix D L And a coefficient matrix a. The linearity is expressed as:
F≈D L A
the dictionary learning described above may be translated into solving the following optimization problem:
epsilon is the maximum value allowed by reconstruction errors, and the solving process of the optimization problem is as follows:
(1) Dictionary published in Image super-resolution via sparse representation of Yang as initial D L . At a known D L Under the condition, the sparse coefficient of each sample is obtained to obtain the D L A corresponding coefficient matrix A;
(2) Under the condition of the known A, the D is updated by adopting a K-SVD method L K-SVD updates the dictionary by adopting a column-by-column updating mode, and when the kth column d of the dictionary is updated k When the other columns of the dictionary are fixed, the current error matrix E is calculated:
adjustment d k And alpha k The error is made as small as possible, and a training dictionary after the first iteration is obtained after each column of the initial dictionary is updated;
(3) Continuously updating the coefficient matrix and the training dictionary, and stopping iterative updating until the reconstruction error of the sample meets the requirement to obtain a low-resolution image feature block F L Corresponding training dictionary D L 。
Further, high resolution image block X H Corresponding dictionary D H Is trained as follows:
obtaining a high-resolution image block X with the size of 4*4 from the step 3 H Converted into a column vector of 16X 1, all X H Forming a matrix of sample data sets, and dictionary D L The training process is the same, and the K-SVD algorithm is utilized to obtain the high-resolution image block X H Corresponding dictionary D H 。
Step 5: at the encoding end, the low resolution image Y L Compression by JPEG2000 standard to obtain Y L And a high-low resolution dictionary D H And D L Packaging and transmitting to a decoding end;
step 6: de-multiplexing at decoding end to obtain low resolution image Y L Compressed code stream and high-low resolution dictionary D of (2) H And D L ;
Step 7: for low resolution image Y L The compressed code stream of (2) is decoded by JPEG2000 standard to obtain low resolution image Y' L The spatial resolution is 160 x 160, then for Y' L The image Y 'with 640 x 640 resolution is obtained by 4 times up-sampling' H ;
Step 8: for image Y' H The same block division as in step 2 is performed, the smooth region is divided into blocks with the sizes of 64 x 64 and 32 x 32, the non-smooth region is divided into blocks with the size of 4*4, and the characteristic is extracted to obtain an image characteristic block F' L ;
Step 9: for the image blocks divided in the step 8, the image blocks with the sizes of 64 x 64 and 32 x 32 are directly used as reconstructed image blocks by using the 4 times up-sampling result in the step 7; for image feature block F' L The reconstruction is carried out by using a sparse representation method, and the specific implementation mode is as follows:
(1) Using image feature blocks F' L And dictionary D L Can solve for the corresponding sparse coefficient α:
F′ L =D L α ||α|| 0 ≤N
wherein alpha is E R N N is the number of atoms in the sparse dictionary.
(2) Corresponding reconstructed high resolution image block X' H Using dictionary D H And the solved sparse coefficient alpha are linearly combined to represent:
X′ H =D H α ||α|| 0 ≤N
step 10: splicing all the reconstructed image blocks to corresponding positions to obtain a reconstructed high-resolution image X 0 Then, the iterative back projection technology is utilized for X 0 Global optimization is carried out to remove possible saw tooth or ringing effect of the reconstructed image, and a final reconstructed image X is obtained * And satisfies reconstruction constraints:
finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.