function varargout = NewGUI(varargin)
% NEWGUI M-file for NewGUI.fig
% NEWGUI, by itself, creates a new NEWGUI or raises the existing
% singleton*.
%
% H = NEWGUI returns the handle to a new NEWGUI or the handle to
% the existing singleton*.
%
% NEWGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in NEWGUI.M with the given input arguments.
%
% NEWGUI('Property','Value',...) creates a new NEWGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before NewGUI_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to NewGUI_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 NewGUI
% Last Modified by GUIDE v2.5 12-Dec-2007 14:28:07
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @NewGUI_OpeningFcn, ...
'gui_OutputFcn', @NewGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 NewGUI is made visible.
function NewGUI_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 NewGUI (see VARARGIN)
% Choose default command line output for NewGUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes NewGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = NewGUI_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 on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%take alll the training image.
%take alll the training image.
im1=imread('group1/bfritza1.pgm');
im2=imread('group1/bfritza2.pgm');
im3=imread('group1/bfritza3.pgm');
%get the feature of image
r1=findfeature(im1);
r2=findfeature(im2);
r3=findfeature(im3);
%find the orientation histigram of image
h1=histc(r1,1:8);
h2=histc(r2,1:8);
h3=histc(r3,1:8);
%save the data
group1(1).im=im1;
group1(2).im=im2;
group1(3).im=im3;
group1(1).feature=r1;
group1(2).feature=r2;
group1(3).feature=r3;
group1(1).histal=h1;
group1(2).histal=h2;
group1(3).histal=h3;
setappdata(gcbf,'group1',group1);
%take group2 the training image.
im4=imread('group2/bfritzb1.pgm');
im5=imread('group2/bfritzb2.pgm');
im6=imread('group2/bfritzb3.pgm');
%get the feature of image
r4=findfeature(im4);
r5=findfeature(im5);
r6=findfeature(im6);
%find the orientation histigram of image
h4=histc(r4,1:8);
h5=histc(r5,1:8);
h6=histc(r6,1:8);
%save the data
group2(1).im=im4;
group2(2).im=im5;
group2(3).im=im6;
group2(1).feature=r4;
group2(2).feature=r5;
group2(3).feature=r6;
group2(1).histal=h4;
group2(2).histal=h5;
group2(3).histal=h6;
setappdata(gcbf,'group2',group2);
%take group3 the training image.
im7=imread('group3/bfritzc1.pgm');
im8=imread('group3/bfritzc2.pgm');
im9=imread('group3/bfritzc3.pgm');
%get the feature of image
r7=findfeature(im7);
r8=findfeature(im8);
r9=findfeature(im9);
%find the orientation histigram of image
h7=histc(r7,1:8);
h8=histc(r8,1:8);
h9=histc(r9,1:8);
%save the data
group3(1).im=im7;
group3(2).im=im8;
group3(3).im=im9;
group3(1).feature=r7;
group3(2).feature=r8;
group3(3).feature=r9;
group3(1).histal=h7;
group3(2).histal=h8;
group3(3).histal=h9;
setappdata(gcbf,'group3',group3);
%take group4 the training image.
im10=imread('group4/bfritzd1.pgm');
im11=imread('group4/bfritzd2.pgm');
im12=imread('group4/bfritzd3.pgm');
%get the feature of image
r10=findfeature(im10);
r11=findfeature(im11);
r12=findfeature(im12);
%find the orientation histigram of image
h10=histc(r10,1:8);
h11=histc(r11,1:8);
h12=histc(r12,1:8);
%save the data
group4(1).im=im10;
group4(2).im=im11;
group4(3).im=im12;
group4(1).feature=r10;
group4(2).feature=r11;
group4(3).feature=r12;
group4(1).histal=h10;
group4(2).histal=h11;
group4(3).histal=h12;
setappdata(gcbf,'group4',group4);
%take group5 the training image.
im13=imread('group5/bfritzg1.pgm');
im14=imread('group5/bfritzg2.pgm');
im15=imread('group5/bfritzg3.pgm');
%get the feature of image
r13=findfeature(im13);
r14=findfeature(im14);
r15=findfeature(im15);
%find the orientation histigram of image
h13=histc(r13,1:8);
h14=histc(r14,1:8);
h15=histc(r15,1:8);
%save the data
group5(1).im=im13;
group5(2).im=im14;
group5(3).im=im15;
group5(1).feature=r13;
group5(2).feature=r14;
group5(3).feature=r15;
group5(1).histal=h13;
group5(2).histal=h14;
group5(3).histal=h15;
setappdata(gcbf,'group5',group5);
%take group6 the training image.
im16=imread('group6/bfritzy1.pgm');
im17=imread('group6/bfritzy2.pgm');
im18=imread('group6/bfritzy3.pgm');
%get the feature of image
r16=findfeature(im16);
r17=findfeature(im17);
r18=findfeature(im18);
%find the orientation histigram of image
h16=histc(r16,1:8);
h17=histc(r17,1:8);
h18=histc(r18,1:8);
%save the data
group6(1).im=im16;
group6(2).im=im17;
group6(3).im=im18;
group6(1).feature=r16;
group6(2).feature=r17;
group6(3).feature=r18;
group6(1).histal=h16;
group6(2).histal=h17;
group6(3).histal=h18;
setappdata(gcbf,'group6',group6);
msgbox('The training is success.You can classify the new image now');
% figure;
% subplot(18,1,1);
% plot(h1);
% subplot(18,1,2);
% imshow(h2);
% subplot(18,1,3);
% plot(h3);
% subplot(18,1,4);
% plot(h4);
% subplot(18,1,5);
% plot(h5);
% subplot(18,1,6);
% plot(h6);
% subplot(18,1,7);
% plot(h7);
% subplot(18,1,8);
% plot(h8);
% subplot(18,1,9);
% plot(h9);
% subplot(18,1,10);
% plot(h10);
% subplot(18,1,11);
% plot(h11);
% subplot(18,1,12);
% plot(h12);
% subplot(18,1,13);
% plot(h13);
% subplot(18,1,14);
% plot(h14);
% subplot(18,1,15);
% plot(h15);
% subplot(18,1,16);
% plot(h16);
% subplot(18,1,17);
% plot(h17);
% subplot(18,1,18);
% plot(h18);
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,path]=uigetfile('*.pgm');
im1=imread(strcat(path,filename));
r1=findfeature(im1);
h1=histc(r1,1:8);
group{1}=getappdata(gcbf,'group1');
group{2}=getappdata(gcbf,'group2');
group{3}=getappdata(gcbf,'group3');
group{4}=getappdata(gcbf,'group4');
group{5}=getappdata(gcbf,'group5');
group{6}=getapp