TUGAS PENGOLAHAN CITRA
1.
UNTUK MENAMPILKAN IMAGE
function
pushbutton1_Callback(hObject, eventdata, handles)
[name_file1,name_path1]
= uigetfile( ...
{'*.bmp;*.jpg;*.tif','files
of type (*.bmp,*.jpg,*.tif)';
'*.bmp','file
Bitmap (*.bmp)';...
'*.jpg','file
jpeg (*.jpg)';...
'*.tif','file
Tif (*.tif)';...
'*.*','all
files (*.*) '},...
'Open Image');
if
~isequal(name_file1,0)
handles.data1=imread
(fullfile(name_path1,name_file1));
guidata (hObject, handles);
axes (handles.axes1);
imshow (handles.data1);
else
return;
end
2. UNTUK GRAYSCALE
function
pushbutton2_Callback(hObject, eventdata, handles)
image1=handles.data1;
gray
= rgb2gray(image1);
axes(handles.axes2);
imshow(gray);
handles.data2
= gray;
guidata
(hObject,handles);
slider
function
slider1_Callback(hObject, eventdata, handles)
gray
= handles.data2;
value
= get (handles.slider1,'value');
thresh
= imcomplement (im2bw(gray,value/255));
axes(handles.axes2);
imshow(thresh);
handles.data3=thresh;
guidata(hObject,handles);
set
(handles.edit1,'string',value)
%
--- Executes during object creation, after setting all properties.
function
slider1_CreateFcn(hObject, eventdata, handles)
if
isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9
.9 .9]);
end
3.
UNTUK EDIT TEXT
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
untuk menyimpan
function
pushbutton3_Callback(hObject, eventdata, handles)
thresh
= handles.data3;
[name_file_save,path_save]
= uiputfile(...
{'*.bmp','File
Bitmap (*.bmp)';...
'*.jpg','File
jpeg (*.jpg)';...
'*.tif','File
Tif (*.tif)';...
'*.*','All
files (*.*) '},...
'Save Image');
if
~isequal (name_file_save,0)
imwrite
(thresh,fullfile(path_save,name_file_save));
return
end