1 / 76

การบีบอัดข้อมูลภาพ ( Image Compression )

การบีบอัดข้อมูลภาพ ( Image Compression ). Outline. วัตถุประสงค์ของการบีบอัดข้อมูล ความซ้ำซ้อนของการแทนค่าข้อมูล แบบจำลองของการบีบอัดข้อมูลภาพ ทฤษฎีข่าวสารเบื้องต้น การบีบอัดแบบไม่สูญเสียข่าวสาร การบีบอัดแบบสูญเสียข่าวสาร JPEG. วัตถุประสงค์

greta
Télécharger la présentation

การบีบอัดข้อมูลภาพ ( Image 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. การบีบอัดข้อมูลภาพ (Image Compression)

  2. Outline • วัตถุประสงค์ของการบีบอัดข้อมูล • ความซ้ำซ้อนของการแทนค่าข้อมูล • แบบจำลองของการบีบอัดข้อมูลภาพ • ทฤษฎีข่าวสารเบื้องต้น • การบีบอัดแบบไม่สูญเสียข่าวสาร • การบีบอัดแบบสูญเสียข่าวสาร • JPEG

  3. วัตถุประสงค์ การลดความซ้ำซ้อนของข้อมูล(redundancy)ในรูปแบบต่างๆในขณะเดียวกันก็ยังคงคุณภาพที่ดีของภาพไว้

  4. ความซ้ำซ้อนของข้อมูล(Data Redundancy) • ความซ้ำซ้อนของการแทนค่าข้อมูล • ความซ้ำซ้อนทางตำแหน่ง • ความซ้ำซ้อนของข้อมูลอันเกิดจากข้อจำกัดของความสามารถทางด้านการรับรู้ภาพ

  5. ความซ้ำซ้อนของการแทนค่าข้อมูล (coding redundancy) • โดยจุดภาพที่เกิดขึ้นบ่อยจะต้องถูกแทนด้วยข้อมูลที่มีจำนวนบิตที่สั้นจุดภาพที่เกิดขึ้นไม่บ่อยจะถูกแทนด้วยข้อมูลที่มีจำนวนบิตที่ยาวกว่า • เป็นการกระทำแบบกลับคืนได้(reversible)

  6. ความซ้ำซ้อนทางตำแหน่ง (spatial or inter-pixel redundancy) • เปรียบเทียบลักษณะทางแสงของจุดภาพใดๆและจุดภาพเพื่อนบ้านข้างเคียงถ้าจุดภาพคู่ใดมีความเหมือนกันเราสามารถลดความซ้ำซ้อนของข้อมูลตรงบริเวณนี้ได้ • เป็นการกระทำแบบกลับคืนได้(reversible)

  7. 200 200 200 200 200 201 201 200 200 200 200 200 201 201 200 200 200 200 200 201 201 200 200 200 200 201 201 201 200 200 200 200 200 200 201 201 201 200 200 200 200 201 201 201 201 201 201 201 201

  8. ความซ้ำซ้อนของข้อมูลอันเกิดจากข้อจำกัดของความสามารถทางด้านการรับรู้ภาพ (visual or psycho-visual redundancy) • เกิดจากข้อจำกัดของความสามารถทางด้านการรับรู้ภาพของมนุษย์(Human Visual System - HVS) • เป็นการกระทำแบบกลับคืนไม่ได้(non-reversible)

  9. 100 100 100 104 104 104 104 100 100 100 104 104 104 104 104 100 100 104 104 104 104 100 100 104 104 104 104 104 100 100 104 104 104 104 104 100 100 100 104 104 104 104 100 200 100 104 104 104 104

  10. Encoder Decoder Source Encoding Channel Decoding Source Decoding Channel Encoding Channel Screen Display Save As Bus

  11. Encoder Decoder Source Encoding Channel Decoding Source Decoding Channel Encoding Channel Truncation FT SymbolicEncoding Mapper Quantization การเข้ารหัส “0” และ “1”

  12. แบบจำลองของการบีบอัดข้อมูลภาพ(Image Compression Models) • Source Coding: Coding for efficient representation of information. (Also called Compression) • Channel Coding: Coding for error free transmission of information through a noisy medium

  13. ทฤษฎีข่าวสารเบื้องต้น(Elements of Information Theory) • ข้อมูล(data) • ข่าวสาร(information) • การบีบอัดข้อมูลจะแทนข้อมูลเดิมด้วยสัญลักษณ์(symbol)หรือcode wordหรือletterซึ่งเป็นข้อมูลใหม่

  14. ค่าเฉลี่ยของจำนวนบิตที่ต้องใช้สำหรับข้อมูลที่กำลังพิจารณาค่าเฉลี่ยของจำนวนบิตที่ต้องใช้สำหรับข้อมูลที่กำลังพิจารณา • ข่าวสารที่ถูกบรรทุกมากับข้อมูลE ซึ่งเรียกว่าthe self-informationของEจะอยู่ในรูปของ • เมื่อพิจารณาฐาน x=2

  15. entropy หรือความไม่เป็นระเบียบ(disorder)หรือความไม่แน่นอน(uncertainty)ของข่าวสารที่มากับข้อมูลE • ความสัมพันธ์ระหว่างthe self-informationและEntropy

  16. E = {1 2 1 2 3 3 3 3 1 2 3 3 3 3 1 2 3 3 1 2} • ก่อนการบีบอัด • 1 แทนด้วย 01, 2 แทนด้วย 10,3 แทนด้วย 11 • ความยาวบิตข้อมูลเฉลี่ย n1=2 • หลังการบีบอัด • P(1) = 5/20 = 1/4, • P(2) = 5/20 = 1/4, หาProbability • P(3) = 10/20 = ½

  17. หลังการบีบอัด • จาก จะได้

  18. หลังการบีบอัด • จาก จะได้ • bits • 1 แทนด้วย 01, 2 แทนด้วย 10,3 แทนด้วย 1 • ความยาวบิตข้อมูลเฉลี่ย n2=1.5

  19. Compression Ratio • Relative Data Redundancy

  20. Lossless and Lossy Compression • Lossless Compression: • No loss of information • Original data exactly recovered from compressed data • Lower compression ratio • Lossy Compression: • Loss of information • Perceptual loss of information reduced (controlled) • Higher compression ratio

  21. Encoder Decoder Source Encoding Channel Decoding Source Decoding Channel Encoding Channel Lossy Compression SymbolicEncoding Mapper Quantization Lossless Compression

  22. Taxonomy of Image Compression Lossless Coding techniques (Entropy Coding) Repetitive Sequence Encoding Lossless Predictive Coding StatisticalEncoding Bitplane Encoding RLE Huffman ArithmeticLZW DPCM

  23. Taxonomy of Image Compression Lossy Coding techniques (Source Coding) Block Truncation Coding Lossy PredictiveCoding Transform Coding Subband Coding Fractal Coding Vector quantization DPAM ADPCM Delta modulation DFTDCT Haar Hadamard Subbands Wavelets

  24. Lossless Compression

  25. 1) Huffman Coding • คำนวณความน่าจะเป็นของข้อมูล • เรียงลำดับข้อมูลตามค่าความน่าจะเป็น • กำหนดสัญลักษณ์ที่ข้อมูลคู่ท้ายสุด • รวมค่าความน่าจะเป็นของข้อมูลคู่ท้ายสุด ใส่ผลลัพธ์ในคอลัมน์ใหม่ทางขวา • สร้างสัญลักษณ์ (เข้ารหัส) โดยไล่ย้อนกลับลูกศร

  26. ตัวอย่างจงใช้วิธีHuffman Codingทำการบีบอัดข้อมูลต่อไปนี้โดยใช้alphabet A = {a1, a2, a3, a4, a5} โดยที่กำหนดให้ค่าความน่าจะเป็นของการเกิดของแต่ละข้อมูล คือ • P(a1) = P(a3) = 0.2, • P(a2) = 0.4 และ • P(a4) = P(a5) = 0.1

  27. ก่อนการเข้ารหัส1101 1111 1110 1001 0010 ข้อมูล A = {a1, a2, a3, a4, a5} ใช้เนื้อที่ในการจัดเก็บข้อมูลละ 4 บิต จะได้ n1 = 4x5 = 20 bits……..(1)

  28. 0011 0010 000 01 1

  29. หลังการเข้ารหัส a1ใช้เนื้อที่ในการจัดเก็บ 2 บิต a2 ใช้เนื้อที่ในการจัดเก็บ 1 บิต a3 ใช้เนื้อที่ในการจัดเก็บ 3 บิต a4 ใช้เนื้อที่ในการจัดเก็บ 4 บิต a5 ใช้เนื้อที่ในการจัดเก็บ 4 บิต จะได้ n2 = 14 bits……..(2)

  30. Compression Ratio • Relative Data Redundancy

  31. จงบีบอัดจุดภาพต่อไปนี้ด้วยวิธี Huffmann พร้อมคำนวณหา CR

  32. N1 = 512 bits • P(50)=14/64 P(51)=10/64 • P(52)=12/64 P(53)=9/64 • P(54)=6/64 P(55)=5/64 • P(56)=4/64 P(57)=4/64

  33. 000 011 010 0000 011 0001

  34. 1 0 00 01 1 01 0 00 1 0 000 01 10 000 11 1 010 001 011

  35. N1 = 512 bits • จำนวน P(50)=14x2=28 bits • จำนวน P(51)=10x3=30 bits • จำนวน P(52)=12x2=24 bits • จำนวน P(53)=9x3=27 bits • จำนวน P(54)=6x4=24 bits N2 = 185 bits • จำนวน P(55)=5x4=20 bits • จำนวน P(56)=4x4=16 bits • จำนวน P(57)=4x4=16 bits

  36. 2) Run-length Coding (RLC) - RLE • ลักษณะการ scan • แบบจบบรรทัด(คอลัมน์)แล้วตั้งต้นใหม่ • แบบ Zigzag • สร้างคู่ลำดับ (ค่าความเข้ม,จำนวนจุดภาพ) • หาจำนวนบิตที่ใช้เก็บค่าความเข้ม • หาจำนวนบิตที่ใช้เก็บตัวเลขจำนวนจุดภาพ

  37. Ex ภาพ b/w ก่อนการเข้ารหัส n1 = 49 บิต

  38. ให้ scan แบบ zigzag ในแนวระดับ • จะได้ (0;7),(1;25),(0;6),(1;4),(0;7) • ใช้เนื้อที่ n2 = (1+5) x 5 วงเล็บ = 30 bits

  39. Compression Ratio • Relative Data Redundancy

  40. 3) Lossless Predictive Coding • แบบจบบรรทัด(คอลัมน์)แล้วตั้งต้นใหม่ (เก็บค่าความเข้มที่จุดตั้งต้นทุกบรรทัด(คอลัมน์)) • แบบ zigzag (เก็บค่าความเข้มที่จุดตั้งต้นตัวเดียว) • หาผลต่างระหว่างความเข้มของจุดข้างหน้าและหลัง • ส่งข้อมูลเหล่านี้เลย หรือ • เข้าสัญลักษณ์โดยใช้ Huffman Codingอีกครั้ง

  41. Ex • ภาพ gray-scale • Pixel ละ 8 bits ก่อนการเข้ารหัส n1 = 8x25 = 200 บิต

  42. กรณีส่งผลต่างโดยตรง • แบบ zigzag ในแนวระดับ • จะได้ 100: 0, 2, 1, 1, -1, 0, -1, -1, 0, 0, 0, 2, 1, 0, 0, 0, -1, -1, -1, 0, -1, 2, 2, 0 • n2 = (1x8 + (24x3)) = 80 bits • 2 

  43. Compression Ratio • Relative Data Redundancy

  44. กรณีนำผลต่าง (-1,0,1,2) มาเข้ารหัสโดยใช้ Huffman Coding ก่อนแล้วส่งไป

  45. พบว่า 0 แทนด้วยรหัส ‘0’, • -1 แทนด้วยรหัส ‘11’, • 2 แทนด้วยรหัส ‘100’, และ • 1 แทนด้วยรหัส ‘101’ • n2 = (10x1)+(7x2)+(4x3)+(3x3)+8 = 53 • 0 -1 1 2 ตัวหน้า

  46. Compression Ratio • Relative Data Redundancy

  47. 4) Lossless Block CodingหรือDictionary Coding ต้องการเข้ารหัสข้อมูลต่อไปนี้ abracadabra ซึ่ง n1 = 11x3 = 33 bits

  48. เริ่มต้นด้วยการอ่านข้อมูล3 ตัวอักษรคือabrแล้วตรวจสอบกับdictionaryซึ่งไม่พบในdictionaryให้ลดความยาวข้อความลงเป็น2ตัวคือab แล้วตรวจสอบกับdictionary อีกครั้งและแทนข้อมูลนี้ด้วยรหัส 101 (abracadabra)

  49. 2. จากนั้นอ่านข้อมูล3ตัวถัดไปคือ rac ซึ่งไม่พบในdictionaryจึงต้องพิจารณาข้อมูลนี้เพียง2ตัวคือra ซึ่งไม่พบในdictionary อีกเช่นกัน จึงแทนrด้วย 100 (abracadabra)

More Related