MATLAB GUI 打开/显示/处理 /保存/图象(图像)程序

 在百思我发表的文章,现在转到csdn来

把这几个文件放在同一个文件夹就ok了
%global im111;
h1=figure( ...
    'menu','none',...
   'color',[1,0.8,0.95],...
   'position',[103.8 50.923 880.2 600],...
   'Name',' 广西工学院信息与计算科学系', ...
   'NumberTitle','off', 'HandleVisibility', 'on', ...
   'Visible','on', 'Resize', 'off',...
   'BusyAction','Queue','Interruptible','off',...
   'IntegerHandle', 'off', ...
   'Doublebuffer', 'on', ...
   'Colormap', gray(256));
h12 = axes( ...
   'units', 'pixels', ...
   'BusyAction','Queue','Interruptible','off',...
   'ydir', 'reverse', ...
   'XLim', [.5 256.5], ...
   'YLim', [.5 256.5],...
   'CLim', [0 1], ...
   'XTick',[],'YTick',[], ...
   'Position', [300 80 500 500]);
blank1 = repmat(uint8(0),128,128);
h13 = image('Parent', h12,...
   'CData', blank1, ...
   'BusyAction','Queue','Interruptible','off',...
   'CDataMapping', 'scaled', ...
   'Xdata', [1 256],...
   'Ydata', [1 256],...
   'EraseMode', 'none');
p11=uicontrol( ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',[0.049 0.870 0.131 0.054], ...
   'String','打开图象', ...
   'Enable', 'on',...
   'callback','open_menu_1');
%------------------------------------------------------
p12=uicontrol( ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',[0.049 0.670 0.131 0.054], ...
   'String','处理图象', ...
   'Enable', 'on',...
    'callback','gray_menu_1');
%--------------------------------------------
  
p13=uicontrol( ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',[0.049 0.770 0.131 0.054], ...
   'String','保存图象', ...
   'Enable', 'on',...
   'callback','save_as_menu_1');
%------------------------------------------------------

%------------------------------------------------------
p14=uicontrol( ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',[0.049 0.270 0.131 0.054], ...
   'String','清空', ...
   'Enable', 'on',...
   'callback',[...
   'set(h13,''CData'',blank1);']);
%-----------------------------------------------
Hn1=uicontrol( ...
   'BusyAction','Queue','Interruptible','off',...
   'Style','pushbutton', ...
   'Units','normalized', ...
   'Position',[0.749 0.010 0.131 0.054], ...
   'String','close', ...
   'Enable', 'on',...
   'callback','close');

%请保存文件名字为:open_menu_1.m
[filename pathname]=uigetfile({'*.bmp','BMP图象(*.bmp)';...
    '*.jpg','JPG图象(*.jpg)';'*.gif','GIF图象(*.gif)';...
    '*.tif','TIF图象(*.tif)';'*.png','PNG图象(*.png)';...
    '*.*','ALL FILES(*.*)'},'请选择一幅图像');

if isequal([filename pathname],[0,0])
    return;
end
str=[pathname filename];
im111=imread(str);
img11= double(im111)/256;
%set(h13,'CData',blank1);
set(h13,'CData',img11);
%hist(img11,[-0.2 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 ]);


=========
%请保存文件名字为:save_as_menu_1.m
[filename,pathname]=...
    uiputfile({'*.bmp','BMP图象(*.bmp)';...
    '*.jpg','JPG图象(*.jpg)';'*.gif','GIF图象(*.gif)';...
    '*.tif','TIF图象(*.tif)';'*.png','PNG图象(*.png)';...
    '*.*','ALL FILES(*.*)'},'图片另存为...');
if isequal([filename pathname],[0,0])
    return;
end
str=[pathname filename];
imwrite(img23,str);


===========
%global imgray;
%请保存文件名字为:gray_menu_1.m
imgray=rgb2gray(im111);
img23=double(imgray)/256;
set(h13,'CData',img23);
%hist(img23,[-0.2 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 ]);

把上面几部分代码,按要求保存在在同一个文件夹,应该可以了
  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

听海拉拉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值