Вы находитесь на странице: 1из 13

Session 2

Session Name: Compression Author Name: C. Jayapritha Department: Information Technology Subject/Course: Graphics and Multimedia Compression Techniques

Session Objectives
At the end of this session, the learner will be able to: Define the term compression. List the needs of compression and its types. Explain the compression standards. Discuss the different types of compression techniques.

Teaching Learning Material


Board and Chalk Slide Presentation

Page 2 Ver: 1.0

Compression C.Jayapritha, Oxford Engineering College

Session Plan
Time (in min) Content Methodology Faculty Approach Typical Student Activity Learning Outcomes (Blooms + Gardeners) Remembering 05 Introduction to Compression Brainstorming Facilitates Participates Linguistic Intrapersonal Interpersonal Skills Remembering Understanding Chalk and Talk Explains Listens Interpersonal Intrapersonal Skills Applying 15 Compression Standards Innovative Quiz Facilitates Participates Logical Verbal Interpersonal Intrapersonal Skills Understanding Applying 15 Compression Techniques Demonstration Demonstrates Listens Logical Interpersonal Intrapersonal Visual Remembering 10 Conclusion Choose and Defend Facilitates Guides Participates Linguistic Interpersonal Intrapersonal Logical Verbal

10

Need for Compression and its Types

Compression C.Jayapritha,Oxford Engineering College

Page 3

Session Inputs
Introduction to Compression
We can start this session by introducing the concept of compression to the learners with the help of a Brainstorming activity. Suggested Activity: Brainstorming The learners may not know anything about compression techniques but they might know the meaning for the word compression. Additionally, some of them may have some extra knowledge on the subject. Here, we can use the brainstorming method to extract the responses from the learners. Reponses from the learners can be listed on the board. Then, we can refine the responses and the irrelevant responses can be dismissed with a reason. Participant 1: Reducing the amount Participant 2: Decreasing the size Participant 3: Compaction Participant 4: If we are starting our motor cycle, the action of compression, the reduction in volume and increase of pressure of the air or combustible mixture in the cylinder prior to ignition, produced by the motion of the piston towards the cylinder head after intake. Participant 5: The coding of data to save storage space or transmission time. Participant 6: A pump or other machine for reducing volume and increasing pressure of gases. Participant 7: Run length encoding Participant 8: A transducer that produces an output with a range of voltages. Participant 9: Algorithms Participant 10: Programs

Page 4 Ver: 1.0

Compression C.Jayapritha, Oxford Engineering College

Data compression or source coding is the process of encoding information using fewer bits through the use of specific encoding schemes which are decoded in the receiver side.

Need for Compression and its Types


Having discussed the concept of compression, we can now explain the types of compression and the need for it to the learners. Need for Compression 1. Compression is the reduction in size of data in order to save space or transmission time. 2. It helps reduce the consumption of expensive resources, such as hard disk space or transmission bandwidth, i.e., to reduce the amount of data storage. 3. It can also reduce the cost for transmission. 4. Compression is used to manage large amount of multimedia data efficiently. 5. Compression is used to remove the redundancies. Types of Compression There are two types of compression. They are: 1. Lossless compression 2. Lossy compression Lossless compression: In this type, compression can be done without any loss of data. This is mostly applied for text documents. Lossy compression: In this type, while performing compression some of the data will be lost. Lossy image compression is used in digital cameras, to increase storage capacities with minimal degradation of picture quality. Similarly, DVDs use the lossy MPEG-2 Video codec for video

Compression C.Jayapritha,Oxford Engineering College

Page 5

compression. Generally speaking, this compression technique is used for images and videos.

Compression Standards
With the help of the above discussion, we have ensured the learners have understood the types of compression. Now, we can explain the compression standards in a simple way using the innovative quiz activity. Suggested Activity: Innovative Quiz We can divide the learners into 4 groups. We can invite 2 volunteers to conduct this quiz, one for asking questions and the other for marking scores. The questions should be prepared in such a way that it makes the learner think about the category of the particular format, or the type of compression, etc. By this method, learners will actively participate and will answer enthusiastically. Additionally, they will learn about different formats available. Finally, we can clarify their doubts, if any. Question 1: CCITT is applied for what type of documents? Group 1: CCITT is applied for text documents. Question 2: What type of compression is it? Group 2: It is a type of lossless compression. Question 3: Where is it actually used? Group 4: It is mostly used in sending Fax documents. Question 4: Can it be used for images? If yes, what type of images? Group 1: Yes, CCITT can be used for binary images. Question 5: JPEG means? Group 2: pass Group 3: Joint Photographic Experts Group. Question 6: What type of documents it is used for? Group 4: Pass Group 1: It is used particularly for color images.

Page 6 Ver: 1.0

Compression C.Jayapritha, Oxford Engineering College

