当前位置:网站首页>[coding and decoding] Huffman coding and decoding based on Matlab GUI [including Matlab source code 1976]
[coding and decoding] Huffman coding and decoding based on Matlab GUI [including Matlab source code 1976]
2022-07-28 04:09:00 【Poseidon light】
One 、 How to get the code
How to get the code 1:
The complete code has been uploaded to my resources :【 Coding and decoding 】 be based on matlab GUI Hoffman Huffman Coding and decoding 【 contain Matlab Source code 1976 period 】
How to get the code 2:
By subscribing to Ziji Shenguang blog Paid column , With proof of payment , Private Blogger , This code is available .
remarks :
Subscribe to Ziji Shenguang blog Paid column , Free access to 1 Copy code ( The period of validity From the Subscription Date , Valid for three days );
Two 、 Research on the implementation method of Huffman coding
In today's information explosion , The importance of data compression is self-evident , There are three steps in the basic process : Modeling expression 、 Quadratic quantization and entropy coding . Entropy coding is also called redundancy compression . Statistical coding is an important part of entropy coding , It mainly includes Hoffman (Huffman) code 、 Run length encoding 、 Binary source code 、 Arithmetic coding 、LZW Coding, etc . This article takes Huffman As a representative of entropy coding , Introduce about Huffman Specific implementation method of coding .
1 introduction
1.1 The numerical transmission system model is shown in Figure 1 Shown .
chart 1 Digital transmission system model
1.2 Source code :
Mainly to solve the problem of effectiveness . By compressing the source 、 disturb 、 Encryption and a series of processing , Strive to transmit the maximum amount of information with the least number , Make the signal more suitable for transmission .
1.3 data compression
It is to represent the signal sent by the source with the least number , Reduce the signal space for a given set of messages or data samples .
2 Statistical coding
Reversible compression, which is common to all kinds of sources ( Lossless coding ) Method , Because most computer files are not allowed to lose information during compression . This kind of method mainly uses the distribution characteristics of the probability of information or information sequence , Pay attention to finding the optimal match between probability and codeword length , This is called statistical coding or probability matching coding . And Hoffman (Huffman) Coding is one of the representative coding schemes [1].
3 Hoffman (Huffman) Coding principle
Huffman Encoding is 1952 Established in for text files , It's a statistical code . It is completely based on the probability of the occurrence of characters to construct the acronym codeword with the shortest average length , It belongs to lossless compression coding .Huffman The code length of the code is variable , For information with high probability of occurrence , The length of the code is short ; For information with low probability of occurrence , The encoding length is long . such , The total code length of processing all information must be less than the symbol length of the actual information [2]. Method 、 step : (1) The probability of the occurrence of the symbol of the signal source ( Here it is called weight ) {w1, w2, …, wn} Constructed as n A collection of binary trees F={T1, T2, …, Tn}, Each of them is a binary tree Ti Only one of them has the right to wi Root node of , Its left and right subtrees are empty . (2) stay F Select two trees with the smallest weight of root node as left and right subtrees to construct a new binary tree , And set the weight of the root node of the new binary tree to its left 、 The sum of the weights of the root node on the right subtree . (3) stay F Delete these two trees , At the same time, add the new binary tree F in . (4) repeat (2) and (3) , until F Only one tree . This tree is Hoffman (Huffman) Trees . (5) In the merge, the root node with small weight is agreed to be on the left subtree , The one with large weight is on the right subtree . Then mark each left branch as “0”, The right branch is marked “1”. The last record from Hoffman (Huffman) From the root node of the tree to the branch passed by each leaf node “0” or “1” Sequence , So as to get the Huffman code .[3]
The average codeword length of the above encoding R= (2+2+2+3+3) /5=2.4. explain : because “1” and “0” The designation of is arbitrary , Therefore, the best code compiled by the above process is not unique , But the average code length is the same , Therefore, it does not affect the coding efficiency and data compression performance .
3、 ... and 、 Partial source code
function varargout = Mianhuffman_GUI(varargin)
% MIANHUFFMAN_GUI M-file for Mianhuffman_GUI.fig
% MIANHUFFMAN_GUI, by itself, creates a new MIANHUFFMAN_GUI or raises the existing
% singleton*.
%
% H = MIANHUFFMAN_GUI returns the handle to a new MIANHUFFMAN_GUI or the handle to
% the existing singleton*.
%
% MIANHUFFMAN_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MIANHUFFMAN_GUI.M with the given input arguments.
%
% MIANHUFFMAN_GUI('Property','Value',...) creates a new MIANHUFFMAN_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before huffman_GUI_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Mianhuffman_GUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Mianhuffman_GUI
% Last Modified by GUIDE v2.5 10-Jul-2022 18:54:24
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Mianhuffman_GUI_OpeningFcn, ...
'gui_OutputFcn', @Mianhuffman_GUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(varargin{
1})
gui_State.gui_Callback = str2func(varargin{
1});
end
if nargout
[varargout{
1:nargout}] = gui_mainfcn(gui_State, varargin{
:});
else
gui_mainfcn(gui_State, varargin{
:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Mianhuffman_GUI is made visible.
function Mianhuffman_GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Mianhuffman_GUI (see VARARGIN)
% Choose default command line output for Mianhuffman_GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Mianhuffman_GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Mianhuffman_GUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{
1} = handles.output;
% --- Executes during object creation, after setting all properties.
function xylj_CreateFcn(hObject, eventdata, handles)
% hObject handle to xylj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function xylj_Callback(hObject, eventdata, handles)
% hObject handle to xylj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of xylj as text
% str2double(get(hObject,'String')) returns contents of xylj as a double
% --- Executes on button press in dqxy.
function dqxy_Callback(hObject, eventdata, handles)
% hObject handle to dqxy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[Filename Pathname]=uigetfile({
'*.txt'},' Please select a file '); % Select the file box function
str=[Pathname Filename]; % Get the path and file name
xinyuan=textread(str,'%s'); % In the form of strings , Read in a text file
xinyuan=xinyuan{
:}; % take cell Type data into char
set(handles.xylj,'string',str) % Show the path of the source
set(handles.xy,'string',xinyuan) % Show source
% --- Executes during object creation, after setting all properties.
function xy_CreateFcn(hObject, eventdata, handles)
% hObject handle to xy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
Four 、 Running results

5、 ... and 、matlab Edition and references
1 matlab edition
2014a
2 reference
[1] Zhang Chenglin . Research on the implementation method of Huffman coding [J]. Education and Teaching Forum . 2013,(26)
3 remarks
This part of the introduction is taken from the Internet , For reference only , If infringement , Contact deletion
边栏推荐
- Machine learning 07: Bayesian learning
- Chinese Remainder Theorem of X problem
- 21天,胖哥亲自带你玩转OAuth2
- CV2. Threshold(), CV2. Findcontours(), CV2. Findcontours image contour processing
- Network visualization: features of convolution kernel and CNN visualization (through the attention part of gradient visualization network)
- 金仓数据库KingbaseES安全指南--5.1. 数据库的传输安全
- [image classification] 2021 MLP mixer nips
- ServletContext、request、response
- What is interface testing and its testing process
- 金仓数据库KingbaseES安全指南--6.2. 身份验证相关的配置文件
猜你喜欢

ESP8266 WIFI 模块和手机通信

《Intel Arria 10 Avalon-MM DMA Interface for PCI Express Solutions User Guide》文档学习

Common weak network testing tools

【无标题】

【无标题】

Embedded development: tips and techniques -- the best practice of defensive programming with C

Go structure

Summary and interpretation of CONDA virtual environment
![Error no matching function for call to 'std:: exception:: exception (const char [15])' problem solving](/img/d1/2fbdf42cf60b5382b5a35c64b172b9.png)
Error no matching function for call to 'std:: exception:: exception (const char [15])' problem solving

仿真测试断开服务器公网连接
随机推荐
Iterator function operation of iterator learning
Kingbasees security guide of Jincang database -- 6.2. Configuration files related to authentication
servlet使用
7/27 (board) dyeing method to determine bipartite graph + find combination number (recursive formula)
Istio's Traffic Management API
程序人生 | 测试工程师还只会点点点?7个捷径教给你快速学习新技术...
一名合格的软件测试工程师,应该具备哪些技术能力?
un7.27:如何在idea中成功搭建若依框架项目?
openpose的一些个人理解
C#跨线程刷新前台UI
Analysis of static broadcast transmission process
金仓数据库KingbaseES安全指南--6.2. 身份验证相关的配置文件
月薪28K学员 自动化测试经验分享
What is interface testing and its testing process
40: Chapter 4: Development File Service: 1:fastdfs: (1): introduction to fastdfs;
Chinese Remainder Theorem of X problem
超好用的 PC 端长截图工具
Selenium -- Web automated testing tool
【图像分类】2021-MLP-Mixer NIPS
Redis cluster