This application claims the priority benefit of Taiwan application serial no. 106132684, filed on Sep. 22, 2017. The entirety of the above-mentioned patent application is hereby incorporated by reference herein and made a part of this specification.
The invention relates to a block-based principal component analysis transformation method and a device thereof, and more particularly to a principal component analysis transformation method and a device thereof that recover the original signal with a smaller data size.
When the traditional principal component analysis (PCA) processes a signal, since the signal has quite large dimensions, the calculation cost for capturing the eigenvector and eigenvalues is also very high. Some related researches proposed solving this problem with hardware, but such solution significantly increases the cost on hardware. As such, how to perform PCA transformation more efficiently is a crucial subject in the industry.
In this concern, the invention provides a block-based principal component analysis transformation method and a device thereof that completely reconstruct the original signal with a small data size.
The invention provides a PCA transformation method and a device thereof, including: obtaining an input signal; dividing the input signal and obtaining a plurality of one-dimension vectors corresponding to the divided input signal, wherein a number of the plurality of one-dimension vectors is a division number; after arranging the plurality of one-dimension vectors to a two-dimension vector, subtracting an average value of the plurality of one-dimension vectors in the number of the division number to obtain a zero-mean vector; calculating a covariance matrix of the zero-mean vector; calculating an eigenvector of the covariance matrix; and multiplying the zero-mean vector by the eigenvector to obtain a projection coefficient.
In an embodiment of the invention, the input signal is a one-dimension signal, and the processes of dividing the input signal and obtaining the plurality of one-dimension vectors corresponding to the divided input signal includes: dividing the one-dimension signal to a plurality of frames and obtaining the plurality of one-dimension vectors according to a plurality of sampling points corresponding to the plurality of frames.
In an embodiment of the invention, the one-dimension signal is a speech signal.
In an embodiment of the invention, the input signal is a two-dimension signal, and the processes of dividing the input signal and obtaining the plurality of one-dimension vectors corresponding to the divided input signal includes: dividing the two-dimension signal to a plurality of blocks, obtaining a plurality of two-dimension matrices corresponding to a plurality of pixels of the plurality of blocks, and transforming the plurality of two-dimension matrices to the plurality of one-dimension vectors.
In an embodiment of the invention, the two-dimension signal is an image signal.
In an embodiment of the invention, the principal component analysis transformation method of the invention further includes: multiplying the projection coefficient by an inverse matrix of the eigenvector to obtain a reconstructed zero-mean vector; adding the average value to the reconstructed zero-mean vector to obtain a recovered one-dimension vector; and arranging the recovered one-dimension vector to a recovered input signal.
The invention provides a block-based principal component analysis transformation device, including a processor and a memory coupled to the processor, wherein the processor obtains an input signal; divides the input signal and obtains a plurality of one-dimension vectors corresponding to the divided input signal, wherein a number of the plurality of one-dimension vectors is a division number; after arranging the plurality of one-dimension vectors to a two-dimension vector, subtracting an average value of the plurality of one-dimension vectors in the number of the division number to obtain a zero-mean vector; calculates a covariance matrix of the zero-mean vector; calculates an eigenvector of the covariance matrix; and multiplies the zero-mean vector by the eigenvector to obtain a projection coefficient.
In an embodiment of the invention, the input signal is a one-dimension signal, and the processor divides the one-dimension signal to a plurality of frames and obtains the plurality of one-dimension vectors according to a plurality of sampling points corresponding to the plurality of frames.
In an embodiment of the invention, the input signal is a two-dimension signal, and the processor divides the two-dimension signal to a plurality of blocks, obtains the plurality of two-dimension matrices corresponding to a plurality of pixels of the plurality of blocks and transforms the plurality of two-dimension matrices to the plurality of one-dimension vectors.
In an embodiment of the invention, the processor multiplies the projection coefficient by an inverse matrix of the eigenvector to obtain a reconstructed zero-mean vector; adds the average value to the reconstructed zero-mean vector to obtain a recovered one-dimension vector; and arranges the recovered one-dimension vector to a recovered input signal.
Based on the foregoing, the block-based principal component analysis transformation method and the device thereof of the invention properly divides a one-dimension signal or two-dimension signal to a plurality of frames or a plurality of blocks in order to obtain a plurality of corresponding one-dimension vectors; next, after arranging the plurality of one-dimension vectors to a two-dimension vector, subtracts an average value of the plurality of one-dimension vectors in a number of the division number to obtain a zero-mean vector; calculates a covariance matrix of the zero-mean vector; calculates an eigenvector of the covariance matrix; and then multiplies the zero-mean vector by the eigenvector to obtain a projection coefficient, which serves as a transformation output of the PCA of the invention. The invention further multiplies the projection coefficient by an inverse matrix of the eigenvector by an inverse transformation to retrieve a reconstructed zero-mean vector, adds the average value to the zero-mean vector to obtain a recovered one-dimension vector, and, lastly, arranges the recovered one-dimension vector to frames or blocks in designated sizes.
To make the above features and advantages of the invention more comprehensible, several embodiments accompanied with drawings are described in detail as follows.
The accompanying drawings are included to provide a further understanding of the invention, and are incorporated in and constitute a part of this specification. The drawings illustrate exemplary embodiments of the invention and, together with the description, serve to explain the principles of the invention.
Some other embodiments of the invention are provided as follows. It should be noted that the reference numerals and part of the contents of the previous embodiment are used in the following embodiments, in which identical reference numerals indicate identical or similar components, and repeated description of the same technical contents is omitted. Please refer to the description of the previous embodiment for the omitted contents, which will not be repeated hereinafter.
Referring to
The processor 110 is, for example, a central processing unit (CPU) or other programmable microprocessor for general use or special use, a digital signal processor (DSP), a programmable controller, an application specific integrated circuit (ASIC), other similar components, or a combination of the foregoing.
The memory 120 is, for example, any type of stationary or movable random access memory (RAM), read-only memory (ROM), flash memory, hard disk drive (HHD), solid state drive (SSD), other similar components, or a combination of the foregoing.
In an embodiment of the invention, the blocked-based principal component analysis transformation device 100 may receive an input signal such as a speech signal or an image signal through a communication component (not illustrated) and store or temporarily store the input signal in the memory 120 for the processor 110 to perform a transformation and an inverse transformation of PCA to the input signal.
Referring to
In step S203, the one-dimension signal is divided to a plurality of frames, and a plurality of one-dimension vectors are obtained according to a plurality of sampling points corresponding to the plurality of frames, wherein a number of the plurality of one-dimension vectors is a number of the plurality of frames. In specific, the processor 110 divides the one-dimension signal according to the plurality of frames in designated sizes, as represented by equation (1).
X
f=[x(f-1)n+1,x(f-1)n+2, . . . ,x(f-1)n+n]T, where f=1, . . . ,F (1)
where f is an fth frame of the one-dimension signal, F is a number of the plurality of frames of the one-dimension signal, n is a number of the plurality of sampling points in the plurality of frames, and T is a transpose of matrix.
In step S205, after arranging the plurality of one-dimension vectors to a two-dimension vector, an average value of the plurality of one-dimension vectors in the number of the plurality of frames is subtracted to obtain a zero-mean vector. In specific, the processor 110 arranges the plurality of original n×1 one-dimension vectors to an n×F two-dimension vector according to equation (2).
X
V=[X1,X2, . . . ,Xf, . . . XF], where f=1, . . . ,F (2)
A zero-mean vector ZV is represented by equation (3), wherein the average value of the plurality of one-dimension vectors in the number of the plurality of frames is represented by equation (4).
In step S207, a covariance matrix of the zero-mean vector is calculated. A covariance matrix C is represented by equation (5).
In step S209, an eigenvector of the covariance matrix is calculated. In specific, the processor 110 extracts an eigenvector evec by a matrix decomposition method, and the eigenvector is a basis function of the frame-based PCA of the invention, and d(·) represents the matrix decomposition method, as represented by equation (6).
e
vec
×e
val
×e
vec
T
=d(C) (6)
In step S211, the zero-mean vector is multiplied by the eigenvector to obtain a projection coefficient. A projection coefficient P is a transformation output of the frame-based PCA of the invention, as represented by equation (7).
e
vec
×Z
V
=P (7)
Referring to
In step S303, the two-dimension signal is divided to a plurality of blocks, a plurality of two-dimension matrices corresponding to a plurality of pixels of the plurality of blocks are obtained, and the plurality of two-dimension matrices are transformed to a plurality of one-dimension vectors, wherein a number of the plurality of one-dimension vectors is a number of the plurality of blocks. In specific, the processor 110 divides the one-dimension signal according to the plurality of blocks in designated sizes, as represented by equation (8).
where r is a block on a rth row of the two-dimension signal, c is a block on a cth column of the two-dimension signal, R is a total number of the plurality of blocks in rows, C is a total number of the plurality of blocks in columns, p is a number of rows of the plurality of pixels in the plurality of blocks, and q is a number of columns of the plurality of pixels in the plurality of blocks.
Next, the processor 110 further uses (·) to transform the plurality of two-dimension matrices to the plurality of one-dimension vectors, as represented by equation (9).
In step S305, after arranging the plurality of one-dimension vectors to a two-dimension vector, an average value of the plurality of one-dimension vectors in the number of the plurality of blocks is subtracted to obtain a zero-mean vector. In specific, the processor 110 arranges the plurality of original (p×q)×B one-dimension vectors to a (p×q)×B two-dimension vector according to equation (10), wherein B is a product of R and C.
X
V=[X1,X2, . . . ,Xν, . . . ,XR×C], where ν=1, . . . ,R×C (10)
The zero-mean vector ZV is represented by equation (11), wherein the average value of the plurality of one-dimension vectors in the number of the plurality of blocks is represented by equation (12).
In step S307, a covariance matrix of the zero-mean vector is calculated. A covariance matrix C is represented by equation (13).
In step S309, an eigenvector of the covariance matrix is calculated. In specific, the processor 110 extracts an eigenvector evec by a matrix decomposition method, and the eigenvector is a basis function of the block-based PCA of the invention, and d(·) represents the matrix decomposition method same as that represented by equation (6).
In step S311, the zero-mean vector is multiplied by the eigenvector to obtain a projection coefficient. A projection coefficient P is a transformation output of the block-based PCA of the invention, same as that represented by equation (7).
Referring to
e
vec
×P=Z′
V (14)
Because the eigenvector is an orthogonal matrix, the inverse matrix of the eigenvector is identical to a transposed matrix of the eigenvector.
In step S403, an average value is added to the reconstructed zero-mean vector to obtain a recovered one-dimension vector, as represented by equation (15).
X′
V
=Z′
V+
In step S405, the recovered one-dimension vector is arranged to a recovered input signal.
If the original input signal is a one-dimension signal, the recovered one-dimension vector is as represented by equation (16), and the recovered input signal is as represented by equation (17).
X
re=[(X′1)T,(X′2)T, . . . (X′f)T, . . . (X′F)T], where f=1, . . . ,F (16)
X′
f=[x′(f-1)n+1,x′(f-1)n+2, . . . ,x′(f-1)n+n]T, where f=1, . . . ,F (17)
If the original input signal is a two-dimension signal, the recovered one-dimension vector is as represented by equation (18), and the recovered input signal is as represented by equation (19). It is noteworthy that, (·) in equation (19) is a transfer function of arranging the plurality of one-dimension vectors to a two-dimension matrix in a designated size.
Table 1 and Table 2 are provided hereinafter to describe the quality test on the inverse transformation recovery and the error on a sampling unit.
Table 1 shows the difference between an original one-dimension speech signal having a sampling frequency of 44.1 k and the speech signal being inverse transformed (i.e. a signal to noise ratio, SNR).
Table 2 shows the difference between an original 256×256 two-dimension image signal and the image signal being inverse transformed (i.e. peak signal to noise ratio, PSNR).
According to Table 1 and Table 2, when a recovery signal is not quantified, it can be shown by the recovered SNR and PSNR of the inverse transformation that the original signal cannot be completely recovered in the recovery test. If an error of 0.5 is added to one point of the signal with and results in the SNR and PSNR results both smaller than the SNR and PSNR values recovered simply by inverse transformation, it shows that the error generated by the inverse transformation is smaller than the difference made by the error of 0.5. Lastly, the signal is completely recovered by the inverse transformation using a rounding process to eliminate the errors in a digital signal.
In
Table 3 is a test result of the recovery quality of the projection coefficient through a rounding process when decimal places is quantified under different block sizes.
In view of Table 3, regardless of the block size, in the PCA method of the invention, when quantifying to the first decimal place, the original image in the blocks of all sizes are completely reconstructed, and the PSNR is infinite.
In
In
In summary of the foregoing, the PCA transformation method and the device thereof properly divides a one-dimension signal or two-dimension signal to a plurality of frames or a plurality of blocks in order to obtain a plurality of corresponding one-dimension vectors, calculates a zero-mean vector of the plurality of one-dimension vectors and calculates a covariance matrix of the zero-mean vector, calculates an eigenvector of the covariance matrix, then multiplies the zero-mean vector by the eigenvector to obtain a projection coefficient, which serves as a transformation output of the PCA of the invention. The invention further multiplies the projection coefficient by an inverse matrix of the eigenvector by an inverse transformation to retrieve a reconstructed zero-mean vector, adds an average value to the zero-mean vector to obtain a recovered one-dimension vector, and, lastly, arranges the recovered one-dimension vector to frames or blocks in designated sizes. In addition, under the premise of a small data size, the PCA transformation method further achieves complete recovery of input signal, which other prior methods cannot achieve.
It will be apparent to those skilled in the art that various modifications and variations can be made to the disclosed embodiments without departing from the scope or spirit of this invention. In view of the foregoing, it is intended that the invention covers modifications and variations provided that they fall within the scope of the following claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
106132684 | Sep 2017 | TW | national |