Be Sociable, Share!

 Algorithm For Implementing Gaussian High Pass:

  •  This is Matlab code to implement Gaussian High pass filter previous i posted about Low pass filter.
  • Gaussian High Pass filter is used sharpening of an image which is inverse of smoothing.
  • First image is read and then it’s shown as a figure just below in screen shots.
  • Calculate size of image.
  • Shift time domain of image into fourier or frequency domain by this command fft2(input-image).
  • Shift the origin of this transform into Center by this command fftshift(f_transform).
  • And then apply the equation of High pass filter that is 1 – exp(-(distance)^2/(2*(d0^2))) or 1 – lowPass.
  • After taking transform again shift and convert the image back into the time domain this is done my taking inverse fourier by this command ifftshift();
  • abs function is used to convert the negative values into the postive values.

Matlab Code :

function GaussianHighpass
a=imread(‘cameraman.tif’);
figure(1)
imshow(a)
[m n]=size(a);
f_transform=fft2(a);
f_shift=fftshift(f_transform);
p=m/2;
q=n/2;
d0=70;
for i=1:m
for j=1:n
distance=sqrt((i-p)^2+(j-q)^2);
low_filter(i,j)=1-exp(-(distance)^2/(2*(d0^2)));
end
end
filter_apply=f_shift.*low_filter;
image_orignal=ifftshift(filter_apply);
image_filter_apply=abs(ifft2(image_orignal));
figure(2)
imshow(image_filter_apply,[])

 

Input image :

Input image

Output Image (Sharpening):

 

sharp

Be Sociable, Share!