Download as pdf or txt
Download as pdf or txt
You are on page 1of 55

Q200-2040 Image Analytics

Basic Image Processing #1

Program Studi S-2 Inovasi Regional


Sekolah Pasca Sarjana Universitas Padjadjaran
Semester Ganjil 2023-2024
Basic Image Processing #1
1. Introduction
2. Pixel Representation
3. Point Processing

Q200-2040 Image Analytics


1. Introduction

Basic Image Processing #1


Apakah Citra Dijital
• An image is an array, or a matrix, of square pixels (picture
elements) arranged in columns and rows.

• A digital image is a representation of a two-dimensional image


as a finite set of digital values, called picture elements or pixels

• A digital image can be considered as a large array of discrete


dots, each of which has a brightness associated with it. These
dots are called picture elements, or more simply pixels.

• We can think of an image as a function, f, from R2 to R: f( x, y )


gives the intensity at position ( x, y )

Q200-2040 Image Analytics


Apakah Pengolahan Citra Dijital

• Pengolahan citra adalah bagian dari pengolahan sinyal


yang difokuskan kepada pengolahan yang berkaitan
dengan gambar-gambar
• Image processing is the science of manipulating a picture
• Tugas utama:
1. Improvement of pictorial information for human interpretation
2. Processing of image data for storage, transmission and
representation for autonomous machine perception

Pengolahan
Citra Orisinal Citra Hasil
Citra

Q200-2040 Image Analytics


Apakah Pengolahan Citra Dijital

• Pengolahan citra adalah bagian dari pengolahan sinyal


yang difokuskan kepada pengolahan yang berkaitan
dengan gambar-gambar
• Image processing is the science of manipulating a picture
• Tugas utama:
1. Improvement of pictorial information for human interpretation
2. Processing of image data for storage, transmission and
representation for autonomous machine perception

Pengolahan
Citra Orisinal Citra Hasil
Citra

Q200-2040 Image Analytics


Bidang yang Berkaitan
Input/output Citra Deskripsi

Citra Pengolahan citra Visi komputer

Deskripsi
Grafika komputer AI

• Grafika komputer : proses penciptaan citra


• Pengolahan citra : proses perbaikan maupun
pemanipulasian lainnya terhadap citra – hasilnya
berupa citra lagi
• Visi komputer : analisis kandungan informasi yang
terdapat pada citra

Q200-2040 Image Analytics


Leveling Pengolahan Citra

Low Level Process Mid Level Process High Level Process


Input: Image Input: Image Input: Attributes
Output: Image Output: Attributes Output: Understanding
Examples: Noise Examples: Simple Examples: Advance
removal, image Object recognition, object recognition,
sharpening measurement, Scene understanding,
segmentation autonomous navigation

Kuliah Image Analytics

Q200-2040 Image Analytics


Jenis-jenis citra dijital
Citra warna

Citra greylevel

Citra biner

Q200-2040 Image Analytics


Jenis Citra Lainnya

Q200-2040 Image Analytics


Jenis Citra Lainnya: Hyperspectral

Q200-2040 Image Analytics


2. Pixel Representation

Basic Image Processing #1


Piksel dan representasinya

Q200-2040 Image Analytics


Warna
• Jumlah Warna = 256 x 256 x
256 = 17.777.216
• Warna Inti (R, G, B)

Q200-2040 Image Analytics


Image Model Secara Umum
n

 I1,1 I1,2 I1,n 


I I 2,n 
m  2,1 I 2,2
 
 
 I m,1 am,2 I m,n 

 r (i, j ) , 0  r (i, j )  255



I i ,i =  b(i, j ) , 0  g (i, j )  255
 g (i, j ), 0  b(i, j )  255

Q200-2040 Image Analytics


Contoh Penerapan Image Model
6

 I1,1 I1,2 I1,6 


I I 2,6 
6  2,1 I 2,2
 
 
 I 6,1 a6,2 I 6,6 

 r (5, 4)

I 5,4 =  b(5, 4)
 g (5, 4)

Q200-2040 Image Analytics


Image Model Setiap Jenis Citra
 r (i, j ) , 0  r (i, j )  255
 Citra Warna
I i ,i =  b(i, j ) , 0  g (i, j )  255
 g (i, j ), 0  b(i, j )  255

 r (i, j ) , 0  r (i, j )  255

I i ,i =  b(i, j ) , 0  g (i, j )  255
 g (i, j ), 0  b(i, j )  255 Citra Greylevel

r (i, j ) = g (i, j ) = b(i, j )

 r (i, j )

I i ,i =  b(i, j )
 g (i, j ) Citra Biner

r (i, j ) = g (i, j ) = b(i, j )
r (i, j ) bernilai 0 atau 255, demikian pula g (i, j ) dan b(i, j )

Q200-2040 Image Analytics


Ukuran, Kuantisasi, dan Sampling
• Ukuran Citra
S = m n q
• Kuantisasi
banyaknya bit yang mewakili sebuah piksel

• Sampling
ukuran resolusi spasial yang digunakan untuk
merepresentasikan citra dijital

Q200-2040 Image Analytics


Ukuran Citra
Citra Warna (RGB)
Level Kuantisasi (Bit)
m n
1 2 3 4 5 6 7 8
32 32 3,072 6,144 9,216 12,288 15,360 18,432 21,504 24,576
64 64 12,288 24,576 36,864 49,152 61,440 73,728 86,016 98,304
128 128 49,152 98,304 147,456 196,608 245,760 294,912 344,064 393,216
256 256 196,608 393,216 589,824 786,432 983,040 1,179,648 1,376,256 1,572,864
512 512 786,432 1,572,864 2,359,296 3,145,728 3,932,160 4,718,592 5,505,024 6,291,456
1024 1024 3,145,728 6,291,456 9,437,184 12,582,912 15,728,640 18,874,368 22,020,096 25,165,824

Citra Graylevel
Level Kuantisasi (Bit)
m n
1 2 3 4 5 6 7 8
32 32 1,024 2,048 3,072 4,096 5,120 6,144 7,168 8,192
64 64 4,096 8,192 12,288 16,384 20,480 24,576 28,672 32,768
128 128 16,384 32,768 49,152 65,536 81,920 98,304 114,688 131,072
256 256 65,536 131,072 196,608 262,144 327,680 393,216 458,752 524,288
512 512 262,144 524,288 786,432 1,048,576 1,310,720 1,572,864 1,835,008 2,097,152
1024 1024 1,048,576 2,097,152 3,145,728 4,194,304 5,242,880 6,291,456 7,340,032 8,388,608

Citra Biner ?

Q200-2040 Image Analytics


Kuantisasi

●●●

8 bit 3 bit 2 bit 1 bit

Q200-2040 Image Analytics


Sampling

●●●

256x256 32x32 16x16 8x8

• Jenis Sampling
– Resampling
– Subsampling

Q200-2040 Image Analytics


Proses Sampling 8x8 menjadi 4x4

Resampling
Subsampling

Q200-2040 Image Analytics


Resampling

Q200-2040 Image Analytics


Subsampling

Q200-2040 Image Analytics


Format Umum Citra Dijital
JPEG
PNG
EPS
GIF
TIFF
PS
PSD

Pada umumnya format citra dijital memanfaatkan


kompresi data sehingga ukuran penyimpanan/ transmisi
citra bisa lebih kecil.

Q200-2040 Image Analytics


Pixel Neighborhood

Q200-2040 Image Analytics


Metode Pemrosesan Piksel
• Point Processing
• Area Processing
• Geometry Processing
• Frame Processing

Q200-2040 Image Analytics


3. Point Processing

Basic Image Processing #1


Point Processing
• Operasi berbasis titik (piksel)
• Bersifat operasi tunggal (titik ke titik)
• Umumnya digunakan untuk image
enhancement

POINT
PROCESSING

Q200-2040 Image Analytics


Metode dalam Point Processing
1. Image Information
2. Brightness
3. Histogram Representation
4. Histogram Equalization
5. Contrast
6. Inverse
7. Graylevel
8. Look-Up Table (LUT)
9. Gamma Correction
10. Thresholding

Q200-2040 Image Analytics


Image Information
• Image Information

Q200-2040 Image Analytics


Brightness
• Contoh

brighter darker
• Formula g (i, j ) = f (i, j )  c
• c is brightnes level, value positive or negative
• if g(i,j) > 255 then g(i,j) = 255 Clamping
• if g(i,j) < 0 then g(i,j) = 0

Q200-2040 Image Analytics


