Convolution problem

Hi,

first post : )
anyway, I've been trying to figure out a way to do a convolution on an image in matlab.
So, there are like a billion ways of doing this thing in matlab. I decided to make two, but I'm hitting some rubble along the way.

First way: in the frequency domain:
the definition of a convolution says that if we convolve in the time domain, we could just multiply in the frequency domain. So this is part of my code...

[code]% Fourier:
foto(:,:,1) = fft2(foto(:,:,1));
foto(:,:,2) = fft2(foto(:,:,2));
foto(:,:,3) = fft2(foto(:,:,3));

% Convolution
foto(:,:,1) = foto(:,:,1) .* fft2(filt);
foto(:,:,2) = foto(:,:,2) .* fft2(filt);
foto(:,:,3) = foto(:,:,3) .* fft2(filt);

% Inverse fourier
foto(:,:,1) = ifft2(foto(:,:,1));
foto(:,:,2) = ifft2(foto(:,:,2));
foto(:,:,3) = ifft2(foto(:,:,3));[/code]

Ok, so, the problem I have here is that my filt and foto(:,:,x) matrix sizes don't fit, so it won't do the multiplication.

And the other method is just using for's in the t-domain, so I won't bore you out with that bit...

thx in advance.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories