0% found this document useful (0 votes)
77 views11 pages

Bab I Permasalahan

The document discusses modifications to a MATLAB program to view and analyze images. 1. It aims to add a push button to open image files of types .jpg, .bmp, .tif, and .gif. 2. It aims to make the histogram popup menu disappear for grayscale images and reappear for color/RGB images. 3. It mentions adding comments to the programmed code and screenshots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views11 pages

Bab I Permasalahan

The document discusses modifications to a MATLAB program to view and analyze images. 1. It aims to add a push button to open image files of types .jpg, .bmp, .tif, and .gif. 2. It aims to make the histogram popup menu disappear for grayscale images and reappear for color/RGB images. 3. It mentions adding comments to the programmed code and screenshots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

BAB I

Permasalahan

1. Membuat Push-Button Buka Citra bisa open file image dengan type file .jpg,
.bmp, .tif, .gif.
2. Membuat pop-upmenu Histogram hilang saat gambar abu-abu dan muncul
kembalu pada saat gambar berwarna/RGB.
3. Memberikan komentar pada program yang dibuat beserta screen shot.

BAB II
Pembahasan

1. Source Code
function varargout = devi(varargin)
% BARU MATLAB code for baru.fig
%
BARU, by itself, creates a new BARU or raises the existing
%
singleton*.
%
%
H = BARU returns the handle to a new BARU or the handle to
%
the existing singleton*.
%
%
BARU('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in BARU.M with the given input arguments.
%
%
BARU('Property','Value',...) creates a new BARU or raises the
%
existing singleton*. Starting from the left, property value pairs
are
%
applied to the GUI before baru_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property
application
%
stop. All inputs are passed to baru_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 baru
% Last Modified by GUIDE v2.5 25-Oct-2016 05:29:10
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @baru_OpeningFcn, ...
'gui_OutputFcn', @baru_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 baru is made visible.


function baru_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject
handle to figure

% eventdata
% handles
% varargin

reserved - to be defined in a future version of MATLAB


structure with handles and user data (see GUIDATA)
command line arguments to baru (see VARARGIN)

% Choose default command line output for baru


handles.output = hObject;
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes baru wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = baru_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;

function editName_Callback(hObject, eventdata, handles)


% hObject
handle to editName (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 editName as text
%
str2double(get(hObject,'String')) returns contents of editName as
a double

% --- Executes during object creation, after setting all properties.


function editName_CreateFcn(hObject, eventdata, handles)
% hObject
handle to editName (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 editSize_Callback(hObject, eventdata, handles)


% hObject
handle to editSize (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 editSize as text

%
str2double(get(hObject,'String')) returns contents of editSize as
a double

% --- Executes during object creation, after setting all properties.


function editSize_CreateFcn(hObject, eventdata, handles)
% hObject
handle to editSize (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 editType_Callback(hObject, eventdata, handles)


% hObject
handle to editType (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 editType as text
%
str2double(get(hObject,'String')) returns contents of editType as
a double

% --- Executes during object creation, after setting all properties.


function editType_CreateFcn(hObject, eventdata, handles)
% hObject
handle to editType (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 pushbuttonBuka.


function pushbuttonBuka_Callback(hObject, eventdata, handles)
% hObject
handle to pushbuttonBuka (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% fungsi ini digunakan untuk membaca citra lena.bmp
%digunakan agar variabel
tersebut dapat digunakan pada seluruh
global y f1 f2 f3 grayscale;
%sub-sub rutin yang terdapat
di dalam fungsi
[filename, pathname] = uigetfile(...
%digunakan untuk memunculkan
kotak dialog open file dan memilih file
{'*.bmp;*.jpg;*.tif;*.gif;',...
%list type file
'file lukisan (*.bmp,*.jpg,*.tif,*.gif)';
'*.bmp','image bmp (*.bmp)';...
'*.jpg','image jpg (*.jpg)';...

'*.tif','image tif (*.tif)';...


'*.gif','image gif (*.gif)';...
'*.*','All file(*.*)'},...
'Pick a file');
gb = strcat(pathname, filename);
y = imread(gb);
%y=imread('lena.bmp');
axes(handles.axes1);
dipilih
imshow(y);
info=imfinfo(gb);

%membaca image yanga ada di komputer


%untuk memilih posisi file yang akan
%untuk menampilkan image yang dipilih
%untuk memberikan informasi image

set(handles.editName,'string',info.Filename);
dari info image itu sendiri

%akan menampilkan nama file

set(handles.editType,'string',info.Format);
info image itu sendiri

%akan menampilkan Type dari

set(handles.editSize,'string',info.FileSize);
info image itu sendiri

%akan menampilkan Size dari

handles.y=y;

%fungsi yang mengakomodir y

[f]=histogram(handles.y);
dari image yang dipilih

%f = perhitingan histogram

absis=0:1:255;

%x = antara 1 sampai 255

axes(handles.axes2)
histogram image yang dipilih

%posisi untuk meletakkan

plot(absis,f,'k')
hasil perhitungan histogram image

%untuk menggambar grafik

%fungsi untuk menampakkan pop-up Histogram citra jika gambar berwarna (RGB)
%dan tidak jika gambar grayscale
if size(handles.y,3)==1;
set(handles.popupmenu2,'Visible','off');
%menyembunyikan popup Histogram
drawnow;
else
set(handles.popupmenu2,'Visible','on');
%menampilkan kembali popup
Histogram
drawnow;
end
grid on
%menampilkan grid pada kotak
histogram
guidata(hObject, handles);

% --- Executes on button press in pushbuttonExit.


function pushbuttonExit_Callback(hObject, eventdata, handles)
% hObject
handle to pushbuttonExit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% fungsi ini untuk menutup figure
delete(handles.figure1);
% --- Executes on button press in pushbuttonHistogram.

function pushbuttonHistogram_Callback(hObject, eventdata, handles)


% hObject
handle to pushbuttonHistogram (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% fungsi ini digunakan untuk menampilkan histogram
[f]=histogram(handles.y);
absis=0:1:255;
axes(handles.axes2)
plot(absis,f,'k')
grid on
function [f]=histogram(cit)
% fungsi lokal untuk menghitung histogram citra
[m n]=size(cit);
citra=double(cit);
for i=1:256, f(i)=0; end;
for j=1:m,
for k=1:n,
f(round(citra(j,k))+1)=f(round(citra(j,k))+1)+1;
end;
end;

% --- Executes on selection change in popupmenu2.


function popupmenu2_Callback(hObject, eventdata, handles) %fungdi untuk
tombol Histogram citra
indeks = get(handles.popupmenu2,'Value');
%karena popupmenu
maka akan terdapat lebih
handles.indeks=indeks;
%dari 1 pilihan
indeks adalah kontrol untuk pilihannya
guidata(hObject,handles);
if indeks==1 %jika menu 1 dipilih maka akan muncul histogram 3 warna (RGB)
[R]=histogram(handles.y(:,:,1)); %R = Histogram Red
[G]=histogram(handles.y(:,:,2)); %G = Hstogram Green
[B]=histogram(handles.y(:,:,3)); %B = Histogram Blue
absis=0:1:255;
%absis/x = antara 1 sampai 255
axes(handles.axes2)
%posisi meletakkan grafik Hstogram
plot(absis,B,'b',absis,R,'r',absis,G,'g') %untuk menggambar grafik
hasil perhitungan histogram image
grid on
%menampilkan grid pada kotak
histogram
else if indeks==2 %jika menu 2 dipilih maka akan muncul histogram red
[f1]=histogram(handles.y(:,:,1));%f1 = Histogram Red
absis=0:1:255;
%absis/x = antara 1 sampai 255
axes(handles.axes2)
%posisi meletakkan grafik Hstogram
plot(absis,f1,'r')
%untuk menggambar grafik hasil
perhitungan histogram image
grid on
%menampilkan grid pada kotak
histogram
else if indeks==3 %jika menu 3 dipilih maka akan muncul histogram
blue
[f2]=histogram(handles.y(:,:,2));%f2 = Histogram Green
absis=0:1:255;
%absis/x = antara 1 sampai 255
axes(handles.axes2)
%posisi meletakkan grafik
Hstogram
plot(absis,f2,'g')
%untuk menggambar grafik hasil
perhitungan histogram image
grid on
%menampilkan grid pada kotak
histogram
else if indeks==4 %jika menu 4 dipilih maka akan muncul
histogram green

[f3]=histogram(handles.y(:,:,3));%f3 = Histogram Blue


absis=0:1:255;
%absis/x = antara 1 sampai
255

axes(handles.axes2)

%posisi meletakkan grafik

Hstogram

plot(absis,f3,'b')
%untuk menggambar grafik
hasil perhitungan histogram image
grid on
%menampilkan grid pada
kotak histogram
end
end
end
end
% hObject
handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2
contents as cell array
%
contents{get(hObject,'Value')} returns selected item from
popupmenu2

% --- Executes during object creation, after setting all properties.


function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject
handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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

2. Screen Shot
a. Gambar 1

2.1 Gambar tampilan awal


b. Gambar 2

2.2 Gambar Open File image

c. Gambar 3

2.3 Gambar File image abu-abu dan hasil Histogramnya


d. Gambar 4

2.4 Gambar image berwarna/RGB dan hasil Histogramnya

e. Gambar 5

2.5 Gambar hasil Histogram RGB

f. Gambar 6

2.6 Gambar Hasil Histogram Red

g. Gambar 7

2.7 Gambar Hasil Histogram Green


h. Gambar 8

2.8 Gambar hasil Histogram Blue

You might also like