⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imratio.m

📁 霍夫曼coding程序
💻 M
字号:
function cr = imratio(f1 , f2)
%IMRATIO Computes the ratio of the bytes in two images/variables.
%   CR = IMRSTIO(F1 , F2) returns the ratio of the number of bytes in
%   variables/files F1 and F2. If F1 and F2 are an original and 
%   compressed image, respectively, CR is the compression ratio.

error(nargchk(2 , 2 , nargin));
cr = bytes(f1) / bytes(f2);

%--------------------------------------------------------------%
function b = bytes(f)
% Return the number of bytes in input f. If f is a string, assume
% that it is an image filename; if not, it is an image variable.
if ischar(f)
    info = dir(f);  b = info.bytes;
elseif isstruct(f)
    % MSTLaB's whos function reports an extra 124 bytes of memory
    % per structure field because of the way MATLAB stores
    % structures in memory. Don't count this extra memory; instead,
    % add up the memory associated with each field.
    b = 0;
    fields = fieldnames(f);
    for k = 1 :length(fields)
        b = b + bytes(f.(fields{k}));
    end
else
    info = whos('f');   b = info.bytes;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -