⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yasuo.m

📁 数字图像处理
💻 M
字号:
function varargout = yasuo(varargin)%YASUO M-file for yasuo.fig%      YASUO, by itself, creates a new YASUO or raises the existing%      singleton*.%%      H = YASUO returns the handle to a new YASUO or the handle to%      the existing singleton*.%%      YASUO('Property','Value',...) creates a new YASUO using the%      given property value pairs. Unrecognized properties are passed via%      varargin to yasuo_OpeningFcn.  This calling syntax produces a%      warning when there is an existing singleton*.%%      YASUO('CALLBACK') and YASUO('CALLBACK',hObject,...) call the%      local function named CALLBACK in YASUO.M with the given input%      arguments.%%      *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 yasuo% Last Modified by GUIDE v2.5 04-Jun-2008 17:10:07% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @yasuo_OpeningFcn, ...                   'gui_OutputFcn',  @yasuo_OutputFcn, ...                   'gui_LayoutFcn',  [], ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})   gui_State.gui_Callback = str2func(varargin{1});endif 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 yasuo is made visible.function yasuo_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   unrecognized PropertyName/PropertyValue pairs from the%            command line (see VARARGIN)% Choose default command line output for yasuohandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes yasuo wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = yasuo_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 structurevarargout{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)%装入图像kk=imread('ziji4.jpg');X=rgb2gray(kk);X=double(X);%[X,map]=rgb2ind(RGB,0.1);%显示图像figure(1);subplot(221);imshow(X,[]);%colormap(map)title('原始图像');axis squaredisp('压缩前图像X的大小:');whos('X')%对图像用bior3.7小波进行2层小波分解[c,s]=wavedec2(X,2,'bior3.7');%提取小波分解结构中第一层低频系数和高频系数ca1=appcoef2(c,s,'bior3.7',1);ch1=detcoef2('h',c,s,1);cv1=detcoef2('v',c,s,1);cd1=detcoef2('d',c,s,1);%分别对各频率成分进行重构a1=wrcoef2('a',c,s,'bior3.7',1);h1=wrcoef2('h',c,s,'bior3.7',1);v1=wrcoef2('v',c,s,'bior3.7',1);d1=wrcoef2('d',c,s,'bior3.7',1);c1=[a1,h1;v1,d1];%显示分解后各频率成分的信息subplot(222);imshow(c1,[]);axis squaretitle('分解后低频和高频信息');%下面进行图像压缩处理%保留小波分解第一层低频信息,进行图像的压缩%第一层的低频信息即为ca1,显示第一层的低频信息%首先对第一层信息进行量化编码ca1=appcoef2(c,s,'bior3.7',1);ca1=wcodemat(ca1,440,'mat',0);%改变图像的高度ca1=0.5*ca1;subplot(223);imshow(ca1,[]);%colormap(map);axis squaretitle('第一次压缩');disp('第一次压缩图像的大小为:');whos('ca1')%保留小波分解第二层低频信息,进行图像的压缩,此时压缩比更大%第二层的低频信息即为ca2,显示第二层的低频信息ca2=appcoef2(c,s,'bior3.7',2);%首先对第二层信息进行量化编码ca2=wcodemat(ca2,440,'mat',0);%改变图像的高度ca2=0.25*ca2;subplot(224);imshow(ca2,[]);%colormap(map);%axis squaretitle('第二次压缩');disp('第二次压缩图像的大小为:');whos('ca2')% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)open tuxiangyasuo1% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)kk=imread('ziji3.jpg');X=rgb2gray(kk);X=double(X);figure();subplot(221);imshow(X,[]);title('原始图像');%colormap(map2);[ca1,ch1,cv1,cd1]=dwt2(X,'bior3.7');a1=upcoef2('a',ca1,'bior3.7',1);h1=upcoef2('h' ,ch1,'bior3.7',1);v1=upcoef2('v',cv1,'bior3. 7',1);d1=upcoef2('d',cd1,'bior3. 7',1);subplot(222);%colormap(map2);imshow(a1,[]);title('第一次压缩图像');[c,s]=wavedec2(X,2,'bior3.7');ca2=appcoef2(c,s ,'bior3. 7',2);a2=wrcoef2('a',c,s,'bior3.7',2);subplot(223);%colormap(map2);imshow(a2,[]);title('第二次压缩图像');% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton4 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)open tuxiangyasuo2% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton5 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)kk=imread('ziji8.jpg');X=rgb2gray(kk);X=double(X);figure();imshow(X,[]);axis squarewname='haar';lev=3;[c,s]=wavedec2(X,lev,wname);alpha=1.5;m=3.5*prod(s(1,:));[thr,nkeep]=wdcbm2(c,s,alpha,m);xd=wdencmp('lvd',c,s,wname,lev,thr,'h');figure(1);subplot(1,2,1);imshow(X,[]);title('原始信号');subplot(1,2,2);imshow(xd,[]);title('压缩后的信号');% --- Executes on button press in pushbutton6.function pushbutton6_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton6 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)open yyyasuo

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -