How compress an image with TIFF format in OpenCV c++?
I proceed some filtering on an Image then I want to save it through imwrite command with TIFF format but the size is big. As in JPEG format can compress a image to lower size. How do I do it in TIFF format. (I'm using OpenCV C++).
Starting from v3.4.6, cv::ImwriteFlags
includes IMWRITE_TIFF_COMPRESSION
(see https://docs.opencv.org/3.4.6/d4/da8/group__imgcodecs.html).
In opencv-python==4.5.5.62
, I have successfully used
import cv2
cv2.imwrite(filename, array, params=(cv2.IMWRITE_TIFF_COMPRESSION, 1)) # None
cv2.imwrite(filename, array, params=(cv2.IMWRITE_TIFF_COMPRESSION, 5)) # LZW
cv2.imwrite(filename, array, params=(cv2.IMWRITE_TIFF_COMPRESSION, 8)) # Adobe Deflate
cv2.imwrite(filename, array, params=(cv2.IMWRITE_TIFF_COMPRESSION, 32946)) # Deflate
See also https://www.awaresystems.be/imaging/tiff/tifftags/compression.html