Pengolahan Citra Digital Menggunakan Transformasi Wavelet


Perbedaan transformasi fourier dengan transformasi wavelet??

Pada bidang pengolahan sinyal digital, kita dapat menggunakan transformasi Fourier untuk memperoleh informasi berapa besar frekuensi dari sebuah sinyal, tetapi kita tidak dapat mengetahui informasi kapan frekuensi itu terjadi. Transformasi Fourier hanya cocok untuk sinyal stasioner (sinyal yang frekuensinya tidak berubah terhadap waktu). Untuk mengatasi hal tersebut maka kita dapat menggunakan transformasi Wavelet yang mampu merepresentasikan informasi waktu dan frekuensi suatu sinyal dengan baik.

Penerapan transformasi wavelet pada bidang pengolahan citra digital antara lain adalah untuk kompresi, filtering, dan analisis tekstur. Berikut ini merupakan contoh aplikasi pemrograman matlab untuk melakukan transformasi wavelet. Pemrograman meliputi proses transformasi terhadap citra grayscale ke dalam empat buah koefisien yaitu koefisien aproksimasi, koefisien detail vertikal, koefisien detail horizontal, dan koefisien detail diagonal.

1. Dekomposisi citra menggunakan wavelet haar level 1 (ukuran citra menjadi 1/2 kali ukuran semula)

clc; clear; close all;

% membaca citra grayscale
Img = imread('lena_gray_512.tif');

% dekomposisi wavelet haar level 1
[c,s] = wavedec2(Img,2,'haar');
[H1,V1,D1] = detcoef2('all',c,s,1);
A1 = appcoef2(c,s,'haar',1);
V1img = wcodemat(V1,255,'mat',1);
H1img = wcodemat(H1,255,'mat',1);
D1img = wcodemat(D1,255,'mat',1);
A1img = wcodemat(A1,255,'mat',1);

figure;
subplot(2,2,1);
imagesc(A1img);
colormap gray;
title('Approximation Coef. of Level 1');

subplot(2,2,2);
imagesc(H1img);
title('Horizontal detail Coef. of Level 1');

subplot(2,2,3);
imagesc(V1img);
title('Vertical detail Coef. of Level 1');

subplot(2,2,4);
imagesc(D1img);
title('Diagonal detail Coef. of Level 1');

2. Dekomposisi citra menggunakan wavelet haar level 2 (ukuran citra menjadi 1/4 kali ukuran semula)

% dekomposisi wavelet haar level 2
[H2,V2,D2] = detcoef2('all',c,s,2);
A2 = appcoef2(c,s,'haar',2);
V2img = wcodemat(V2,255,'mat',1);
H2img = wcodemat(H2,255,'mat',1);
D2img = wcodemat(D2,255,'mat',1);
A2img = wcodemat(A2,255,'mat',1);

figure;
subplot(2,2,1);
imagesc(A2img);
colormap gray;
title('Approximation Coef. of Level 2');

subplot(2,2,2)
imagesc(H2img);
title('Horizontal detail Coef. of Level 2');

subplot(2,2,3)
imagesc(V2img);
title('Vertical detail Coef. of Level 2');

subplot(2,2,4)
imagesc(D2img);
title('Diagonal detail Coef. of Level 2');

3. Dekomposisi citra menggunakan wavelet daubechies 4 level 1 (ukuran citra menjadi 1/2 kali ukuran semula)

% dekomposisi wavelet daubechies 4 level 1
[c,s] = wavedec2(Img,2,'db4');
[H1,V1,D1] = detcoef2('all',c,s,1);
A1 = appcoef2(c,s,'haar',1);
V1img = wcodemat(V1,255,'mat',1);
H1img = wcodemat(H1,255,'mat',1);
D1img = wcodemat(D1,255,'mat',1);
A1img = wcodemat(A1,255,'mat',1);

figure;
subplot(2,2,1);
imagesc(A1img);
colormap gray;
title('Approximation Coef. of Level 1');

subplot(2,2,2);
imagesc(H1img);
title('Horizontal detail Coef. of Level 1');

