图像压缩——比率
文章目錄
- 1.背景知識
- 2.兩幅圖像文件和/或變量的比特數的比率
1.背景知識
如圖1所示,圖像壓縮系統是由兩個截然不同的結構塊組成的:一個編碼器和一個解碼器。圖像f(x, y)被送人編碼器,該編碼器根據輸入數據建立一-組符號,并運用它們來描繪圖像。若用n1和n2分別表示原圖像及編碼后的圖像中信息攜帶單元的數量(通常是比特),則得到的壓縮結果可以通過壓縮比對其進行量化:
Cr=n1/n2
若壓縮比為10(或10∶1),則表明在壓縮過的數據集中對于每1個單元,原圖像有10個信息攜帶單元(如比特)。在MATLAB中,用于表示兩幅圖像文件和/或變量的比特數的比率可通過如下M
2.兩幅圖像文件和/或變量的比特數的比率
在MATLAB中,用于表示兩幅圖像文件和/或變量的比特數的比率可通過如下函數計算出來:
函數imratio:
函數bytes:
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)%MATLAB'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 elseinfo = whos ( 'f ') ;b = info.bytes; end圖像的壓縮:
r = imratio ('girl.jpg', 'rabbit.jpg')運行結果:
總結
- 上一篇: html audio 播放amr,vue
- 下一篇: python中怎么调整代码字体格式,py