1 of 30

PERTEMUAN KE 9 – KOMPRESI CITRA

PENGOLAHAN CITRA

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

2 of 30

R

P

S

METODE HUFFMAN

01

METODE RLE

02

METODE LAINNYA

03

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

3 of 30

DEFINISI HUFFMAN

01

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

4 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

Metode Huffman atau Huffman Coding adalah teknik kompresi lossless (tanpa kehilangan data) yang digunakan untuk mengkodekan data dengan panjang kode yang berbeda tergantung pada frekuensi kemunculan simbol.

Metode ini ditemukan oleh David A. Huffman (1952)

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

5 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

Prinsip Dasar Metode Huffman :

Memberikan kode biner dengan panjang berbeda untuk setiap simbol, berdasarkan frekuensi kemunculannya.

➡️ Simbol yang sering muncul → kode pendek

➡️ Simbol yang jarang muncul → kode panjang

👉 Tujuannya: memperkecil total jumlah bit untuk mewakili data, tanpa kehilangan informasi (lossless).

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

6 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

Langkah-langkah

  • Kelompokkan karakter dan hitung jumlah karakternya
  • Urutkan karakter tersebut berdasar jumlah karakter terbanyak ke tersedikit. Karakter dan jumlah ini kemudian kita sebut sebagai pasangan node dan nilai.
  • Gabungkan dua node terkecil menjadi satu node baru. Nilai node = node 1 + node 2
  • Ulangi langkah 2 dan 3 hingga hanya terdapat 1 node
  • Buat pohon binary (pohon Huffman), kemudian beri label. Label 0 untuk cabang kiri dan 1 untuk cabang kanan.
  • Susun kode Huffman
  • Encode karakter

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

7 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

Berikut adalah contoh implemenasi metode Huffman pada teks, agar lebih mudah dipahami

Misal :

Saya mempunyai sebuah kalimat

“NAMA SAYA ANDRI”

Jika disimpan dalam kode ASCII (8 bit),

maka kalimat tersebut membutuhkan :

15 (karakter) x 8 (bit) = 90 bit data

Bagaimana jika diencode menggunakan

Metode Huffman ?

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

8 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

1. Kelompokkan karakter dan hitung jumlah karakternya

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

9 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

2. Urutkan berdasar jumlah karakaternya dari yang terbesar

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

10 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

3. Gabungkan 2 node terkecil menjadi 1 node baru

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

11 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

3. Gabungkan 2 node terkecil menjadi 1 node baru

Lakukan terus sampai hanya tersisa 1 node

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

12 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

3. Gabungkan 2 node terkecil menjadi 1 node baru

Lakukan terus sampai hanya tersisa 1 node

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

13 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

4. Buat Pohon Binary

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

14 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

5. Susun Kode Huffman

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

15 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

6. Encode Kalimat

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

16 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

7. Berapa jumlah bit yang dibutuhkan sekarang ?

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

17 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

7. Berapa jumlah bit yang dibutuhkan sekarang ?

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

18 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

Bagaimana jika yang

dimampatkan adalah Citra ?

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

19 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE HUFFMAN

Tugas :

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

20 of 30

METOE RLE

02

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

21 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE RLE

Metode Run-Length Encoding

adalah metode kompresi yang sangat sederhana, yaitu dengan mengelompokkan nilai-nilai yang sama di satu deret (run-length)

Metode ini cocok digunakan untuk pemampatan yang memiliki kesamaan nilai yang cukup tinggi, sehingga lebih cocok untuk kompresi citra terutama citra non RGB, daripada kompresi text.

Metode ini merupakan salah satu Metode Loseless,�dimana tidak ada data yang hilang sama sekali

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

22 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE RLE

Langkah-Langkah Metode RLE

Pemampatan citra dilakukan dengan membuat

rangkaian pasangan nilai (p, q)

untuk setiap baris pixel,

nilai pertama (p) menyatakan derajat keabuan,

nilai kedua (q) menyatakan jumlah pixel berurutan

yang memiliki derajat keabuan (dinamakan run length).

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

23 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE RLE

Contoh Soal :

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

24 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE RLE

1. Pecah citra, menjadi row per row

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

25 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE RLE

2. Buat pasangan Run-Length untuk setiap barisnya

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

26 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE RLE

2. Buat pasangan Run-Length untuk setiap barisnya��disederhanakan menjadi berikut!

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

27 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE RLE

3. Hitung ukuran citra hasil encoding

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

28 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE RLE

4. Hitung Nisbah Pemampatan

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

29 of 30

  • Input the text content you want according to the content you need, and input the text and other information.Input the text content you want according to the content you need, and input the text and other information.

  • Input the text content you want according to the content you need, and input the text and other information.

20NN

METODE RLE

Tugas :

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

30 of 30

Tim Penyusun:

1.

2.

3

TERIMA

KASIH

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA

PROGRAM STUDI INFORMATIKA

UNIVERSITAS GUNADARMA