A list,

The GUI functions: load pictures, gray processing pictures, 0.5 times zoom pictures, save processing version R2014a Chinese version

Ii. Source code

function varargout = GUI_TEST(varargin)
% GUI_TEST MATLAB code for GUI_TEST.fig
%      GUI_TEST, by itself, creates a new GUI_TEST or raises the existing
%      singleton*.
%
%      H = GUI_TEST returns the handle to a new GUI_TEST or the handle to
%      the existing singleton*.
%
%      GUI_TEST('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_TEST.M with the given input arguments.
%
%      GUI_TEST('Property'.'Value',...). creates anew GUI_TEST or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_TEST_OpeningFcn gets called.  An
%      unrecognized property name orinvalid value makes property application % stop. All inputs are passed to GUI_TEST_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_TEST

% Last Modified by GUIDE v2. 5 20-Mar- 2020. 09:03:44

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_TEST_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_TEST_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_TEST is made visible.
function GUI_TEST_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_TEST (see VARARGIN)

% Choose default command line output for GUI_TEST
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes GUI_TEST wait for user response (see UIRESUME)
% uiwait(handles.figure1);
global label;
label=0;



% --- Outputs from this function are returned to the command line.
function varargout = GUI_TEST_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 OriginalPic;

[filename,pathname]=uigetfile({'*.bmp; *.jpg; *.png; *.jpeg; *.tif'},'Select an image'.'F:\test');
str=[pathname filename];

if isequal(filename,0)||isequal(pathname,0)
    warndlg('Please select a picture first! '.'Warning');
    return;
else
    OriginalPic= imread(str);
    axes(handles.axes1);
    imshow(OriginalPic);
end;





% --- 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)
global OriginalPic; global GrayPic; global label; [rows , cols , colors] = size(OriginalPic); % GrayPic = zeros(rows, cols); GrayPic = uint8(GrayPic); % the image isdouble, transform the all-zero matrix into uint8 formatfor i = 1:rows  
    for j = 1:cols  
        GrayPic(i , j) = OriginalPic(i , j , 1) *0.3+OriginalPic(i , j , 2) *0.59+OriginalPic(i , j , 3) *0.11; According to W % =0.30,V=0.59,U=0.11Weighted operation, get the most reasonable gray image End End axes(handles. Axes2); imshow(GrayPic); label=1;




% --- 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 OriginalPic;
global ScalePic;
global label;

ScalePic=imresize(OriginalPic,0.5.'cubic');

axes(handles.axes2);
imshow(ScalePic);
label=2;


% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global OriginalPic;
global GrayPic;
global ScalePic;
global label;

[FileName,PathName] = uiputfile({'*.jpg'.'JPEG(*.jpg)'; .'*.bmp'.'Bitmap(*.bmp)'; .'*.gif'.'GIF(*.gif)'; .'*. *'.'All Files (*.*)'},...
                                 'Save Picture'.'Untitled');
Copy the code

3. Operation results



Fourth, note

Version: 2014 a