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
February 2010

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

2010.02.08 17:43 "OpenImageIO; was Re: fftw and TIFF files", by Larry Gritz
2010.02.09 07:58 "Re: OpenImageIO; was Re: fftw and TIFF files", by Debora Gil
2010.03.05 16:30 "Re: Tiffs", by <debita@gmail.com>
2010.03.05 18:50 "Re: Tiffs", by Larry Gritz

2010.02.09 07:58 "Re: OpenImageIO; was Re: fftw and TIFF files", by Debora Gil

Hi,

This OpenImageIO Project looks really good. I think I'll give it a try
because I'm using C++. I'll let you know about the results.

Thanks and best regards,
Debora

-----Mensaje original-----
De: tiff-bounces@lists.maptools.org
[mailto:tiff-bounces@lists.maptools.org] En nombre de Larry Gritz
Enviado el: lunes, 08 de febrero de 2010 18:43
Para: tiff@lists.maptools.org
Asunto: [Tiff] OpenImageIO; was Re: fftw and TIFF files

I'll take this opportunity to point people to another open source
project I'm administering: http://www.openimageio.org

OpenImageIO (OIIO for short) is a format-agnostic API for reading and
writing image files.  TIFF is among many image file formats supported
(using libtiff underneath, of course).  But even if you are only
interested in TIFF, you may find that using OIIO's API's to read TIFF
files is simpler and more straightforward than struggling with the raw
libtiff calls.  There are also a lot of other useful features of the
library, including an image tile cache that lets you literally access
hundreds of GB of image data without worrying about which parts are in
memory or which files are opened, and a filtered texture system.

But the aspect of OIIO that is relevant to Debora's question is that the
basic API for reading images automatically does format conversion and
will read data into buffers with strides.  For example, your basic issue
is that you want to read data from a TIFF file (perhaps with arbitrary
bit depth) into a buffer of double[2], but you want the pixel values to
end up in every other buffer slot.  Piece of cake.  You can do it with
about 7 lines of code:

        ImageInput *in = ImageInput::create (filename);
        ImageSpec spec;
        in->open (filename, spec); /* res is now in spec.{width,height}
*/
	fftw_complex *img1 = fftw_malloc(sizeof(fftw_complex) *
spec.width * spec.height);
	memset (img1, 0, sizeof(fftw_complex) * spec.width *
spec.height);  // zero it out
        in->read_image (TypeDesc::DOUBLE /* desired data format */, 
			pixels /* buffer */,
		        2*sizeof(double) /* optional: x stride */);
        in->close ();
        delete in;

This will work for scanline or tiled images, any bit depth with proper
conversion to double, etc.  (Though as I've written it, the code assumes
a single data channel. To be robust, it should check spec.nchannels
before proceeding with the read_image.)  Also, if you had the need to
read other file formats, this code would not need to be modified, as
long as it's a file format that OIIO understands or can find a plugin
for.

I hope you are using C++.  If it's straight C, never mind.

	-- lg


On Feb 8, 2010, at 8:48 AM, tiff-request@lists.maptools.org wrote:

> ----------------------------------------------------------------------
> 
> Date: Mon, 8 Feb 2010 11:47:27 +0100
> From: "Gil, Debora, VF-ES (dgilalv) STU" <debora.gil@vodafone.com>
> Subject: [Tiff] fftw and TIFF files
> To: <tiff@lists.maptools.org>
> 
> Hi,
> 
> I'm trying to do the phase correlation of two TIFF images (a reference
> image and an image received via fax) to determine if they are similar
> and or have any offset.
> 
> For this I'm using LibTIFF and FFTW. In order to do this I need to
load
> the Image data to the FFTW input arrays:
> 
> fftw_complex *img1 = ( fftw_complex* )fftw_malloc( sizeof(
fftw_complex
> ) * width * height ); <- this is the input array (it's a double[2]
> composed of the real and imaginary parts of a complex number)
> 
> As I said, what I need to do is load the image data on that input
array.
> I would like to do something like this:
> 
> for( i = 0; i < height ; i++ ) {
>    for( j = 0 ; j < width ; j++) {
>        img1[k][0] = <- here goes the image data
>        img1[k][1] = 0.0;
>    }
> }
> 
> This kind of thing is what I've seen in an OpenCV example for reading
> TIFF images, but it doesn't seem to work so I decided to try with
> LibTIFF. 
> 
> Thanks in advance,
> 
> Debora
> 

--
Larry Gritz
lg@larrygritz.com