Anda di halaman 1dari 26

Mengolah Citra/Image/Gambar digital

Grafika Komputer

A 1 Piksel = 1 nilai warna/intensitas


1 nilai posisi/koordinat (x,y)
Digital Image Processing

Computer Vision
Catatan :
8 bit warna graysacle = 256 warna, variasi warna
0,1,2,3,......255.

7 bit warna graysacle = 128 warna, variasi warna


0,1,2,3,......127.

Dalam citra tidak ada warna yang melebihi


intensitas/warna 255, sekalipun hasil dari
pengolahan secara matematika.

Representasi warna dalam citra digambarkan dalam


Misal, Subimage citra graysacle A(x,y)
diagram cartesian terbalik.
berukuran 5 x 4 adalah sebagai berikut :

90 80 120 128 80
(1,1 (1,2) (1,3) (1,4) (1,5)
)
100 81 180 80 100
(2,1 (2,2) (2,3) (2,4) (2,5)
)
0 20 40 0 8
(3,1 (3,2) (3,3) (3,4) (3,5)
)
90 180 255 100 80 A(x,y)
(4,1 (4,2) (4,3) (4,4) (4,5)
R=90
) 80 120 128 0
G=10 100 20 20 200
0 0 100 50 80
B=0 (1,2) (1,3 (1,4) (1,5)
(1,1) )

B(x,y)

Buatlah matrik berukuran 5 x 5 sehingga menunjukkan bahwa :


A(x,y) adalah subimage citra graysacle 7 bit.
B(x,y) adalah subimage citra biner.
C(x,y) adalah subimage citra true color.
Pertemuan 3. Peningkatan Kualitas Citra (Image Enhancement)

Contoh: (4,1)
1. Transformasi Citra Warna ke Graysacle Ain(x,y)

R=90 R=30 R=60 R=30 R=10


G=8 G=30 G=50 G=40 G=20 80 30
0 B=30 B=10 B=50 B=30 (1,1) (1,2) (1,3) (1,4) (1,5)
B=70 (1,2) (1,3) (1,4) (1,5) (2,3) (2,4) (2,5)
(1,1) (2,1) (2,2)
R=40 R=30 R=90 R=0 R=125
G=6 G=20 G=70 G=0 G=125 (3,1) (3,2) (3,3) (3,4) (3,5)
0 B=10 B=50 B=0 B=125
B=20 (2,2) (2,3) (2,4) (2,5) (4,1) (4,2) (4,3) (4,4) (4,5)
(2,1) Aout (x,y)
R=80 R=40 R=20 R=60 R=40
G=6 G=50 G=20 G=20 G=20
0 B=30 B=20 B=10 B=30
B=70 (3,2) (3,3) (3,4) (3,5)
(3,1)
R=40 R=10 R=10 R=70 R=50
G=4 G=20 G=10 G=30 G=40
0 B=30 B=40 B=20 B=60
B=40 (4,2) (4,3) (4,4) (4,5)

Penyelesaian :
F out ( 1,1 )=¿ ¿
90+ 80+70
F out ( 1,1 )= = 80
3
2. Transformasi Grayscale ke Biner

30 0 80 120 10
(1,1) (1,2) (1,3) (1,4) (1,5)
20 30 80 20 60
(2,1) (2,2) (2,3) (2,4) (2,5)
90 20 10 40 60
(3,1) (3,2) (3,3) (3,4) (3,5)
90 80 100 60 100
(4,1) (4,2) (4,3) (4,4) (4,5)

B(x,y)
Diketahui :
Fin max = 120
Fin min = 0

Penyelesaian :
T = 120 + 0 = 120 = 60
2 2
Fout (1,1) =
3. Kecerahan (Brightness)

Subimage citra grayscale C(x,y) dilakukan peningkatan kualitas citra menggunakan operasi kecerahan (brightness) dengan konstanta kecerahan = 2. Maka tentukan matrik
citra hasilnya !