Implementasi Metode
186 191 39 82 10 247 227 286 291 139 182 110 347 327 255 255 139 182 110 255 255

87 239 120 109 0 169 157 187 339 220 209 100 269 257 187 255 220 209 100 255 255

233 122 225 88 8 80 70 333 222 325 188 108 180 170 255 222 255 188 108 180 170

95 217 184 188 2 176 228 100 195 317 284 288 102 276 328 CLAMP 195 255 255 255 102 255 255

209 109 190 188 170 254 53 309 209 290 288 270 354 153 255 209 255 255 255 255 153

125 91 70 152 97 38 120 225 191 170 252 197 138 220 225 191 170 252 197 138 220

239 213 24 171 193 254 210 339 313 124 271 293 354 310 255 255 124 255 255 255 255

186 191 39 82 10 247 227 86 91 -61 -18 -90 147 127 86 91 0 0 0 147 127

87 239 120 109 0 169 157 -13 139 20 9 -100 69 57 0 139 20 9 0 69 57

233 122 225 88 8 80 70 133 22 125 -12 -92 -20 -30 133 22 125 0 0 0 0

95 217 184 188 2 176 228 -100 -5 117 84 88 -98 76 128 CLAMP 0 117 84 88 0 76 128

209 109 190 188 170 254 53 109 9 90 88 70 154 -47 109 9 90 88 70 154 0

125 91 70 152 97 38 120 25 -9 -30 52 -3 -62 20 25 0 0 52 0 0 20

239 213 24 171 193 254 210 139 113 -76 71 93 154 110 139 113 0 71 93 154 110

Q200-2040 Image Analytics


Histogram

• Melihat karakteristik citra


• Contoh

Q200-2040 Image Analytics


Histogram Representation
Image
4 4 3 3
4 4 3 3 6
4 1 2 3 5
0 1 2 3 4

frequency
3
2
1
0
1 2 3 4 5 6 7
Intensity

Q200-2040 Image Analytics


Histogram Processing
• Histogram Equalization
– Hasil proses bergantung kepada kondisi
data/piksel
– Histogram menjadi uniform
– Proses dilakukan secara otomatis
• Histogram Specification
– Histogram yang diinginkan dispesifikasikan

Q200-2040 Image Analytics


Histogram Equalization
sum normalized sum
0 1 0.43
1 3 1.31
2 5 2.18
3 11 4.81
4 16 7.00
5 16 7.00
6 16 7.00
7 16 7.00

Hasil
7 7 5 5
7 7 5 5 6
7 1 2 5 5
0 1 2 5 4
frequency

3
2
1
0
1 2 3 4 5 6 7
Intensity

Q200-2040 Image Analytics


Contoh Nyata Histogram Equalization

Q200-2040 Image Analytics


Contrast
• Distribusi jumlah ‘piksel terang’ dan ‘piksel gelap’.
• jenis kontras
– Low contrast image
– High contrast image
– Good Contrast
• Adjustment value : -100 to 100
• Formula :
https://ie.nitk.ac.in/blog/2020/01/19/algorithms-
for-adjusting-brightness-and-contrast-of-an-image/

Q200-2040 Image Analytics


Contoh Kontras

Q200-2040 Image Analytics


Inverse
• Operasi kebalikan (invert) dari nilai citra
• Formulasi g (i, j ) = 255 − f (i, j )
• Contoh :

Invert

Q200-2040 Image Analytics


Konversi Citra Color ke Greylevel
• Citra warna menjadi citra keabuan

• Metode Paling Sederhana : Averaging


f r (i, j ) + f g (i, j ) + f b (i, j )
g (i, j ) =
3
• Metode Lain
1. Pembobotan
2. Desaturation
3. Decomposition
4. Single Color Channel
5. …
Q200-2040 Image Analytics
Metode Lain
2. Pembobotan g (i, j ) = pr f r (i, j ) + pg f g (i, j ) + pb f b (i, j )
pr pg pb Sebutan
0.3 0.59 0.11 Human Eye Correction
0.2126 0.7152 0.0722 Luma, ITU-R , BT.709
0.299 0.587 0.114 BT.601
Max( R, G, B) + Min( R, G, B)
3. Desaturation Gray =
2
4. Decomposition Gray = Max( R, G, B)

 Gray = Min( R, G, B)
5. Single color Channel Gray = R

Gray = G
Gray = B

