matlab - Low pass gaussian filter with a specified cut off frequency -


i'm playing around hybrid images, , wanted use gaussian filter low pass filter image. however, make hybrid images, 2 filters supposed used on 2 images being combined different cut off frequencies.

does fspecial() allow specify cut off frequencies when employ make gaussian filter? (i know can specify filter size , sigma , there relation between sigma , cut off frequency). if can specify cut off frequencies using sigma, sigma need set cut off frequency of 0.2 hz.

i'll first answer regarding 1d , rest follow. may trivial, bare me while. lets assume following code:

t=linspace(0,20,2^10); %time vector in seconds w=0.2; %in hz signal=cos(2*pi*w*t)+rand(1,length(t))-0.5; % signal in seconds dt=t(2)-t(1) ; n=length(signal); df=1/(n*dt);    % frequency resolution (df=1/max_t) if mod(n,2)==0     f_vec= df*((1:n)-1-n/2);  % length vectors else     f_vec= df*((1:n)-0.5-n/2);  end 

so, have created noisy signal of specific frequency. f_vec frequency vector stretches f =[-f_max,-f_max+df,...,0,...,f_max], f_max=1/(2*dt). if design 1d gaussian filter (in fourier space) follows:

f_vec0=0; sigma=1; filter=exp( -(f_vec-f_vec0).^2./(2*sigma^2));  

and filtering in fourier doamin:

f_signal=fftshift(fft(signal)); filt_signal=fftshift(ifft(f_signal.*filter)); 

so, filter applied, sigma=1 means the cut off frequency (that decided 1% of filter's maximum (which 1)) approximately @ 3 hz:

 cutoff_freq=f_vec(find(filter>=0.01,1,'last')) 

taking 2d trivial, careful units. images, there pixels position unit, , 1/pixels spacial frequency. fspecial function generates 2d matrix of predefined filter. usage of fspecial this:

psf = fspecial('gaussian',hsize,sigma); blurred = imfilter(image,psf,'symmetric','conv'); 

using convolution multiplying in fourier domain. sigma in fourier domain proportional 1/sigma of position domain, etc...


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -