THRESHOLDING CITRA DIGITAL – (Matlab)
THRESHOLDING
CITRA DIGITAL – (Matlab)
Scribe coding untuk Push Button atau tombol
Open Image
% --- Executes on button press in pushbutton1.
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
Scribe coding untuk Push Button atau tombol Grayscale
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
image1=handles.data1;
gray = rgb2gray(image1);
axes(handles.axes2);
imshow(gray);
handles.data2 = gray;
guidata (hObject,handles);
Scribe coding untuk Slider
% --- Executes on slider movement.
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
Scribe coding 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
Scribe coding untuk Push Button atau tombol Save
% --- Executes on button press in pushbutton3.
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));
else
return
end
HASIL
THRESHOLDING CITRA DIGITAL
Komentar
Posting Komentar
Semoga bermanfaat