30 0 80 120 10
(1,1) (1,2) (1,3) (1,4) (1,5)
20 30 80 20 60 Maka, matrik output citra C(x,y) adalah sbb :
(2,1) (2,2) (2,3) (2,4) (2,5)
90 20 10 40 60
(3,1) (3,2) (3,3) (3,4) (3,5)
90 80 100 60 254
(4,1) (4,2) (4,3) (4,4) (4,5)
C(x,y)

Diketahui :
k=2

Penyelesaiannya :
Fout (1,1)= 30 + 2 = 32
Fout (1,2)= 0 + 2 = 2

Fout (4,5)= 254 + 2 = 256  255


32
(1,1) (1,2) (1,3) (1,4) (1,5)

(2,1) (2,2) (2,3) (2,4) (2,5)

(3,1) (3,2) (3,3) (3,4) (3,5)


255
(4,1) (4,2) (4,3) (4,4) (4,5)
4. Kontras (Contrast)

Contoh :
Subimage citra grayscale D(x,y) dilakukan peningkatan kualitas citra menggunakan operasi kontras. Maka tentukan matrik citra hasilnya !

30 0 80 120 10 Maka, matrik citra hasilnya adalah sbb :


(1,1) (1,2) (1,3) (1,4) (1,5)
20 30 80 20 60 (1,1) (1,2) (1,3) (1,4) (1,5)
(2,1) (2,2) (2,3) (2,4) (2,5)
90 20 10 40 60 (2,1) (2,2) (2,3) (2,4) (2,5)
(3,1) (3,2) (3,3) (3,4) (3,5)
90 80 100 60 254 (3,1) (3,2) (3,3) (3,4) (3,5)
(4,1) (4,2) (4,3) (4,4) (4,5)
D(x,y) (4,1) (4,2) (4,3) (4,4) (4,5)
D(x,y)

Diketahui :
Fmax = 255
Fin max = 254

Penyelesaian :

Fout (1,1) = 30 + (30 ((255-254)/254))=....?


Fout (1,2) = 0 + (0 ((255-254)/254))=0
Fout (1,3) = 80 + (80 ((255-254)/254))=.....
..... dst
5. Invers (Negasi)

Contoh :
Subimage citra grayscale E(x,y) dilakukan operasi invers. Maka tentukan matrik citra hasilnya !

30 0 80 120 10 Maka, matrik citra hasilnya adalah sbb :


(1,1) (1,2) (1,3) (1,4) (1,5)
20 30 80 20 60 (1,1) (1,2) (1,3) (1,4) (1,5)
(2,1) (2,2) (2,3) (2,4) (2,5)
90 20 10 40 60 (2,1) (2,2) (2,3) (2,4) (2,5)
(3,1) (3,2) (3,3) (3,4) (3,5)
90 80 100 60 254 (3,1) (3,2) (3,3) (3,4) (3,5)
(4,1) (4,2) (4,3) (4,4) (4,5)
E(x,y) (4,1) (4,2) (4,3) (4,4) (4,5)
E(x,y)

Diketahui :
Fmax = 255

Penyelesaian :
Fout (1,1)= 255 – 30 = 225
Fout (1,2)= 255 – 0 = 225
Fout (1,3)= 255 – 80 =
Pertemuan 4 :

Filter citra biasanya berukuran 3x3, 5x5, 7x7, 9x9, 11x11.

Teknik menyelesaikan filtering pada citra terdiri dua yaitu :


1. Teknik Zero Padding (Full Processing) = Kita melakukan processing kepada seluruh matrik citra input.
2. Teknik Half Processing = Memberikan nilai tepi matrik (bingkai) tetap untuk citra input dan citra output

1) Filter Maksimum
Penyelesaikan :

a). Teknik Zero Padding

10 15 20 5 4 3 2 1 0 10
6 7 4 3 6 2 7 9 0 3
2 1 5 2 7 9 0 4 7 36
6 5 1 0 5 2 8 5 7 5
9 2 3 6 2 6 9 0 1 4
8 4 7 3 9 7 5 3 1 0
6 3 6 8 0 2 4 6 5 2
2 8 5 3 8 9 0 10 3 6
A(x,y)

