Still Image Compression
Still Image Compression
ABSTRACT:
Images are generated, edited and transmitted on a very regular basis in a vast number of systems today. The raw image data generated by the sensors on a camera is very voluminous to store and hence not very efficient. It becomes especially cumbersome to move it around in bandwidth constrained systems or where bandwidth is to be conserved for cost purposes such as the World Wide Web. Such scenarios demand use of efficient image compressing techniques such as the JPEG algorithm technique which compresses the image to a high degree with little loss in perceived quality of the image. Today JPEG algorithm has become the de facto standard in image compression. MATLAB program for DCT based JPEG compression of an still image was written.
CONTENTS:
Introduction Base line sequential mode compression Block diagram for encoder & decoder Performing DCT transform Quantization of DCT coefficient Zigzag ordering of coefficient Run-length coding of DCT coefficients(AC and DC) JPEG Decoder - Block Diagram - Explanation MATLAB Program Conclusion Reference
Introduction:
Image compression and coding: JPEG:
The JPEG standard for coding of digital images was designed by Joint Photographic Expert Group (JPEG), under both the International Standards Organization (ISO) and the International Telecommunications UnionTelecommunication Sector (ITU-T). Aims to support a wide variety of applications for compression of continuoustone images and is most frequently used means of compressing still images. JPEG specifies two classes of encoding and decoding, viz. lossless and lossy. 1. Lossless compression: Lossless compression is based on predictive DPCM method using neighboring pixel values. 2. Lossy compression: JPEG standard defines three lossy compression modes, namely baseline sequential mode, progressive mode, and hierarchical mode. These compressions are based on Discrete Cosine Transform (DCT). Transmission of DCT co-efficient are different in all mode. Produces reconstructed image with high visual fidelity DCT based coding are of 2 types:1. Baseline system (what is commonly known as JPEG!): lossy Can handle gray scale or color images, with 8 bits per color component 2. Extended system: can handle higher precision (12 bit) images.
Baseline sequential mode compression: An image is partitioned into 8x8 non-overlapping pixel block. For each 8x8 block, three steps are involved: - Block DCT - Perceptual-based quantization
3
Fig.1
Fig.2
Fig.3
Fig.4
Performing DCT transformation: The image is divided into 8x8 blocks.Zero padding is done if required. Consider the following as an example of an 8x8 sub image:
Then each 8 bit sample ranging from [0,255] is level shifted by subtracting 128 to be centered around zero which yields range [-128,127]
u is the horizontal spatial frequency, for the integers v is the vertical spatial frequency, for the integers
gx,yis the pixel value at coordinates (x,y) .Gu,vis the DCT coefficient
at
coordinates
(u,v)
Use uniform quantization on each coefficient Different coefficient is quantized with different step-size(Q)
Human eye is more sensitive to low frequency components Low frequency coefficients with a smaller Q High frequency coefficient with larger Q Specified in a normalization matrix
Normalization matrix can then be scaled by a scale factor (QP),which is inversely proportional to a quality factor Quality factor: 100% best quality -> lower quality One can use either the default normalization matrix, or specify anarbitrary matrix For color images, a different normalization matrix can be specifiedfor each color component.
whereGis the nonquantized DCT coefficients; Q is the quantization matrix above; and B is the quantized DCT coefficients.
Using this quantization matrix with the DCT coefficient matrix from above results in: For example, using 415 (the DC coefficient) and rounding to the nearest integer,
After doing Zigzag ordering run-length code is obtained. For the above example run length code is [-26,(0,2),(1,2),(0,2),(0,3),(0,2),(0,3)and so on]
o Coding process for AC symbol: AC Coefficients: Runlength coding Many high frequency AC coefficients are zero after first few low-frequency coefficients Runlength Representation: Ordering coefficients in the zigzag order Specify how many zeros before a non-zero value, this is denoted by RUN Specify the category in which the nonzero vale falls. And this is denoted by CAT Each symbol=(length-of-zero, non-zero-value)=(RUN,CAT) Code all possible symbols using Huffman coding More frequently appearing symbols are given shorter codewords One can use default Huffman tables or specify its own tables. Instead of Huffman coding, arithmetic coding can be used to achievehigher coding efficiency at an added complexity.
10
JPEG DECODER:
11
A JPEG decoder is capable of reconstructing image data from a stream of compressed image data. This requires that some transformations be applied to the compressed image giving reconstruction of the image data.
BLOCK DIAGRAM:
o VLD unit:
The VLD unit should perform the variable length decoding operation. The JPEG standard allows the use of two DC tables and two AC tables for a baseline sequential decoder. The VLD decide the table needed for the decompression. Present inVLD table. The control logic is responsible for loading the correct Huffman tables in the VLD table. The VLD unit assumes that the correct tables have been loaded. The VLD requires bits from the compressed image data in order to function. To get one or more bits from the compressed image data, the VLD can ask the bit ASU for these bits.
o ZZ unit:
The ZZ unit should perform the zigzag scan operation.
o DQ unit:
The DQ unit should perform the dequantization allowing the use of up to four dequantization tables for a baseline sequential decoder. To select the correct dequantization table, an extra parameter should be supplied to the dequantization unit. The dequantization tables needed by the dequantization unit can be found in the DQ table.The control logic is responsible for loading the correct dequantization tables in the DQ table.Thedequantization unit assumes that the correct tables have been loaded.
o Bit ASU:
The compressed image data can be modeled as a stream of bytes. The JPEG decoder movesthrough this byte stream while it decodes the image. The bit ASU is used to facilitate the JPEG decoder in accessing these bits and bytes. The bit ASU has therefore a number of procedures.
o IDCT:
12
The IDCT unit in the image processor should realize the inverse discrete cosine transform. Ittherefore takes one block as its input. It then applies an inverse discrete transformation withan 8-bit precision to it. After computation of the IDCT, the signed output samples are level-shifted. This level shifting converts the output to an unsigned representation. For 8-bit precision, the level shift is performed by adding 128 to every element of the block that came out of the IDCT. If necessary, the output samples shall be clamped to stay within the range appropriate for the precision (0 to 255 for 8-bit precision).
o Re-ordering unit:
The output of the color conversion unit is a minimal coded unit [MCU]. It describes all colorcomponents in a region of the image. The first MCU outputted describes the top-left mostregion of the image. The MCU are then outputted in a row-by-row fashion. Most image display systems (e.g. video and computer) describe an image in a lineby-line manner. The re-ordering unit should provide a conversion between the system in which MCUs are used to describe a region of the image and the system in which the image is described in aline-by-line style. If necessary, the re-ordering unit should resize a MCU to make sure that the original image is maintained.
o Control logic:
This unit controls the data flow in the processor and requests communication packets from thecommunication channel and sends the enclosed data to the correct units. In case, thecommunication packet is a Block packet, the enclosed block must be sent to the IDCT unit.When the IDCT unit has finished, the control logic has to check whether a complete MCU ispresent in the memory and the MCU can be processed. When the control logic receives an EOI packet from the communication channel, it should finish its operation..
RESULT:
13
CONCLUSION:
14
This report describes the design and implementation of a JPEG encoder and decoder. For JPEG encoder the procedure sequentially follows DCT transformation of each pixel of the image, Quantization of samples, zigzag ordering to have 2-D array in 1-D format, variable length coding using Run length and Hoffmann coding to obtain the compressed image. This compressed image is then decoded with the blocks of variable length decoder and follows the reverse format. The output after compression contains lossy data. However such data losses are irrelevant to the observer. Reference:
Official JPEG site: www.jpeg.or Gonzalez and Woods, Digital image processing, 2nd
edition.
15