AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
March 2006

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2006.03.31 05:49 "16-bit TIFF to 8-bit BMP/TIF ???", by Chris Le Brese
2006.03.31 13:47 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by Edward Lam
2006.03.31 16:05 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by Bob Friesenhahn
2006.03.31 16:13 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by Bernie Pallek
2006.03.31 16:34 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by Bob Friesenhahn
2006.03.31 16:39 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by Edward Lam
2006.04.02 08:03 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by Chris Le Brese
2006.04.02 16:19 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by Bob Friesenhahn
2006.04.02 17:15 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by David Scriven
2006.03.31 16:05 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by Bernie Pallek

2006.03.31 16:05 "Re: 16-bit TIFF to 8-bit BMP/TIF ???", by Bernie Pallek

> I am in the process of writing a program using openCV
> that analyses 8 bit images. The problem I have is that
> images produced from a fluorescent camera are
> 16 bit unsigned greyscale TIFF images (industry
> standard).
> ...
> The way I would like to do this is to get every pixels
> intensity value (16 bit) and Square root it to bring
> it into the range between 0 and 255.

It sounds like you'll want to do something like this:

- open original TIFF
- create new TIFF as 8-bit greyscale
- begin loop
-- read one scanline worth from original (see TIFFReadEncodedStrip)
-- normalize the scanline (run through each pair of octets, treating them as
   a 16-bit word, do your sqrt(), and store in another buffer)
-- write one scanline to new file (see TIFFWriteEncodedStrip)
- end loop when all scanlines have been processed
- close new file
- close original file

You'll probably want to set these tags, at least, before writing your data:
TIFFTAG_PHOTOMETRIC
TIFFTAG_IMAGEWIDTH
TIFFTAG_IMAGELENGTH
TIFFTAG_SAMPLESPERPIXEL (probably 1)
TIFFTAG_BITSPERSAMPLE (probably 8)
TIFFTAG_ORIENTATION (ORIENTATION_TOPLEFT)
TIFFTAG_PLANARCONFIG (probably PLANARCONFIG_CONTIG)
TIFFTAG_ROWSPERSTRIP
TIFFTAG_COMPRESSION

Note, you don't have to write your directory stuff explicitly; it will be
done automagically (at least for me, it worked out that way).