[Image compression] based on matlab GUI multi-level tree set split sorting spiht image compression [including Matlab source code 2688]

⛄1. Multilevel tree set splitting

Research and Matlab implementation of Set Partitioning in Hierarchical Trees (SPIHT) algorithm. Since EZW is the basis of SPIHT, based on the Matlab code of EZW algorithm, I quickly completed the code writing of SPIHT, but the most painful thing is that I didn't understand the principle of the algorithm at the beginning, and the program made a mistake in the initial diversity. After two days of debugging, I couldn’t find the root problem. Yesterday, I looked at the algorithm principle again from the beginning, and found the problem... Hehe, a little carelessness has delayed my time and energy for two or three days! After the problem was solved, I wrote the program comments. Last time, I didn’t write any comments for the code of the EZW algorithm. It made everyone look hard, sorry! Well, let's start to discuss the principle of the SPIHT algorithm, and then give the specific Matlab code.

1 SPIHT Algorithm and EZW Algorithm
EZW algorithm is an embedded image coding algorithm based on zero tree. Although in wavelet transform coefficients, zero tree is a relatively effective data structure representing unimportant coefficients. However, in wavelet coefficients There is also a tree structure whose root is important and other nodes other than the root are unimportant. For such a coefficient structure, the zero tree is not a very effective representation. A. Said and WAPearlman proposed a new and better performance implementation method based on the basic idea of ​​Shapiro Zero Tree Coding Algorithm (EZW), which is based on Set Partitioning in Hierarchical Trees (SPIHT) encoding algorithm. It uses the concepts of spatial orientation tree (SOT: spatial orientation tree), all descendants set D(i,j) and non-direct descendants set L(i,j) to more effectively represent the coefficient structure of the above features, thereby improving the Coding efficiency.
The SPIHT algorithm can generate an embedded bit stream, so that when the received bit stream is interrupted at any point, the image can be decompressed and reconstructed, and has good progressive transmission characteristics; the initialization process and refinement process of the algorithm are similar to EZW algorithm, which improves the representation method of EZW importance map, that is, the sorting information of important coefficients in the table, makes the representation of the set more streamlined, thereby improving the coding efficiency and image compression rate. Compared with the EZW algorithm, the peak signal-to-noise ratio (PSNR) of the SPIHT algorithm is improved at different bit rates, and it has the characteristics of low computational complexity and easy control of the bit rate.

The SPIHT algorithm adopts a unique method in the division of coefficient subsets and the transmission of important information. It can transmit the ranking information of coefficients implicitly while realizing the priority transmission of coefficients with large amplitudes. What does this implicit transmission mean? We know that the execution path of any sorting algorithm is defined using the comparison results of branch points! If the decoder and the encoder use the same sorting algorithm, the decoder can obtain the sorting information by executing the same path for the coefficient comparison result input by the encoder, which is the so-called "implicit transmission of sorting information". We will see later that most of the codes of the decoding and encoding procedures of the SPIHT algorithm are the same, and only differ in terms of input and output and branch points!

2 Tree structure, diversity rule and ordered table used by
SPIHT algorithm 2.1 Tree structure
The tree structure of SPIHT algorithm is basically the same as that of EZW algorithm, the difference is:
for an image decomposed by N-level two-dimensional wavelet, in the EZW algorithm In the zero tree structure, LL_N has three children HL_N, LH_N and HH_N; in the tree structure of the SPIHT algorithm, LL_N has no children!
I'm sorry to say that the program I mentioned earlier was wrong, but I didn't see it clearly. I just thought that the point (1, 1) had no children. As a result, the initialized unimportant subset table LIS contained points with parent-child relationships. These points are repeatedly scanned during the sorting and scanning process, redundant LSP lists are generated, and the reconstructed image is distorted... Hey, carelessness can't be done!
In the tree structure of the SPIHT algorithm, each node of the tree corresponds to a wavelet coefficient, and we use coordinates (r, c) to identify the node or coefficient Cr, c. Coefficients in the lowest frequency subband LL_N and coefficients in the highest frequency subband have no children.
Suppose X is a wavelet coefficient coordinate set: X={| (r,c) |}, for positive integer n, define the function Sn (X) as follows: if max{| Cr,c |}>= 2 ^ n then
Sn (X) = 1

