Senin, 13 Agustus 2012

Filtering pada Image menggunakan LPF





clc;
close all;
% Lowpass Filter Design
LowpassFilter = Fspecial('gaussian', [11 11], 1.3);

%  fft of lowpass filter
       LowpassFilterSpectrum = fftshift(fft2(LowpassFilter, intRows, intCols));

% Figure
   figure('Name', 'Lowpass Filter', 'NumberTitle', 'off', 'MenuBar', 'none');
    colormap('gray');
    subplot(1,2,1);
    imagesc(log10(1+abs(LowpassFilterSpectrum)));
    title('Log Magnitude');
    subplot(1,2,2);
    imagesc(angle(LowpassFilterSpectrum));
    title('Phase');
   
 % filtering  
    imgLennaFiltered = LowpassFilterSpectrum .* imgLennaSpectrum;
    figure('Name', 'Lowpass Filtered Image', 'NumberTitle', 'off', 'MenuBar', 'none');
    colormap('gray');
    subplot(2,2,1);
    imagesc(log10(1+abs(imgLennaFiltered)));
    title('Log Magnitude');
    subplot(2,2,2);
    imagesc(angle(imgLennaFiltered));
    title('Phase');

  % Inverse FFT
    subplot(2,2,3);
    imgLennaLowpassFiltered = abs(ifft2(imgLennaFiltered));
    imgLennaLowpassFiltered = circshift(imgLennaLowpassFiltered,[-1.*floor(length(LowpassFilter)/2) -1.*floor(length(LowpassFilter)/2)]);
    imagesc(imgLennaLowpassFiltered);
    title('Inverse FFT of Lowpass Filtered Image');
   
    subplot(2,2,3);
    imagesc(imgLennaPhase);
    title('Phase of FFT of lenna.gif');
   
    subplot(2,2,4);
    imagesc(imgLennaInverseFFT);
    title('Inverse fft');

Tidak ada komentar:

Posting Komentar