Citra Sesi02 03 Point Operation2
-
Upload
adhieresthenes -
Category
Documents
-
view
42 -
download
3
Transcript of Citra Sesi02 03 Point Operation2
IF-UTAMA 1
IF-UTAMA 1
Point Operation
Dosen Pembina Sriyani Violina
Danang Junaedi
IF-UTAMA 2
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.
• 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.
IF-UTAMA 3
Digital 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 4
General Areas of Image Processing
• 3 general areas of digital image processing
– Point Operations
• Pixel Point Processing
– Local Operations
• Pixel Group Processing
– Global Operations
IF-UTAMA 2
IF-UTAMA 5
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 1 2 3 4 4 6
0 152 120 22 215 34 1 0 117
1 3 114 199 134 88 20 60 199
2 234 72 65 17 145 185 235 181
3 141 214 169 134 85 234 237 68
4 241 154 141 231 145 236 35 27
5 45 95 65 127 123 94 47 166
6 127 98 137 149 67 45 52 29
7 162 81 83 189 69 195 94 171
8 64 123 130 100 58 226 214 34
102 189 174 35 169 203 243 135
213 235 219 137 22 195 168 208
227 103 192 243 102 220 187 21
IF-UTAMA 6
Point Operations / Intensity Transform
input gray level u
ou
tpu
t g
ray
leve
l
v
• 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
Operasi-operasi Dasar Pengolahan CitraOperasi Aljabar : Aritmatika & BooleanOperasi Geometri
Operasi Aljabar
• 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
IF-UTAMA 3
Operasi Aritmatika
• Beberapa operasi aritmatika:
– Penjumlahan
– Pengurangan
– Perkalian
– Pembagian
Untuk citra RGB,
operasi dilakukan per plane
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
• 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
Efek Pengurangan pada CitraEfek 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
IF-UTAMA 4
Operasi Boolean
• Operasi boolean � AND, OR, NOT
• Kombinasinya : NAND, NOR, XOR
Operasi Geometri
• Proses yang memanipulasi posisi spatial dari pixel
• Contoh:
– Zoom (in & out)
– Rotasi
– Flipping
– Cut & paste
– Warping
Zoom
• 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.
Aspect Ratio
• Rasio antara jumlah titik vertikal dan horizontal untuk mendapatkan panjang yang sama di kedua arah tersebut
IF-UTAMA 5
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 out
• Ada informasi pada citra yang harus dihilangkan.
• Salah satu metode sederhana � ambil rata-rata 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 in � reversible
Zoom 2x Zoom 0.5x
IF-UTAMA 6
Zoom out � not reversible
Zoom 0.25x Zoom 4x
Rotasi
Rotate 900
Rotate 900
• Rotasi sederhana: kelipatan 900
– salin pixel-pixel baris ke pixel-pixel kolom sesuai
arah rotasi
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;
}
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 β
IF-UTAMA 7
Rotasi X0 (cont’d)
• Di titik mana sebaiknya sumbu putaran?
• Bagaimana rumus umum mencari ukuran citra yang
dirotasikan X0?
243
254
352
352
Rotasi
450
Flipping
horizontal
vertikal
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;
}
Cut & Paste
• Pemilihan (mulai paling mudah):
– Segiempat
– Bentuk geometri lain: lingkaran, elips, poligon
– Freeform
IF-UTAMA 8
Warping
Warp
• Citra diubah dengan cara mengatur kembali
hubungan spatial antara objek dengan suatu template spatial � menimbulkan efek-efek khusus
Contoh warping
IF-UTAMA 31
Point Operations
• 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
IF-UTAMA 32
Point Operation Process
• 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 9
IF-UTAMA 33
0 1 2 3 4 4 6
0 152 120 22 215 34 1 0 117
1 3 114 199 134 88 20 60 199
2 234 72 65 17 145 185 235 181
3 141 214 169 134 85 234 237 68
4 241 154 141 231 145 236 35 27
5 45 95 65 127 123 94 47 166
6 127 98 137 149 67 45 52 29
7 162 81 83 189 69 195 94 171
8 64 123 130 100 58 226 214 34
102 189 174 35 169 203 243 135
213 235 219 137 22 195 168 208
227 103 192 243 102 220 187 21
0 1 2 3 4 4 6
0 255 180
1
2
3
4
5
6
7
8
Operation
x 1.5
I(x,y)
O(x,y)
Point Operation Process
IF-UTAMA 34
Point Operation Process
The Point Operation process is denoted by:
O(x,y) = M . I(x,y)
where M is the mapping function or operation
IF-UTAMA 35
Point Operations
• 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 36
Gambaran Transformasi Citra
IF-UTAMA 10
IF-UTAMA 37
UM
CP
EN
EE
63
1 S
lide
s (
cre
ate
d b
y M
.Wu
© 2
00
4)
Typical Types of Gray-level Transformation
Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)
IF-UTAMA 38
Transformasi Citra
IF-UTAMA 39
Mengubah Format kuantisasi
IF-UTAMA 40
Konversi RGB ke Gray Scale
IF-UTAMA 11
IF-UTAMA 41
Konversi Gray Scale ke Biner
IF-UTAMA 42
Konversi Gray Scale ke m Bit
IF-UTAMA 43
Pengaturan Brightness
IF-UTAMA 44
Pengaturan Contrast
IF-UTAMA 12
IF-UTAMA 45
Inversi
IF-UTAMA 46
Negative Image
IF-UTAMA 47
Example: Negative Transformation
UM
CP
EN
EE
63
1 S
lide
s (
cre
ate
d b
y M
.Wu
© 2
00
4)
Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)
IF-UTAMA 48
Transformasi Logaritmik
IF-UTAMA 13
IF-UTAMA 49
Contoh
• Tranformasi Logaritmik
• Transformasi Inverse Logaritmik
IF-UTAMA 50
Example: Log Transformation
UM
CP
EN
EE
63
1 S
lide
s (
cre
ate
d b
y M
.Wu
© 2
00
4)
Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)
IF-UTAMA 51
Transformasi Power Law
IF-UTAMA 52
Contoh Hasil Transformasi power Law
IF-UTAMA 14
IF-UTAMA 53
Gamma Characteristics & Gamma Correction
• 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
U
L’
L’ = a Uγ
L
U ~ logL
~ L1/γ
UM
CP
EN
EE
63
1 S
lide
s (
cre
ate
d b
y M
.Wu
© 2
00
1/2
00
4)
IF-UTAMA 54
Example: Effects of Different Gammas
( “vectors” sample image
from Matlab )
L02.2 L0
1/2.2
L0
UM
CP
EN
EE
63
1 S
lide
s (
cre
ate
d b
y M
.Wu
© 2
00
1)
IF-UTAMA 55
UM
CP
EN
EE
63
1 S
lide
s (
cre
ate
d b
y M
.Wu
© 2
00
4)
Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)
IF-UTAMA 56
Look-Up Table (LUT)
• 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 15
IF-UTAMA 57
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 58
Input Operation Output
Value Value
0 x 1.5 0
1 x 1.5 2
2 x 1.5 3
3 x 1.5 5
4 x 1.5 6
5 x 1.5 8
6 x 1.5 9
7 x 1.5 11
8 x 1.5 12
9 x 1.5 14
10 x 1.5 15
11 x 1.5 17
12 x 1.5 18
250 x 1.5 255
251 x 1.5 255
252 x 1.5 255
253 x 1.5 255
254 x 1.5 255
255 x 1.5 255
Note:
Output values are
integers & between
0 and 255
Example of a LUT
IF-UTAMA 59
Referensi
1. Achmad Basuki, Pelatihan Image Processing
dan Aplikasinya, Politeknik Elektronika Negeri Surabaya, 2005
2. Min Wu, Point Operations, ECE Department, Univ. of Maryland, College Park, 2004
3. http://csusap.csu.edu.au/~xzheng/lectures/mis303/MIS303_5.ppt, Tanggal Akses : 29 April 2009