function varargout = TempMonitor(varargin)
% TEMPMONITOR MATLAB code for TempMonitor.fig
% TEMPMONITOR, by itself, creates a new TEMPMONITOR or raises the existing
% singleton*.
%
% H = TEMPMONITOR returns the handle to a new TEMPMONITOR or the handle to
% the existing singleton*.
%
% TEMPMONITOR('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TEMPMONITOR.M with the given input arguments.
%
% TEMPMONITOR('Property','Value',...) creates a new TEMPMONITOR or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before TempMonitor_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to TempMonitor_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 TempMonitor
% Last Modified by GUIDE v2.5 18-Jun-2022 12:37:18
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @TempMonitor_OpeningFcn, ...
'gui_OutputFcn', @TempMonitor_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 TempMonitor is made visible.
function TempMonitor_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 TempMonitor (see VARARGIN)
% Choose default command line output for TempMonitor
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes TempMonitor wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = TempMonitor_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 ReadFig.
function ReadFig_Callback(hObject, eventdata, handles)
% 读图
% hObject handle to ReadFig (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% global FileName
global I
[FileName,PathName] = uigetfile('.jpg'); % 打开窗口
TotalPath = [PathName, '\', FileName]; % 完整路径
IRGB = imread(TotalPath); % 读图
% I = rgb2gray(IRGB);
r = IRGB(:,:,1);
g = IRGB(:,:,2);
b = IRGB(:,:,3);
I = .299*r + .587*g + .114*b; % 转灰度图
set(handles.text5,'String',strcat(TotalPath,' loaded.')) % 显示加载
axis(handles.FigOri);
imshow(I)
title('彩色图像灰度化') % 画灰度图
% --- Executes on button press in AddNoise.
function AddNoise_Callback(hObject, eventdata, handles)
% 加噪声按钮
% hObject handle to AddNoise (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I NoiseType J
if isempty(NoiseType) % 判断是否选择噪声类型
msgbox('未选择噪声类型')
error('未选择噪声类型')
end
t = get(handles.NoisePara, 'String');
if iscell(t)
tt = t{1};
elseif isa(t, 'string') || isa(t, 'char')
tt = t;
end
NoisePara = str2num(tt); % 加载噪声参数
% NoisePara = str2num(get(handles.NoisePara, 'String'));
if strcmp(NoiseType, 'Gauss') % 高斯噪声
type = 'gaussian';
elseif strcmp(NoiseType, 'Salt') % 椒盐噪声
type = 'salt & pepper';
else % 未选择报错
msgbox('未选择噪声类型')
error('未选择噪声类型')
end
J = imnoise(I,type,NoisePara); % 加噪
axis(handles.FigOri); % 画图
plot([1 2], [3 4])
imshow(J)
title([NoiseType,'噪声,参数:', num2str(NoisePara)])
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
global NoiseType % 根据下拉菜单确定噪声类型
NoiseSel = get(handles.popupmenu1, 'Value');
switch NoiseSel
case 1
NoiseType = 'None';
case 2
NoiseType = 'Gauss';
case 3
NoiseType = 'Salt';
end
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function FigPath_Callback(hObject, eventdata, handles)
% hObject handle to FigPath (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of FigPath as text
% str2double(get(hObject,'String')) returns contents of FigPath as a double
% --- Executes during object creation, after setting all properties.
function FigPath_CreateFcn(hObject, eventdata, handles)
% hObject handle to FigPath (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function NoisePara_Callback(hObject, eventdata, handles)
% hObject handle to NoisePara (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of NoisePara as text
% str2double(get(hObject,'String')) returns contents of NoisePara as a double
% --- Executes during object creation, after setting all properties.
function NoisePara_CreateFcn(hObject, eventdata, handles)
% hObject handle to NoisePara (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in Filter.
function Filter_Callback(hObject, eventdata, handles)
% 滤波按钮
% hObject handle to Filter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data