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
没有合适的资源?快使用搜索试试~ 我知道了~
Matlab基于GUI界面的图像处理双线性插值最邻近插值
共10个文件
m:5个
fig:4个
jpg:1个
需积分: 23 2 下载量 140 浏览量
2022-07-18
09:27:22
上传
评论 2
收藏 268KB RAR 举报
温馨提示
ChaZhiChuLi.m 双线性插值和最邻近插值对图像放大和缩放整数倍,整数由用户自己输入 Denglv.m 登录界面 XuanZe.m 选择常规图像处理和插值处理模块 GeZhongChaZhi.m 对比度亮度增强模块,直方图均衡化处理,显示处理前后的直方图 ChaZhiChuLi.fig 双线性插值和最邻近插值对图像放大和缩放整数倍界面 Denglv.fig 登录界面 XuanZe.fig 选择模块界面 GeZhongChaZhi.fig 对比度亮度增强模块,直方图均衡化处理,显示处理前后的直方图界面 该压缩文件解压缩后直接点击运行Denglv.m即可,登录账号:2017020207;登录密码:ZYL,下载后有任何运行问题可以加Q:3467096262联系我给予解决,或则直接在下方评论区评论就可以了。
资源详情
资源评论
资源推荐
收起资源包目录
图像处理.rar (10个子文件)
ChaZhiChuLi.fig 62KB
XuanZe.m 3KB
GeZhongChaZhi.fig 49KB
a1.jpg 138KB
cubic_factor.m 400B
ChaZhiChuLi.m 8KB
GeZhongChaZhi.m 10KB
Denglv.m 5KB
Denglv.fig 9KB
XuanZe.fig 6KB
共 10 条
- 1
智能算法与BP神经网络
- 粉丝: 202
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0