Feng Juan's second assignment

Source: Internet
Author: User

Reference Books topic:

2, using the program Huff_enc and Huff_dec to do the following (in each case, the use of compressed images generated by the codebook).

(a) Encode Sena, Sensin, and Omaha images.

(b) Write a procedure to get the difference between adjacent, and then encode the difference image using Huffman.

Give the file size of each experiment and explain the difference.

Solution: (a)

Filename Before compression After compression Compression ratio
Sena 34. 57K 1.14
Sensin 34. 31. 1.06
Omaha 34. 58K 1.12

4. A source selects letters from the symbol set A={A1,A2,A3,A4,A5} with a probability of P (A1) =0.15,p (A2) =0.04,p (A3) =0.26,p (A4) =0.05,p (A5) = 0.50.

(a) Calculate the entropy of the source.

(b) To seek the Huffman code of this source.

(c) Ask for the average length and redundancy of the code in (b).

Solution:

(a) H (a) = -0.15*log20.15-0.04*log20.04-0.26*log20.26-0.05*log20.05-0.50*log20.50

=0.15* 2.737+0.04*4.644+0.26*1.943+0.05*4.322+0.5*1

=0.411+0.186+0.505+0.216+0.5

=1.818 (Bits/symbol)

(b) a1:001

a2:0000

A3:01

a4:0001

A5:1

(c) Average length: l=0.15*3+0.04*4+0.26*2+0.05*4+0.5*1

=0.45+0.16+0.52+0.2+0.5

=1.83 (Bits/symbol)

Redundancy: l-h (A) =1.83-1.818=0.012 (Bits/symbol)

5. A symbol set A={A1,A2,A3,A4}, with a probability of P (A1) =0.1,p (A2) =0.3,p (A3) =0.25,p (A4) = 0.35, use the following procedure to find a Huffman code:

(a) The first process outlined in this chapter;

(b) The minimum variance process.

Explain the differences between the two Huffman codes.

Solution:

(a) The first Huffman code

Symbol

Probability

Code

A1

0.1

000

A2

0.3

01

A3

0.25

001

A4

0.35

1

The second type of Huffman code

Symbol

Code

A1

11

A2

01

A3

10

A4

00

(b) Average code length:

First Huffman code: l=3*0.1+2*0.3+3*0.25+1*0.35=2

The second Huffman code: l=2*0.1+2*0.3+2*0.25+2*0.35=2

Variance:

First type: s2=0.1 (3-2) 2+0.3 (2-2) 2+0.25 (3-2) 2+0.35 (1-2) 2=0.70

Second type: s2=0.1 (2-2) 2+0.3 (2-2) 2+0.25 (2-2) 2+0.35 (2-2) 2 =0

The second type of Huffman code is superior

6, reference book "Introduction to Data Compression (4th edition)" Page 30

6. There are several images and voice files in the accompanying data set in this book.

(a) Write a procedure to calculate the first-order entropy of some of the images and voice files.

(b) Select an image file and calculate its second-order entropy. Try to explain the difference between the first order entropy and the second entropy.

(c) For the image file used in (b), calculate the entropy of the difference of its neighboring pixels. Try to explain your findings.

For:

                 

(b) The first order entropy of the image file is earth.img: 4.770801, the second entropy is: 2.568358

It is known that the first-order entropy of the image is much larger than the second entropy. The second-order compression of files can increase the compression and reduce storage space.

(c) The first order entropy of the image file is earth.img: 4.770801, the second entropy is: 2.568358, the difference entropy is 3.962699

By comparison , the difference entropy is between the first order entropy and the second entropy. For the first order entropy, the difference entropy is an ideal compression algorithm.

Feng Juan's second assignment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.