EE25266 – ASIC/FPGA Chip Design Mahdi Shabany Electrical Engineering Department Sharif University of Technology Final Project – Spring 2015 JPEG Image Compression What is JPEG Compression JPEG, which stands for Joint Photographic Experts Group (the name of the committee that created the JPEG standard) is a lossy compression algorithm for images. A lossy compression scheme is a way to inexactly represent the data in the image, such that less memory is used yet the data appears to be very similar. This is why JPEG images will look almost the same as the original images they were derived from most of the time, unless the quality is reduced significantly, in which case there will be visible differences. The JPEG algorithm takes advantage of the fact that humans can’t see colors at high frequencies. These high frequencies are the data points in the image that are eliminated during the compression. JPEG compression also works best on images with smooth color transitions, which will make sense when I explain below how the algorithm works. JPEG Algorithm The algorithm behind JPEG is relatively straightforward and can be explained through the following steps: 1. Take an image and divide it up into 8-pixel by 8-pixel blocks. If the image cannot be divided into 8-by-8 blocks, then you can add in empty pixels around the edges, essentially zero-padding the image. 2. For each 8-by-8 block, get image data such that you have values to represent the color at each pixel. 3. Take the Discrete Cosine Transform (DCT) of each 8-by-8 block. 4. After taking the DCT of a block, matrix multiply the block by a mask that will zero out certain values from the DCT matrix. 5. Finally, to get the data for the compressed image, take the inverse DCT of each block. All these blocks are combined back into an image of the same size as the original. As it may be unclear why these steps result in a compressed image, I’ll now explain the mathematics and the logic behind the algorithm. Base Principle of JPEG Compression The JPEG standard is based on the Discrete Cosine Transform (DCT). It gives a lot of flexibility so as to obtain a desired compression ration (CR). As presented in figure 1, the base principle of JPEG compression for color images considers the four main operations: color space conversion and downsampling, DCT-2D, quantization, Zig-Zag scanning and entropy coding [3] [4]. Color Space Conversion and Downsampling Three-dimensional space of RGB is commonly used to represent the color space, while threedimensional space of YCbCr is adopted in the system of JPEG compression. So if the base principle of JPEG compression is employed to deal with the color static image, it is necessary to convert YCbCr color space into RGB color space, which is given by[1]: ( ) ( )( ) ( ) Considering that it is more insensitive to the information of chrominance than to the information of luminance Y in human visual system, so the method to downsample the data of and by 50% is used to increase compression ration. DCT-2D Discrete Cosine Transform (DCT) represents the image as the sum of sinusoids of varying magnitude and frequencies, the DCT calculation is fairly complex; in fact, this is the most costly step in JPEG compression. DCT is used to produce uncorrelated coefficients, allowing effective compression as each coefficient can be treated independently without risk of affecting compression efficiency. The human visual system is very dependent on spatial frequencies within an image. In fact it is more sensitive to the lower frequencies than to the higher ones. Thus we can discard information that is not perceptible to the human visual system and keep the information that is important to it. The DCT-2D is computed as follows: first, the image data is divided into non-overlapped 8*8 matrix blocks; second, all of the 8*8 matrix blocks are transformed by the two dimensional Discrete Cosine Transform, which is given by the following equation. ∑∑ * {√ + * + {√ The result of this equation is an 8*8 matrix representing the frequency domain of the pixel values in the original 8*8 block. Most of the image data will be retained in only a portion of the matrix. Quantization Quantization is used to allow for a better compression ration, the quantization is the operation that introduces information losses in the JPEG compression process. The goal of the quantization step is to generate a sparse matrix to allow a large compression rate at the entropy coding operation. Quantization is defined as division of each DCT coefficient by the corresponding quantization value S(u,v) , followed by rounding to the nearest integer, which is given by equation [4] ( The matrix of ) is represented as follows: [ ] is also called as the coefficient of DCT, in equation [5], the coefficient of is referred as the DC coefficient, the others are referred as the AC coefficient. Two kinds of table are needed in the quantization step: one is the luminance table; the other is the chrominance table. The typical tables adopted for quantization are given below: Because Division operations are not efficient for hardware resources, in the most of implementations they are replaced with multiplication and shift operations. For example, dividing an output DCT coefficient by quantization value 13 can be expressed as * + Where [...] represents truncation to integer value. So the DCT coefficient is actually multiplied by 5041 which is stored in the proposed implementation as the corresponding quantization value and then the least significant 16 bits are discarded by a shift operation. Zig-Zag Scanning and Entropy Coding After quantization is used, the DC coefficient and AC coefficient of each 8*8 block should be read in a Zig-Zag order, as depicted in figure 2. Initially, n new DC coefficient is calculated by differential pulse-code modulation (DPCM). The DC coefficient is the first value in the matrix. It is determined by computing the different value between the current DC coefficient and the last DC coefficient, as shown in figure 3. If there is no previous block, then the previous value is set to zero. Afterwards, the remaining values in the matrix are called as the AC coefficients. These values are encoded slightly differently using an 8-bit value represented as RRRRSSSS. The run-length, 4 bits RRRR value, is the number of zeros preceding a non-zero value using the zigzag format of reading the matrix. The non-zero value is then coded by size, 4 bits SSSS value, as is described for the difference magnitude. Finally, all of the DC coefficient and the AC coefficients should be coded by Huffman code. While considering that this is not focus in our research, so it will not be described particularly in this paper. Your Tasks You are highly recommended to study the relevant papers available in WEB. Your design should be real time, so use the technics discussed in class. You should simulate this system in MATLAB, then you should design and implement a hardware for complete system, this part should be done by ISE (over VIRTEX 6), although you should write a testbench and design a test strategy using matlab outputs and ModelSim. The verified design should be synthesized by Design Compiler and the ASIC flow should be completely done (using DC and SoC encounter). All the parts should be documented and be delivered according to this timeline: MATAB simulation and RTL design and hardware implementation of YCbCr and DCT and Quntization MATAB simulation and RTL design and hardware implementation zig-zag and entropy coding The complete ASIC Flow Preparing the final report 16 ordibehesht 30 ordibehesht 13 khordad 20 khordad For each part you need to deliver: 1) A report in pdf file. The report should clearly mention the detail of the design. Also it should tell us how to test your design and find the related files (both designs and test benches) 2) All codes both in Matlab and Verilog in two separate folders. The file names and signal names should be consistent in Matlab and Verilog for ease of verification. 3) The designs should be verified with appropriate test vectors. You need to provide post-synthesis simulation results. You need to provide the test vectors too. References 1. Multiplierless and fully pipelined JPEG compression soft IP targeting FPGAs 2. A Novel Parallel JPEG Compression System Based on FPGA

© Copyright 2020