SIP Toolbox

mkfftfilter - Builds 2D frequency-domain filters

Calling Sequence

transfer_function = mkfftfilter(image,filtername,frequency1[,frequency2])

Parameters

Description

This function gives some popular filters to be applied on the spectrum (fft) of an image.

The Fourier Transform gives informations about which frequencies are present in a signal (=spectrum).

A great property of the spectrum is that the original image can be reconstructed from it. Of course, modifications in the spectrum will result in a modified image, but spectrum modifications can be easier and more intuitive.

A combination of several filters is possible.

All these filters are cylindrical and act only on amplitude (not on phase). The following filters are available (h is the trasfer function):

h=1/(1+(f/frequency1)^(2*n)) n=1,2 or 3 for 'butterworth1', 'butterworth2' or 'butterworth3'.

The exponential filter: h=exp(-(f/frequency1)^1);

The gaussian filter which is a particular case of the exponential: h=exp(-(f/frequency1)^2);

h=1 if f<=frequency1 h=-(f-frequency2)/(frequency2-frequency1) h=0 if f>=frequency2

Examples

   stacksize(4e7); // increase the stack size because 
                   // images are very much memory consumming

   image=gray_imread(SIPDIR+'images/ararauna.png');
   xset("window",0);xbasc();imshow(image);
   xtitle("Original Image");

   IM=fft(image,-1);

   //calculate the power spectrum
   spectrum=real((IM).*conj(IM));
   //for visualisation: the low frequencies are moved to the center of the image
   //with sip_fftshift,
   //the use of log(spectrum+1) allows to observe great amplitude variations.
   xset("window",1);xbasc();imshow(sip_fftshift(log(spectrum+1)),[]);
   xtitle("Power Spectrum");

   //transfer function
   h=mkfftfilter(image,'binary',20);
   xset("window",2);xbasc();imshow(h);
   xtitle("Transfer Function");

   IM2=IM.*sip_fftshift(h);//spectrum modification

   //reverse transform
   im2=real(fft(IM2,1));
   xset("window",3);xbasc();xselect();imshow(im2,[]);
   xtitle("Low-pass binary filtering");

   //High-pass filter
   IM3=IM.*sip_fftshift(1-h);//spectrum modification with (1-h)
   im3=real(fft(IM3,1));
   xset("window",4);xbasc();xselect();imshow(im3,[]);
   xtitle("High-pass binary filtering");

   //Combination of 2 filters
   h1=mkfftfilter(image,'binary',30);
   h2=mkfftfilter(image,'binary',5);
   h=h1-h2;
   IM4=IM.*sip_fftshift(h);//spectrum modification
   im4=real(fft(IM4,1));
   xset("window",5);xbasc();xselect();imshow(im4,[]);
   xtitle("Band-pass binary filtering");
   

Authors

Jocelyn Druel <jocelyn.druel1@libertysurf.fr>

Availability

The latest version of the Scilab Image Processing toolbox can be found at

http://siptoolbox.sourceforge.net

See Also

sip_fftshift,  gsm2d,  imconv,