im = imread('d:\comp vision\images\travis.jpg');
im = rgb2gray(im);

% im = imresize(im,0.5);
% imshow(im)
% 
% freqcomp(im, 200, 0);


%freqcomp(im, 1000, .01);



avfilt = averagefilter(480,640,21,21);       % average filter
gafilt = fspecial('gaussian', [480 640], 6); % gaussian filter

imfft = fft2(im);
gafiltfft = fft2(gafilt);
avfiltfft = fft2(avfilt);
newimavfft = avfiltfft.*imfft;
newimgafft = gafiltfft.*imfft;

imwritesc(im, 'im.png');
imwritesc(gafilt, 'gafilt.png');
imwritesc(avfilt, 'avfilt.png');

imwritesc(fftshift(log(abs(imfft)+eps)), 'imfft.png');

imwritesc(fftshift(log(abs(gafiltfft)+eps)), 'gafiltfft.png');
imwritesc(fftshift(log(abs(avfiltfft)+eps)), 'avfiltfft.png');

imwritesc(fftshift(log(abs(newimavfft)+eps)), 'newimavfft.png');
imwritesc(fftshift(log(abs(newimgafft)+eps)), 'newimgafft.png');

imwritesc(fftshift(real(ifft2(newimavfft))), 'newimav.png');
imwritesc(fftshift(real(ifft2(newimgafft))), 'newimga.png');