Q200-2040 Image Analytics
Contoh

Q200-2040 Image Analytics


LOOK-UP TABLE

Input LUT Output

7 7 5 4 2 0 0 5 5 3 2 1

7 6 4 3 0 1 0

7 6 4 3 1 2 1

6 6 4 2 0 3 1

5 5 3 1 0 4 2

5 3

6 4

7 5

Q200-2040 Image Analytics


Koreksi Gamma

• F adalah citra asli


• G adalah citra hasil proses
• 1/Gamma adalah faktor koreksi antara 0 sd 1

Q200-2040 Image Analytics


Thresholding
• Umumnya proses dilakukan setelah citra
warna dikonversikan ke citra greylevel
• Hasilnya berupa citra biner
• Metode
– Simple Thresholding
– Multilevel/Adaptive Thresholding
– OTSU Thresholding
• Contoh

Q200-2040 Image Analytics


Konsep Thresholding
• One-level

• Multi-level

Q200-2040 Image Analytics


Simple Thresholding
255 if f (i, j )  T
g (i, j ) = 
0 otherwise

T=128

Q200-2040 Image Analytics


Representasi Citra Biner

•Pengolahan Citra Dijital


Q200-2040 Image Analytics
Multilevel / Adaptive Thresholding
• Berikut merupakan langkah-langkah untuk
mendapatkan nilai ambang (Gonzales, 2002):

Ulangi hingga nilai-nilai 𝜇1 dan 𝜇2 tidak berubah lagi

Q200-2040 Image Analytics


OTSU Thresholding
• Nobuyuki Otsu, A Threshold Selection Method from Gray-Level
Histograms, IEEE Transactions on System, Man, and Cybernetics.
SMC-9(1), 1979, Electro-Technical Laboratory, Tokyo
University(2007), Tokyo, Japan

• Algoritma
1. Hitung histogram dan probabilitas untuk setiap tingkat intensitas
2. Tentukan nilai bobot awal (ωi(0)) dan rata-rata (μi(0))
3. Untuk setiap t=1 sampai intensitas maksimum lakukan
1. Perbaharui nilai ωi dan μi
2. Hitung variansi untuk setiap t (σ2b )
4. Nilai optimal threshold adalah nilai minimum dari variansi pada t
5. Kita dapat melakukan perhitungan dual maxima dengan formulasi

(σ2b1 +σ2b2 )/2

Q200-2040 Image Analytics


Latihan
• Diketahui Gambar 1 adalah sebuah citra dijital dengan resolusi
256x256 dengan komposisi 24bpp (bit per pixel), dan Gambar 2
adalah sebuah area (subwindow) dari Gambar 1 pada posisi
{(172,32), (177,37)} yang komposisi elemen RGBnya dapat dilihat
pada pada tabel Elemen Red, Elemen Green dan Elemen Blue.

Q200-2040 Image Analytics


Soal 1

a. Tentukan ukuran (size) citra pada


Gambar 1 dalam satuan kilobyte
b. Tentukan karakteristik citra digital
pada Gambar 2
c. Tentukan kompoisis nilai piksel jika
dilakukan operasi brigthness dengan
nilai c = 100
d. Tentukan komposisi piksel jika Gambar
2 akan dikonversikan ke citra gray level
dengan metode Perataan
e. Tentukan komposisi nilai piksel hasil
point d jika dikonversikan menjadi
citra biner dengan metode Simple
Thresholding dan nilai T=128

Q200-2040 Image Analytics


Soal 2

a. Tentukan ukuran (size) citra pada Gambar


1 dalam satuan kilobyte
b. Tentukan komposisi piksel jika Gambar 2
akan dikonversikan ke citra gray level
dengan metode BT.709.
c. Tentukan Nilai Threshold apabila dilakukan
proses konversi dari graylevel (hasil b) ke
biner menggunakan metode Adaptive
Thresholding.
d. Tentukan nilai elemen RGB Hasil b, tingkat
kuantisasinya diturunkan dari 24bpp
menjadi 3bpp.
e. Tentukan nilai elemen RGB jika Hasil d
ditransformasikan dengan sebuah LUT
dengan komposisi sekuensial sbb: {{0, 1, 1,
3, 4, 5, 5, 7}}
f. Lakukan operasi histogram equalization
terhadap citra Hasil d

Q200-2040 Image Analytics

You might also like