简体   繁体   中英

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. 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.

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?

It could be that the source is compressed tif while the rewritten one is not compressed.

See https://code.ros.org/trac/opencv/ticket/1080 for a potential solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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