python cv2.imencode()(将图像编码到内存缓冲区中。)(图像压缩原理)
生活随笔
收集整理的這篇文章主要介紹了
python cv2.imencode()(将图像编码到内存缓冲区中。)(图像压缩原理)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
from cv2\__init__.py
def imencode(ext, img, params=None): # real signature unknown; restored from __doc__"""imencode(ext, img[, params]) -> retval, buf. @brief Encodes an image into a memory buffer.將圖像編碼到內存緩沖區中。. . The function imencode compresses the image and stores it in the memory buffer that is resized to fit the. result. See cv::imwrite for the list of supported formats and flags description.imencode函數壓縮圖像并將其存儲在已調整大小以適合結果的內存緩沖區中。 有關支持的格式和標志說明的列表,請參見cv :: imwrite。. . @param ext File extension that defines the output format.定義輸出格式的文件擴展名。. @param img Image to be written.要寫入的圖像。. @param buf Output buffer resized to fit the compressed image.調整輸出緩沖區的大小以適合壓縮圖像。. @param params Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.特定于格式的參數。 參見cv :: imwrite和cv :: ImwriteFlags。"""pass發現被壓縮后的圖片數據量是原來的23分之一了,難道不會造成數據、像素值丟失?
它壓縮的原理是什么?
應該是用到了某種算法,將有聯系的數據形成一塊打包,從而減少數據量,底層暫時不用管它,知道怎么用imencode()和imdecode()就行
參考文章1:利用Opencv提供的imencode和imdecode進行圖像視頻傳輸(發送端支持Linux和Windows雙系統)
總結
以上是生活随笔為你收集整理的python cv2.imencode()(将图像编码到内存缓冲区中。)(图像压缩原理)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: \x49\x51\x5a\x56\x54
- 下一篇: numpy ndarray.tostri