【课题】基于GUI小波变换图像压缩分析【Matlab 570期】

一、简介

基于matlab GUI小波变换图像压缩分析

二、源代码

unction varargout = multi_wavelet(varargin)

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @multi_wavelet_OpeningFcn, ...
                   'gui_OutputFcn',  @multi_wavelet_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 multi_wavelet is made visible.
function multi_wavelet_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 multi_wavelet (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = multi_wavelet_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)
% 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)
global I ;
[fname,pname]=uigetfile('*.*');
I=imread(strcat(pname,'\',fname));
[m,n,k]=size(I);
if k~=1
I=rgb2gray(I);
end
I=double(I);
axes(handles.axes1);
imshow(mat2gray(I));
title('原始图像的灰度图');

% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{
    
    get(hObject,'Value')} returns selected item from popupmenu1

global I ;
w1=get(handles.popupmenu1,'value')
switch w1   %选择小波基
case 1
   w2= 'bior 3.7';
case 2
    w2='bior 1.1';
case 3    
    w2='bior 1.3';
case 4    
    w2='bior 1.5';
case 5    
   w2='bior 2.2';
case 6   
   w2='bior 2.4';
case 7   
   w2= 'bior 2.6';
case 8   
    w2='bior 2.8';
case 9    
    w2='bior 3.1';
case 10    
    w2='bior 3.3';
case 11    
    w2='bior 3.5';
case 12    
    w2='bior 3.9';
case 13    
    w2='bior 4.4';
case 14    
    w2='bior 5.5';
case 15    
    w2='bior 6.8';
case 16    
    w2='db1';
case 17    
    w2='db4';
case 18    
    w2='db15';
end
disp('压缩前图像的大小');%显示文字
whos('I')           %显示图像属性
% 进行二维小波变换 'bior3.7'
[a,b] = wavedec2(I, 3,w2); % 分三层,wavedec2:2维多层小波分解
% 提取各层低频信息
c1 = appcoef2( a, b,w2, 1 );%提取二维小波分解低频系数
axes(handles.axes18);
imshow(c1, []);
title('第一层低频部分:');
ca1=wcodemat(c1,440,'mat',0);   %对第一层信息进行量化编码
axes(handles.axes2);
imshow(ca1, []);
title('第一次压缩后图像:');
disp('第一次压缩图像的大小');%显示文字
whos('ca1');
c2= appcoef2( a, b,w2, 2 );
axes(handles.axes19);
imshow(c2, []);
title('第二层低频部分:');
ca2=wcodemat(c2,440,'mat',0);   %对第一层信息进行量化编码
axes(handles.axes6);

三、运行结果

在这里插入图片描述
在这里插入图片描述

四、备注

完整代码或者代写添加QQ 912100926

猜你喜欢

转载自blog.csdn.net/m0_54742769/article/details/115293231