Tarefa 3
Crie um GUIDE com as seguintes funções: - Um botão para abrir uma imagem
- Abra a imagem contaminada com ruído;
- Um botão que aplique um filtro de mediana e tenha opção de selecionar as seguintes máscaras: 3x3 5x5 7x7 - Comente os resultados ao utilizar os diferentes tamanhos de máscaras na imagem contaminada.
- Um botão para aplicar o filtro de Gauss na imagem contaminada;
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 img
img = imread(uigetfile('*.jpg;*.png;*.bitmap'));
axes(handles.axes1);
imshow(img);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global img cinza
cinza = rgb2gray(img);
axes(handles.axes2);
imshow(cinza);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
axes(handles.axes3);
b = medfilt2(cinza,[3 3])
imshow(b); title ('Filtro mediana 3x3');
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
axes(handles.axes3);
c = medfilt2(cinza,[5 5])
imshow(c);title ('Filtro mediana 5x5');
% --- 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 cinza
axes(handles.axes3);
d = medfilt2(cinza,[7 7])
imshow(d);title ('Filtro mediana 7x7');
% --- 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 cinza
GAU = get(handles.popupmenu1,'Value');
switch GAU
case 2
g = imgaussfilt(cinza,2);
axes(handles.axes3);
imshow(g);title ('Filtro Gaussiano');
end
% --- 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
% --- 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