JPEG: Image Compression Standard Dian Nuswantoro University Ferda Ernawan, Ph.D
Terminology The terminology between original image and image compression Compression Ratio Bit per pixel
Compression Ratio Example: Original Image Size = 256X256(pixels) X 1(byte/pixel) = 65536 bytes Image 256X256 pixels, 256 level grayscale can be compressed file size 6554 byte.
Bits per Pixel Example: Original Image Size = 256X256(pixels) X 1(byte/pixel) = 65536 bytes Image 256X256 pixels, 256 level grayscale can be compressed file size 6554 byte. Compressed file = 6554(bytes)X8(bits/pixel) = 52432 bits
Why we need to compress? Savings in storage and transmission data multimedia data (example: image and video) memiliki ukuran data yang besar. difficult to send real-time uncompressed video over current network relatif lambat perangkat penyimpanan mereka dan tidak memungkinkan play back multimedia data secara real time. Perangkat penyimpanan relatif lambat Tidak memungkinkannya playing back uncompressed multimedia data in real time 1x CD-ROM transfer rate ~ 150 kB/s 320 x 240 x 24 fps color video bit rate ~ 5.5MB/s => 36 seconds needed to transfer 1-sec uncompressed video from CD
Why we need to compress? Transmission To transmit an RGB 512X512, 24 bit image via modem 28.8 kilobits/second
The goal of image compression The goal of image compression is to reduce the amount of data required to represent a digital image. Important for reducing storage requirements and improving transmission rates.
JPEG Standard Dalam sistem pengkodean atau compression berdasarkan JPEG, pengkodean menggunakan discrete cosine transform, merupakan metode yang paling populer untuk image compression. Metode tersebut dapat dilakukan dalam empat langkah secara berurutan sebagai berikut:
JPEG Standard JPEG (Joint Photographic Experts Group) adalah standar internasional untuk image compression, baik grayscale dan color. The JPEG standard have two basic compression methods. Lossy Compression Lossless compression
Element of JPEG Standard Encoder encoder mengambil digital source image data dan table spesification (quantization), dan melalui serangkaian prosedur tertentu untuk menghasilkan compressed image data. Decoder decoder mengambil compressed image data, dan table specification (dequantization) dan melalui serangkaian prosedur tertentu untuk menghasilkan digital reconstructed image data.
JPEG Operation JPEG memiliki mode operasi sebagai berikut: Sequential mode: mengkompress image dengan menscan dari kiri-ke-kanan, atas ke bawah untuk scaning. Progressive mode: Mengkompress image dalam beberapa scanning. Ketika waktu transmisi atau proses lama, gambar akan ditampilkan dari tidak jelas menjadi sempurna tampilannya.
Sequential DCT Untuk modus DCT berbasis sequential, 8x8 blok sampel dari image merupakan blok input yang akan diproses dari kiri ke kanan, dari blok baris ke blok baris selanjutnya dari atas ke bawah. Setelah blok telah diubah oleh metode DCT, kemudian akan menghasilkan 64 koeficient setiap blok tersebut, 64 coeficient tersebut diquantisasi, yang kemudian dikodekan dengan metode entropy. Hasil dari compressed image data adalah meminimalkan koefisien-koefisien data sebuah image dalam penyimpanan.
Sequential Operation
Progressive DCT-based Untuk modus DCT berbasis progressive, 8x8 blok juga biasanya dikodekan dalam urutan yang sama, tetapi dalam beberapa scan melalui image. Hal ini dicapai dengan menambah buffer memori image antara quantizer dan encoder entropi. Setiap blok diubah oleh DCT dan diquantisasi, yang kemudian koefficiennya disimpan dalam buffer. DCT coefficient tersebut dalam buffer kemudian sebagian dikodekan dengan beberapa scan.
Progressive Operation
Encoding In the encoding process the input component’s samples are grouped into 8 x8 blocks, and each block is transformed by the forward DCT (FDCT). The result of forward DCT is a set of 64 values referred to as DCT coefficients. One of these values is referred to as the DC coefficient and the other 63 as the AC coefficients.
Encoder 2D DCT Quantization Entropy Image 8x8 blocks Compressed Image Quantization Table Huffman Table The 2-Dimensional DCT is performed on the 8x8 blocks of the image data in the general JPEG framework. Baseline Coding in JPEG consists of 2-Dimensional DCT Processing
Encoder 2D DCT Quantization Entropy Image 8x8 blocks Compressed Image Quantization Table Huffman Table For each layers, the DCT coefficients shall be quantized separately. The quantization process has the key role in the JPEG compression. It is the process which removes the high frequencies present in the original image. This is done due to the fact that the eye is much more sensitive to lower spatial frequencies than to higher frequencies.
Image Compression Encoder
Color Space Conversion Dalam rangka mencapai kinerja kompresi yang baik, korelasi antara komponen-komponen warna dikurangi dengan mengkonversi warna RGB ke warna YCbCr. RGB harus dipisahkan menjadi bagian luminance (Y) dan bagian chrominance 2 (Cb dan Cr) seperti yang direkomendasikan dalam standard JPEG.
YCbCr The value Y = 0.299R + 0.587G + 0.114B is called the luminance. It is the value used by monochrome monitors to represent an RGB colour. The values Cb and Cr are called chromimance values and represent 2 coordinates in a system which measures the nuance and saturation of the color. These values indicate how much blue and how much red are in that color, respectively.
The advantage RGB to YCbCr The advantage of converting the image into luminance- chrominance color space is that the luminance and chrominance components are very much decorrelated between each other. Moreover, the chrominance channels contain much redundant information and can easily be sub-sampled without any visual quality for the reconstructed image.
RGB to YCbCr The transformation from RGB to YUV is based on the following mathematical expression: Y: the luminance represents the brightness Cb: the difference between the gray and blue Cr: the difference between the gray and red
Sub Block 8x8
Cont. The 88 blocks are processed from left-to-right and from top-to-bottom. The purpose of the DCT is to transform the value of pixels to the spatial frequencies. These spatial frequencies are very related to the level of detail present in an image. High spatial frequencies corresponds to high levels of detail, while lower frequencies corresponds to lower levels of detail.
FDCT-2D The inverse DCT of coefficient F(u,v) are given by: The DCT of a signal f(x,y) are given as follows: The inverse DCT of coefficient F(u,v) are given by: Where
FDCT-2D The mathematical definition of FDCT-2D with sub block 8x8 as follow :
Representation of DCT Coefficient u 0 1 2 3 4 5 6 7 v 1 2 3 4 5 6 7
DCT coefficient result
DCT coefficient result
Cont. DCT-based image compression relies on two techniques to reduce the data required to represent the image. The first is quantization of the image's DCT coefficients; the second is entropy coding of the quantized coefficients. Quantization is the process of reducing the number of possible values of a quantity. Entropy coding is a technique for representing the quantized data as compactly as possible, thereby reducing the number of bits needed to represent it.
Quantization Quantization refers to the process of approximating the continuous set of values in the image data with finite set of values. The input to be quantized is always the original data, and the output is always one in the middle of a finite number of levels. The quantizer is a function whose set of output values are discrete and usually finite. This is the process of estimation, and a good process is one which can present the original with minimum loss or deformation.
Quantization Each of the 64 DCT coefficients are uniformly quantized. Each element in the quantization matrix is an integer between 1 and 255. Each DCT coefficient F(u,v) is divided by the corresponding quantizer step-size parameter Q(u,v) in the quantization matrix and rounded to the nearest integer as :
Standard Quantization Table The standard JPEG luminance and chrominance quantization tables QL and QR are given below:
Quantization The quantization process has the key role in the image compression. It is the process which removes the high frequencies present in the original image. This is done due to the fact that the eye is much more sensitive to lower spatial frequencies than to higher frequencies. This is done by dividing values at high indexes in the vector (the amplitudes of higher frequencies) with larger values than the values by which are divided the amplitudes of lower frequencies.
Quantization
Quantization Result
Histogram analysis DC Coefficient for Luminance using 8x8 DCT
Histogram analysis DC coefficient for Cr using 8x8 DCT
Histogram analysis DC Coefficient for Cb using 8x8 DCT