function varargout = GeZhongChaZhi(varargin)
% GEZHONGCHAZHI MATLAB code for GeZhongChaZhi.fig
% GEZHONGCHAZHI, by itself, creates a new GEZHONGCHAZHI or raises the existing
% singleton*.
%
% H = GEZHONGCHAZHI returns the handle to a new GEZHONGCHAZHI or the handle to
% the existing singleton*.
%
% GEZHONGCHAZHI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GEZHONGCHAZHI.M with the given input arguments.
%
% GEZHONGCHAZHI('Property','Value',...) creates a new GEZHONGCHAZHI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GeZhongChaZhi_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GeZhongChaZhi_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 GeZhongChaZhi
% Last Modified by GUIDE v2.5 16-Jul-2022 17:48:16
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GeZhongChaZhi_OpeningFcn, ...
'gui_OutputFcn', @GeZhongChaZhi_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 GeZhongChaZhi is made visible.
function GeZhongChaZhi_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 GeZhongChaZhi (see VARARGIN)
% Choose default command line output for GeZhongChaZhi
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GeZhongChaZhi wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GeZhongChaZhi_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 FileName
[FileName,pathname]=uigetfile({'*.bmp;*.jpg;*.png;*.jpeg;*.tif'},'选择一个图片','D:\dzy:\qwh'); %获取图片地址
str=[pathname FileName]; %存储文件地址
global I
if isequal(FileName,0)||isequal(pathname,0) %少部分即提示
warndlg('Please select a picture first!','Warning');
return;
else
I= imread(str); %读取原始图片
axes(handles.axes1); %在axes1中显示
imshow(I);
end;
% --- 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)
global I a1
a1=str2num(get(handles.edit1,'string'));
[srcWidth ,srcHeight,Color]=size(I);
%
% % 最近邻
% % 思想是根据 srcWidth/dstWidth = srcX/dstY,最后再对srcX取整
% % 缺点是精度不够,严重失真
%
%dstWidth=srcWidth+CONST*2;%放大加,缩小减
%dstHeight=srcHeight+CONST*2;
%dstWidth=srcWidth-CONST*2;
%dstHeight=srcHeight-CONST*2;
dstWidth=floor(srcWidth*a1);
dstHeight=floor(srcHeight*a1);
resize_img=zeros(dstWidth,dstHeight,Color,class(I));
% 像素变化公式计算公式
for i=1:dstWidth
for j=1:dstHeight
for n = 1:Color
src_i=i*(srcWidth/dstWidth);
src_j=j*(srcHeight/dstHeight);
resize_img(i,j,n)=I(ceil(src_i),ceil(src_j),n); % round四舍五入
end
end
end
axes(handles.axes2); %在axes1中显示
imshow(resize_img)
title("最近邻插值法放大图像");
% --- 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)
global I a1
[srcWidth ,srcHeight,Color]=size(I);
%
% % 最近邻
% % 思想是根据 srcWidth/dstWidth = srcX/dstY,最后再对srcX取整
% % 缺点是精度不够,严重失真
%
%dstWidth=srcWidth+CONST*2;%放大加,缩小减
%dstHeight=srcHeight+CONST*2;
%dstWidth=srcWidth-CONST*2;
%dstHeight=srcHeight-CONST*2;
dstWidth=floor(srcWidth/a1);
dstHeight=floor(srcHeight/a1);
resize_img=zeros(dstWidth,dstHeight,Color,class(I));
% 像素变化公式计算公式
for i=1:dstWidth
for j=1:dstHeight
for n = 1:Color
src_i=i*(srcWidth/dstWidth);
src_j=j*(srcHeight/dstHeight);
resize_img(i,j,n)=I(ceil(src_i),ceil(src_j),n); % round四舍五入
end
end
end
axes(handles.axes2); %在axes1中显示
imshow(resize_img)
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)
global I a2
a2=str2num(get(handles.edit2,'string'));
[srcWidth ,srcHeight,Color]=size(I);
dstWidth=floor(srcWidth*a2);
dstHeight=floor(srcHeight*a2);
resize_img=zeros(dstWidth,dstHeight,Color,class(I));
% 像素变化公式计算公式
for i=1:dstWidth-1
for j=1:dstHeight-1
for n = 1:Color
src_i=i*(srcWidth/dstWidth);
src_j=j*(srcHeight/dstHeight);
src_ii=fix(src_i);
src_iu=src_i - src_ii; % none fix part
src_jj=fix(src_j);
src_jv=src_j - src_jj;
if src_ii == 0
src_ii=src_ii+1;
end
if src_jj ==0
src_jj=src_jj+1;
end
resize_img(i,j,n)=(1-src_iu)*(1-src_jv)*I(src_ii,src_jj,n)+(1-src_iu)*src_jv*I(src_ii,src_jj+1,n)+src_iu*(1-src_jv)*I(src_ii+1,src_jj,n)...
+src_iu*src_jv*I(src_ii+1,src_jj+1,n);
end
end
end
axes(handles.axes3); %在axes1中显示
imshow(resize_img)
%title("双线性插值法放大图像");
title("双线性插值法放大图像");
% --- 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)
% --- 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)
global I a2
a2=str2num(get(handles.edit2,'string'));
[srcWidth ,srcHeight,Color]=size(I);
dstWidth=floor(srcWidth/a2);
dstHeight=floor(srcHeight/a2);
resize_img=zeros(dstWidth,dstHeight,Color,class(I));
% 像素变化公式计算公式
for i=1:dstWidth-1
for j=1:dstHeight-1
for n = 1:Color
src_i=i*(srcWidth/dstWidth);
src_j=j*(srcH

智能算法与BP神经网络
- 粉丝: 228
- 资源: 1
最新资源
- 中科岩创隧道自动化监测解决方案
- Manatee 1.09电磁噪声振动计算软件:引领电机NVH领域革新,带教程易上手,超越同类软件的强大后处理功能,电机电磁振动噪声NVH解决利器:Manatee 1.09软件教程全面,强大后处理参数化
- C2000 MCU同步降压升压转换器的数字控制系统应用与优化
- .NET 9 彻底改变了 API 的文档:从 Swashbuckle 到 Scalar
- datax-mysql8驱动
- 气动影响下叶片裂纹应力集中现象的Fluent分析,基于气动影响的叶片裂纹应力集中现象的Fluent分析与研究,Fluent,考虑气动影响情况下的叶片裂纹应力集中 ,Fluent; 考虑气动影响; 叶片
- MATLAB驱动的高尔夫模拟仿真系统:深度定制球杆与挥杆参数的互动体验,基于MATLAB的全方位高尔夫模拟仿真系统:精确设定球杆与天气因素,让用户享受个性化的挥杆力量与角度掌控体验,基于MATLAB的
- 单向光伏并网逆变器:结构解析与性能追踪图集,包括整体结构图、并网电流电压曲线图、最大功率追踪MPPT控制图及直流母线电压曲线图,单向光伏并网逆变器:结构解析与性能追踪图集,含最大功率追踪图及电流电压曲
- COMSOL裂缝地层THM耦合离散模型与地热能开采过程研究:探究随机复杂裂缝对增强地热系统的影响,COMSOL裂缝地层THM耦合与离散随机复杂裂缝模型在地热能开采中的应用研究,COMSOL裂缝地层的T
- 基于C2000 MCU峰值电流控制模式的升压电路实现在电源领域的应用与优化
- site-packages.rar
- BUCK控制策略对比及主电路图详解:开环与闭环控制的波形与调节过程分析,BUCK控制策略对比及主电路图详解:开环与闭环控制的波形与调节过程分析,BUCK多种控制策略对比 图一BUCK主电路图与控制策略
- 永磁同步电机MATLAB仿真:直接转矩控制下的转速外环与磁链内环优化,转矩脉动显著减小,永磁同步电机MATLAB仿真:直接转矩控制下的转速外环与磁链内环优化,转矩脉动显著减小,永磁同步电机(PMSM)
- 清华大学最新学习教程《DeepSeek与AI幻觉》
- 销售数据集,数据集包含模拟不同产品、地区和客户的销售交易信息,可以用于机器学习
- 可以快速使用的一个日志模块,可以打印不同颜色,绑定到RichTextBox
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



评论0