Senin, 13 Agustus 2012

Filtering pada Image menggunakan HPF





clc;
close all;
 
   % High Pass Filter Design
  
    % a)
    HighpassFilter = Fspecial('laplacian');
   
    % b) fft of highpass filter
    HighpassFilterSpectrum = fftshift(fft2(HighpassFilter,intRows,intCols));
   
    % c)    figure('Name', 'Highpass Filter', 'NumberTitle', 'off', 'MenuBar', 'none');
    colormap(gray);
    subplot(1,2,1);
    imagesc(log10(1+abs(HighpassFilterSpectrum)));
    title('Log Magnitude');
    subplot(1,2,2);
    imagesc(angle(HighpassFilterSpectrum));
    title('Phase');
   
    % d) Filtering
    imgLennaFiltered = HighpassFilterSpectrum .* imgLennaSpectrum;
    figure('Name', 'Highpass 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');
   
    % e) Inverse FFT
    subplot(2,2,3);
    imgLennaHighpassFiltered = abs(ifft2(imgLennaFiltered));
    imgLennaHighpassFiltered = circshift(imgLennaHighpassFiltered,[-1.*floor(length(HighpassFilter)/2) -1.*floor(length(HighpassFilter)/2)]);
    imagesc(imgLennaHighpassFiltered);
    title('Inverse FFT of Highpass Filtered Image');

Tidak ada komentar:

Posting Komentar