0
votes

I'm trying to do some image processing in GNU Octave using fft2 command, but i'm having problem with the inverse transform.

I can calculate the transform with no problem, do whatever i want with it, but when i return to space domain and try to plot the image, all i get is a all black image.

I even tried to only do the forward and inverse transform and nothing more, still same problem.

What can i do?

The image i'm using to test, by the way, is that one:

http://bootstrapbay.com/blog/wp-content/uploads/2014/05/yellow-taxi_vvvjao.png

Code:

I = imread('image.jpg');

imshow(I) % Produces image correctly

I2 = fft2(I);

I2 = ifft2(I2);

imshow(I2) % Produces black image

1
sorry about the link, i can't post images (yet)ebernardes
Can you show your code?runDOSrun
The relevant code where you do everything you described (don't comment, edit your post).runDOSrun
just did, i placed it on the question, sorryebernardes

1 Answers

1
votes

If you'll try actually using e.g. a jpg you'll see that it's giving you a very different result when compared to your png. Your problem is that you're loading a uint8 with imread but fft2 produces a double valued result (you can check more details on this answer). Also, the images are imported as RGB - that's 1 dimension too much.

So to fix it, just pick a channel for your transformations and tell it your scale (dmin,dmax):

a = double(imread('image.png'));
a = a(:,:,1);
ffta = fft2(a);
img = ifft2(ffta);

dmin = min(min(abs(img)));
dmax = max(max(abs(img)));

imshow(img, [dmin dmax])
pause(5)

results in the recovery of the grayscale image:

enter image description here

If you have the image package, you can also make use of functions like im2double etc (see e.g. here).