Source code saat program pertama kali
dijalankan
function
utama_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output =
hObject;
guidata(hObject,
handles);
handles.namafile=' ';
handles.direktori=' ';
set(handles.btnReset,'Enable','off');
I=imread('ui.jpg');
set(handles.proyekPD,'CurrentAxes',handles.gbrAsli);
set(imshow(I));
set(handles.proyekPD,'CurrentAxes',handles.gbrHasil);
set(imshow(I));
set(handles.txtdata1,'string','');
set(handles.txtdata2,'string','');
set(handles.txtdata3,'string','');
set(handles.txtProses,'string','');
set(handles.gbrAsli,'Userdata',I);
set(handles.proyekPD,'CurrentAxes',handles.gbrHistogram);
imhist(rgb2gray(I));
Source code saat program Memilih
gambar(Image)
function
btnBrowse_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
[handles.namafile,handles.direktori]=uigetfile({'*.bmp;*.jpg','file
citra(*.bmp,*.jpg)';'*.bmp','file
bitmap(*.bmp)';'*.jpg','file
jpg(*.jpg)';'*.*','semua file(*.*)'},'buka
file citra host/asli');
I=imread(fullfile(handles.direktori,handles.namafile));
if
size(handles.namafile,2)>0
set(handles.btnReset,'Enable','on');
set(proyek.proyekPD,'CurrentAxes',proyek.gbrAsli);
set(imshow(I));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHistogram);
imhist(rgb2gray(I));
set(proyek.txtProses,'String','Pilih
Image');
set(proyek.gbrAsli,'Userdata',I);
mywidth=int2str(size(I,1));
myheight=int2str(size(I,2));
mysize=(['size
image:',mywidth,'x',myheight]);
mypath=(['path
image:',handles.direktori,handles.namafile]);
mypaths=([handles.direktori,handles.namafile]);
[infogambar]=([mypaths '
Resolusi:',image_width,'x',image_height]);
set(handles.txtProperties,'string',infogambar);
else
set(handles.txtdata1,'string','');
set(handles.txtdata2,'string','');
set(handles.txtdata3,'string','');
set(handles.txtProses,'string','');
return;
end
Source code saat program menekan tombol
Grayscale
function
btnGrayscale_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.gbrAsli,'Userdata');
J=rgb2gray(I);
set(proyek.proyekPD,'CurrentAxes',proyek.gbrAsli);
set(imshow(I));
set(proyek.proyekPD,'CurrentAxes',handles.gbrHistogram);
imhist(rgb2gray(I));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHasil);
set(imshow(J));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHistogramHasil);
imhist(J);
set(handles.txtProses,'String','GrayScale');
set(proyek.gbrAsli,'Userdata',I);
set(proyek.gbrHasil,'Userdata',J);
Source code saat program menekan tombol
Reset
function
btnReset_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
mau=questdlg(['Reset
' get(proyek.proyekPD,'Name')''],['Anda
ingin Reset Aplikasi ini?'],'Ya','Tidak','Ya');
if
strcmp(mau,'Tidak')
return;
else
arrayfun(@cla,findall(0,'type','axes'))
set(handles.txtdata1,'string','');
set(handles.txtdata2,'string','');
set(handles.txtdata3,'string','');
axes(handles.gbrAsli);cla;
axes(handles.gbrHasil);cla;
axes(handles.gbrHistogram);cla;
axes(handles.gbrHistogramHasil);cla;
set(handles.btnReset,'Enable','off');%on
hm = msgbox('Reset','Reset
Sukses','help');
end
Source code saat program menekan tombol
Grayscale(RED)
function
btnRed_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.gbrAsli,'Userdata');
red=I(:,:,1); %memanggil
matriks gambar yang hanya berisi piksel warnamerah
set(proyek.proyekPD,'CurrentAxes',proyek.gbrAsli);
set(imshow(I));
set(proyek.proyekPD,'CurrentAxes',handles.gbrHistogram);
imhist(rgb2gray(I));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHasil);
set(imshow(red));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHistogramHasil);
imhist(red);
set(handles.txtProses,'String','Red
Matrix');
set(proyek.gbrAsli,'Userdata',I);
set(proyek.gbrHasil,'Userdata',red);
Source code saat program menekan tombol Grayscale(Green)
function
btnGreen_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.gbrAsli,'Userdata');
green=I(:,:,2); %memanggil
matriks gambar yang hanya berisi piksel hijau
set(proyek.proyekPD,'CurrentAxes',proyek.gbrAsli);
set(imshow(I));
set(proyek.proyekPD,'CurrentAxes',handles.gbrHistogram);
imhist(rgb2gray(I));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHasil);
set(imshow(green));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHistogramHasil);
imhist(green);
set(handles.txtProses,'String','Green
Matrix');
set(proyek.gbrAsli,'Userdata',I);
set(proyek.gbrHasil,'Userdata',green);
Source code saat program menekan tombol
Grayscale(Blue)
function
btnBlue_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.gbrAsli,'Userdata');
blue=I(:,:,3); %memanggil
matriks gambar yang hanya berisi piksel biru
set(proyek.proyekPD,'CurrentAxes',proyek.gbrAsli);
set(imshow(I));
set(proyek.proyekPD,'CurrentAxes',handles.gbrHistogram);
imhist(rgb2gray(I));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHasil);
set(imshow(blue));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHistogramHasil);
imhist(blue);
set(handles.txtProses,'String','Blue
Matrix');
set(proyek.gbrAsli,'Userdata',I);
set(proyek.gbrHasil,'Userdata',blue);
Source code saat program menekan tombol
Normalisasi BW
function
btnBW_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
I=get(proyek.gbrAsli,'Userdata');
red=I(:,:,1); %memanggil
matriks gambar yang hanya berisi piksel warna merah
green=I(:,:,2);%
memanggil matriks gambar yang hanya berisi piksel warna hijau
blue=I(:,:,3); %memanggil
matriks gambar yang hanya berisi piksel warna biru
gray2=0.3*red+0.5*green+0.2*blue ;
set(proyek.proyekPD,'CurrentAxes',proyek.gbrAsli);
set(imshow(I));
set(proyek.proyekPD,'CurrentAxes',handles.gbrHistogram);
imhist(rgb2gray(I));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHasil);
set(imshow(gray2));
set(proyek.proyekPD,'CurrentAxes',proyek.gbrHistogramHasil);
imhist(gray2);
set(proyek.txtProses,'String','B/W
Function');
set(proyek.gbrAsli,'Userdata',I);
set(proyek.gbrHasil,'Userdata',gray2);
No comments:
Post a Comment