2010.02.08 10:47 "[Tiff] fftw and TIFF files", by

2010.03.05 16:30 "Re: [Tiff] Tiffs", by Deborah

Hi Larry,

I don't remember if I thanked you for your comments on my problem.

As you adviced me I'm trying to use OpenImageIO.

This is the code I have so far:

#include <imageio.h>
using namespace OpenImageIO;
#include <fftw3.h>

int main (int argc, char *argv[])
{

    ImageInput *Recibida = ImageInput::create (argv[1]);
    ImageInput *Original = ImageInput::create (argv[2]);

    ImageSpec specRecibida;
    ImageSpec specOriginal;

    Recibida->open (argv[1], specRecibida);
    Original->open (argv[2], specOriginal);

    int width = specOriginal.width;
    int height = specOriginal.height;

    fftw_complex *imgRecibida = ( fftw_complex*
)fftw_malloc(sizeof(fftw_complex) * width * height);
    fftw_complex *imgOriginal = ( fftw_complex*
)fftw_malloc(sizeof(fftw_complex) * width * height);
    fftw_complex *imgResultado = ( fftw_complex*
)fftw_malloc(sizeof(fftw_complex) * width * height);

    fftw_plan fft_imgRecibida = fftw_plan_dft_1d( width * height,
imgRecibida, imgRecibida, FFTW_FORWARD, FFTW_ESTIMATE );
    fftw_plan fft_imgOriginal = fftw_plan_dft_1d( width * height,
imgOriginal, imgOriginal, FFTW_FORWARD, FFTW_ESTIMATE );
    fftw_plan ifft_Resultado = fftw_plan_dft_1d( width * height,
imgResultado, imgResultado, FFTW_BACKWARD, FFTW_ESTIMATE );

unsigned char *pixelsRecibida, *pixelsOriginal;
    Recibida->read_image (TypeDesc::DOUBLE, pixelsRecibida,
2*sizeof(double));
    Original->read_image (TypeDesc::DOUBLE, pixelsOriginal,
2*sizeof(double));
*
  for(int k = 0 ; k < width * height ; k++ ) {
        imgRecibida[k][0] = pixelsRecibida[k];
        imgRecibida[k][1] = 0.0;

        imgOriginal[k][0] = pixelsOriginal[k];
        imgOriginal[k][1] = 0.0;
    }
*

    fftw_execute( fft_imgRecibida );
    fftw_execute( fft_imgOriginal );

    return 0;
}

I'm trying to do two autocorrelations, as you can see, of two images. One is an image received via Fax and the other one is the original image (the one that was sent).

When I read the image with read_image, I want this image to be read into imgRecibida (and the other image in imgOriginal). They are pointers to

 typedef double fftw_complex[2];

I don't understand what is the x stride, or why in your example you said 2*sizeof(double), I tried reading the OpenImageIO documentation but still can't get the meaning... I suppose this is because I'm not really familiar with image processing and also because my native language isn't English, so maybe I'm missing some important point. Shouldn't it be specRecibida.nchannels * something, AutoStride? or something like that?

Do you have any other comment that could help me?

Thanks again and I'm sorry if I'm bothering you.

Deborah

---------- Mensaje reenviado ----------
> From: "Larry Gritz" <lg@larrygritz.com>

> Date: Mon, 8 Feb 2010 18:43:23 +0100
> Subject: [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 files