I have compressed and reconstructed an ECG signal using wavelet coefficients. In the compression part, many of wavelet coefficients are set to zero. For example, if in original ECG $5000$ wavelet coefficients have been obtained, now $4900$ coefficients have been set to zero. I have reconstructed the ECG signal using only $100$ coefficient, but how do I measure the compression ratio?
You can get a crude wavelet "condensation" ratio of $100/5000 = 1/50$, but nothing more.
Indeed, you cannot get a compression ratio in that case, for several reasons. A stricto sensu compression ratio is given by the size of the compressed file divided by the file of the original file. But:
- we do not have the size of the original file. Imagine it is a raw raster file, whose size is: (number of samples $\times$ precision) + header size. The number of samples could be of $5000$ samples, but there is no certainty. It could be due to redundant wavelets, edge extension. And we have no idea about the original precision. Suppose $16$-bit.
- we do not have a compressed file. First, the nonzero wavelet coefficients could be coded on $32$-bit floats. Then, if the data is $16$-bit, the condensation ratio is doubled. Second, you do not know the location (time-scale index) of the kept coefficients. They should be coded too. Without them, if you send your $100$ coefficients to somebody, he would not be able to reconstruct the data. Even with the location, we don't have a compressed file, which generally included quantization, entropy coding, etc.
You can have better estimates using first- or second-order entropy of the coefficients, that can give you an estimate of the theoretical limit.
The compression ratio can be obtained by dividing the number of non-zero values in the output by the number of non-zero values in the input. Therefore, the smaller the resulting value the better.