基于matlab GUI均值+中值+空间+高斯滤波图像去噪
一、简介
基于matlab GUI均值+中值+空间+高斯滤波图像去噪
二、源代码
% --- 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)
%选择图片,可以是以下格式(*这个符号是通配符,表示可以是任意长度的任意字符)
????[filename,pathname]=uigetfile({'*.*';'*.bmp';'*.jpg';'*.tif';'*.jpeg'},'选择图像');
????%将im定义成全局变量,这样在代码的任何位置都可以使用im了。
????global im;
????%如果没有输入路径,则弹出错误对话框
????if isequal(filename,0)||isequal(pathname,0)
??????errordlg('您还没有选取图片!!','程序员哥哥告诉你');
??????return;
????else
????????%合成路径+文件名
????????image=[pathname,filename];
????????%读取图像
????????im=imread(image);
????????%打开坐标,方便操作
????????set(handles.axes1,'HandleVisibility','ON');
????????%使用图像,操作在坐标axes1里
????????axes(handles.axes1);
????????%在坐标图axes1里显示原图像
????????imshow(im);
????????title('原始图像');
????end
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject ???handle to listbox1 (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 listbox1 contents as cell array
% ???????contents{get(hObject,'Value')} returns selected item from listbox1
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject ???handle to listbox1 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ???empty - handles not created until after all CreateFcns called
% Hint: listbox 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 radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
global gs;
global jy;
global zs;
global ps;
jy=0;
gs=1;
zs=0;
ps=0;
% hObject ???handle to radiobutton1 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ???structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
global gs;
global jy;
global zs;
global ps;
jy=1;
gs=0;
zs=0;
ps=0;
% hObject ???handle to radiobutton2 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ???structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton2
% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
global gs;
global jy;
global zs;
global ps;
jy=0;
gs=0;
zs=1;
ps=0;
% hObject ???handle to radiobutton3 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ???structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton3
% --- Executes on selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject ???handle to listbox2 (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 listbox2 contents as cell array
% ???????contents{get(hObject,'Value')} returns selected item from listbox2
% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject ???handle to listbox2 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ???empty - handles not created until after all CreateFcns called
% Hint: listbox 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 radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject ???handle to radiobutton4 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ???structure with handles and user data (see GUIDATA)
global zzl;
global jzl;
global kjl;
global gsl;
jzl=1;
zzl=0;
kjl=0;
gsl=0;
% Hint: get(hObject,'Value') returns toggle state of radiobutton4
% --- Executes on button press in radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject ???handle to radiobutton5 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ???structure with handles and user data (see GUIDATA)
global zzl;
global jzl;
global kjl;
global gsl;
jzl=0;
zzl=1;
kjl=0;
gsl=0;
% Hint: get(hObject,'Value') returns toggle state of radiobutton5
三、运行结果
|