How can calculate compression ratio in Principal component analysis using SVD
Show older comments
compression ratio is the rate of original file on the compressed file. but in PCA tech the ratio= 1024/(2*PrinComps+1)?
Answers (2)
Image Analyst
on 18 Sep 2017
0 votes
I don't understand the question. Compression ratio is the ratio of the disk size of the original (uncompressed) image divided by the size of the compressed image file. Like if the original file was 10 MB and you compressed it, what whatever method (SVD or otherwise), and now the size of the compressed file is 2 MB, then the compression ratio is 10/5 = 5 to 1. So, is that formula not working for you?
6 Comments
Noor Abbas
on 18 Sep 2017
Edited: Walter Roberson
on 18 Sep 2017
Walter Roberson
on 18 Sep 2017
No. 1024 has no obvious relationship to "disk size of the original (uncompressed) image", and (2*PrinComps+1) has no obvious relationship to "size of the compressed image file".
Remember that your image is likely uint8, which is one byte per pixel component, but the principle components you calculate are double, which are 8 bytes per pixel component.
It is also difficult to understand why you wrote,
%%Extract first 40 principal component
PrinComps=25
That looks like 25 components to me.
Image Analyst
on 18 Sep 2017
Use dir() to get the file size.
Walter Roberson
on 18 Sep 2017
Note that dir() will tell you the size of the image on disk. Image files often contain overhead like comments and information about resolution and exposure, and image files often have compression applied to them for storage on disk. To find out the size of the image for compression purposes you should use
temp = whos('data');
image_storage_size = temp.bytes;
Noor Abbas
on 20 Sep 2017
Walter Roberson
on 20 Sep 2017
I showed how to use whos to find out the data storage requirement of a matrix. Call that on the original matrix. Call that on each of the matrices of non-constant values that are needed together to reconstruct the original matrix, and sum those. The original size divided by the sum of the representation matrix sizes is the compression ratio.
Noor Abbas
on 18 Sep 2017
0 votes
Categories
Find more on Image Segmentation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!