메뉴
HN
Hacker News 42일 전

데이터 압축의 모든 것: 원리부터 최적화까지

IMP
8/10
핵심 요약

데이터 압축은 데이터 저장과 전송에 필요한 비트 수를 줄이는 기술로, 손실 없는 압축과 손실 압축으로 나뉩니다. 이 책은 정보 이론, 코딩, 모델링, 변환 기법 등 데이터 압축의 핵심 원리와 알고리즘을 심도 있게 다루고 있으며, 최적의 모델링이 인공지능(AI) 문제와도 깊이 연관되어 있음을 강조합니다. 데이터 압축 기술을 이해하고 구현하려는 개발자와 연구자들에게 필수적인 내용을 제공합니다.

번역된 본문

데이터 압축 해설 (Data Compression Explained) - Matt Mahoney 저. Copyright (C) 2010-2012, Dell, Inc. 이 책의 내용을 복사하고 배포할 수 있으며, 단 (1) 배포하는 모든 자료에 이 라이선스가 포함되어 있고, (2) 자료가 수정되지 않았으며, (3) 이 책의 자료를 포함하는 복사본이나 저작물에 대해 요금을 부과하거나 다른 대가를 요구하지 않는다는 조건입니다. 이러한 제한 사항은 총 1페이지 미만의 인용된 발췌문으로 정의되는 일반적인 "공정 사용(fair use)"에는 적용되지 않습니다. 이 책은 http://mattmahoney.net/dc/dce.html 에서 무료로 다운로드할 수 있습니다. 마지막 업데이트: 2013년 4월 15일. 전자책 리더 번역: Alejo Sanchez (2011년 10월 29일): mobi(Kindle) 및 epub(기타 리더).

이 책에 대하여 이 책은 데이터 압축이 어떻게 작동하는지 이해하거나 데이터 압축 소프트웨어를 작성하고자 하는 독자를 위한 것입니다. 기초적인 프로그래밍 능력과 약간의 수학적 기술이 필요합니다. 다루는 구체적인 주제는 다음과 같습니다:

  1. 정보 이론: 범용 압축은 없음, 코딩의 한계, 모델링은 계산 불가능, 압축은 인공지능 문제

  2. 벤치마크: 캘거리 코퍼스(Calgary corpus) 결과

  3. 코딩: 허프만(Huffman), 산술 코딩, 비대칭 이진 수치 코드(단항, 라이스, 골롬, 엑스트라 비트), 아카이브 포맷(오류 감지, 암호화)

  4. 모델링: 고정 차수(바이트 단위, 비트 단위, 간접), 가변 차수(DMC, PPM, CTW), 문맥 혼합(선형 혼합, 로지스틱 혼합, SSE, 간접 SSE, 일치, PAQ, ZPAQ, Crinkler)

  5. 변환: RLE, LZ77(LZSS, deflate, LZMA, LZX, ROLZ, LZP, 스내피, 중복 제거), LZW 및 사전 인코딩, 기호 순위 지정, BWT(문맥 정렬, 역변환, bzip2, BBB, MSufSort v2 및 v3, Itoh-Tanaka, DivSufSort, Bijective), 예측 필터링(델타 코딩, 색상 변환, 선형 필터링), 특수 변환(E8E9, 사전 컴파일), 허프만 사전 코딩

  6. 손실 압축: 이미지(BMP, GIF, PNG, TIFF, JPEG), JPEG 재압축(Stuffit, PAQ, WinZIP PackJPG), 비디오(NTSC, MPEG), 오디오(CD, MP3, AAC, 돌비, 보비스) 결론, 감사의 글, 참고 문헌 이 책은 자체적으로 완결성을 갖추도록 의도되었습니다. 적절한 곳에 출처가 링크되어 있지만, 내용을 이해하기 위해 이를 클릭할 필요는 없습니다.

  7. 정보 이론 데이터 압축은 데이터를 저장하거나 전송하는 데 필요한 비트 수를 줄이는 기술입니다. 압축은 무손실(lossless) 또는 손실(lossy) 방식으로 이루어질 수 있습니다. 무손실 압축된 데이터는 정확히 원래 값으로 압축 해제될 수 있습니다. 그 예로 1848년 모스 부호가 있습니다. 알파벳의 각 글자는 점과 선의 시퀀스로 코딩됩니다. 영어에서 가장 흔한 글자인 E와 T는 가장 짧은 코드를 받습니다. 가장 드문 J, Q, X, Z는 가장 긴 코드가 할당됩니다. 모든 데이터 압축 알고리즘은 최소한 하나의 모델과 코더(선택적 전처리 변환 포함)로 구성됩니다. 모델은 확률 분포를 추정합니다(E가 Z보다 더 흔함). 코더는 가능성이 높은 기호에 더 짧은 코드를 할당합니다. 코딩 문제에는 효율적이고 최적의 솔루션이 존재합니다. 그러나 최적의 모델링은 계산 불가능한 것으로 증명되었습니다. 모델링(또는 이에 상응하는 예측)은 인공지능(AI) 문제이자 예술의 영역입니다. 손실 압축은 눈이나 귀에 인식되지 않는 이미지나 오디오 클립의 세부 정보와 같은 "중요하지 않은" 데이터를 버립니다. 2009년까지 사용된 1953년 방송용 컬러 TV의 NTSC 표준이 그 예입니다. 인간의 눈은 밝기(흑백)에 대해 민감한 반면, 동일한 밝기를 가진 색상(빨간색과 녹색 등) 간의 미세한 차이에는 덜 민감합니다. 따라서 컬러 신호는 흑백 신호보다 좁은 주파수 대역을 통해 더 낮은 해상도로 전송됩니다. 손실 압축은 중요한 데이터와 중요하지 않은 데이터를 분리하는 변환으로 시작하여, 이후 중요한 부분을 무손실 압축하고 나머지는 버리는 방식으로 진행됩니다. 인간의 뇌가 인식할 수 있는 것과 없는 것을 이해해야 하므로, 이러한 변환은 인공지능(AI) 문제이기도 합니다. 정보 이론은 무손실 압축이 가능한 것과 불가능한 것, 그리고 어느 정도까지 가능한지에 대한 명확한 한계를 설정합니다.