0 0 0 0 0 0 0 0 0 0 0 0
0 10 15 20 5 4 3 2 1 0 10 0
(1,1 (1,2) (1,3 (1,4) (1,5 (1,6) (1,7 (1,8) (1,9) (1,10)
) ) ) )
0 6 7 4 3 6 2 7 9 0 3 0
(2,2
)
0 2 1 5 2 7 9 0 4 7 36 0
0 6 5 1 0 5 2 8 5 7 5 0
0 9 2 3 6 2 6 9 0 1 4 0
0 8 4 7 3 9 7 5 3 1 0 0
0 6 3 6 8 0 2 4 6 5 2 0
0 2 8 5 3 8 9 0 10 3 6 0
0 0 0 0 0 0 0 0 0 0 0 0

Fout (1,1)= 0,0,0,0,0,6,7,10,15 = 15


Fout (1,2)= 0,0,0,4,6,7,10,15,20 = 20
Fout (1,3)=0,0,0,3,4,5,7,15,20 = 20

Misal filter yang diminta adalah 5x5, maka analisisnya adalah sbb :
Fout (1,1)=0,0,0,0,0,0,0,0,0,0,1,1,2,2,3,4,5,5,5,6,6,7,10,15,20 = 20
Fout (8,10)=0,0,0,0,0,2,3,5,6
Maka, Citra Hasilnya adalah sbb :
15 20 20
(1,1 (1,2 (1,3
) ) )

2. Teknik Half Processing


Citra input :
10 15 20 5 4 3 2 1 0 10
6 7 4 3 6 2 7 9 0 3
2 1 5 2 7 9 0 4 7 36
6 5 1 0 5 2 8 5 7 5
9 2 3 6 2 6 9 0 1 4
8 4 7 3 9 7 5 3 1 0
6 3 6 8 0 2 4 6 5 2
2 8 5 3 8 9 0 10 3 6
A(x,y)
Penyelesaian :
Fout (2,2) = 1,2,4,5,6,7,10,15,20 = 20

Maka, citra hasilnya adalah sbb :


10 15 20 5 4 3 2 1 0 10
6 20 3
(2,2)
2 36
6 5
9 4
8 0
6 2
2 8 5 3 8 9 0 10 3 6
Korelasi

Penyelesaian :
1. Teknik Zero Padding

0 0 0 0 0 0 0 0 0 0 0 0
0 5 3 3 0 4 4 0 5 2 2 0
0 4 2 1 3 4 0 5 1 3 3 0
0 6 3 0 1 6 2 3 0 7 0 0
0 7 4 0 1 2 3 2 0 7 0 0
0 7 4 5 1 0 6 3 2 7 0 0
0 7 4 5 5 7 7 6 2 6 4 0
0 6 0 1 4 7 0 7 2 0 2 0
0 6 5 1 3 2 4 4 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
A(x,y)
Fout (1,1)= ( 1 x 0) + ( 0 x 0) + ( 1 x 0) +
( 0 x 0) + ( 2 x 5) + ( 0 x 3) +
(-1 x 0) + ( 0 x 4) + (-2 x 2)
= 10 – 4 = 6
Fout (1,2)= ( 1 x 0) + ( 0 x 0) + ( 1 x 0) +
( 0 x 5) + ( 2 x 3) + ( 0 x 3) +
(-1 x 4) + ( 0 x 2) + (-2 x 1)
= 6 -4 -2 = 0

Maka, matrik citra output adalah sbb :


6 0

2. Teknik Half Processing


Citra Input :

5 3 3 0 4 4 0 5 2 2
4 2 1 3 4 0 5 1 3 3
6 3 0 1 6 2 3 0 7 0
7 4 0 1 2 3 2 0 7 0
7 4 5 1 0 6 3 2 7 0
7 4 5 5 7 7 6 2 6 4
6 0 1 4 7 0 7 2 0 2
6 5 1 3 2 4 4 1 0 0
A(x,y)
Penyelesaian :
Fout (2,2)= ( 1 x 5) + ( 0 x 3) + ( 1 x 3) +
( 0 x 4) + ( 2 x 2) + ( 0 x 1) +
(-1 x 6) + ( 0 x 3) + (-2 x 0)
= 5 +3 +4 - 6 = 6
Maka, matrik citra output :
5 3 3 0 4 4 0 5 2 2
(1,1
)
4 6 3
(2,1 (2,2
) )
6 0
7 0
7 0
7 4
6 2
6 5 1 3 2 4 4 1 0 0
Pertemuan 5
1) Penajaman Citra