Question 7: What type of compression is it? Group 2: It is a type of lossy compression. The important terms discussed in the session are as follows: 1. CCITT- Consultative Committee for International Telephony and Telegraphy For binary imageslossless compression that too in text documents 2. JPEG-Joint Photographic Experts Group For color images-lossy compression 3. MPEG-Motion Pictures Expert group For videos-lossy compression 4. Gp3 Videos-lossy compression

Compression Techniques
After explaining about the compression standards, it would now be appropriate to explain the compression techniques with the help of execution of a simple program. Suggested Activity: Demonstration We can execute a simple program for text compression. The program can be executed in such a way that the repeated elements in the text are removed and it is given a symbol to represent the repeated elements. This can be applied to the repeated word also. The word which occur more number of times can be given a symbol which will reduce the space occupied. This method can be followed for image compression also.

Compression C.Jayapritha,Oxford Engineering College

Page 7

Program: #include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> #include<stdlib.h> void main() { FILE *f1,*f2; int i=0,j=0,a=0,b=0,k,count=1; char s[30],s2[30],s1[30],c[30]; clrscr(); printf("\n Enter the message"); scanf("%s",&s); f1=fopen("Z:\INPUT.TXT","w"); while(s[i]!='\0') { if(s[i]!=s[i+1]) { if(count>=2) { s1[j+1]=s[i]; itoa(count,c,10); s1[j++]='#'; s1[j++]=c[0]; if(count>9) s1[j++]=c[i]; } else for(k=0;k<count;k++) s1[j++]=s[i]; i++; count=1; } else { count++; i++; } } s1[j++]='\0'; fprintf(f1,"%s",s1); printf("\n the encoded message %s",s1); fclose(f1); f2=fopen("@:pINPUT.TXT","r"); fscanf(f2,"%s",s1); while(s1[a]!='\0') { if(s1[a+1]=='#') { c[0]=s1[a+2];

Page 8 Ver: 1.0

Compression C.Jayapritha, Oxford Engineering College

c[1]='\0'; count=atoi(c); for(k=0;k<count;k++) s2[b++]=s1[a]; a+=3; } else { s2[b++]=s1[a]; a++; } } s2[b++]='\0'; if(strcmp(s2,s)==0) printf("\n The encode message\n%s",s2); else printf("The encoded message\n%s",s); fclose(f2); getch(); } OUTPUT: Enter the message:BOOOOOOOOOT The encoded message: B#9T The decoded message: BOOOOOOOOOT

This program is executed in a way such that the repeated letter in the input is eliminated and we have the encoded data. In the receiver side, decompression technique is applied to retrieve the original data. This will reduce the transmission time and bandwidth needed. We can also use this compression algorithm for storage purposes.

Conclusion
To conclude this session on compression, let us review the learners understanding with the help of the following activity.

Suggested Activity: Choose and Defend We can use choose and defend method that will help the learners to think beyond the content discussed. The entire classroom is divided into two groups. Group 1 should talk about the advantages of lossless compression and disadvantages of lossy compression; and group 2 should talk about the advantages of lossy compression and disadvantages of lossless compression.

Compression C.Jayapritha,Oxford Engineering College

Page 9

Group 1: No loss of data Group 2: Even though there is loss, it will not affect the content in the document. Group 1: But it can affect the quality of the picture. Group 2: As the images and videos occupy lot of memory space unlike text, we may have to compromise. Group 1: Simple To summarize, while performing lossy compression some of the data will be lost. Lossy image compression is used in digital cameras, to increase storage capacities with minimal degradation of picture quality. Similarly, DVDs use the lossy MPEG2 Video codec for video compression. Generally, this compression technique is used for images and videos. Lossless compression can be executed without any loss of data. This is mostly applied for text documents.

Page 10 Ver: 1.0

Compression C.Jayapritha, Oxford Engineering College

Summary
In this session, we learnt to:
Define the term compression. List the needs of compression and its types. Explain the compression standards. Discuss the different types of compression techniques.

Compression C.Jayapritha,Oxford Engineering College

Page 11

Assignment
1. Take a text document, define your own compression format and try to apply that to the document. Then, convert your defined standard into C code which should perform compression for any given text document. 2. Take a black and white image, technically a binary image and put checked lines in that image. Now mark 1 for that particular check box if it is in black color and 0 if it is white. Do it for the entire image. Now write a C program which will accept your binary codes and should reproduce the image.

Page 12 Ver: 1.0

Compression C.Jayapritha, Oxford Engineering College

References
Andleigh, P.K. and Thakrar, K., Multimedia Systems and Design, Prentice Hall of India, 2003. Judith Jeffcoate, Multimedia in Practice: Technology and Applications, Prentice Hall of India, 1998. http://59.163.61.3:8080/GRATEST/SHOWTEXFILE.do?page_id=user_image&u ser_image_id=2447

Compression C.Jayapritha,Oxford Engineering College

Page 13