Ask Your Question

Tiff images, DPI and compression

asked 2013-08-06 06:40:37 -0600

Samjakar gravatar image

Hi, I am working on a combination of OpenCV2.4.0, and leptonica. We are processing tiff images. At the end of the image processing, I am noticing that the DPI of the resultant image ( created using "imwrite") has come down from 150 to 96 and I also notice that the image has been compressed by LZW method thought the original image was uncompressed. Also, the Bit Depth has come me down from to 8 from 32 (as was on the original image). Are there ways to fix these three?

  • Karthik
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2013-08-06 21:52:09 -0600

It seems you could used the parameters list of imwrite to set some TIFF parameters. set TIFFTAG_COMPRESSION to COMPRESSION_NONE to avoid compression. TIFFTAG_BITSPERSAMPLE can only be 8 or 16, not 32. Is the DPI important? Because, if you have the same number of pixels, it only says the physical size of your image.

But all tests have made lead to an error if I don't used the LZW compression (with the last GIT version of OpenCV)! Which is quite strange because the parameters are read, according to the code in module/highgui/src/grfmt_tiff.cpp line 483 (even if 3 lines above the comment says the opposite). You could try to patch it or report the bug. If you patch it, please consider the other flags (see 3rdparty/libtiff/tiff.h for an overview).

edit flag offensive delete link more

answered 2014-01-23 03:00:54 -0600

EK gravatar image

Hello,@Samjakar, Can you tell us how to read the origin images in tiff file,using 3rd library? or use opencv function? Give you codes,and maybe it was changed when you read it.

edit flag offensive delete link more


Hi EK, I know I am very late in responding to the question. Let me know if you still needed some response here or if you have found out what you wanted to know. A lot of developments at work and life has been hectic. :). I apologize.


Samjakar gravatar imageSamjakar ( 2014-06-09 04:51:11 -0600 )edit

Question Tools

1 follower


Asked: 2013-08-06 06:40:37 -0600

Seen: 6,242 times

Last updated: Jan 23 '14