Documente Academic
Documente Profesional
Documente Cultură
PENGOLAHAN CITRA
DIGITAL
Oleh :
Wakhid Rokhayadi
NIM. 15.01.63.0001
UNIVERSITAS
STIKUBANK
SEMARANG 2015
PRAKTIKUM KONVERSI WARNA KE GRAY
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before GUI_01GRAY is made visible.
function GUI_01GRAY_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 GUI_01GRAY (see VARARGIN)
% Choose default command line output for GUI_01GRAY
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI_01GRAY wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_01GRAY_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)
[namafile, namadirektori] = uigetfile(...
{'*.bmp;*.jpg','File gambar(*.bmp,*.jpg)';...
'*.bmp','File Bitmap(*.bmp)';...
'*.jpg','File JPEG(*.jpg)';...
'*.*','Semua File(*.*)'},...
'Buka File Gambar Asli');
if ~isequal(namafile,0)
handles.dataGambar=imread(fullfile(namadirektori,namafile));
guidata(hObject,handles);
handles.dataGambar2=handles.dataGambar;
axes(handles.axes1);
imshow(handles.dataGambar2);
else
return;
end
% --- 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)
dataGambarProses=(handles.dataGambar);
dataGambarProsesGrey=rgb2gray(dataGambarProses);
axes(handles.axes2);
imshow(dataGambarProsesGrey);
% --- 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)
close();
end
% End initialization code - DO NOT EDIT
% --- Executes just before GUI_01BW is made visible.
function GUI_01BW_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 GUI_01BW (see VARARGIN)
% Choose default command line output for GUI_01BW
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI_01BW wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_01BW_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)
[namafile, namadirektori] = uigetfile(...
{'*.bmp;*.jpg','File gambar(*.bmp,*.jpg)';...
'*.bmp','File Bitmap(*.bmp)';...
'*.jpg','File JPEG(*.jpg)';...
'*.*','Semua File(*.*)'},...
'Buka File Gambar Asli');
if ~isequal(namafile,0)
handles.dataGambar=imread(fullfile(namadirektori,namafile));
guidata(hObject,handles);
handles.dataGambar2=handles.dataGambar;
axes(handles.axes1);
imshow(handles.dataGambar2);
else
return;
end
% --- 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)
dataGambarProses=(handles.dataGambar);
dataGambarProsesBW=im2bw(dataGambarProses);
axes(handles.axes2);
imshow(dataGambarProsesBW);
% --- 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)
close();
10
axes(handles.axes2);
imshow(dataGambarProsesRotasi);
% --- 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)
close();
11
12
end
% End initialization code - DO NOT EDIT
% --- Executes just before GUI_01Croping is made visible.
function GUI_01Croping_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 GUI_01Croping (see
VARARGIN)
% Choose default command line output for GUI_01Croping
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI_01Croping wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_01Croping_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)
[namafile, namadirektori] = uigetfile(...
{'*.bmp;*.jpg','File gambar(*.bmp,*.jpg)';...
'*.bmp','File Bitmap(*.bmp)';...
'*.jpg','File JPEG(*.jpg)';...
'*.*','Semua File(*.*)'},...
'Buka File Gambar Asli');
if ~isequal(namafile,0)
handles.dataGambar=imread(fullfile(namadirektori,namafile));
guidata(hObject,handles);
handles.dataGambar2=handles.dataGambar;
axes(handles.axes1);
imshow(handles.dataGambar2);
else
return;
end
% --- 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)
dataGambarProses=(handles.dataGambar);
dataGambarProsesCroping=imcrop(dataGambarProses, [10 10 300 300]);
axes(handles.axes2);
13
imshow(dataGambarProsesCroping);
% --- 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)
close();
14
15
16
dataGambarProsesBlackWhite=im2bw(dataGambarProses);
axes(handles.axes2);
imshow(dataGambarProsesBlackWhite);
% --- 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)
dataGambarProses=(handles.dataGambar);
dataGambarProsesCroping=imcrop(dataGambarProses, [10 10 300 300]);
axes(handles.axes2);
imshow(dataGambarProsesCroping);
% --- Executes on button press in pushbutton5.
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)
dataGambarProses=(handles.dataGambar);
dataGambarProsesRotasi=imrotate(dataGambarProses, 45);
axes(handles.axes2);
imshow(dataGambarProsesRotasi);
% --- Executes on button press in pushbutton6.
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)
close();
17
18
mfilename, ...
gui_Singleton, ...
@GUI_02B_OpeningFcn, ...
@GUI_02B_OutputFcn, ...
19
'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 GUI_02B is made visible.
function GUI_02B_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 GUI_02B (see VARARGIN)
% Choose default command line output for GUI_02B
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI_02B wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_02B_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)
[namafile, namadirektori] = uigetfile(...
{'*.bmp;*.jpg','File gambar(*.bmp,*.jpg)';...
'*.bmp','File Bitmap(*.bmp)';...
'*.jpg','File JPEG(*.jpg)';...
'*.*','Semua File(*.*)'},...
'Buka File Gambar Asli');
if ~isequal(namafile,0)
handles.dataGambar=imread(fullfile(namadirektori,namafile));
guidata(hObject,handles);
handles.dataGambar2=handles.dataGambar;
axes(handles.axes1);
imshow(handles.dataGambar2);
dataGambarProses=(handles.dataGambar);
20
dataGambarProsesGray=rgb2gray(dataGambarProses);
axes(handles.axes2);
imshow(dataGambarProsesGray);
dataGambarProses=(handles.dataGambar);
dataGambarProsesBlackWhite=im2bw(dataGambarProses);
axes(handles.axes3);
imshow(dataGambarProsesBlackWhite);
dataGambarProses=(handles.dataGambar);
dataGambarProsesCroping=imcrop(dataGambarProses, [10 10 300
300]);
axes(handles.axes4);
imshow(dataGambarProsesCroping);
dataGambarProses=(handles.dataGambar);
dataGambarProsesRotasi=imrotate(dataGambarProses, 45);
axes(handles.axes5);
imshow(dataGambarProsesRotasi);
else
return;
end
% --- 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)
close();
21
22
23
% --- Outputs from this function are returned to the command line.
function varargout = MK_03_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)
[namafile, namadirektori] = uigetfile(...
{'*.bmp;*.jpg','File gambar(*.bmp,*.jpg)';...
'*.bmp','File Bitmap(*.bmp)';...
'*.jpg','File JPEG(*.jpg)';...
'*.*','Semua File(*.*)'},...
'Buka File Gambar Asli');
if ~isequal(namafile,0)
handles.dataGambar=imread(fullfile(namadirektori,namafile));
guidata(hObject,handles);
handles.dataGambar2=handles.dataGambar;
axes(handles.axes1);
imshow(handles.dataGambar2);
set(handles.edit1,'String',namafile);
set(handles.edit2,'String',size(handles.dataGambar,1));
set(handles.edit3,'String',size(handles.dataGambar,2));
else
return;
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata,
% hObject
handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future
MATLAB
% handles
structure with handles and user data
dataGambarProses=(handles.dataGambar);
dataGambarProsesGray=rgb2gray(dataGambarProses);
axes(handles.axes2);
imshow(dataGambarProsesGray);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata,
% hObject
handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future
MATLAB
% handles
structure with handles and user data
handles)
version of
(see GUIDATA)
handles)
version of
(see GUIDATA)
24
dataGambarProses=(handles.dataGambar);
dataGambarProsesBlackWhite=im2bw(dataGambarProses);
axes(handles.axes2);
imshow(dataGambarProsesBlackWhite);
% --- 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)
dataGambarProses=(handles.dataGambar);
dataGambarProsesCroping=imcrop(dataGambarProses, [10 10 300 300]);
axes(handles.axes2);
imshow(dataGambarProsesCroping);
% --- Executes on button press in pushbutton5.
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)
dataGambarProses=(handles.dataGambar);
dataGambarProsesRotasi=imrotate(dataGambarProses, 45);
axes(handles.axes2);
imshow(dataGambarProsesRotasi);
% --- Executes on button press in pushbutton6.
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)
close();
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 edit2_Callback(hObject, eventdata, handles)
% hObject
handle to edit2 (see GCBO)
25
26
27
28
% varargin
command line arguments to MK_04 (see VARARGIN)
% Choose default command line output for MK_04
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes MK_04 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = MK_04_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)
[namafile, namadirektori] = uigetfile(...
{'*.bmp;*.jpg','File gambar(*.bmp,*.jpg)';...
'*.bmp','File Bitmap(*.bmp)';...
'*.jpg','File JPEG(*.jpg)';...
'*.*','Semua File(*.*)'},...
'Buka File Gambar Asli');
if ~isequal(namafile,0)
handles.dataGambar=imread(fullfile(namadirektori,namafile));
guidata(hObject,handles);
handles.dataGambar2=handles.dataGambar;
sumI=sum(sum(handles.dataGambar));
s=size(handles.dataGambar);
axes(handles.axes1);
imshow(handles.dataGambar2);
set(handles.edit1,'String',namafile);
set(handles.edit2,'String',size(handles.dataGambar,1));
set(handles.edit3,'String',size(handles.dataGambar,2));
handles.red=handles.dataGambar(:,:,1);
handles.green=handles.dataGambar(:,:,2);
handles.blue=handles.dataGambar(:,:,3);
sumR = sum(sum(handles.red));
sumG = sum(sum(handles.green));
sumB = sum(sum(handles.blue));
n= (sumR+sumG+sumB);
ratarataR = 1/n*sumR*1.0e+005;
ratarataG = 1/n*sumG*1.0e+005;
ratarataB = 1/n*sumB*1.0e+005;
set(handles.edit4,'String',ratarataR);
set(handles.edit5,'String',ratarataG);
29
set(handles.edit6,'String',ratarataB);
else
end
return;
30
dataGambarProses=(handles.dataGambar);
dataGambarProsesRotasi=imrotate(dataGambarProses, 45);
axes(handles.axes2);
imshow(dataGambarProsesRotasi);
31
32
% 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