当前位置:网站首页>Hefei University of technology information theory and coding course design, including code, visual interface, course design report

Hefei University of technology information theory and coding course design, including code, visual interface, course design report

2022-07-23 05:20:00 Martin_ ctf

Course design of information theory and coding in Hefei University of Technology , With code , Visual interface , Course design report

Students who want the source code click here

It must be done

Binary Huffman coding is applied to any input string sequence 、fano code 、 Run length coding and Arithmetic coding , Give the coding result 、 Coding efficiency ; And realize the corresponding decoding operation .

Choose a question

Yes, one BMP First, binary Huffman coding and run length coding are carried out for the gray-scale image of format , According to the result of Huffman coding, the run length coding is transformed into binary sequence .( Pixels are encoded by Hoffman , Run with equal length code ). And design the corresponding decoding .

Development tools and environments

Editing tools :Visual Studio Code
Compiler tools :python 3.9.7
Interface tools :PyQt5 designer
The library used :math; Pillow 8.4.0; PyQt5 5.15.4;

Module partition

As shown in the figure below , There are five buttons , Realize the corresponding functions of five topics , Call five python File for corresponding coding . Enter the encoded string in the text box , Click on different buttons , You can get the character and its corresponding code , Coding results , Decoding result and coding efficiency .Huffman Encoded as Huffman.py,Fano Encoded as fano.py, The run length code is run_length2.py, The arithmetic code is signal.py, The gray image is encoded as bmp_huffman.py, The source file of the main interface is main.ui and UI_main.py, The main function is main.py Be responsible for unified management of coding program and interface program . The following figure shows the main window of the software :

The following is the module division of each sub file :

Huffman.py The division of modules

The name of the function Function input Output function
Class nodeHuffman Node parameters A node
get_text_count() Encoded string Characters and corresponding probabilities
create_nodes() Character string Node list
create_huffman_tree() Node list Huffman Trees and root nodes
huffman_encoding() Character frequency and Huffman Trees The string and average code length of each node
encode_str() Text and node list Encoded string
decode_str() Encoded string and node list Decoded string
get_H() Characters and corresponding probabilities The entropy of the source

fano.py The division of modules

The name of the function Function input Output function
Class nodefano Node parameters A node
get_text_count() Encoded string Characters and corresponding probabilities
create_nodes() Character string Node list
fano_encode() Node list and character corresponding probability Each node is compiled into a string
encode_str() Text and node list Encoded string
decode_str() List of encoded string nodes Decoded string
get_H() Characters and corresponding probabilities The entropy of the source
get_average_code_length() Node list Average code length

run_lenggth2.py Module partition

The name of the function Function input Output function
get_text_count() Encoded string Characters and corresponding probabilities
get_max_bin_length() Encoded string Maximum binary length of run length code
encode_str() Encoded string and run list Encoded string
decode_str() Encoded string and run list Decoded string
get_H() Characters and corresponding probabilities The entropy of the source

signal.py The division of modules

The name of the function Function input Output function
get_text_count() Encoded string The entropy and average code length of characters and their corresponding probabilities and sources
encode_str() The corresponding probability of encoded string and character Decimal decimals compiled
ten2bin() Decimal number Binary decimals
decode_str() The corresponding probability of decimal decimals and characters Decoded string

bmp_huffman.py The division of modules

The name of the function Function input Output function
Class nodeHuffman Node parameters A node
get_image_list() Image path ( Images ) List of pixel values , Itinerary list , Maximum binary length
get_image_list_count() List of pixel values A character , Frequency dictionary and corresponding character probability
create_nodes() Character string Node list
create_huffman_tree() Node list Huffman Trees and root nodes
huffman_encoding() Character frequency and Huffman Trees The string and average code length of each node
encode_str() List of pixel values , Node list , Run table Encoded string
decode_str() Encoded string and node list Decoded string
get_H() Characters and corresponding probabilities The entropy of the source
get_average_length() Run list and node list Average code length
compare() Image path , Decode string and pixel value list Whether the decoding is consistent

Interface function

As shown in the figure Click the corresponding button to realize the corresponding function

 Insert picture description here  Insert picture description here Students who want the source code click here
Students who want the source code click here
Students who want the source code click here

原网站

版权声明
本文为[Martin_ ctf]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207221753570494.html