python cv2.imencode()(将图像编码到内存缓冲区中。)(图像压缩原理)

女生的网名这么多〃 提交于 2020-01-01 10:41:24

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双系统)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!