g(x,y)
Contoh Soal !
Subimage grayscale A(x,y) dilakukan segementasi citra dengan menggunakan filter Laplacian dengan derajat penajaman adalah 2. Maka
tentukan matrik citra hasilnya !

10 6 8 5 2 Diketahui :
2 1 3 8 1 α =2
0 2 4 5 1 0 -2 0
10 2 8 5 2 -2 9 -2
5 5 6 8 9 0 -2 0
A(x,y) g(x,y)

Maka, matrik citra hasilnya adalah sbb :


10 6 8 5 2
2 0 0 44 1
0 4 0 9 1
10 0 38 0 2
5 5 6 8 9

Penyelesaian :
Fout(2,2) = ( 0 x 10) + (-2 x 6 ) + ( 0 x 8 ) + Fout(2,3) = ( 0 x 6 ) + (-2 x 8) + ( 0 x 5) +
(-2 x 2 ) + ( 9 x 1 ) + (-2 x 3 ) + (-2 x 1) + ( 9 x 3) + (-2 x 8) +
( 0 x 0 ) + ( -2 x 2 ) + ( 0 x 4 ) ( 0 x 2) + (-2 x 4) + ( 0 x 5)
= -12 – 4 + 9 -6 -4 = 0 = -16-2+27-16-8 = 0
Latihan !
Subimage grayscale A(x,y) dilakukan peningkatan kualitas citra dengan menggunakan filter emboss dari arah kiri dan emboss dari arah kanan
atas dengan derajat emboss adalah 2. Maka tentukan matrik untuk masing-masing citra hasilnya !

10 6 8 5 2
2 1 3 8 1
0 2 4 5 1
10 2 8 5 2
5 5 6 8 9
A(x,y)
Pertemuan 6 :
Contoh Soal !
Subimage citra grayscale A(x,y) dilakukan pencerminan berdasarkan sumbu y, maka tentukan matrik citra hasilnya !
10 5 6 8 2
4 5 6 1 2
0 6 7 8 5
5 1 2 4 2
9 6 9 5 3
A(x,y)
Diketahui :
W=5

Penyelesain :
Fout(1,1) => x1’=5-1+1=5 =>(5,1) Fout(2,1) => x2’=5-2+1=5 =>(4,1) Fout(3,1) => x3’=5-3+1=5 =>(3,1)
Fout(1,2) => x1’=5-1+1=5 =>(5,2) Fout(2,2) => x2’=5-2+1=5 =>(4,2) Fout(3,2) => x3’=5-3+1=5 =>(3,2)
Fout(1,3) => x1’=5-1+1=5 =>(5,3) Fout(2,3) => x2’=5-2+1=5 =>(4,3) Fout(3,3) => x3’=5-3+1=5 =>(3,3)
Fout(1,4) => x1’=5-1+1=5 =>(5,4) Fout(2,4) => x2’=5-2+1=5 =>(4,4) Fout(3,4) => x3’=5-3+1=5 =>(3,4)
Fout(1,5) => x1’=5-1+1=5 =>(5,5) Fout(2,5) => x2’=5-2+1=5 =>(4,5) Fout(3,5) => x3’=5-3+1=5 =>(3,5)

Fout(4,1) => x4’=5-4+1=5 =>(3,1) Fout(5,1) => x3’=5-3+1=5 =>(3,1)


