Sie sind auf Seite 1von 11

PROGRAM YANG DIBUAT MINIMAL SEPULUH MENU(BUTTON / SLIDER / EDIT

TEXT)

Dibawah berikut adalah beberapa kodingan menu pada komponen yang


tertera pada gambar diatas.

*Tidak semua menu di gambar diatas ada kodingannya pada file ini
%Tombol Open Image
function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[file path]=uigetfile({'*.jpg';'*.bmp';'*.jpeg';'*.png'},'Buka Gambar');
image = [path file];
handles.file=image;
if (file == 0)
warndlg('Gambar Belum Di Pilih');
end

handles.img=imread(image);
handles.i=imread(image);

h=waitbar(0,' Please Wait...');


steps=100;
for step=1: steps
waitbar(step/steps);
end
close(h);

axes(handles.g1);cla;imshow(handles.img);
axes(handles.g2);cla;imshow(handles.img);
guidata(hObject,handles);
% RGB component graph
r=handles.i(:,:,1);
g=handles.i(:,:,2);
b=handles.i(:,:,3);
x=size(r); x=(1:x(1,2));
r=r(1,:); g=g(1,:); b=b(1,:);
axes(handles.g4); plot(x,r,'r');
hold on
plot(x,g,'g'); plot(x,b,'b'); hold off;

% --- Executes on slider movement.


% Slider Brighness. Set min:-100 & max: 100 (Pada object Inspector)
function sld_Brightness_Callback(hObject, eventdata, handles)
% hObject handle to sld_Brightness (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

x=get(hObject, 'Value');
img=handles.img;
img=img+x
axes(handles.g2); cla ; imshow(img);
handles.img=img;
updateg4(handles)

% --- Executes on slider movement.


% Slider Channel RED. Set min:-100 & max: 100 (Pada object Inspector)
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=get(hObject,'Value');
r=handles.img(:,:,1);
g=handles.img(:,:,2);
b=handles.img(:,:,3);
redbaru=r+x;
rcon=cat(3,redbaru,g,b);
axes(handles.g2); cla ; imshow (rcon);
handles.img=rcon;
updateg4(handles)

% --- Executes on slider movement.


% Slider KOntras. Set min:-100 & max: 100 (Pada object Inspector)
function slider3_Callback(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=get(hObject, 'Value');
img=handles.img;
img=img.*x;
axes(handles.g2); cla ; imshow(img);
handles.img=img;
updateg4(handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of
slider

% Slider Negasi. Set min:-100 & max: 100 (Pada object Inspector)
function sld_negasi_Callback(hObject, eventdata, handles)
% hObject handle to sld_negasi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=get(hObject, 'Value');
img=handles.img;
img=img-x;
axes(handles.g2); cla ; imshow(255-img);
handles.img=img;
updateg4(handles)
set(handles.nv,'String',num2str(x));
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of
slider

% --- Executes on slider movement.

% Slider Channel Green. Set min:-100 & max: 100 (Pada object Inspector)
function slider5_Callback(hObject, eventdata, handles)
% hObject handle to slider5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

x=get(hObject,'Value');
r=handles.img(:,:,1);
g=handles.img(:,:,2);
b=handles.img(:,:,3);
greenbaru=g+x;
gcon=cat(3,r,greenbaru,b);
axes(handles.g2); cla ; imshow (gcon);
handles.img=gcon;
updateg4(handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of
slider

% --- Executes on slider movement.


% Slider Channel Green. Set min:-100 & max: 100 (Pada object Inspector)
unction slider6_Callback(hObject, eventdata, handles)
% hObject handle to slider6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=get(hObject,'Value');
r=handles.img(:,:,1);
g=handles.img(:,:,2);
b=handles.img(:,:,3);
bluebaru=b+x;
bcon=cat(3,r,g,bluebaru);
axes(handles.g2); cla ; imshow (bcon);
handles.img=bcon;
updateg4(handles)
% Hints: get(hObject
% Slider Channel Green. Set min:-100 & max: 100 (Pada object Inspector)
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
imcrop(handles.g2);
handles.img=getimage(gca); close;
axes(handles.g2); cla; imshow(handles.img)
guidata(hObject,handles);
updateg4(handles);

% --- Executes on button press in btnreset.

% Button reset
function btnreset_Callback(hObject, eventdata, handles)
% hObject handle to btnreset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
handles.img=handles.i;
axes(handles.g2); cla; imshow(handles.img);
axes(handles.g4); cla;updateg4(handles);
guidata(hObject,handles);
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in btnsave.


%button save
function btnsave_Callback(hObject, eventdata, handles)
% hObject handle to btnsave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
[file path]= uiputfile('*.jpg','Save Image as');
save=[path file]; imwrite(handles.img,save,'jpg');

%button smoothing Gaussian


% --- Executes on button press in btngaussian.
function btngaussian_Callback(hObject, eventdata, handles)
% hObject handle to btngaussian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
hsize= [8 8]; sigma=1.7;
h=fspecial('gaussian',hsize,sigma);
handles.img=imfilter(handles.img,h,'replicate');
axes(handles.g2);cla ;imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);

%button smoothing mean filtering.


function btnmean_Callback(hObject, eventdata, handles)
% hObject handle to btnmean (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
hsize= [3 3];
h=fspecial('average',hsize);
handles.img=imfilter(handles.img,h,'replicate');
axes(handles.g2);cla ;imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);

% --- Executes on button press in btnmedian.

%button smoothing mean filtering.


function btnmedian_Callback(hObject, eventdata, handles)
% hObject handle to btnmedian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
x=get(hObject, 'Value');
img=handles.img;
j = filter2(fspecial('average',3),img);
B = medfilt2(j,[5 5]);
axes(handles.g2);imshow(B);
guidata(hObject,handles);
updateg4(handles);
% handles structure with handles and user data (see GUIDATA)

%button smoothing sharp filtering.


function btnunsharp_Callback(hObject, eventdata, handles)
% hObject handle to btnunsharp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
alpha=0.1;
h=fspecial('unsharp',alpha);
handles.img=imfilter(handles.img,h,'replicate');
axes(handles.g2);cla ;imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);

% axes:g5, edittext1(x1), edittext2(x2), edittext2(y1), edittext4(y2),


file dda.m (yang pernah kita buat)
% --- Executes on button press in btndda.
function btndda_Callback(hObject, eventdata, handles)
% hObject handle to btndda (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
xa = str2double(get(handles.x1,'String'));
ya = str2double(get(handles.y1,'String'));
xb = str2double(get(handles.x2,'String'));
yb = str2double(get(handles.y2,'String'));
axes(handles.g5); cla;
DDA(xa,ya,xb,yb);
hold on;
guidata(hObject,handles);

% --- Executes on button press in pushbutton17.

% axes:g5, edittext1(xcenter), edittext2(ycenter), edittext2(jari),


file lingkaran.m (yang pernah kita buat)
function pushbutton17_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
jari = str2double(get(handles.jarijari,'String'));
xcenterr = str2double(get(handles.xcenter,'String'));
ycenterr = str2double(get(handles.ycenter,'String'));
axes(handles.g5); cla;
lingkaran(jari,xcenterr,ycenterr);
axis([-1 100 -1 100]);
guidata(hObject,handles);

% --- Executes on button press in pushbutton18.


%axes:g5, edittext1(t), edittext2(r), edittext2(x), file lingkaran.m
(yang pernah kita buat)
function pushbutton18_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
t = str2double(get(handles.tinggitabung,'String'));
r = str2double(get(handles.jaritabungan,'String'));
x = str2double(get(handles.xtabung,'String'));
y = str2double(get(handles.ytabung,'String'));
axes(handles.g5); cla;
tabung(t,r,x,y);
guidata(hObject,handles);

% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in btndisk.


%button edge detection: disk
function btndisk_Callback(hObject, eventdata, handles)
% hObject handle to btndisk (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
radius = 5;
h=fspecial('disk',2*radius+1);
handles.img=imfilter(handles.img,h,'replicate');
axes(handles.g2);cla ;imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in btnlaplacian.


%button smooting: laplacian
function btnlaplacian_Callback(hObject, eventdata, handles)
% hObject handle to btnlaplacian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
ALPHA = 0.2;
h=fspecial('laplacian',ALPHA);
handles.img=imfilter(handles.img,h);
axes(handles.g2);cla ;imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in btnlog.


%button smooting:: gaussian
function btnlog_Callback(hObject, eventdata, handles)
% hObject handle to btnlog (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
hsize= [8 8]; sigma=0.9;
h=fspecial('log',hsize,sigma);
handles.img=imfilter(handles.img,h,'replicate');
axes(handles.g2);cla ;imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in btnmotion.


%button smooting:: motion
function btnmotion_Callback(hObject, eventdata, handles)
% hObject handle to btnmotion (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
LEN= 9;
THETA=5;
h=fspecial('motion',LEN,THETA);
handles.img=imfilter(handles.img,h,'replicate');
axes(handles.g2);cla ;imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in btnPrewitt.


%button smooting:: prewit
function btnPrewitt_Callback(hObject, eventdata, handles)
% hObject handle to btnPrewitt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
h=fspecial('prewitt');
handles.img=imfilter(handles.img,h','replicate');%h di transpose
axes(handles.g2);cla ;imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in btnsobel.


%button smooting:: sobel
function btnsobel_Callback(hObject, eventdata, handles)
% hObject handle to btnsobel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
h=fspecial('sobel');
handles.img=imfilter(handles.img,h');%h di transpose
axes(handles.g2);cla ;imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);
% handles structure with handles and user data (see GUIDATA)

%slider rotasi gammbar

% --- Executes on slider movement.


function slider7_Callback(hObject, eventdata, handles)
% hObject handle to slider7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
rrv=(get(hObject,'Value'));
handles.rot=handles.img;
handles.rot=imrotate(handles.rot,rrv);
axes(handles.g2); cla; imshow(handles.rot);
guidata(hObject,handles)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of
slider

%resize gambar, editext: e1, e2, button resize

% --- Executes on button press in pushbutton25.


function pushbutton25_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton25 (see GCBO)
h=str2num(get(handles.e1,'String'));
w=str2num(get(handles.e2,'String'));
handles.img=imresize(handles.img, [h w]);
axes(handles.g2); cla; imshow(handles.img);
guidata(hObject,handles);
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
les and user data (see GUIDATA)

%tombol greyscale
% --- Executes on button press in pushbutton36.
function pushbutton36_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton36 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

handles.img = rgb2gray(handles.img);
axes(handles.g2); cla; imshow(handles.img);
guidata(hObject,handles);
updateg4(handles);

Das könnte Ihnen auch gefallen