Matlab GUI open/display/process/save/image (image) Program

Source: Internet
Author: User
Tags bmp image uicontrol

The article I posted at best is now transferred to csdn

Put these files in the same folder.
% Global im111;
H1 = figure (...
'Menu ', 'none ',...
'Color', [1, 0.8, 0.95],...
'Position', [103.8 50.923 880.2 600],...
'Name', 'department of information and computing science of Guangxi Institute of Technology ',...
'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],...
'Xticket', [], 'yticket', [],...
'Position', [300 80 500 500]);
Blank1 = repmat (uint8 (0), 128,128 );
H13 = image ('parent', H12 ,...
'Cdata', blank1 ,...
'Busyaction', 'queue ', 'interruptible', 'off ',...
'Datamapping', 'scaled ',...
'Xdata', [1 256],...
'Ydata', [1 256],...
'Erasemode', 'None ');
P11 = uicontrol (...
'Busyaction', 'queue ', 'interruptible', 'off ',...
'Style', 'pushutton ',...
'Units ', 'normalized ',...
'Position', [0.049 0.870 0.131 0.054],...
'String', 'open image ',...
'Enable', 'on ',...
'Callback', 'open _ menu_1 ');
% ------------------------------------------------------
P12 = uicontrol (...
'Busyaction', 'queue ', 'interruptible', 'off ',...
'Style', 'pushutton ',...
'Units ', 'normalized ',...
'Position', [0.049 0.670 0.131 0.054],...
'String', 'processing image ',...
'Enable', 'on ',...
'Callback', 'Gray _ menu_1 ');
% --------------------------------------------

P13 = uicontrol (...
'Busyaction', 'queue ', 'interruptible', 'off ',...
'Style', 'pushutton ',...
'Units ', 'normalized ',...
'Position', [0.049 0.770 0.131 0.054],...
'String', 'Save image ',...
'Enable', 'on ',...
'Callback', 'Save _ as_menu_1 ');
% ------------------------------------------------------

% ------------------------------------------------------
P14 = uicontrol (...
'Busyaction', 'queue ', 'interruptible', 'off ',...
'Style', 'pushutton ',...
'Units ', 'normalized ',...
'Position', [0.049 0.270 0.131 0.054],...
'String', 'clear ',...
'Enable', 'on ',...
'Callback ',[...
'Set (H13, 'cdata', blank1); ']);
% -----------------------------------------------
HN1 = uicontrol (...
'Busyaction', 'queue ', 'interruptible', 'off ',...
'Style', 'pushutton ',...
'Units ', 'normalized ',...
'Position', [0.749 0.010 0.131 0.054],...
'String', 'close ',...
'Enable', 'on ',...
'Callback', 'close ');

% Save the file name as open_menu_1.m.
[Filename pathname] = uigetfile ({'*. BMP', 'bmp image (*. BMP )';...
'*. Jpg', 'jpg image (*. jpg) ';' *. gif ', 'gif image (*. GIF )';...
'*. Tif', 'tif image (*. tif) ';' *. PNG ', 'png image (*. PNG )';...
'*. *', 'All files (*. *) '}, 'select an image ');

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]);

==========
% Save the file name as save_as_menu_1.m.
[Filename, pathname] =...
Uiputfile ({'*. BMP', 'bmp image (*. BMP )';...
'*. Jpg', 'jpg image (*. jpg) ';' *. gif ', 'gif image (*. GIF )';...
'*. Tif', 'tif image (*. tif) ';' *. PNG ', 'png image (*. PNG )';...
'*. *', 'All files (*. *) '}, 'Save the image ...');
If isequal ([filename pathname], [0, 0])
Return;
End
STR = [pathname filename];
Imwrite (img23, STR );

==============
% Global imgray;
% Save the file name: 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]);

Save the above Code in the same folder as required.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.