2d fft

What would be the easiest way to take a 2D Fourier Transform of an image, and draw the result? Currently I get the pixels from a black and white image in the following way:

TImage *img = TImage::Open("image.jpg"); TImage *img2 = (TImage*)img->Clone("img2"); TArrayD *arr = img2->GetArray(1024, 1024);

now I’m confused about what form the pixels should be in to tak e the fourier transform. I guess my choices are histogram, matrix, TArray or just a plain Double_t array, but there are problems with all of these formats. the FFTW3 package seems to need a Double_t array, so, for instance, right now I’m trying to do the following:

Double_t *in= new Double_t[1024][1024]; in=arr;

but if I try to convert back to a TArray (to draw the image after the transform) I get errors (like Error: Incorrect assignment to arr1, wrong type ‘Double_t*’).
Does anybody have any ideas? Thanks

Greetings,

You can use the SetImage() method of TImage/TASImage to create an image from a C-style double array.

Hi,

The best way to set the points for a tranform is to use

If you don’t care about your memory consumption, you could copy the values from the image into some array, loop over it and fill the transform object (the data is copied into the transform object). Alternatively, you could try to get the values straight from the image, but I don’t know how to do it. I’ll ask the graphics experts to comment on that.

Cheers,
Anna

Cochonou- I actually tried that already, but I get a segmentation error. It only works if I try to set the image with values from a TArray.

Hi,
long waited good question :slight_smile:
I’ll try to prepare a couple of examples asap.

Regards. Valeriy