else Sn (X) = 0

If Sn(X) = 1, the set of coordinates X is significant with respect to the threshold 2^n, otherwise it is insignificant.

2.2 Diversity rules
First introduce the following four set symbols:
(1) O (r,c) —— the set of all children of node (r,c); (
2) D (r,c) —— node (r,c) The collection of all descendants (including children);
(3) L (r,c) —— the collection of all non-direct descendants of node (r,c) (ie excluding children);
L (r,c) = D (r, c) — O (r,c)
(4) H —— coordinate set of all tree roots. (For N-level wavelet decomposition, H is the set of coordinates of all coefficients in LL_N, HL_N, LH_N and HH_N)
According to the characteristics of the tree structure of the SPIHT algorithm, except for LL_N, LL_1, HL_1, LH_1 and HH_1, for any coefficient Coordinates (r, c), both: (Since the initial value of the Matlab matrix subscript is 1, the formula has been adjusted accordingly)
O (r,c) = { (2 r-1,2 c-1), (2 r-1,2 c), (2 r,2 c-1), (2 r,2 c) }

The diversity rules of the SPIHT algorithm are as follows:
(1) The initial coordinate set is {(r,c) | (r,c)∈H }, {D(r,c) | (r,c)∈H }.
(2) If D(r,c) is significant with respect to the current threshold, then D(r,c) is split into L(r,c) and O(r,c).
(3) If L (r,c) is important to the current threshold, then L (r,c) is split into four sets D (rO,cO), (rO,cO) ∈ O (r,c).

2.3 Ordered table
The SPIHT algorithm introduces three ordered tables to store important information:
(1) LSP - important coefficient table;
(2) LIP - unimportant coefficient table;
(3) LIS - unimportant subset table .
In these three tables, each entry is identified by coordinates (r, c). In LIP and LSP, coordinates (r,c) represent a single wavelet coefficient; while in LIS, coordinates (r,c) represent two sets of coefficients, namely D(r,c) or L (r,c), respectively called They are D-type table items and L-type table items. When implemented in Matlab, a new list LisFlag is used to identify the type of each table item in the LIS. The elements of LisFlag have two characters 'D' and 'L'.

⛄ 2. Part of the source code

function varargout = spiht_main(varargin)
% SPIHT_MAIN M-file for spiht_main.fig
% SPIHT_MAIN, by itself, creates a new SPIHT_MAIN or raises the existing
% singleton*.
%
% H = SPIHT_MAIN returns the handle to a new SPIHT_MAIN or the handle to
% the existing singleton*.
%
% SPIHT_MAIN(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in SPIHT_MAIN.M with the given input arguments.
%
% SPIHT_MAIN(‘Property’,‘Value’,…) creates a new SPIHT_MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before spiht_main_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to spiht_main_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help spiht_main

% Last Modified by GUIDE v2.5 10-May-2023 17:03:12

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @spiht_main_OpeningFcn, …
‘gui_OutputFcn’, @spiht_main_OutputFcn, …
‘gui_LayoutFcn’, [] , …
‘gui_Callback’, []);
if nargin && ischar(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 spiht_main is made visible.
function spiht_main_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 spiht_main (see VARARGIN)

% Choose default command line output for spiht_main
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes spiht_main wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% — Outputs from this function are returned to the command line.
function varargout = spiht_main_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 on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
global Orig_I;
[filename,pathname] = …
uigetfile({‘.bmp’;'.raw’;‘.jpg’;'.gif’;‘.png’;'.tif’},‘Read Pic’);
str = [pathname filename];
Orig_I = double(imread(str));
axes(handles.axes1);
set(gca,‘XColor’,‘white’)
set(gca,‘Color’,‘white’)
box off
imshow(Orig_I,[]);

% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,‘Value’) returns toggle state of pushbutton1

⛄3. Running results

insert image description here

⛄4. Matlab version and references

1 matlab version
2014a

2 References
[1] Process detailed explanation and Matlab implementation of multilevel tree set splitting (SPIHT) algorithm

3 Remarks
Introduction This part is taken from the Internet and is for reference only. If there is any infringement, please contact to delete

Guess you like

Origin blog.csdn.net/TIQCmatlab/article/details/131157974