subplot(2,2,3);
imagesc(V1img);
title('Vertical detail Coef. of Level 1');

subplot(2,2,4);
imagesc(D1img);
title('Diagonal detail Coef. of Level 1');

4. Dekomposisi citra menggunakan wavelet daubechies 4 level 2 (ukuran citra menjadi 1/4 kali ukuran semula)

% dekomposisi wavelet daubechies 4 level 2
[H2,V2,D2] = detcoef2('all',c,s,2);
A2 = appcoef2(c,s,'db4',2);
V2img = wcodemat(V2,255,'mat',1);
H2img = wcodemat(H2,255,'mat',1);
D2img = wcodemat(D2,255,'mat',1);
A2img = wcodemat(A2,255,'mat',1);

figure;
subplot(2,2,1);
imagesc(A2img);
colormap gray;
title('Approximation Coef. of Level 2');

subplot(2,2,2)
imagesc(H2img);
title('Horizontal detail Coef. of Level 2');

subplot(2,2,3)
imagesc(V2img);
title('Vertical detail Coef. of Level 2');

subplot(2,2,4)
imagesc(D2img);
title('Diagonal detail Coef. of Level 2');

5. Dekomposisi citra menggunakan wavelet Symlets 4 level 1 (ukuran citra menjadi 1/2 kali ukuran semula)

% dekomposisi wavelet Symlets 4 level 1
[c,s] = wavedec2(Img,2,'sym4');
[H1,V1,D1] = detcoef2('all',c,s,1);
A1 = appcoef2(c,s,'haar',1);
V1img = wcodemat(V1,255,'mat',1);
H1img = wcodemat(H1,255,'mat',1);
D1img = wcodemat(D1,255,'mat',1);
A1img = wcodemat(A1,255,'mat',1);

figure;
subplot(2,2,1);
imagesc(A1img);
colormap gray;
title('Approximation Coef. of Level 1');

subplot(2,2,2);
imagesc(H1img);
title('Horizontal detail Coef. of Level 1');

subplot(2,2,3);
imagesc(V1img);
title('Vertical detail Coef. of Level 1');

subplot(2,2,4);
imagesc(D1img);
title('Diagonal detail Coef. of Level 1');

6. Dekomposisi citra menggunakan wavelet Symlets 4 level 2 (ukuran citra menjadi 1/4 kali ukuran semula)

% dekomposisi wavelet Symlets 4 level 2
[H2,V2,D2] = detcoef2('all',c,s,2);
A2 = appcoef2(c,s,'sym4',2);
V2img = wcodemat(V2,255,'mat',1);
H2img = wcodemat(H2,255,'mat',1);
D2img = wcodemat(D2,255,'mat',1);
A2img = wcodemat(A2,255,'mat',1);

figure;
subplot(2,2,1);
imagesc(A2img);
colormap gray;
title('Approximation Coef. of Level 2');

subplot(2,2,2)
imagesc(H2img);
title('Horizontal detail Coef. of Level 2');

subplot(2,2,3)
imagesc(V2img);
title('Vertical detail Coef. of Level 2');

subplot(2,2,4)
imagesc(D2img);
title('Diagonal detail Coef. of Level 2');

Fungsi pengolahan citra digital di atas adalah memperoleh hasil transformasi yang berupa koefisien-koefisien wavelet yaitu koefisien aproksimasi, koefisien detail vertikal, koefisien detail horizontal, dan koefisien detail diagonal. Koefisien-koefisien tersebut dapat digunakan lebih lanjut untuk keperluan ekstraksi ciri, kompresi, dan keperluan-keperluan lainnya.

File source code lengkap beserta citra pada pemrograman di atas dapat diperoleh melalui halaman berikut ini: Source Code

Posted on September 25, 2018, in Pengolahan Citra, Pengolahan Sinyal and tagged , , , , , , , , , , , , , , , , , . Bookmark the permalink. 1 Comment.

  1. Kalau data nya berupa angka gimna Pak Adi ? Yg di contohkan kebanyakan gambar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: