Review • Data image dinyatakan sebagai matrik dengan ukuran matrik adalah resolusi (ukuran image) dan nilai tiap elemennya adalah nilai warna dari setiap pixel pada image tersebut.
Point Operation Dosen Pembina Sriyani Violina Danang Junaedi
IF-UTAMA
• Kuantisasi pada image adalah banyaknya level warna yang digunakan untuk menyatakan dari warna yang paling gelap (hitam) sampai warna yang paling terang sesuai satuan atau format warna yang digunakan.
1
Digital Image Processing
IF-UTAMA
2
General Areas of Image Processing
• Function of Image Processing: to change – perceived / viewed image contrast – perceived / viewed image colour – perceived spatial information – reduce image noise – change viewing conditions – segmentation / pattern recognition
IF-UTAMA
IF-UTAMA
• 3 general areas of digital image processing – Point Operations • Pixel Point Processing – Local Operations • Pixel Group Processing – Global Operations
3
IF-UTAMA
4
1
Basics of Digital Images (review)
•
• Digital images are a 2D array of values in rows and columns given by I(x,y) (or some by I(c,r)) 0 152 3 234 141 241 45 127 162 64 102 213 227
1 120 114 72 214 154 95 98 81 123 189 235 103
2 22 199 65 169 141 65 137 83 130 174 219 192
3 215 134 17 134 231 127 149 189 100 35 137 243
4 34 88 145 85 145 123 67 69 58 169 22 102
4 1 20 185 234 236 94 45 195 226 203 195 220
6 0 60 235 237 35 47 52 94 214 243 168 187
117 199 181 68 27 166 29 171 34 135 208 21
•
•
Basic idea – “Zero memory” operation • each output only depend on the input intensity at the point – Map a given gray or color level u to a new level v, i.e. v = f ( u ) – Doesn’t bring in new info. – But can improve visual appearance or make features easier to detect Example-1: Color coordinate transformations – RGB of each pixel luminance + chrominance components etc. Example-2: Scalar quantization – quantize pixel luminance/color with fewer bits v output gray level
0 1 2 3 4 5 6 7 8
Point Operations / Intensity Transform
input gray level IF-UTAMA
5
IF-UTAMA
u 6
Operasi Aljabar
Operasi-operasi Dasar Pengolahan Citra Operasi Aljabar : Aritmatika & Boolean Operasi Geometri
IF-UTAMA
• X opr Y = Z – X: citra – Y: citra atau besaran skalar – Z: citra • Level komputasi: – Berbasis titik (pointwise): dilakukan antara tiap elemen X dan Y – Berbasis matriks: melibatkan matriks ketetanggaan
2
Operasi Aritmatika • Beberapa operasi aritmatika: – Penjumlahan – Pengurangan – Perkalian – Pembagian
Efek Penjumlahan pada Citra • Y citra: – Z adalah jumlah nilai brightness dari tiap pixel pada X dan Y • Y besaran skalar: – Z adalah versi yang lebih terang dari citra X – nilai kenaikan brightness sama dengan Y
Untuk citra RGB, operasi dilakukan per plane
Efek Pengurangan pada Citra • Y citra: – Z adalah perbedaan nilai brightness antar X dan Y • Y besaran skalar: – Z adalah versi yang lebih gelap daripada X – nilai penurunan brightness sama dengan Y
IF-UTAMA
Efek Perkalian & Pembagian pada Citra • Perkalian – Y citra: • Z adalah hasil product antara nilai brightness citra X dan Y – Y besaran skalar: • nilai brightness Z proporsional terhadap X pada nilai Y • Pembagian – Y citra: • Z adalah nilai skala brightness pada tiap pixel di X terhadap tiap pixel di Y – Y besaran skalar: • nilai brightness Z akan proportional terbalik terhadap X dengan nilai Y
3
Operasi Boolean • Operasi boolean AND, OR, NOT • Kombinasinya : NAND, NOR, XOR
IF-UTAMA
Operasi Geometri • Proses yang memanipulasi posisi spatial dari pixel • Contoh: – Zoom (in & out) – Rotasi – Flipping – Cut & paste – Warping
Zoom
Aspect Ratio
• Proses-proses yang melibatkan penaikan atau penurunan ukuran citra • Teknik yang paling sederhana dalam zooming menduplikasikan nilai pixel pada arah X atau Y. • Jika citra tidak di zoom dengan nilai yang sama, maka “aspect ratio” dari citra akan berubah.
• Rasio antara jumlah titik vertikal dan horizontal untuk mendapatkan panjang yang sama di kedua arah tersebut
4
Zoom in • Resolusi tidak bertambah • Perubahan pada besar pixelnya – titik kecil dapat terlihat lebih besar Zoom 3x AR = 1
Zoom 3x AR ≠ 1
Contoh algoritma zoom 2x, AR = 1 int i,j,m,n; m=0; n=0; for (i=0;i<=jmlbaris-1;i++) { for(j=0;j<=jmlkolom-1;j++) { Z[m,n] = X[i,j]; Z[m,n+1] = X[i,j]; Z[m+1,n] = X[i,j]; Z[m+1,n+1] = X[i,j]; n=n+2; } m=m+2; n=0; }
Zoom in reversible
Zoom out • Ada informasi pada citra yang harus dihilangkan. • Salah satu metode sederhana ambil ratarata dari n pixel bertetangga pada X sebagai nilai dari satu pixel pada Z – Contoh: hasil rata-ratanya 4 pixel pada X menjadi 1 pixel pada Z Zoom 2x
IF-UTAMA
Zoom 0.5x
5
Zoom out not reversible
Rotasi • Rotasi sederhana: kelipatan 900 – salin pixel-pixel baris ke pixel-pixel kolom sesuai arah rotasi
Zoom 0.25x
Zoom 4x
Rotate 900
Rotate 900
Algoritma rotasi 900 int i,j,k; k=jmlkolom-1; for (i=0;i<=jmlbaris-1;i++) { for(j=0;j<=jmlkolom-1;j++) { Z[j,k] = X[i,j]; } k=k-1; }
IF-UTAMA
Rotasi β0
Titik (a,b) (c,d), dimana : a = r.cos α b = r.sin α c = r.cos(α+β) = r.cos α.cos β–r.sin α.sin β = a.cos β – b.sin β d = r.sin(α+β) = r.sin α.cos β+r.cos α.sin β = b.cos β + a.sin β
6
Flipping
Rotasi X0 (cont’d)
horizontal
254
352 Rotasi 450 243 352
vertikal
• Di titik mana sebaiknya sumbu putaran? • Bagaimana rumus umum mencari ukuran citra yang dirotasikan X0?
Algoritma flipping vertikal int i,j,k; k=jmlbaris-1; for (i=0;i<=jmlbaris-1;i++) { for(j=0;j<=jmlkolom-1;j++) { Z[k,j] = X[i,j]; } k=k-1; }
IF-UTAMA
Cut & Paste • Pemilihan (mulai paling mudah): – Segiempat – Bentuk geometri lain: lingkaran, elips, poligon – Freeform
7
Warping
Contoh warping
• Citra diubah dengan cara mengatur kembali hubungan spatial antara objek dengan suatu template spatial menimbulkan efek-efek khusus Warp
Point Operations
Point Operation Process
• Point Operations are primarily used to change the perceived or viewed optical densities or colours and the perceived or viewed image contrast • A point operation operates on individual pixels and does not take into account any neighbouring pixel values • The same operation occurs on all of the pixels in the image
• The process of the Point Operation is, starting at the top left of the image, to calculate the new (output) pixel value and place this at the same spatial location in a new (output) matrix of the same dimension as the original image. • The process then moves to the pixel to the right and perform the operation until all pixels in the row have an output. • The process then moves to the next row and continues until the entire image has an output.
IF-UTAMA
IF-UTAMA
31
IF-UTAMA
32
8
Point Operation Process
Point Operation Process
I(x,y) 0 1 2 3 4 5 6 7 8
0 152 3 234 141 241 45 127 162 64 102 213 227
1 120 114 72 214 154 95 98 81 123 189 235 103
2 22 199 65 169 141 65 137 83 130 174 219 192
3 215 134 17 134 231 127 149 189 100 35 137 243
4 34 88 145 85 145 123 67 69 58 169 22 102
4 1 20 185 234 236 94 45 195 226 203 195 220
6 0 60 235 237 35 47 52 94 214 243 168 187
117 199 181 68 27 166 29 171 34 135 208 21
The Point Operation process is denoted by: O(x,y) = M . I(x,y) where M is the mapping function or operation
Operation x 1.5
O(x,y) 0 1 0 255 180 1 2 3 4 5 6 7 8
2
3
IF-UTAMA
4
4
6
33
Point Operations
IF-UTAMA
34
Gambaran Transformasi Citra
• The output of a point operations can be: – a new image • the new image O(x,y) will be the same size, rows and columns, and have the same bit depth, as the original image I(x,y) – the displaying on stored image • displayed contrast or brightness may or may not be altered compared to the original image values • LUTs will typically be used to do this operation (some discussion earlier)
IF-UTAMA
IF-UTAMA
35
IF-UTAMA
36
9
Typical Types of Gray-level Transformation UMCP ENEE631 Slides (created by M.Wu © 2004)
Transformasi Citra
Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)
IF-UTAMA
37
Mengubah Format kuantisasi
IF-UTAMA
IF-UTAMA
IF-UTAMA
38
Konversi RGB ke Gray Scale
39
IF-UTAMA
40
10
Konversi Gray Scale ke Biner
IF-UTAMA
Konversi Gray Scale ke m Bit
41
Pengaturan Brightness
IF-UTAMA
IF-UTAMA
IF-UTAMA
42
Pengaturan Contrast
43
IF-UTAMA
44
11
Inversi
IF-UTAMA
Negative Image
45
IF-UTAMA
46
Transformasi Logaritmik
UMCP ENEE631 Slides (created by M.Wu © 2004)
Example: Negative Transformation
Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)
IF-UTAMA
IF-UTAMA
47
IF-UTAMA
48
12
Contoh
Example: Log Transformation UMCP ENEE631 Slides (created by M.Wu © 2004)
• Tranformasi Logaritmik
• Transformasi Inverse Logaritmik
IF-UTAMA
49
Transformasi Power Law
IF-UTAMA
IF-UTAMA
Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)
IF-UTAMA
50
Contoh Hasil Transformasi power Law
51
IF-UTAMA
52
13
• Non-linearity in CRT display – Voltage U vs. Displayed luminance L’ γ • L’ ~ U where γ = 2.0 ~ 2.5 • Use preprocessing to compensate γdistortion – U ~ L 1/ γ – log(L) gives similar compensation curve to γ-correction • good for many practical applications – Camera may have L1/γc capturing distortion with γc = 1.0-1.7 • Power-law transformations are also useful for general purpose contrast manipulation IF-UTAMA
Example: Effects of Different Gammas L0
L’ L’ = a U
γ
UMCP ENEE631 Slides (created by M.Wu © 2001)
UMCP ENEE631 Slides (created by M.Wu © 2001/2004)
Gamma Characteristics & Gamma Correction
U U
~ logL ~L
1/γ
L
53
( “vectors” sample image from Matlab )
L01/2.2
L02.2
IF-UTAMA
54
Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)
Look-Up Table (LUT) UMCP ENEE631 Slides (created by M.Wu © 2004)
• The LUT is a point operation that can have any mathematical calculation as its basis. • Used for both display of the image and for creation of a new stored image • LUTs are still constrained by the bit depth of the image ie, clipping and the output value must be an integer • LUT’s are used to improve performance of the operation.
IF-UTAMA
IF-UTAMA
55
IF-UTAMA
56
14
Input Value 0 1 2 3 4 5 6 7 8 9 10 11 12
Look-Up Table (LUT) • Each operation is performed on each possible value within the image ie. in an 8 bit depth image, on the values 0, 1, 2, ………, 255. • If the image has a spatial resolution of 1000 rows and columns, then the operation, without the use of LUT’s, would have to be performed 1,000,000 times, rather than 256 times • With LUT’s, values still need to be “looked-up” but overall operation performance is improved.
IF-UTAMA
57
250 251 252 253 254 255
Operation Output Value x 1.5 0 x 1.5 2 x 1.5 3 x 1.5 5 x 1.5 6 x 1.5 8 x 1.5 9 x 1.5 11 x 1.5 12 x 1.5 14 x 1.5 15 x 1.5 17 x 1.5 18
x x x x x x
1.5 1.5 1.5 1.5 1.5 1.5
255 255 255 255 255 255
Example of a LUT
Note: Output values are integers & between 0 and 255
IF-UTAMA
58
Referensi 1.
2. 3.
Achmad Basuki, Pelatihan Image Processing dan Aplikasinya, Politeknik Elektronika Negeri Surabaya, 2005 Min Wu, Point Operations, ECE Department, Univ. of Maryland, College Park, 2004 http://csusap.csu.edu.au/~xzheng/lectures/mis 303/MIS303_5.ppt, Tanggal Akses : 29 April 2009
IF-UTAMA
IF-UTAMA
59
15