3.2.5 Pseudocode Midpoint Filter
Secara sederhana filter midpoint bertujuan untuk menghitung titik tengah antara nilai maksimum dan nilai minimum dalam daerah citra yang diliputi oleh filter.
Berikut ini merupakan pseudocode program midpoint filter.
Pada pseudocode program midpoint filter, pertama nilai pixel citra diambil dari layer R , B atau G, dari kernel 3x3 selanjutnya dilakukan pengurutan secara
ascending dan diambil nilai mediannya kemudian di-replace pada posisi pusat kernel 3x3 tersebut. Demikian seterusnya berulang-ulang sampai pada lebar dan tinggi citra
yang dapat dicakup filter
int temp,temp2 int x,y
for j := 1 to y – 1 do for I := 1 to x – 1 do
temp2[0, 0]
pixel of image i - 1, j - 1 temp[0]
temp2[0, 0] temp2[1, 0]
pixel of image i, j - 1 temp[1]
temp2[1, 0] temp2[2, 0]
pixel of image i + 1, j - 1 temp[2]
temp2[2, 0] temp2[3, 0]
pixel of image i - 1, j temp[3]
temp2[3, 0] temp2[4, 0]
pixel of image i, j temp[4]
temp2[4, 0] temp2[5, 0]
pixel of imagei + 1, j temp[5]
temp2[5, 0] temp2[6, 0]
pixel of image i - 1, j + 1 temp[6]
temp2[6, 0] temp2[7, 0]
pixel of imagei, j + 1 temp[7]
temp2[7, 0] temp2[8, 0]
pixel of imagei + 1, j + 1 temp[8]
temp2[8, 0] endfor
endfor Ascending Bubble Sorting
midpointi, j temp2[8, 0]+temp2[0,0]
Universitas Sumatera Utara
3.2.6 Pseudocode Mean Squared Error MSE
Berikut ini merupakan pseudocode dari program mean squared error.
double nilai_mse = 0 int a1, b1, c1, a2, b2, c2
int x,y int temp1, temp2, temp3, temp4
x width of data citra asli
x1 height of data citra asli
y width of data citra hasil
y1 height of data citra hasil
if x == y x1 == y1 then for i
0 x do for j
0 x1 do endfor
endfor a1
GetPixeli, j for Red from data_citraAsli b1
GetPixeli, j for Green from data_citraAsli c1
GetPixeli, j for Blue from data_citraAsli a2
GetPixeli, j for Red from data_citraHasil b2
GetPixeli, j for Green from data_citraHasil c2
GetPixeli, j for Blue from data_citraHasil temp1
a1 - a2 temp2
b1 - b2 temp3
c1 - c2 temp1
temp1 temp1 temp2
temp2 temp2 temp3
temp3 temp3 if temp1 0 then
temp1 temp1 -1
if temp2 0 then temp2 = temp2 -1
if temp3 0 then temp3 = temp3 -1
temp4 temp1 + temp2 + temp3 3
nilai_mse += temp4 endif
endif endif
nilai_mse nilai_mse x x1
Universitas Sumatera Utara
3.2.6 Pseudocode Peak Signal Noise to Ratio PSNR