Fout(4,2) => x4’=5-4+1=5 =>(3,2) Fout(5,2) => x3’=5-3+1=5 =>(3,2)
Fout(4,3) => x4’=5-4+1=5 =>(3,3) Fout(5,3) => x3’=5-3+1=5 =>(3,3)
Fout(4,4) => x4’=5-4+1=5 =>(3,4) Fout(5,4) => x3’=5-3+1=5 =>(3,4)
Fout(4,5) => x4’=5-4+1=5 =>(3,5) Fout(5,5) => x3’=5-3+1=5 =>(3,5)
Penskalaan
Kv = 2 dan Kh =2=> zoom in
10 5 6 8 2
4 5 6 1 2
0 6 7 8 5
5 1 2 4 2
9 6 9 5 3
Ain(x,y)
Penyelesaian :
Vertikal
10 5 6 8 2
10 5 6 8 2
4 5 6 1 2
4 5 6 1 2
0 6 7 8 5
0 6 7 8 5
5 1 2 4 2
5 1 2 4 2
9 6 9 5 3
9 6 9 5 3
Aout(x,y)
Hasil kombinasi sbb :
10 10 5 5 6 6 8 8 2 2
10 10 5 5 6 6 8 8 2 2
4 4 5 5 6 6 1 1 2 2
4 4 5 5 6 6 1 1 2 2
0 0 6 6 7 7 8 8 5 5
0 0 6 6 7 7 8 8 5 5
5 5 1 1 2 2 4 4 2 2
5 5 1 1 2 2 4 4 2 2
9 9 6 6 9 9 5 5 3 3
9 9 6 6 9 9 5 5 3 3

Horizontal :
10 10 5 5 6 6 8 8 2 2
4 4 5 5 6 6 1 1 2 2
0 0 6 6 7 7 8 8 5 5
5 5 1 1 2 2 4 4 2 2
9 9 6 6 9 9 5 5 3 3
Interpolasi :
Kh=2 (Interpolasi)
1 3 5 7 9
3 3 3 9 11
5 3 5 7 9
7 5 5 5 7
9 7 9 11 11

1 2 3 4 5 6 7 8 9 9
3 3 3 3 3 6 9 10 11 11
5 4 3 4 5 6 7 8 9 9
7 6 5 5 5 5 5 6 7 7
9 8 7 8 9 10 11 11 11 11

Transponse :

1 3 5 7 9
3 3 3 9 11
5 3 5 7 9
7 5 5 5 7
9 7 9 11 11
Aout (x,y)
Maka, matriks hasilnya adalah sbb :
Pertemuan 7 :
1) Image Blending
Contoh :
Subimage citra grayscale masing-masing adalah A(x,y) dan B(x,y) akan dilakukan penjumlahan citra dengan bobot citra A adalah 0,3. Maka
tentukan matrik citra hasilnya !
10 100 40 0 30 10 50 30 80 10
60 50 50 20 40 30 30 20 70 20
40 30 30 20 20 10 20 80 50 30
50 20 20 10 10 20 10 90 40 20
30 10 0 50 0 0 10 100 30 90
A(x,y) B(x,y)

Penyelesaian :
Diketahui : WA= 0,3, maka WB = 1-0,3 =0,7

Fout(1,1) = (0,3 * 10)+(0,7 * 10) = 3 + 7 = 10


Fout(1,2) = (0,3 * 100)+(0,7 * 50) = 30 + 35 = 65
Fout(1,3) = (0,3 * 40)+(0,7 * 30) = 12 + 21 = 33
...... dst
2)
2) Pengurangan Citra (Deteksi Gerak Objek)
Contoh :
Subimage citra grayscale masing-masing adalah A(x,y) dan B(x,y) berurutan diambil pada pukul 02.50 WIB dan 02.40 WIB. Maka tentukan
hasil analisis gerak objek pada citra tersebut

10 100 40 0 30 0
60 50 50 20 40 60 60 50 20 40
40 30 30 20 20 40 30 30 20 20
50 20 20 10 10 50 20 10 10 10
30 10 0 50 0 30 10 10 50 0
A(x,y) B(x,y)

10 100 40 0 30
Penyelesaian :

Penyelesaian :
3. Operasi Bolean

Contoh :

1 1 0 0 1 0 1 1 1 0
0 1 1 0 0 1 1 0 1 0
0 0 1 1 0 0 1 1 1 1
1 1 0 1 0 0 1 0 1 1
0 1 1 1 0 1 0 1 1 1
A(x,y) B(x,y)

1. emily -> ANd


2. Novia Chandra -> OR
3. Iva ->XOR
4. Mustika ->notA And A

Anda mungkin juga menyukai