I have images in two folders,in e drive,one folder consists of normal images ,and other compressed images
image(foldername)consists of original images
image1(foldername)consists of compressed folder
i want to calculate the size of each folder and compression ratio,please help

 採用された回答

Jonathan Sullivan
Jonathan Sullivan 2012 年 3 月 2 日

0 投票

im1_stats = dir(filename_image1);
im2_stats = dir(filename_image2);
ratio = im1_stats.bytes./im2_stats.bytes

6 件のコメント

kash
kash 2012 年 3 月 2 日
Jonathan in filename_image1 is it
im1_stats = dir(e:\image);
in my case
i get
4x1 struct array with fields:
name
date
bytes
isdir
datenum
i have 10 images
Jonathan Sullivan
Jonathan Sullivan 2012 年 3 月 2 日
kash, You want the file name, not the directory. So for example, let's say that the image your compressed is called image_uncompressed.jpg, and the compressed image is called image_compressed.jpg. Your code should then read:
filename_image1 = 'e:\image\image_uncompressed.jpg';
filename_image2 = 'e:\image\image_compressed.jpg';
im1_stats = dir(filename_image1);
im2_stats = dir(filename_image2);
ratio = im1_stats.bytes./im2_stats.bytes
kash
kash 2012 年 3 月 2 日
Jonathan i have 15images in that folder
Jonathan Sullivan
Jonathan Sullivan 2012 年 3 月 2 日
編集済み: Walter Roberson 2019 年 7 月 30 日
Oh. I understand now. Try this
folder1_stats = dir(folder1);
folder2_stats = dir(folder2);
size_folder1 = sum([folder1_stats.bytes]);
size_folder2 = sum([folder2_stats.bytes]);
ratio = size_folder1./size_folder2
kash
kash 2012 年 3 月 2 日
Thanks Jonathan
Abdesselam Bassou
Abdesselam Bassou 2017 年 11 月 23 日
txk a lot

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

質問済み:

2012 年 3 月 2 日

編集済み:

2019 年 7 月 30 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by