원문 보기
원문 보기 (영어)
Data Compression Explained Matt Mahoney Copyright (C) 2010-2012, Dell, Inc . You are permitted to copy and distribute material from this book provided (1) any material you distribute includes this license, (2) the material is not modified, and (3) you do not charge a fee or require any other considerations for copies or for any works that incorporate material from this book. These restrictions do not apply to normal "fair use", defined as cited quotations totaling less than one page. This book may be downloaded without charge from http://mattmahoney.net/dc/dce.html . Last update: Apr. 15, 2013. e-reader translations by Alejo Sanchez, Oct. 29, 2011: mobi (Kindle) and epub (other readers). About this Book This book is for the reader who wants to understand how data compression works, or who wants to write data compression software. Prior programming ability and some math skills will be needed. Specific topics include: 1. Information theory No universal compression Coding is bounded Modeling is not computable Compression is an artificial intelligence problem 2. Benchmarks Calgary corpus results 3. Coding Huffman arithmetic asymmetric binary numeric codes ( unary , Rice, Golomb , extra bit ) archive formats ( error detection , encryption ) 4. Modeling Fixed order : bytewise bitwise , indirect Variable order : DMC , PPM , CTW Context mixing : linear mixing , logistic mixing , SSE , indirect SSE , match , PAQ , ZPAQ , Crinkler 5. Transforms RLE LZ77 ( LZSS , deflate , LZMA , LZX , ROLZ, LZP , snappy , deduplication ) LZW and dictionary encoding Symbol ranking BWT ( context sorting , inverse , bzip2 , BBB , MSufSort v2 and v3 , Itoh-Tanaka , DivSufSort , Bijective ) Predictive filtering ( delta coding , color transform , linear filtering ) Specialized transforms ( E8E9 , precomp ) Huffman pre-coding 6. Lossy compression Images ( BMP , GIF , PNG , TIFF , JPEG ) JPEG recompression ( Stuffit , PAQ , WinZIP PackJPG ) Video ( NTSC , MPEG ) Audio (CD, MP3, AAC, Dolby, Vorbis) Conclusion Acknowledgements References This book is intended to be self contained. Sources are linked when appropriate, but you don't need to click on them to understand the material. 1. Information Theory Data compression is the art of reducing the number of bits needed to store or transmit data. Compression can be either lossless or lossy. Losslessly compressed data can be decompressed to exactly its original value. An example is 1848 Morse Code . Each letter of the alphabet is coded as a sequence of dots and dashes. The most common letters in English like E and T receive the shortest codes. The least common like J, Q, X, and Z are assigned the longest codes. All data compression algorithms consist of at least a model and a coder (with optional preprocessing transforms). A model estimates the probability distribution (E is more common than Z). The coder assigns shorter codes to the more likely symbols. There are efficient and optimal solutions to the coding problem. However, optimal modeling has been proven not computable. Modeling (or equivalently, prediction) is both an artificial intelligence (AI) problem and an art. Lossy compression discards "unimportant" data, for example, details of an image or audio clip that are not perceptible to the eye or ear. An example is the 1953 NTSC standard for broadcast color TV, used until 2009. The human eye is less sensitive to fine detail between colors of equal brightness (like red and green) than it is to brightness (black and white). Thus, the color signal is transmitted with less resolution over a narrower frequency band than the monochrome signal. Lossy compression consists of a transform to separate important from unimportant data, followed by lossless compression of the important part and discarding the rest. The transform is an AI problem because it requires understanding what the human brain can and cannot perceive. Information theory places hard limits on what can and cannot be compressed losslessly, and by how much: There is no such thing as a "universal" compression algorithm that is guaranteed to compress any input, or even any input above a certain size. In particular, it is not possible to compress random data or compress recursively. Given a model (probability distribution) of your input data, the best you can do is code symbols with probability p using log 2 1/p bits. Efficient and optimal codes are known. Data has a universal but uncomputable probability distribution. Specifically, any string x has probability (about) 2 -|M| where M is the shortest possible description of x, and |M| is the length of M in bits, almost independent of the language in which M is written. However there is no general procedure for finding M or even estimating |M| in any language. There is no algorithm that tests for randomness or tells you whether a string can be compressed any further. 1.1. No Universal Compression This is proved by the counting argument . Suppose there were a compression algorithm that could compress all strings of at least a certain size, say, n bits. There are exactly 2 n different binary strings of length n. A universal compressor would have to encode each input differently. Otherwise, if two inputs compressed to the same output, then the decompresser would not be able to decompress that output correctly. However there are only 2 n - 1 binary strings shorter than n bits. In fact, the vast majority of strings cannot be compressed by very much. The fraction of strings that can be compressed from n bits to m bits is at most 2 m - n . For example, less than 0.4% of strings can be compressed by one byte. Every compressor that can compress any input must also expand some of its input. However, the expansion never needs to be more than one symbol. Any compression algorithm can be modified by adding one bit to indicate that the rest of the data is stored uncompressed. The counting argument applies to systems that would recursively compress their own output. In general, compressed data appears random to the algorithm that compressed it so that it cannot be compressed again. 1.2. Coding is Bounded Suppose we wish to compress the digits of π, e.g. "314159265358979323846264...". Assume our model is that each digit occurs with probability 0.1, independent of any other digits. Consider 3 possible binary codes: Digit BCD Huffman Binary ---- ---- ---- ---- 0 0000 000 0 1 0001 001 1 2 0010 010 10 3 0011 011 11 4 0100 100 100 5 0101 101 101 6 0110 1100 110 7 0111 1101 111 8 1000 1110 1000 9 1001 1111 1001 --- ---- ---- ---- bpc 4.0 3.4 not valid Using a BCD (binary coded decimal) code, π would be encoded as 0011 0001 0100 0001 0101... (Spaces are shown for readability only). The compression ratio is 4 bits per character (4 bpc). If the input was ASCII text, the output would be compressed 50%. The decompresser would decode the data by dividing it into 4 bit strings. The Huffman code would code π as 011 001 100 001 101 1111... The decoder would read bits one at a time and decode a digit as soon as it found a match in the table (after either 3 or 4 bits). The code is uniquely decodable because no code is a prefix of any other code. The compression ratio is 3.4 bpc. The binary code is not uniquely decodable. For example, 111 could be decoded as 7 or 31 or 13 or 111. There are better codes than the Huffman code given above. For example, we could assign Huffman codes to pairs of digits. There are 100 pairs each with probability 0.01. We could assign 6 bit codes (000000 through 011011) to 00 through 27, and 7 bits (0111000 through 1111111) to 28 through 99. The average code length is 6.72 bits per pair of digits, or 3.36 bpc. Similarly, coding groups of 3 digits using 9 or 10 bits would yield 3.3253 bpc. Shannon and Weaver (1949) proved that the best you can do for a symbol with probability p is assign a code of length log 2 1/p. In this example, log 2 1/0.1 = 3.3219 bpc. Shannon defined the expected information content or equivocation (now called