?? yasuo.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 + -