Analysis class P2

22 views (last 30 days)
Sergio Federer
Sergio Federer on 7 Dec 2022
Answered: Ronald Mcdonald on 21 Dec 2022
HSI, CMY e imagens em RGB separado
function varargout = guidep2(varargin)
% GUIDEP2 MATLAB code for guidep2.fig
% GUIDEP2, by itself, creates a new GUIDEP2 or raises the existing
% singleton*.
%
% H = GUIDEP2 returns the handle to a new GUIDEP2 or the handle to
% the existing singleton*.
%
% GUIDEP2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUIDEP2.M with the given input arguments.
%
% GUIDEP2('Property','Value',...) creates a new GUIDEP2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before guidep2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to guidep2_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 guidep2
% Last Modified by GUIDE v2.5 07-Dec-2022 11:01:27
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @guidep2_OpeningFcn, ...
'gui_OutputFcn', @guidep2_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 guidep2 is made visible.
function guidep2_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 guidep2 (see VARARGIN)
% Choose default command line output for guidep2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes guidep2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = guidep2_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 im1
im1 = imread(uigetfile('.jpg;.gif;.tif;.png')); %abrir imagem
axes(handles.axes1);%direcionar para o eixo 1
imshow(im1);%mostrar a imagem
% --- 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 im1
cmy = imcomplement (im1);
axes(handles.axes2);%direcionar para o eixo 2
imshow(cmy)
% --- 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 im1
hsi = rgb2hsv(im1);
axes(handles.axes3);%direcionar para o eixo 3
imshow(hsi);
% --- 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 im1 Red Green Blue
%criar componentes em RGB separadas
R= im1 (:,:,1);
G= im1 (:,:,2);
B= im1 (:,:,3);
Red = cat(3,R,G*0,B*0);
Green = cat (3,R*0,G,B*0);
Blue = cat (3,R*0,G*0,B);
axes (handles.axes2);%direciona pro eixo 2
imshow(Red);
axes (handles.axes3);%direcionar pro eixo 3
imshow(Green);
axes (handles.axes4);%direcionar eixo 4
imshow(Blue);
cor = cat(2, Red, Green, Blue);%mostra as 3 imaegens juntas
axes(handles.axes5);%direciona pro eixo 5
imshow(cor)

Accepted Answer

Sergio Federer
Sergio Federer on 7 Dec 2022
% --- Abrir imagem
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 a
[filename,path] = uigetfile('*.jpg;*.png;*.tif','Selecione imagem');
a = imread(strcat(path,filename));
axes(handles.axes1)
imshow(a)
% --- Escala de cinza
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 a
global cinza
cinza = rgb2gray(a);
axes(handles.axes2)
imshow(cinza)
% --- Limiarizar
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
limiarizar = im2bw(cinza);
axes(handles.axes3)
imshow(limiarizar)
% --- Negativo
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
negativo = imcomplement(cinza);
axes(handles.axes3)
imshow(negativo)
% --- Histograma
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.axes4)
imhist(cinza)
% --- Equalizar histograma
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
histoeq = histeq(cinza);
axes(handles.axes5)
imhist(histoeq)
% --- Equalizar imagem
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 cinza
eqimg = histeq(cinza);
axes(handles.axes3)
imshow(eqimg)
% --- Resetar
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cla(handles.axes1,'reset')
cla(handles.axes2,'reset')
cla(handles.axes3,'reset')
cla(handles.axes4,'reset')
cla(handles.axes5,'reset')
% --- Média
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
global n
w = (1/n^2)*ones(n);
media = im2uint8(mat2gray(imfilter(double(cinza),w)));
axes(handles.axes3)
imshow(media)
% --- Mediana
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
global n
mediana = ordfilt2(cinza,((n^2-1)/2)+1,true(n));
axes(handles.axes3)
imshow(mediana)
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
global n
num = get(hObject,'String');
n = str2double(num);
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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
% --- Logaritmo
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
logaritmo = im2uint8(mat2gray(log(1+ double(cinza))));
axes(handles.axes3)
imshow(logaritmo)
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
global a
rodar = imrotate(cinza,a);
axes(handles.axes3)
imshow(rodar)
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
global a
num2 = get(hObject,'String');
a = str2double(num2);
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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
% --- Redimensionar
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
global b
red = imresize(cinza,b);
axes(handles.axes3)
imshow(red)
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
global b
num3 = get(hObject,'String');
b = str2double(num3);
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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 pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
cortar = imcrop(cinza);
axes(handles.axes3)
imshow(cortar)

More Answers (14)

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Ronald Mcdonald
Ronald Mcdonald on 21 Dec 2022

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!