function varargout = GUI(varargin)
% GUI MATLAB code for GUI.fig
% GUI, by itself, creates a new GUI or raises the existing
% singleton*.
%
% H = GUI returns the handle to a new GUI or the handle to
% the existing singleton*.
%
% GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI.M with the given input arguments.
%
% GUI('Property','Value',...) creates a new GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_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
% Edit the above text to modify the response to help GUI
% Last Modified by GUIDE v2.5 14-Jul-2017 12:35:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_OpeningFcn, ...
'gui_OutputFcn', @GUI_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 GUI is made visible.
function GUI_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 GUI (see VARARGIN)
% Choose default command line output for GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_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 xingcheng.
function xingcheng_Callback(hObject, eventdata, handles)
% hObject handle to xingcheng (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
I=imread('C:\Users\Admin\Desktop\chepail.bmp');
image1=im2bw(I,0.43);
axes(handles.axes5);
imshow(I);
X=image1(:); %令X为新建的二值图像的一维数据组
x=1:1:length(X); % 编码之前的图像数据
plot(handles.axes6,x,X(x));
% 游程编码程序段
j=1;
image4(1)=1;
for z=1:1:(length(X)-1)
if (X(z)==X(z+1))
image4(j)=image4(j)+1;
else data(j)=X(z);
j=j+1;
image4(j)=1;
end
end
data(j)=X(length(X));
image4length=length(image4); % 计算游程编码后的所占字节数
H=length(x);
%y=1:1:image4length ;
CR1=H/image4length; % 压缩比
% 游程编码解压
i=1;
for m=1:image4length
for n=1:1:image4(m);
rec_image(i)=data(m);
i=i+1;
end
end
u=1:1:length(rec_image); % 解压后的图像数据
plot(handles.axes7,u,rec_image(u));
rec2_image=reshape(rec_image,32,115); % 重建二维二维图像数组
axes(handles.axes8);
imshow(rec2_image);
handles.text4 = CR1;
set(handles.edit4,'string',CR1);
% --- Executes on button press in DCT.
function DCT_Callback(hObject, eventdata, handles)
% hObject handle to DCT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
RGB=imread('C:\Users\Admin\Desktop\chepail.bmp');
R=RGB(:,:,1);
G=RGB(:,:,2);
B=RGB(:,:,3);
axes(handles.axes1);
imshow(RGB);
Y=0.299*double(R)+0.587*double(G)+0.114*double(B);
U=-0.169*double(R)-0.3316*double(G)+0.5*double(B);
V=0.5*double(R)-0.4186*double(G)-0.0813*double(B);
axes(handles.axes2);
imshow(uint8(Y));
T=dctmtx(8);
BY=blkproc(Y,[8 8],'P1*x*P2',T,T');
BU=blkproc(U,[8 8],'P1*x*P2',T,T');
BV=blkproc(V,[8 8],'P1*x*P2',T,T');
a= [16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 55;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99;]; %量化值
b=[ 17 18 24 47 99 99 99 99;
18 21 26 66 99 99 99 99;
24 26 56 99 99 99 99 99;
47 66 99 99 99 99 99 99;
99 99 99 99 99 99 99 99;
99 99 99 99 99 99 99 99;
99 99 99 99 99 99 99 99;
99 99 99 99 99 99 99 99;];
BY2=blkproc(BY,[8 8],'x./P1',a);
BU2=blkproc(BU,[8 8],'x./P1',b);
BV2=blkproc(BV,[8 8],'x./P1',b);
BY3=int8(BY2);
BU3=int8(BU2);
BV3=int8(BV2);
BY4=blkproc(double(BY3),[8 8],'x.*P1',a);
BU4=blkproc(double(BU3),[8 8],'x.*P1',b);
BV4=blkproc(double(BV3),[8 8],'x.*P1',b);
mask=[
1 1 1 1 1 0 0 0;
1 1 1 1 0 0 0 0;
1 1 1 0 0 0 0 0;
1 1 0 0 0 0 0 0;
1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;];
BY5=blkproc(BY4,[8 8],'P1.*x',mask);
BU5=blkproc(BU4,[8 8],'P1.*x',mask);
BV5=blkproc(BV4,[8 8],'P1.*x',mask);
YI=blkproc(double(BY5),[8 8],'P1*x*P2',T',T);
UI=blkproc(double(BU5),[8 8],'P1*x*P2',T',T);
VI=blkproc(double(BV5),[8 8],'P1*x*P2',T',T);
axes(handles.axes3);
imshow(uint8(YI));
RI=YI-0.001*UI+1.402*VI;
GI=YI-0.344*UI-0.714*VI;
BI=YI+1.772*UI+0.001*VI;
RGBI=cat(3,RI,GI,BI);%经过DCT变换和量化后的YUV图像
RGBI=uint8(RGBI);
axes(handles.axes4);
imshow(RGBI);
I = RGBI;
[M,N] = size(I);
I1 = I(:);
P = zeros(1,256);
%获取各符号的概率;
for i = 0:255
P(i+1) = length(find(I1 == i))/(M*N);
end
k = 0:255;
dict = huffmandict(k,P); %生成字典
enco = huffmanenco(I1,dict); %编码
deco = huffmandeco(enco,dict); %解码
Ide = col2im(deco,[M,N],[32,115],'distinct'); %把向量重新转换成图像块;
handles.axes4 = imshow(uint8(Ide));
CR=length(enco)/length(deco);
set(handles.edit3,'string',CR);
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double

xchan9_
- 粉丝: 2
- 资源: 6
最新资源
- 2023-04-06-项目笔记 - 第四百一十四阶段 - 4.4.2.412全局变量的作用域-412 -2025.02.19
- 基于STM32的智能环境系统设计20250211
- 基于元胞自动机法的枝晶生长模拟:任意角度偏心正方算法结合流体动力学LBM研究,基于元胞自动机法的枝晶生长模拟:任意角度偏心正方算法结合流体动力学LBM分析,C++程序,基于元胞自动机法模拟枝晶生长,能
- 单相全波可控整流电路:变压器中心抽头下的电流与波形特性研究,深入理解单相全波可控整流电路:原理、应用与参数计算,单相全波可控整流电路 此电路变压器是带中心抽头的,在u2正半周T1工作,变压器二次绕组
- terraform solace provider plugins
- MATLAB中蚁群算法在TSP问题上的应用研究,MATLAB实现蚁群算法求解旅行商TSP问题的优化策略,MATLAB 用蚁群算法解决旅行商TSP问题 ,MATLAB; 蚁群算法; 旅行商TSP问题
- 路径规划算法仿真:A星算法改进版,高效搜索与路径优化,带梯度下降及S-G滤波器处理,Matlab实现,可定量比较不同算法效果,改进A*算法:权重系数提升搜索效率、冗余拐角优化及路径平滑处理(Matla
- 基于C51单片机的花椒智能烘干设备的设计20250218
- 转速电流双闭环无传感器无刷直流电机Simulink模型解析:探究转速、转矩、反向电动势与三相电流之间的关系,转速电流双闭环无传感器无刷直流电机Simulink模型解析:探究转速、转矩、反向电动势与三相
- LaTeX-OCR-PRO图像识别项目实战
- Malab Simulink MW级直驱风机模型解析及参考文献资源分享,基于Malab Simulink构建的MW级直驱风机模型及其相关参考文献,Malab Simulink MW级直驱风机模型,附赠
- 风力永磁同步发电机设计及仿真分析:Maxwell电磁仿真在1.5兆瓦风力发电机中的应用与工况研究,基于Maxwell电磁仿真的1.5兆瓦风力永磁同步发电机设计与工况分析,1.5兆瓦风力发电机 maxw
- SCI计算复现系列:Pandat代算与自操作实践下的共晶成分设计-以Al-Cu-Si三元合金共晶点成分寻找为例,SCI计算复现:共晶成分设计实例-Al-Cu-Si三元合金共晶点成分的相图计算与Pa
- DeepSeek:本地搭建
- 基于双馈发电机与电池储能系统的频率调节控制策略Simulink模型研究,基于双馈发电机与电池储能系统的频率调节控制策略Simulink模型研究,风储调频 使用双馈发电机(DFIG)相关的电池储能系统
- 永磁同步电机PMSM模糊PI控制策略:详细搭建过程、仿真效果及与传统PI对比资料全套打包介绍,永磁同步电机PMSM模糊PI控制策略详解:搭建过程、参考资料、与传统PI对比及仿真效果展示,永磁同步电机P
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


