Académique Documents
Professionnel Documents
Culture Documents
2. Sintaks Program
function varargout = UTS_AjayIrdan_TI5B(varargin)
% UTS_AJAYIRDAN_TI5B MATLAB code for UTS_AjayIrdan_TI5B.fig
% UTS_AJAYIRDAN_TI5B, by itself, creates a new UTS_AJAYIRDAN_TI5B or raises the existing
% singleton*.
%
% H = UTS_AJAYIRDAN_TI5B returns the handle to a new UTS_AJAYIRDAN_TI5B or the handle to
% the existing singleton*.
%
% UTS_AJAYIRDAN_TI5B('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UTS_AJAYIRDAN_TI5B.M with the given input arguments.
%
% UTS_AJAYIRDAN_TI5B('Property','Value',...) creates a new UTS_AJAYIRDAN_TI5B or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before UTS_AjayIrdan_TI5B_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to UTS_AjayIrdan_TI5B_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
% --- Outputs from this function are returned to the command line.
function varargout = UTS_AjayIrdan_TI5B_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)
if ~isequal(filename,0)
Info = imfinfo(fullfile(pathname,filename));
if Info.BitDepth == 1
msgbox('Citra masukan harus citra RGB atau Grayscale');
return
elseif Info.BitDepth == 8
Gambar = imread(fullfile(pathname,filename));
axes(handles.axes1)
cla('reset')
imshow(Gambar)
title('Gambar Asli 8 Bit')
else
Gambar = rgb2gray(imread(fullfile(pathname,filename)));
axes(handles.axes1)
cla('reset')
imshow(Gambar)
title('Gambar Asli RGB')
end
else
return
end
handles.Gambar = Gambar;
guidata(hObject,handles);
set(handles.slider1,'Enable','on')
set(handles.slider1,'Value',1)
set(handles.slider2,'Enable','on')
set(handles.slider2,'Value',0)
set(handles.slider3,'Enable','on')
set(handles.slider4,'Enable','on')
axes(handles.axes2)
cla('reset')
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes3)
cla('reset')
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes4)
cla('reset')
set(gca,'XTick',[])
set(gca,'YTick',[])
% Here is cheap and easy way to change brightness or contrast in Matlab by percentage.
% 1
%
% newImage = imadjust(originalImage, [a b], [c d]);
%
% Where variables a, b, c and d are between 0 and 1.
%
% To increase contrast: decrease b
% To decrease contrast: increase a
% To increase brightness: increase c
% To decrease brightness: decrease d
nilai_slider1 = get(handles.slider1,'Value');
nilai_slider2 = get(handles.slider2,'Value');
set(handles.edit1,'String',num2str(nilai_slider1))
GambarAsli = handles.Gambar;
GambarKontras = imadjust(GambarAsli, [nilai_slider2 nilai_slider1], [0 1]);
axes(handles.axes2);
imshow(GambarKontras);
title('Gambar Kontras')
axes(handles.axes4)
h = histogram(GambarKontras(:));
xlim([0 255])
grid on
title('Histogram Kontras')
GambarAsli = handles.Gambar;
GambarKontras = imadjust(GambarAsli, [nilai_slider2 nilai_slider1], [0 1]);
axes(handles.axes2);
imshow(GambarKontras);
title('Gambar Kontras')
axes(handles.axes4)
h = histogram(GambarKontras(:));
xlim([0 255])
grid on
title('Histogram Kontras')
GambarAsli = handles.Gambar;
LowFilter = [ns3 ns3 ns3; ns3 ns3 ns3; ns3 ns3 ns3]/8;
GambarLowFilter = uint8(conv2(double(GambarAsli),LowFilter,'same'));
% filterImage = imadjust(originalImage, [nilai_slider3 nilai_slider1], [0 1]);
axes(handles.axes3);
imshow(GambarLowFilter);
title('Low Pass Filter')
axes(handles.axes4)
h = histogram(GambarLowFilter(:));
xlim([0 255])
grid on
title('Histogram Filter')
GambarAsli = handles.Gambar;
HighFilter = [ns4 -2 ns4; -3 ns4 -2; ns4 -2 ns4];
GambarHighFilter = uint8(conv2(double(GambarAsli),HighFilter,'same'));
% filterImage = imadjust(originalImage, [nilai_slider3 nilai_slider1], [0 1]);
axes(handles.axes3);
imshow(GambarHighFilter);
title('High Pass Filter')
axes(handles.axes4)
h = histogram(GambarHighFilter(:));
xlim([0 255])
grid on
title('Histogram Filter')
GambarAsli = handles.Gambar;
BlockSetting = @(block_struct) ...
std2(block_struct.data) * ones(size(block_struct.data));
GambarBlockProc = blockproc(GambarAsli,[ns5 ns5],BlockSetting);
axes(handles.axes3);
imshow(GambarBlockProc,[]);
title('Block Processing')
axes(handles.axes4)
h = histogram(GambarBlockProc(:));
xlim([0 255])
grid on
title('Histogram Block Proc')
GambarAsli = handles.Gambar;
BlockSetting = @(block_struct) ...
std2(block_struct.data) * ones(size(block_struct.data));
GambarBlockProc = blockproc(GambarAsli,[ns5 ns5],BlockSetting);
axes(handles.axes3);
imshow(GambarBlockProc,[]);
title('Block Processing')
axes(handles.axes4)
h = histogram(GambarBlockProc(:));
xlim([0 255])
grid on
title('Histogram Block Proc')