[NEW] (1) I click "buka citra" and choose image, i click "ekstrasi citra" not change colour . i hope i click "ekstrasi citra" change image for garyscale colour. (2) I click "buka citra" and choose image, but button "identifikasi" can not click
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fauzan Alghifari
el 27 de Abr. de 2020
Comentada: Fauzan Alghifari
el 1 de Mayo de 2020
function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_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 untitled
% Last Modified by GUIDE v2.5 25-Apr-2020 18:25:13
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_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 untitled is made visible.
function untitled_OpeningFcn(hObject, ~, 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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(~, ~, 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;
function edit1_Callback(~, ~, ~) %#ok<DEFNU>
% 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
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, ~, ~) %#ok<DEFNU>
% 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
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, ~, handles) %#ok<DEFNU>
% 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)
% menampilkan menu browse file
[file, path] = uigetfile({'*.jpg;*.png', 'menampilkan'});
% jika ada file yang dipilih maka menjalankan perintah di bawahnya
if ~isequal(file,0)
% membaca file citra yang dipilih
img = imread(fullfile(path, file));
% menampilkan citra pada axes
axes(handles.axes1)
imshow(img)
title('Citra RGB')
% menyimpan variabel Img pada lokasi handle (lokasi penyimpanan MATLAB
% agar dapat dipanggil pada pushbutton yang lain
handles.Img = img;
guidata(hObject, handles)
% mereset button2
set(handles.pushbutton2,'Enable','on')
set(handles.pushbutton3,'Enable','off')
set(handles.edit1,'String',[])
set(handles.text2,'String',[])
set(handles.uitable2,'Data',[])
cla(handles.axes2, 'reset')
set(handles.axes2,'XTick',[])
set(handles.axes2,'YTick',[])
else
return
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(~, ~, handles) %#ok<DEFNU>
% 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)
% memanggil variabel Img yang ada pada lokasi handles
Img = handles.Img;
% mengkonversi citra grayscale pada axes
axes(handles.axes2)
imshow(Img)
title('Citra Grayscale')
% melakukan ekstraksi ciri orde satu pada citra grayscale
function c = imhist(I)
c = accumarray(I(:)+1, 1, [256 1]);
H = imhist(Img)';
H = H/sum(H);
I = (0:255);
CiriMEAN = I * H';
CiriENT = -H * log2(H+eps)';
CiriVAR = (I-CiriMEAN).^2*H';
CiriSKEW = (I-CiriMEAN).^3*H'/ CiriVAR^1.5;
CiriKURT = (I-CiriMEAN).^4*H'/ CiriVAR^2-3;
data_uji = [CiriMEAN,CiriENT,CiriVAR,CiriSKEW,CiriKURT];
% menampilkan hasil ekstraksi ciri orde satu pada tabel
data_tabel = cell(5,2);
data_tabel{1,1} = 'Mean';
data_tabel{2,1} = 'Entropy';
data_tabel{3,1} = 'Variance';
data_tabel{4,1} = 'Skewness';
data_tabel{5,1} = 'Kurtosis';
data_tabel{1,2} = num2str(CiriMEAN);
data_tabel{2,2} = num2str(CiriENT);
data_tabel{3,2} = num2str(CiriVAR);
data_tabel{4,2} = num2str(CiriSKEW);
data_tabel{5,2} = num2str(CiriKURT);
set (handles.text2,'String','Hasil_Ekstraksi Ciri')
set (handles.uitable2,'Data',data_tabel,'RowName',1:5)
% mereset button2
set (handles.pushbutton3,'Enable','on')
set (handles.edit1,'String',[])
% memanggil variabe data_uji yang ada lokasi handles
handles.data_uji = data_uji;
guidata(hObject, handles)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(~, ~, handles) %#ok<DEFNU>
% 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)
% memanggil variabel data_uji yang ada pada lokasi handles
data_uji = handles.data_uji;
% load data_latih dan target_latih hasil pelatihan
dl = load('data_latih');
tl = load('target_latih');
% pengujian menggunakan algoritam multivism
output = multivsm(dl.data_latih, tl.target_latih, data_uji);
% mengubah nilai keluaran menjadi kelas keluaran
switch output
case 1
jenis_bunga = 'Kamboja Plumeria Alba';
case 2
jenis_bunga = 'Kamboja Plumeria Rubra';
case 3
jenis_bunga = 'Kamboja Plumeria Pudica';
case 4
jenis_bunga = 'Melati Gambir';
case 5
jenis_bunga = 'Melati Kuning';
otherwise
jenis_bunga = 'tidak dikenali';
end
% menampilkan hasl identifikasi jenis bunga pada edit text
set(handles.edit1,'String',jenis_bunga)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(~, ~,handles) %#ok<DEFNU>
% 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)
% mereset button2
set(handles.pushbutton2,'Enable','on')
set(handles.pushbutton3,'Enable','off')
set(handles.edit1,'String',[])
set(handles.text2,'String',[])
set(handles.uitable2,'Data',[])
set(handles.axes2)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])

0 comentarios
Respuesta aceptada
Walter Roberson
el 27 de Abr. de 2020
You put the code for the replacement imhist function in the wrong place. It goes at the end of the file. You should not have changed pushbutton2_Callback to add the code: you should just have put
function c = imhist(I)
c = accumarray(I(:)+1, 1, [256 1]);
at the bottom of the file.
And as I told you before, you should delete that code for pushbutton5_Callback.
9 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Graphics Object Properties en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
