简体   繁体   English

OpenCV保存图像显着增加.tif的文件大小

[英]OpenCV Save Image Dramatically Increases File Size of .tif

I'm using OpenCV in Python to find images within other images using the MatchTemplate method. 我在Python中使用OpenCV使用MatchTemplate方法在其他图像中查找图像。 I've noticed that when I load a .tif file then re-save it, even if I have not altered the image in opencv, the file size is increasing dramatically, eg, from 68kb to 25mb. 我注意到当我加载.tif文件然后重新保存它时,即使我没有在opencv中更改图像,文件大小也会急剧增加,例如从68kb增加到25mb。

I wrote a very basic script to verify that this happens without any other code modifying the image. 我写了一个非常基本的脚本来验证这是否发生,而没有任何其他代码修改图像。

import cv, sys

filename = sys.argv[1]

image = cv.LoadImage(filename)
cv.SaveImage('test.tif', image)

I didn't see any options for optimizing the image. 我没有看到任何优化图像的选项。 Any ideas on how I might be able to maintain the original file size within OpenCV or is this just a matter of compressing after the fact? 关于如何在OpenCV中维护原始文件大小的任何想法,或者这只是在事后压缩的问题?

It could be that the source is compressed tif while the rewritten one is not compressed. 可能是源被压缩而tif,而重写的源没有被压缩。

See https://code.ros.org/trac/opencv/ticket/1080 for a potential solution 有关可能的解决方案,请参阅https://code.ros.org/trac/opencv/ticket/1080

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM