Senin

Script Matlab untuk pembuatan histogram

clear all;
close all;

l=imread('Sunset.jpg');
l1=rgb2gray(l);
figure(1)
subplot(1,2,1)
imshow(l1)

title('Gambar Asli');
[counts x]=imhist(l1);
counts1=counts(2:256-1,:);
x1=[2:1:255];
h=hist(counts1,x1);
p=histeq(l1,h);
subplot(1,2,2)
imshow(p);

title('Gambar Diproses');
hold on;
figure(2)
subplot(1,2,1)
imhist(l1)

title('Proses Histogram dari Gambar Asli');
subplot(1,2,2)
imhist(p)
title('Proses Histogram dari Gambar yang di Edit');
hold on;

k=mean2(l1);
k2=mean2(p);
dev=std2(l1);
dev1=std2(p);
[co xi]=imhist(l1,8);
[co1 xi1]=imhist(p,8);
m=mean2(xi);
m2=mean2(xi1);
stdev=std2(xi);
stdev1=std2(xi1);

disp('Gambar Asli');
disp(k);
disp(m);
disp(dev);
disp(stdev);

disp('Gambar Diproses');
disp(k2);
disp(m2);
disp(dev1);
disp(stdev1);

Program Matlab deteksi Tepi

Ini adalah script dengan matlab untuk membuat program deteksi tepi.
function varargout = deteksi_tepi(varargin)
% DETEKSI_TEPI M-file for deteksi_tepi.fig
% DETEKSI_TEPI, by itself, creates a new DETEKSI_TEPI or raises the existing
% singleton*.
%
% H = DETEKSI_TEPI returns the handle to a new DETEKSI_TEPI or the handle to
% the existing singleton*.
%
% DETEKSI_TEPI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DETEKSI_TEPI.M with the given input arguments.
%
% DETEKSI_TEPI('Property','Value',...) creates a new DETEKSI_TEPI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before deteksi_tepi_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to deteksi_tepi_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help deteksi_tepi

% Last Modified by GUIDE v2.5 12-Oct-2008 20:05:38

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @deteksi_tepi_OpeningFcn, ...
'gui_OutputFcn', @deteksi_tepi_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 deteksi_tepi is made visible.

function deteksi_tepi_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 deteksi_tepi (see VARARGIN)

% Choose default command line output for deteksi_tepi
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes deteksi_tepi wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = deteksi_tepi_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 during object creation, after setting all properties.
function text1_CreateFcn(hObject, eventdata, handles)
% hObject handle to text1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called


% --- Executes on button press in cari.
function cari_Callback(hObject, eventdata, handles)
% hObject handle to cari (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[a, path]=uigetfile(...
{'*.bmp;*.jpg','File yg dpet dibuka (*.bmp,*.jpg)';
},...
'Browser');
if ~isequal(a, 0)
handles.buka=imread(fullfile(path,a));
guidata(hObject,handles);
hold on;
axes(handles.axes1);
imshow(handles.buka);
hold on;
axes(handles.axes2);
imhist(handles.buka);
else
return;
end
set(handles.text1,'string',a);



% --- Executes on button press in proses.
function proses_Callback(hObject, eventdata, handles)
% hObject handle to proses (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
I = handles.buka ;
guidata(hObject,handles);
handles.bw=edge(I,'sobel');
hold on;
axes(handles.axes8);
imshow(handles.bw);
handles.bw1=edge(I,'canny');
hold on;
axes(handles.axes3);
imshow(handles.bw1);
handles.bw2=edge(I,'prewitt');
hold on;
axes(handles.axes4);
imshow(handles.bw2);