資源簡介
交互式原理與應(yīng)用的實(shí)際操作。本文件采用Matlab的代碼進(jìn)行操作。實(shí)現(xiàn)了DCT變換。
中間的Huffman編碼略有精簡

代碼片段和文件信息
function?varargout?=?DCT(varargin)
gui_Singleton?=?1;
gui_State?=?struct(‘gui_Name‘???????mfilename?...
???????????????????‘gui_Singleton‘??gui_Singleton?...
???????????????????‘gui_OpeningFcn‘?@DCT_OpeningFcn?...
???????????????????‘gui_OutputFcn‘??@DCT_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?DCT?is?made?visible.
function?DCT_OpeningFcn(hobject?eventdata?handles?varargin)
handles.output?=?hobject;
%?Update?handles?structure
guidata(hobject?handles);
%?---?Outputs?from?this?function?are?returned?to?the?command?line.
function?varargout?=?DCT_OutputFcn(hobject?eventdata?handles)?
varargout{1}?=?handles.output;
%?---?Executes?on?button?press?in?Sure.
function?Sure_Callback(hobject?eventdata?handles)
global?image;?%至關(guān)重要??!
%如果不再一次用global?image,那么就調(diào)用不了sure里的變量
%同時還會報(bào)錯說類型不對...struct...Image之類的
temp?=?get(handles.argument‘string‘);
argument?=?str2double(temp);
image_compress?=?dct_compress_function(imageargument);
axes(handles.axes2);
imshow(image_compress);
title(‘變換后圖像‘);
%PSNR
psnr?=?PSNR_compute(imageimage_compress);
set(handles.PSNR‘string‘psnr);
%compression?ratio
set(handles.compress_rate‘string‘rate);
function?argument_Callback(hobject?eventdata?handles)
%?---?Executes?during?object?creation?after?setting?all?properties.
function?argument_CreateFcn(hobject?eventdata?handles)
if?ispc?&&?isequal(get(hobject‘BackgroundColor‘)?get(0‘defaultUicontrolBackgroundColor‘))
????set(hobject‘BackgroundColor‘‘white‘);
end
function?PSNR_Callback(hobject?eventdata?handles)
function?PSNR_CreateFcn(hobject?eventdata?handles)
if?ispc?&&?isequal(get(hobject‘BackgroundColor‘)?get(0‘defaultUicontrolBackgroundColor‘))
????set(hobject‘BackgroundColor‘‘white‘);
end
%?--------------------------------------------------------------------
function?File_Callback(hobject?eventdata?handles)
%?--------------------------------------------------------------------
function?Open_File_Callback(hobject?eventdata?handles)
global?image;
[filenamepathname]=uigetfile({‘*.bmp;*.jpg;*.png;*.jpeg;*.tif‘}‘選擇圖像‘);
if?isequal(filename0)||isequal(pathname0)
????warndlg(‘Please?select?a?picture?first!‘‘Warning‘);
????return;
else
????str=[pathname?filename];
????image=?imread(str);
????axes(handles.axes1);
????imshow(image);
????title(‘原始圖像‘);
end
%?--------------------------------------------------------------------
function?Save_File_Callback(hobject?eventdata?handles)
[FileNamePathName]?=?uiputfile({‘*.jpg‘‘JPEG(*.jpg)‘;...
?????????????????????????????????‘*.bmp‘‘Bitmap(*.bmp)‘;...
?????????????????????????????????‘*.gif‘‘GIF(*.gif)‘;...
?????????????????????????????????‘*.*‘
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????34641??2018-12-31?23:23??DCT.fig
?????文件???????3584??2018-12-31?23:23??DCT.m
?????文件???????4951??2019-01-03?21:47??dct_compress_function.m
?????文件????????448??2018-12-31?17:41??Inverse_function.m
?????文件??????19181??2018-12-31?16:53??lena.jpg
?????文件????????322??2018-12-31?17:56??PSNR_compute.m
-----------?---------??----------?-----??----
????????????????63127????????????????????6
- 上一篇:down_sample下采樣
- 下一篇:MATLAB第四版課后部分程序
評論
共有 條評論