20201229

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 a new 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 or invalid 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'},'选择一个图片','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);%图像是double型的,将全零矩阵转化为uint8格式

for 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;

%按照W=0.30,V=0.59,U=0.11进行加权运算,得到最合理的灰度图像

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

if FileName==0

return;

else

if(label==1)

imwrite(GrayPic,[PathName,FileName]);

else if(label==2)

imwrite(ScalePic,[PathName,FileName]);

else

imwrite(OriginalPic,[PathName,FileName]);

end

end

end

% --- Executes during object creation, after setting all properties.

function axes1_CreateFcn(hObject, eventdata, handles)

set( gca, 'xtick', [] ); %去掉x轴的刻度

set( gca, 'ytick', [] ); %去掉y轴的刻度

% hObject    handle to axes1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate axes1

% --- Executes during object creation, after setting all properties.

function axes2_CreateFcn(hObject, eventdata, handles)

set( gca, 'xtick', [] ); %去掉x轴的刻度

set( gca, 'ytick', [] ); %去掉y轴的刻度

% hObject    handle to axes2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate axes2

% --- Executes on key press with focus on pushbutton1 and none of its controls.

function pushbutton1_KeyPressFcn(hObject, eventdata, handles)

% hObject    handle to pushbutton1 (see GCBO)

% eventdata  structure with the following fields (see MATLAB.UI.CONTROL.UICONTROL)

%Key: name of the key that was pressed, in lower case

%Character: character interpretation of the key(s) that was pressed

%Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed

% handles    structure with handles and user data (see GUIDATA)

% --- If ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200320131256610.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI5Njg3ODQ3,size_16,color_FFFFFF,t_70)Enable == 'on', executes on mouse press in 5 pixel border.

% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1.

function pushbutton1_ButtonDownFcn(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)

(0)

相关推荐

  • PyQt5(designer)入门教程

    PyQt5入门教程 2019/12/11更新:我平时不看CSDN的,之前一时兴起发了过来,没想到反响还不错.这次就顺便把后来新增的一个小节放上来,并且在文末增加了我的GitHub(一看GitHub就知 ...

  • 【图像识别】基于卷积神经网络CNN实现车牌识别matlab源码

    过去几年,深度学习(Deep learning)在解决诸如视觉识别(visual recognition).语音识别(speech recognition)和自然语言处理(natural langua ...

  • 【GUI应用】Matlab实现矩阵计算器

    界面设计 效果展示 主体源码 %%矩阵相加a=str2num(get(handles.edit1,'string'));b=str2num(get(handles.edit2,'string'));[ ...

  • Matlab:Matlab中常用的函数、案例详细攻略

    Matlab:Matlab中常用的函数.案例详细攻略 常用函数 Matlab中的bwmorph函数解释 bwmorph:对二值图像的形态学操作. BW2 = bwmorph(BW,operation) ...

  • 【黑客数学·每日一题】第20201229期-答案

    【黑客数学·每日一题】第20201229期-答案

  • 【黑客数学·每日一题】第20201229期

    【黑客数学·每日一题】第20201229期

  • 20201229投资日志

     ( 以下内容来自语音转换,如遇错别字病句以语音为准.) 2020年12月28日大盘收评: 本周一上证指数收盘于3397.29点,K线收出阳十字星,成交量小幅放大,目前上证指数走势符合周评给出的预 ...

  • (20201229)在行情初期如何具体分辨出领头羊股票?

    (20201229)在行情初期如何具体分辨出领头羊股票?

  • 每日荐书20201229

    每天推荐一本属于今天的书 <马尔特手记>:里尔克创作生涯中的第一个高峰,它记录了一个出生于没落贵族.性情孤僻敏感的丹麦青年诗人的回忆与自白,某种程度上是作者自身的写照.小说由71个没有连续 ...

  • 20201229今晚,满屏利好!

    铁子们晚上好,我是你们的鱼哥! 今天指数虽然跌的不多,但是后台有铁子跟鱼哥说跌出了股灾的感觉.不瞒大家,今天鱼哥也迎来了近期首次小幅回撤. 有回撤,很正常,但是鱼哥告诉大家的是,不要灰心,只要沿着正确 ...

  • 20201229关键词新闻auMaroc

    根据官方时间,今日摩洛哥国内官方时区为GMT+1,与我们国内亲人所在时区GMT+8相比,晚七小时. 当地时事:摩洛哥卫生部部长解释新冠疫苗物流延迟 L'actualité locale: Covid- ...

  • 【每日一谜】20201229

    [每日一谜20201229] 美人一去近一月,唯忆先前结同心.(16笔字一)  (小贴士:亲们直接回复谜底给公众号即可,不含任何标点空格及数字顺序,若您的谜底正确,将会收到自动回复哦.) [上期揭底2 ...

  • 沐沐说-20201229

    今天我和妈妈又玩了一种新式打球的游戏

  • 沈绍功:12种妇女病家传秘方易简经方 2020-12-29

    沈绍功:12种妇女病家传秘方 易简经方 2020-12-29 因为公众号更改推送机制,推文不再按照时间线显示,可能你在时间线里面就看不到"易简经方"的文章了.如果你希望可以及时看到 ...