1 / 72

Lecture 10: data compression

Lecture 10: data compression. Outline. Basics of Data Compression Text & N u meric Compression Image Compression Audio Compression Video Compression Data Security Through Encryption أساسيات ضغط البيانات النص والضغط الرقمي ضغط الصورة ضغط الصوت ضغط الفيديو أمن البيانات من خلال التشفير.

worthington
Télécharger la présentation

Lecture 10: data compression

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 10:data compression

  2. Outline • Basics of Data Compression • Text & Numeric Compression • Image Compression • Audio Compression • Video Compression • Data Security Through Encryption • أساسيات ضغط البياناتالنص والضغط الرقميضغط الصورةضغط الصوتضغط الفيديوأمن البيانات من خلال التشفير

  3. Learning Outcomes • Differentiate between the lossless and the lossy data compression processالتفريق بين فقدان البيانات وفقدان عملية ضغط البيانات

  4. Basics of Data Compression • Digital compression concepts • Compression techniques are used to replace a file with another that is smaller • Compressed data requires less storage and can be transmitted at a faster rate • Decompression techniques expands the compressed file to recover the original data – either exactly or in facsimile • A pair of compression / decompression techniques that work together is called a codec for short

  5. مفاهيم الضغط الرقميوتستخدم تقنيات الضغط لاستبدال ملف مع آخر أصغرتتطلب البيانات المضغوطة تخزين أقل ويمكن نقلها بمعدل أسرعتقوم تقنيات إزالة الضغط بتوسيع الملف المضغوط لاستعادة البيانات الأصلية - إما بالضبط أو بالفاكسويسمى زوج من تقنيات الضغط / إزالة الضغط التي تعمل معا برنامج ترميز قصير

  6. Uncompressed data Compression / coder Compressed data 10010110010 CODEC 10101011100 Decompression / decoder Basics of Data Compression (cont) • Compress Decompress – CoDec • Main function ofCODEC: toreduce the redundancy in data • How ??? – by replacing definable patterns with shorter sequences of symbols

  7. Basics of Data Compression (cont) • Types of Codecs • LossyCoDecs • Codecs that produces only an approximation of the original data • e.g: audio and digital images • Lossless CoDecs • Codecs that upon decompression always reproduce the originals file exactly • e.g: text and numeric data

  8. أنواع برامج الترميزلودي كوديكسبرامج الترميز التي تنتج فقط    تقريب من    البيانات الأصليةعلى سبيل المثال: الصوت والصور الرقميةفقدان كوديسبرامج الترميز التي عند الضغط دائما إعادة إنتاج الملف الأصلي تماماعلى سبيل المثال: نص وبيانات رقمية

  9. Basics of Data Compression (cont) • Speed of Compression / Decompression • Describes theamount of time required to compress and decompress data • eithersymmetrically or asymmetrically • Symmetric CoDec • takes approximately the same amount of time to compress and decompress a file • e.g:video teleconferencingtransmission • Asymmetric CoDec • simple, fast decompression speed but compression is more complicated and significantly slower • e.g: storing and accessingCD-ROM / DVD

  10. سرعة الضغط / الضغطيصف مقدار الوقت المطلوب    لضغط وضغط البياناتإما بشكل متناظر أو غير متماثلمتناظرة كوديكيأخذ تقريبا نفس الكمية من    الوقت لضغط وفك ضغط ملفمثل: نقل الفيديو عن بعدكوديك غير المتماثلةبسيطة وسريعة سرعة الضغط ولكن    ضغط أكثر تعقيدا و    بشكل ملحوظ أبطأعلى سبيل المثال: تخزين والوصول إلى سد-روم / دفد

  11. Basics of Data Compression (cont) • CoDecmethods • CoDec can be distinguish in 3 ways: • Syntactic method (entropy encoding) • attempt to reduce the redundancy of symbolic patterns without any attention to the type of information represented (ignores the source of information) • Semantic method (Source coding) • consider special properties of the type of information represented (helps to transform or reduce the amount of non-essential information in the original) • Hybrid method • combine bothsyntactic and semanticapproaches Firstly, prepare the data using semantic method and then reduce it further with entropy encoding

  12. طرق كوديككوديك يمكن التمييز في 3 طرق:الطريقة التركيبية (ترميز الإنتروبيا)محاولة الحد من التكرار من أنماط رمزية دون أي اهتمام لنوع المعلومات الممثلة (يتجاهل مصدر المعلومات)الطريقة الدلالية (ترميز المصدر)النظر في خصائص خاصة لنوع المعلومات الممثلة (يساعد على تحويل أو تقليل كمية المعلومات غير الضرورية في الأصل)طريقة الهجينالجمع بين النهج النحوية والدلالية أولا، إعداد البيانات باستخدام الأسلوب الدلالي ومن ثم تقليله أكثر مع ترميز الإنتروبيا

  13. Entropy Encoding • Run-Length Coding • Huffman Coding • Arithmetic Coding • Source Coding • Prediction • DPCM, DM • Transformation • FFT, DCT • Layered Coding • Bit Position, Subsampling, Sub-band coding • Hybrid • JPEG, MPEG, H.261, DVI RTV, DVI PLVترميز الطبقاتبيت بوسيتيون، أخذ العينات الفرعية، تشفير النطاق الفرعيالهجينجبيغ، مبيغ، H.261، دفي رتف، دفي بلف ترميز إنتروبيتشغيل طول الترميزهوفمان الترميزالترميز الحسابيترميز المصدرتنبؤدبم، دمتحويلففت، دكت

  14. Text and Numeric Compression • Several methods for compressing files representing text and numeric data • 1) Run Length Encoding (RLE) • A simple and direct form of compression • Based on the assumption that a great deal of redundancy is present in the repetition of particular sequences of symbols • Example: consider a sequence of text : A BB CC DDDDDDDDD EE F GGGGG after compression will become A BB CC D#9 EE F G#5 • Fax transmissions use RLE for data reduction

  15. والبيانات الرقمية1) تشغيل طول ترميز (رل)شكل بسيط ومباشر للضغطاستنادا إلى افتراض أن قدرا كبيرا من التكرار موجود في تكرار تسلسل معين من الرموزمثال: النظر في تسلسل من النص:           A بب سيسي دد إي F غغبعد ضغط سوف تصبحA بب سيسي D # 9 E F G # 5يستخدم إرسال الفاكسات رل لخفض البيانات

  16. Text and Numeric Compression (cont)

  17. Text and Numeric Compression (cont) • Run Length Encoding (RLE) • Some data contain a sequence of identical bytes • The RLE technique replaces these runs of data by using a marker or a counter that indicates the number of occurrences • 3-bytes encoding: Uncompressed data  AAAAOOOOOOOOBBBBCCCDCC Compressed data  A#4 O#8 B#4 C CC D C C The # acts as the marker, followed by a number indicating the number of occurrence. This example shows that each run of code is compressed. تشغيل ترميز الطول (رل)تحتوي بعض البيانات على تسلسل من وحدات البايت المتطابقةتقنية رل تحل محل هذه البيانات من البيانات باستخدام علامة أو عداد يشير إلى عدد من الأحداث

  18. Text and Numeric Compression (cont) • Run Length Encoding (RLE) • RLE can also be coded using 2-bytes • The first byte indicates the number of occurrence, where the second indicates the data • 2-bytes encoding: Uncompressed data  AAAAOOOOOOOOBBBBCCCDCC Compressed data  4A 8O 4B 3C D C C As a result of this, RLE manages to compress the data down a bit. The original data = 22-bytes (AAAAOOOOOOOOBBBBCCCDCC) RLE compresses it down to 11-bytes (4A 8O 4B 3C D C C) تشغيل ترميز الطول (رل)رل يمكن أيضا أن تكون مشفرة باستخدام 2 بايتالبايتة الأولى تشير إلى عدد حدوث، حيث يشير الثاني إلى البيانات

  19. Text and Numeric Compression (cont) • Run Length Encoding (RLE) • Compresses more efficiently if the run of strings is really long. Example: • AAAAAAAAAAAAAAAAAAAA becomes 20A • Instead of 20-bytes… the storage is brought down to just 2-bytes (1-bytes for ’20’ and 1-byte for ‘A’) • RLE compression ratio can be measure by the formula: • (original size / compressed size) : 1 • For the previous example… compression ratio is 22/11 : 1, which is 2:1

  20. Text and Numeric Compression (cont) • Run Length Encoding (RLE) • RLE on repetitive data source • Consider this: 1, 3, 4, 1, 3, 4, 1, 3, 4, 1, 3, 4 • RLE  4(1,3,4) – translates to 4 occurrences of 1,3 and 4 • RLE on differencing • Consider this: 1,2,4,5,7,8,10 • RLE can also take the differences between adjacent strings and encodes them. In this case, 1 and 2 = 1; 2 and 4 = 2; 4 and 5 = 1… and so on • The respective compressed differences would be  1,2,1,2, 1,2. Further compression  3(1,2)

  21. Text and Numeric Compression (cont) • Run Length Encoding (RLE) • RLE only good for long runs! • As the previous examples show, only long runs of identical data are worth compressing • If we don’t have longs runs of data… no compression might be achieved. In some cases, data expansion might happen!!! • Consider this: • “SAMSUNGNOKIASONYACER” = 20 bytes • 3S 3A M U 3N G 2O K I Y C E R = ? bytes تشغيل ترميز الطول (رل)رل جيدة فقط لأمد طويل!كما تظهر الأمثلة السابقة، فقط أشواط طويلة من البيانات متطابقة تستحق ضغطإذا لم يكن لدينا شوط تشغيل البيانات ... لا يمكن أن يتحقق ضغط. في بعض الحالات، قد يحدث توسع البيانات !!!فكر في ذلك:

  22. Text and Numeric Compression (cont) • 2) Huffman Codes • Form ofstatisticalencoding that exploits the overall distribution or frequency of symbols in a source • Produces an optimal coding for a passage-based source on assigning the fewest number of bits to encode each symbol given the probability of its occurrence • e.g. • if a passage-based content has a lot of character“e”then it would make sense to replace it with the smallest sequence of bits possible. Other characters can use its normal representation • refer the HUFFMAN tree

  23. رموز هوفمانشكل ترميز إحصائي يستغل التوزيع العام أو تردد الرموز في المصدرتنتج ترميزا مثاليا لمصدر يستند إلى المقطع على تخصيص أقل عدد من البتات لتشفير كل رمز نظرا لاحتمال حدوثه  على سبيل المثال.إذا كان للمحتوى القائم على المقطع الكثير من الحرف "e" فإنه سيكون من المنطقي استبداله بأصغر تسلسل من البتات الممكنة. يمكن أن تستخدم أحرف أخرى تمثيلها العاديراجع شجرة هفمان

  24. Text and Numeric Compression (cont) • Huffman Codes • This technique is based on the probabilistic distribution of symbols or characters • Characters with the most number of occurrences are assigned the shortest length of code • The code length increases as the frequency of occurrence decreases • Huffman codes are determined by successively constructing a binary tree • The leaves of the tree represent the characters to be coded

  25. رموز هوفمانويستند هذا الأسلوب على التوزيع الاحتمالي للرموز أو الأحرفيتم تعيين الأحرف التي لها أكبر عدد من مرات الظهور أقصر طول من التعليمات البرمجيةويزيد طول الشفرة كلما انخفض تواتر حدوثهايتم تحديد رموز هوفمان من خلال بناء على التوالي شجرة ثنائيةأوراق الشجرة تمثل الحروف المراد ترميزها

  26. Text and Numeric Compression (cont) • Huffman Codes • Characters are arranged in descending order of probability • The tree is further built further by repeatedly adding two lowest probabilities and resorting • This process goes on until the sum of probabilities of the last two symbols is 1 • Once this process is complete, a Huffman binary tree can be generatedيتم ترتيب الأحرف في ترتيب تنازلي من الاحتماليتم بناء الشجرة أبعد من ذلك عن طريق إضافة مرارا وتكرارا اثنين من احتمالات أدنى واللجوءوتستمر هذه العملية حتى يصل مجموع احتمالات الرمزين الأخيرين إلى 1بمجرد اكتمال هذه العملية، يمكن إنشاء شجرة هوفمان الثنائية

  27. Text and Numeric Compression (cont) • Huffman Codes • The resultant code words are then formed by tracing the tree path from the root node to the end-nodes code words after assigning 0s and 1s to the branches • If we do not obtain a probability of 1 in the last two symbols, most likely there is a mistake in the process. This probability of 1 which forms the last symbol is the root of the binary treeثم يتم تشكيل الكلمات رمز الناتجة عن طريق تتبع مسار شجرة من عقدة الجذر إلى الكلمات نهاية العقد رمز بعد تعيين 0S و 1 S إلى الفروعإذا لم نحصل على احتمال 1 في آخر حرفين، على الأرجح هناك خطأ في هذه العملية. هذا الاحتمال 1 الذي يشكل الرمز الأخير هو جذر الشجرة الثنائية

  28. Text and Numeric Compression (cont) • Huffman Codes (example) • Let’s say you have this particular probabilistic distribution: A = 0.10; B = 0.35; C = 0.16; D = 0.2; E = 0.19 • The characters are listed in order of decreasing probability B = 0.35; D = 0.2; E = 0.19; C = 0.16; A = 0.10 • Two characters with the lowest probability are combined A = 0.10 and C = 0.16  AC = 0.26 • Re-Sort… and the new list is: B = 0.35; AC = 0.26; D = 0.2; E = 0.19 • Then repeat what was done in step 2 D = 0.2 and E = 0.19  DE = 0.39 • Re-Sort the list again and we get: DE = 0.39; B = 0.35; AC = 0.26

  29. Text and Numeric Compression (cont) • Huffman Codes (example - continued) • Again… get the lowest two probs. and repeat the process B = 0.35 and AC = 0.26  BAC = 0.61 • Re-Sort… and you get the new list: BAC = 0.61; DE = 0.39 • Finally, BAC and DE are combined… and you get BACDE = 1.0 From all the combinations of probabilistic values that you’ve done… a binary tree is constructed. Each edge from node to sub-node is assigned either a 1 or 0من جميع تركيبات القيم الاحتمالية التي قمت به ... يتم إنشاء شجرة ثنائية. يتم تعيين كل حافة من عقدة إلى عقدة فرعية إما 1 أو 0

  30. Text and Numeric Compression (cont) P(BACDE) = 1.0 • Huffman Codes (resulting binary tree) 0 1 P(BAC) = 0.61 P(DE) = 0.39 0 1 0 1 Huffman Code for each Character P(B) = 0.35 P(AC) = 0.26 P(D) = 0.2 P(E) = 0.19 0 1 P(C) = 0.16 P(A) = 0.10

  31. Text and Numeric Compression (cont) • 3) LZW compression (Lempel-Ziv Welch) • Based on recognizing commonstring patterns • Basic strategy: replace strings in a file with bit codes rather than replacing individual characters with bit codes • Greater compressionrate than both previous methods • ضغط لزو (ليمبيل-زيف ويلش)استنادا إلى الاعتراف أنماط سلسلة مشتركةالاستراتيجية الأساسية: استبدال سلاسل في ملف مع رموز بت بدلا من استبدال الأحرف الفردية مع رموز بتمعدل ضغط أكبر من كل من الطرق السابقة

  32. Text and Numeric Compression (cont) • 3) LZW compression (Lempel-Ziv Welch)

  33. Image Compression • Image compression involves reducing the size of image data files, while retaining the necessary information. ضغط الصورة ينطوي على تقليل حجم ملفات بيانات الصور، مع الاحتفاظ بالمعلومات اللازمة.

  34. Image Compression (cont’d) • Besides Compression Ratio, another way to state the compression is to use the terminology of bits per pixel. إلى جانب نسبة الضغط، وهناك طريقة أخرى لتأكيد الضغط هو استخدام المصطلحات من بت لكل بكسل. • For an NxN image: • Example: • Say that we have a 256x256 image which is compressed to 6,554 bytes.

  35. Image Compression (cont’d) • The importance of reduction of file size: • T0 reduce the amount of storage needed. • To reduce the bandwidth requirement when sending the file over the network. أهمية الحد من حجم الملف:T0 تقليل كمية التخزين اللازمة.لتقليل متطلبات عرض النطاق الترددي عند إرسال الملف عبر الشبكة.

  36. Image Compression (cont’d) • The amount of data required for digital image is enormous. كمية البيانات المطلوبة للصورة الرقمية هائلة. • A single 512x512, 8-bit image requires 2,097,152 bits (256 KB) for storage. • A single 512x512 RGB color image requires 786 KB for storage. • To transmit the RGB image using a 56.6 kbps modem would require 1.8 minutes.

  37. Huffman Coding (Image example) • The Huffman algorithm can be described in five steps: • Find the gray-level probabilities for the image by finding the histogram. • Order the input probabilities (histogram magnitudes) from smallest to largest. • Combine the smallest two by addition. • Repeat step 2, until two probabilities are left. • By working backward the tree, generate the code by alternating assignment of 0 and 1.

  38. ويمكن وصف خوارزمية هوفمان بخمس خطوات:العثور على الاحتمالات على مستوى الرمادي للصورة من خلال العثور على الرسم البياني.ترتيب الاحتمالات الإدخال (المدرجات الرسم البياني) من أصغر إلى أكبر.الجمع بين أصغر اثنين من إضافة.كرر الخطوة 2، حتى يتم ترك اثنين من الاحتمالات.عن طريق العمل إلى الوراء الشجرة، وتوليد التعليمات البرمجية عن طريق التناوب التنازل من 0 و 1.

  39. 50 40 Number of pixels 30 20 10 0 1 2 3 Gray level Huffman Coding (Image example) Example: We have an image with 2 bits/pixel, giving 4 possible gray levels. The image is 10 rows by 10 columns. The histogram of the image is given below:

  40. Huffman Coding (Image example) • Step 1: Find the gray-level probabilities. • g0 = 20/100 = 0.2 • g1 = 30/100 = 0.3 • g2 = 10/100 = 0.1 • g3 = 40/100 = 0.4 • Step 2: Order probabilities from smallest to largest • g3 0.4 • g1 0.3 • g0 0.2 • g2 0.1

  41. + + + Huffman Coding (Image example) • Step 3: Combine the smallest two by addition. • 0.4  0.4 • 0.3  0.3 • 0.2  0.3 0.1 • Step 4: Reorder and add until two values remain. • 0.4  0.4 0.6 • 0.3  0.3 0.4 • 0.2  0.3 • 0.1

  42. Huffman Coding (Image example) • Step 5: Generate the code. The final code is given in the following table.

  43. Huffman Coding (Image example) • Note that the gray-level with the highest probability is assigned the least number of bits. ويلاحظ أن المستوى الرمادي ذي أعلى احتمال يعين أقل عدد من البتات.

  44. Run-Length Coding (Image example) • RLC is an image compression method that works by counting the number of adjacent pixels with the same gray-level value. • This count, called the run length, is then coded and stored. • There are many variations of RLC: • Basic methods: used for binary images • Extended versions: for gray-scale images

  45. رلك هي طريقة ضغط الصور التي تعمل عن طريق عد عدد وحدات البكسل المجاورة بنفس قيمة الرمادي.ثم يتم ترميز هذا العدد، يسمى طول المدى، وتخزينها.هناك العديد من الاختلافات في رلك:الأساليب الأساسية: تستخدم للصور الثنائيةالإصدارات الموسعة: للصور على نطاق رمادي

  46. Run-Length Coding (Image example) • There can be two types of RLC: • Horizontal RLC: count along rows • Vertical RLC: count along columns • The number of bits used for the coding depends on the number of pixels in a row: • If the row has 2n pixels, then the required number of bits is n. • A 256x256 image requires 8 bits, since 28 = 256.

  47. Run-Length Coding (Image example) • The next step is to define a convention for the first RLC number in a row. • Does it represent a run of 0’s or 1’s? • Consider the following binary image:

  48. Run-Length Coding (Image example) • Apply RLC to this image, using: • Horizontal RLC • The first RLC number represents a run of 0’s • The RLC numbers are: • First row: 8 Fifth row: 1,3,2,1,1 • Second row: 0,4,4 Sixth row: 2,1,2,2,1 • Third row: 1,2,5 Seventh row: 0,4,1,1,2 • Fourth row: 1,5,2 Eighth row: 8

  49. Image Compression • popular formats for compressing digital images: 1) GIF (Graphic Interchange Format) Compression • LZW codec forlosslesscompression (8-bit images) • look for repeated horizontal patterns along each scan line • can handle multiple images • TIFF (Tagged Image File Format) Compression • based on LZW method • widely used by a variety of applications and hardware platforms

  50. تنسيقات شعبية لضغط الصور الرقمية:1) جيف (غرافيك إنتيرتشانج فورمات) ضغطالترميز لزو للضغط ضياع (صور 8 بت)والبحث عن أنماط أفقية متكررة على طول كل خط المسح الضوئييمكن التعامل مع صور متعددةتيف (الموسومة تنسيق ملف الصورة) ضغطاستنادا إلى طريقة لزووتستخدم على نطاق واسع من قبل مجموعة متنوعة من التطبيقات والأجهزة المنصات

More Related