日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

图像压缩——比率

發(fā)布時間:2024/1/1 编程问答 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 图像压缩——比率 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

  • 1.背景知識
  • 2.兩幅圖像文件和/或變量的比特數(shù)的比率

1.背景知識

如圖1所示,圖像壓縮系統(tǒng)是由兩個截然不同的結(jié)構(gòu)塊組成的:一個編碼器和一個解碼器。圖像f(x, y)被送人編碼器,該編碼器根據(jù)輸入數(shù)據(jù)建立一-組符號,并運用它們來描繪圖像。若用n1和n2分別表示原圖像及編碼后的圖像中信息攜帶單元的數(shù)量(通常是比特),則得到的壓縮結(jié)果可以通過壓縮比對其進行量化:

Cr=n1/n2
若壓縮比為10(或10∶1),則表明在壓縮過的數(shù)據(jù)集中對于每1個單元,原圖像有10個信息攜帶單元(如比特)。在MATLAB中,用于表示兩幅圖像文件和/或變量的比特數(shù)的比率可通過如下M

2.兩幅圖像文件和/或變量的比特數(shù)的比率

在MATLAB中,用于表示兩幅圖像文件和/或變量的比特數(shù)的比率可通過如下函數(shù)計算出來:

函數(shù)imratio:

function cr = imratio(f1, f2) %IMRATIO Computes the ratio of the bytes in two images/variables. %CR = IMRATIO(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) ) ;% Check input arguments cr = bytes (f1)/ bytes ( f2);% Compute the ratio

函數(shù)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')

運行結(jié)果:

總結(jié)

以上是生活随笔為你收集整理的图像压缩——比率的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。