Error : Evaluating uicontrol Callback
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Why are there many errors in the matlab code if it is run using matlab r2009a?. Please help to make perfect the matlab code
function varargout = project(varargin)
% PROJECT M-file for project.fig
% PROJECT, by itself, creates a new PROJECT or raises the existing
% singleton*.
%
% H = PROJECT returns the handle to a new PROJECT or the handle to
% the existing singleton*.
%
% PROJECT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PROJECT.M with the given input arguments.
%
% PROJECT('Property','Value',...) creates a new PROJECT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before project_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to project_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 project
% Last Modified by GUIDE v2.5 11-Apr-2023 21:45:24
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @project_OpeningFcn, ...
'gui_OutputFcn', @project_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 project is made visible.
function project_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 project (see VARARGIN)
% Choose default command line output for project
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes project wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = project_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 open.
function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[nama_file1, nama_path1]=uigetfile(...
{'*.bmp; *.jpg',' File Citra(*.bmp, *.jpg)';
'*.bmp','File Bitmap(*.bmp)';...
'*.jpg','File Jpeg(*.jpg)';...
'*.*', 'Semua File(*.*)'},...
'Buka citra asli')';
if ~isequal (nama_file1,0);
handles.data1=imread(fullfile(nama_path1, nama_file1));
guidata(hObject, handles);
handles.current_data1=handles.data1;
axes(handles.axes1)
imshow(handles.current_data1);
else
return
end
info = imfinfo(fullfile(nama_path1, nama_file1));
set(handles.edit1,'String', nama_file1);
set(handles.edit2,'String', info.FileSize);
set(handles.edit3,'String', info.Width);
set(handles.edit4,'String', info.Height);
set(handles.edit5,'String', info.BitDepth);
set(handles.edit6,'String', info.ColorType);
% --- Executes on button press in hapus.
function hapus_Callback(hObject, eventdata, handles)
% hObject handle to hapus (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc
set(handles.edit1,'String','');
set(handles.edit2,'String','');
set(handles.edit3,'String','');
set(handles.edit4,'String','');
set(handles.edit5,'String','');
set(handles.edit6,'String','');
cla(handles.axes1,'reset');
cla(handles.axes2,'reset');
% --- Executes on button press in histogram.
function histogram_Callback(hObject, eventdata, handles)
% hObject handle to histogram (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ColorType = get(handles.edit6),'String';
figure;
switch ColorType
case 'grayscale'
imhits(handles.data1);
title('Histogram Intensitas Warna Grayscale');
case 'truecolor'
subplot(3,1,1)
imhist(handles.data1(:,:,1));
title('Histogram Intensitas Warna Merah');
subplot(3,1,2)
imhist(handles.data1(:,:,2));
title('Histogram Intensitas Warna Hijau');
subplot(3,1,3)
imhist(handles.data1(:,:,3));
title('Histogram Intensitas Warna Biru');
% --- Executes on button press in binary.
function binary_Callback(hObject, eventdata, handles)
% hObject handle to binary (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
imageBiner = handles.data1;
gray = rgb2gray;
bw = im2bw (gray);
bwmap = zeros (2, 3);
bwmap(2, :)=1;
axes(handles.axes2);
imshow(bw);
title('Citra Biner');
colormap(handkes.axes2, bwmap);
% --- Executes on button press in grayscale.
function grayscale_Callback(hObject, eventdata, handles)
% hObject handle to grayscale (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
imagegray = handles.data1;
gray = rgb2gray(imagegray);
axes(handles.axes2);
imshow(gray);
title('Citra Grayscale');
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
% --- 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
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (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 edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (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 edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (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 edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (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 edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (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 edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (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 edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (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 edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a double
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (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 edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (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 edit8 as text
% str2double(get(hObject,'String')) returns contents of edit8 as a double
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (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 substraksi.
function substraksi_Callback(hObject, eventdata, handles)
% hObject handle to substraksi (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({'*.jpg;*.png;*.bmp','Supported Image Files'},...
'Select Image');
if isequal(filename,0) || isequal(pathname,0)
return;
end
fullPath = [pathname, filename];
handles.originalImage = imread(fullPath);
axes(handles.originalImageAxes);
imshow(handles.originalImage);
guidata(hObject,handles);
function substraksi_Callback(hObject, eventdata, handles)
% hObject handle to substraksi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if ~isfield(handles,'originalImage')
errordlg('Please select an image to process','Image Error');
return;
end
if ~isfield(handles,'referenceImage')
errordlg('Please select a reference image','Image Error');
return;
end
resultImage = imsubtract(handles.originalImage,handles.referenceImage);
axes(handles.resultImageAxes);
imshow(resultImage);
handles.resultImage = resultImage;
guidata(hObject,handles);
function substraksi_Callback(hObject, eventdata, handles)
% hObject handle to substraksi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if ~isfield(handles,'resultImage')
errordlg('Please process an image before saving','Image Error');
return;
end
[filename, pathname] = uiputfile({'*.jpg;*.png;*.bmp','Supported Image Files'},...
'Save Image As');
if isequal(filename,0) || isequal(pathname,0)
return;
end
fullPath = [pathname, filename];
imwrite(handles.resultImage,fullPath);
function referenceImage = readReferenceImage()
% This function reads the reference image for subtraction operation
[filename, pathname] = uigetfile({'*.jpg;*.png';
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!