Citra Digital
Pixel 8-bit
8-bit 8-bit
R G
B Pixel Citra 24-bit
Gambar 2.2 Citra Digital Gambar di atas menunjukkan citra digital yang menggunakan 24-bit warna
tiap pixel-nya. 24-bit warna dibagi ke dalam tiga bagian sebesar 8-bit, tiap bagian merupakan representasi intensitas warna dasar yaitu merah, hijau, dan biru RGB.
3
5. CMYK Mode
, menampilkan citra dalam kombinasi empat warna dasar cyan, magenta
, yellow dan black, tiap warna memiliki intensitas 0-255 8-bit
2.2.1 Mode Warna
Menampilkan sebuah citra pada layar monitor diperlukan lebih informasi mengenai letak dari pixel-pixel pembentuk citra. Untuk memperoleh gambaran yang tepat
dibutuhkan juga informasi tentang warna-warna yang dipakai untuk menggambarkan sebuah citra digital. Beberapa mode warna yang sering digunakan:
1. Bitmap Mode
, memerlukan 1-bit data untuk menampilkan warna dan warna yang dapat ditampilkan hanya warna hitam dan putih monokrom
2. Indexed Color Mode
, mengurutkan warna dalam jangkauan 0-255 8-bit 3.
Grayscale Mode , menampilkan citra dalam 256 tingkat keabuan
4. RGB Mode
, menampilkan citra dalam kombinasi tiga warna dasar red, green, dan blue, tiap warna dasar memiliki intensitas warna 0-255 8-bit
4
Menyimpan citra ke dalam media penyimpanan dalam bentuk digital memiliki bentuk yang beragam. Ada dua cara penyimpanan yang biasa dilakukan oleh
2.2.2 Penyimpanan Citra
3
A. Munir, Pengantar Pengolahan Citra, hal 10
4
Paul Bourke, Bicubic Interpolation for Image Scaling, http: astronomy.swin.edu.au~pbourkebitmap
Universitas Sumatera Utara
perangkat lunak yaitu bitmap dan vector. Dalam hal ini sering juga digunakan istilah program paint dan program draw.
Program paint atau program berbasis bitmap menyimpan citra sebagaimana ditampilkan di layar yaitu sebagai array dari pixel-pixel. Perubahan yang dilakukan
pada citra dengan menggunakan program ini akan mengubah langsung tiap titik atau pixel
pada citra. Kelebihan cara ini adalah kemudahannya untuk menampilkan gambar secara rinci dengan pola-pola yang kompleks atau gambar fotorealistik, yang
tidak dapat dengan mudah direpresentasikan sebagai model matematika. Program draw atau program berbasis vector menyimpan citra sebagai model
matematika, dan setiap elemen citra disimpan secara terpisah. Perubahan yang dilakukan pada citra menggunakan program ini akan mengubah deskripsi matematika
yang menyusun gambar dan program menghitung perubahan yang perlu pada warna- warna pixel secara tidak langsung. Kelebihan cara ini adalah kemampuannya untuk
menciptakan gambar dalam resolusi yang berbeda tanpa kehilangan mutu gambar yang berarti.
2.2.2.1 Format File Citra BMP
Format file BMP merupakan format standar sistem operasi Windows dan IBM OS2. Format ini mendukung mode warna dari Bitmap Mode hingga RGB Mode.
BMP mudah dibuka dan disimpan, tetapi ada beberapa aturan khusus yang harus dicermati, diantaranya:
1. Format file ini menyimpan datanya secara terbalik, yaitu dari bawah ke atas 2. Citra dengan resolusi warna 8-bit, lebar citra harus merupakan kelipatan dari
4, bila tidak maka pada saat penyimpanan akan ditambahkan beberapa byte pada data hingga merupakan kelipatan dari 4.
3. Citra dengan resolusi warna 24-bit, urutan penyimpanan tiga warna dasar adalah biru, hijau, merah B, G, R. Lebar citra dikalikan dengan 3 harus
merupakan kelipatan dari 4, bila tidak maka pada saat penyimpanan akan ditambahkan beberapa byte pada data hingga merupakan kelipatan dari 4.
4. BMP mendukung pemampatan run length encoding RLE Format file BMP secara jelas dapat dilihat pada Tabel 2.1 berikut ini:
Universitas Sumatera Utara
Tabel 2.1 Format File BMP
5
Name Size
Description Header
14 bytes Signature
2 bytes ‘BM’
File Size 4 bytes
File Size in bytes Reserved
4 bytes Unused = 0
Data Offset 4 bytes
File Offset to Raster
Info Header
40 bytes Windows
Structure: BITMAPINFOHEADER
Size 4 bytes
Size of Info Header = 40 Width
4 bytes Bitmap Width
Height 4 bytes
Bitmap Height Planes
2 bytes Number of planes = 1
BitCount 2 bytes
Bits per Pixel 1 = monocrome palette, NumColors = 1
4 = 4 bit palletized, NumColors = 16 8 = 8 bit palletized, NumColors = 256
16 = 16 bit RGB, NumColors = 65536 24 = 24 bit RGB, NumColors = 16 M
Compression 4 bytes
Types of Compression 0 = BI_RGB no compression
1 = BI_RLE8 8 bit RLE encoding 2 = BI_RLE4 4 bit RLE encoding
ImageSize 4 bytes
compressed Size of Image It is valid to set this = 0 if compressed =
XpixelsPerM 4 bytes
Horizontal Resolution: Pixelsmeter YpixelsPerM
4 bytes Vertical Resolution: Pixelsmeter
ColorsUsed 4 bytes
Number of actually used colors ColorImportant 4 bytes
Number of important colors = 0 all
Color Table
4 NumColors Present only if info. BitsPerPixel
≤ 8
5
Ibid, Paul Bourke.
Universitas Sumatera Utara
bytes Color should be ordered by importance
Red 1 byte
Red Intensity Green
1 byte Green Intensity
Blue 1 byte
Blue Intensity Reserved
1 byte Unused = 0
Repeated NumColors Times
Raster Data
Info.ImageSize bytes
The Pixel Data
2.2.2.2 Format File Citra GIF
Format file GIF Graphics Interchange Format merupakan hasil rancangan CompuServe Incorporated
. Format ini dirancang untuk memudahkan pertukaran citra bitmap
antarkomputer. GIF hanya mendukung resolusi warna sampai 256 warna 8- bit
. Format file GIF memiliki dua versi yaitu GIF 87a dan GIF89a. Versi GIF89a
diperkenalkan pada bulan Juli 1989 merupakan perbaikan dari versi GIF87a. Pada GIF89a ditambahkan kemampuan untuk menampilkan citra dengan latar belakang
transparan background transparency, penyimpanan data citra secara interlaced dan kemampuan untuk menampilkan citra animasi.
GIF menggunakan variable-length code yang merupakan modifikasi dari algoritma LZW Lemple-Ziv Wetch untuk memampatkan data citra. Teknik
pemampatan data ini mampu menghasilkan pemampatan yang baik dan merupakan teknik pemampatan yang mampu mengembalikan data sama persis dengan aslinya
lossless data comperssion. Format lengkap file citra GIF dapat dilihat pada Tabel 2.2 berikut ini.
Tabel 2.2 Format File GIF
6
Name Size
Description Signature
6 bytes ‘GIF87a’ or ‘GIF89a’
Global Descriptor
7 bytes Always present
6
D. C Kay, J. R Levine, Graphics File Formats 2nd Edition, hal 35
Universitas Sumatera Utara
Width 2 bytes
Width in pixels Height
2 bytes Height in pixels
Flags 1 bytes
Global descriptor flags
Global Color Map Bit 7 =1 if Global ColorMap exists should be
true in almost all cases =0 if default map is used. Or if every
image has a Local Color Map Color Resolution
Bits Bit 6-4
+1 = significant bits per color in Global Color Map
Reserved Bit 3
= 0 Pixel Bits
Bit 2-0 +1 = Color Depth, Number of Global
Colors := 2
colordepth
Background Color 1 byte
Background color number from Global Color Map or default map
Aspect Ratio 1 byte
Usually =0
Global Color Map
Number of Global Colors
3 Global color table, present only when
Global Descriptor Flags Global Color Map =1
Red 1 byte
Red intensity of color not necessarily 8 significant bits
Green 1 byte
Green intensity of color not necessarily 8 significant bits
Blue 1 byte
Blue intensity of color not necessarily 8 significant bits
Repeated Number Of Global Colors Times
Extension Blocks
Cannot be pre calculated
Optional, may be repeated any number of times. Read first byte to check its precense
Header 1 byte
= 21 Function Code
1 byte There is a list of known function codes
Length 1 byte
Data Length bytes
Interpretation of this data depends on its function code
Universitas Sumatera Utara
Repeated any number of times. Read first byte to check for terminator Terminator
1 byte = 0
Local Descriptor
10 bytes Local descriptor, always present
Header 1 bytes
=2C Pos X
2 bytes Horizontal position of image in global
image Pos Y
2 bytes Vertical position of image in global image
Width 2 bytes
Width of image Height
2 bytes Height of image
Flags 1 bytes
Local descriptor Flags
Local Color Map Bit 7
=1 if Local Color Map exists =0 if Global Color Map or default map is
used Interlaced Image
Bit 6 =1 Interlaced
=0 Non Interlaced Sorted
Bit 5 Usually =0
Reserved Bit 4-3
=0 Pixel Bits
Bit 2-0 -1= Color Depth,
Number of Local Colors := 2
color depth
Local Color Map
Number of Local Color 3
Local color table, present only when local Descriptor Flags. Local Color Map =1
Red 1 byte
Red intensity of color Green
1 byte Green intensity of color
Blue 1 byte
Blue intensity of color Repeated number of Local Color times
Rasted DataBlock
Cannot be pre calculated
Always present
Initial Code Size 1 byte
Usually = Color Depth, except for balck white, where it is 2
Length 1 byte
Data Length bytes
The pixel data bit stream. See decompression and compression schemes
Universitas Sumatera Utara
Repeated any number of times, read first byte to check for terminator Terminator
1 byte =0
Extension Blocks
Cannot be pre calculated
Optional. Read first byte to check its presence
Format is identical to the Extension Block above
Terminator
1 byte =3B
2.2.3.3 Format File Citra JPEG
Format file Joint Photographic Experts Group JPEG atau yang biasa disingkat JPG meningkat pesat penggunaannya. Format ini terkenal karena ukurannya yang mini
dibandingkan dengan format-format lainnya. JPEG mendukung mode warna RGB, CMYK dan Grayscale, tetapi tidak
mampu menampilkan citra dengan latar belakang transparan. Format JPEG menterjemahkan informasi tersebut menjadi komponen
luminance komponen cahaya dan dua komponen chromatic komponen perubahan
warna dari hijau ke merah dan dari biru ke kuning. Untuk kompresinya format file citra ini menggunakan kompresi JPEG.
Format lengkap dari JPEG dapat dilihat pada Tabel 2.4 berikut ini. Tabel 2.3 Format File JPEG
7
Name Size
Description
SOI marker 2 bytes
FF D8 APP0 marker
2 bytes FF E0
Length 2 bytes
Identifer 5 bytes
“JFIF” or “JFXX” + terminator 00 Version
2 bytes Ex. 01 02
→ ver.1.02 Units
1 byte Units for the X and Y densities,
units =0: no units , S and Y specify the pixel aspect ratio
Units = 1: X and Y are dots per inch
7
Ibid, D. C Kay, J. R Levine, hal 40
Universitas Sumatera Utara
Units =2: X and Y are dots per cm Xdensity
2 bytes Horizontal pixel density
Ydensity 2 bytes
Vertical pixel density Xthumbnail
1 byte Thumbnail horizontal pixel count
Ythumbnail 1 byte
Thumbnail vertical pixel count RGBn
3n bytes Packed 24-bit RGB values for the thumbnail
pixels, n = Xthumbnail Y thumbnail
Data x bytes
EOI marker 2 bytes
FF D9
2.3 Pengertian Kriptografi