问题描述
我正在使用opencv裁剪tif文件,一切都很好,除了将图像保存到文件之外-opencv始终使用LZW压缩,但是我不需要对生成的文件进行压缩,我感谢opencv在节省磁盘驱动器空间方面的帮助,但现在不是正确的时机。
那么有没有一种方法可以使用特定的压缩方案(包括不压缩)或不保存tif文件?
原始图片未应用压缩方案,我正在使用ROI选择区域,然后使用SaveImage将其保存到目标文件。
I'm using opencv to crop tif files, everthing is fine, except for saving image to a file - opencv always uses LZW compression, but i don't need compression on resulting files, i do appreciate opencv's help in saving my disk drive space, but now is not the right time to do it.
So is there a way to save tif files with specific compression scheme (including no compression) or no?
Original images have no compression scheme applied and i'm using ROI to select area and SaveImage to save it to the target file. Any help appreciated!
推荐答案
TIFF压缩级别是硬编码的,无法在运行时更改。如果要在计算机上编译OpenCV,则可以在此文件中编辑压缩级别
The TIFF compression level is hard coded and cant be changed at run time. If you are compiling OpenCV on your machine, then you can edit the compression level in this file
3rdparty/libtiff/tiff.h
您会发现以下行:
#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */
希望有帮助。
编辑:在opencv代码中查看以下行:
您应该能够传递所需的TIFFTAG_COMPRESSION值,包括COMPRESSION_NONE。
see this line in the opencv code:https://github.com/Itseez/opencv/blob/b46719b0931b256ab68d5f833b8fadd83737ddd1/modules/imgcodecs/src/grfmt_tiff.cpp#L564you should be able to pass the desired value for TIFFTAG_COMPRESSION, including COMPRESSION_NONE.
这篇关于将tiff文件保存在opencv中时,是否可以设置特定的压缩方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!