Convolution problem - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Convolution problem

nipnip Posts: 5Member

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.