Importing 4 jpg files to face_GUI

1 view (last 30 days)
I am trying to capture 4 jpg images to a GUI. The picture is captured and opens in Matlab as subplot. How to modify it to open in my face_GUI?
function varargout = face_GUI(varargin)
% FACE_GUI M-file for face_GUI.fig
% FACE_GUI, by itself, creates a new FACE_GUI or raises the existing
% singleton*.
%
% H = FACE_GUI returns the handle to a new FACE_GUI or the handle to
% the existing singleton*.
%
% FACE_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FACE_GUI.M with the given input arguments.
%
% FACE_GUI('Property','Value',...) creates a new FACE_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before face_GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to face_GUI_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 face_GUI
% Last Modified by GUIDE v2.5 24-Mar-2013 10:57:27
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @face_GUI_OpeningFcn, ...
'gui_OutputFcn', @face_GUI_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 face_GUI is made visible.
function face_GUI_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 face_GUI (see VARARGIN)
% Choose default command line output for face_GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes face_GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = face_GUI_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)
varargout{1} = handles.output;
m=4;
s=[];
figure(1);
prefix_image='t';
fileformat='.jpg';
for i=1:m
image1= imread(strcat(prefix_image,num2str(i),fileformat));
%figure(i);
img=rgb2gray(image1);
%whos
subplot(2,2,i);
imshow(img);
[iraw icol]=size(img);
temp=reshape(img,iraw*icol,1);
s=[s temp];
end
%part2 normalizt the images to reduce lighting conditions
for i=1:m
temp=double(s(:,i));
m2=mean(temp);
st2=std(temp);
s(:,i)=((temp-m2)*60/st2)+120;
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)
varargout{1} = handles.output;
m=4;
s=[];
figure(2);
prefix_image='t';
fileformat='.jpg';
for i=1:m
image1= imread(strcat(prefix_image,num2str(i),fileformat));
%figure(i);
img=rgb2gray(image1);
%whos
subplot(2,2,i);
imshow(img);
[iraw icol]=size(img);
temp=reshape(img',iraw*icol,1);
s=[s temp];
end
%part2 normalizt the images to reduce lighting conditions
for i=1:m
temp=double(s(:,i));
m2=mean(temp);
st2=std(temp);
s(:,i)=(temp-m2)*60/st2+120;
end
for i=1:m
img=reshape(s(:,i),icol,iraw);
img=img';
subplot(2,2,i);
imshow(img);
end
m2=mean(s,2);
tmimg=uint8(m2);
img=reshape(tmimg,icol,iraw);
img=img';
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
varargout{1} = handles.output;
m=4;
s=[];
figure(3);
prefix_image='t';
fileformat='.jpg';
for i=1:m
image1= imread(strcat(prefix_image,num2str(i),fileformat));
%figure(i);
img=rgb2gray(image1);
%whos
subplot(2,2,i);
imshow(img);
[iraw icol]=size(img);
temp=reshape(img',iraw*icol,1);
s=[s temp];
end
%part2 normalizt the images to reduce lighting conditions
for i=1:m
temp=double(s(:,i));
m2=mean(temp);
st2=std(temp);
s(:,i)=(temp-m2)*60/st2+120;
end
for i=1:m
img=reshape(s(:,i),icol,iraw);
img=img';
subplot(2,2,i);
imshow(img);
end
m2=mean(s,2);
tmimg=uint8(m2);
img=reshape(tmimg,icol,iraw);
img=img';
imshow(img);
dbx=[];
for i=1:m
temp=double(s(:,i));
dbx=[dbx temp];
end
A=dbx';
L=A*A';
[vv dd]=eig(L);
v=[];
d=[];
for i=1:size(vv,2)
if (dd(i,i)>1.0e-4)
v=[v vv(:,i)];
d=[d dd(i,i)];
end
end
%sort, will return an ascending sequence
[B index]=sort(d);
ind=zeros(size(index));
dtemp=zeros(size(index));
vtemp=zeros(size(v));
len=length(index);
for i=1:len
dtemp(i)=B(len+1-i);
ind(i)=len+1-index(i);
vtemp(:,ind(i))=v(:,i);
end
d=dtemp;
v=vtemp;
%Normalization of eigenvectors
for i=1:size(v,2) %access each column
kk=v(:,i);
temp=sqrt(sum(kk.^2));
v(:,i)=v(:,i)./temp;
end
%Eigenvectors of C matrix
u=[];
for i=1:size(v,2)
temp=sqrt(d(i));
u=[u (dbx*v(:,i))./temp];
end
%Normalization of eigenvectors
for i=1:size(u,2)
kk=u(:,i);
temp=sqrt(sum(kk.^2));
u(:,i)=u(:,i)./temp;
end
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
varargout{1} = handles.output;
m=4;
s=[];
figure(4);
prefix_image='t';
fileformat='.jpg';
for i=1:m
image1= imread(strcat(prefix_image,num2str(i),fileformat));
%figure(i);
img=rgb2gray(image1);
%whos
subplot(2,2,i);
imshow(img);
[iraw icol]=size(img);
temp=reshape(img',iraw*icol,1);
s=[s temp];
end
%part2 normalizt the images to reduce lighting conditions
for i=1:m
temp=double(s(:,i));
m2=mean(temp);
st2=std(temp);
s(:,i)=(temp-m2)*60/st2+120;
end
for i=1:m
img=reshape(s(:,i),icol,iraw);
img=img';
subplot(2,2,i);
imshow(img);
end
m2=mean(s,2);
tmimg=uint8(m2);
img=reshape(tmimg,icol,iraw);
img=img';
imshow(img);
dbx=[];
for i=1:m
temp=double(s(:,i));
dbx=[dbx temp];
end
A=dbx';
L=A*A';
[vv dd]=eig(L);
v=[];
d=[];
for i=1:size(vv,2)
if (dd(i,i)>1.0e-4)
v=[v vv(:,i)];
d=[d dd(i,i)];
end
end
%sort, will return an ascending sequence
[B index]=sort(d);
ind=zeros(size(index));
dtemp=zeros(size(index));
vtemp=zeros(size(v));
len=length(index);
for i=1:len
dtemp(i)=B(len+1-i);
ind(i)=len+1-index(i);
vtemp(:,ind(i))=v(:,i);
end
d=dtemp;
v=vtemp;
%Normalization of eigenvectors
for i=1:size(v,2) %access each column
kk=v(:,i);
temp=sqrt(sum(kk.^2));
v(:,i)=v(:,i)./temp;
end
%Eigenvectors of C matrix
u=[];
for i=1:size(v,2)
temp=sqrt(d(i));
u=[u (dbx*v(:,i))./temp];
end
%Normalization of eigenvectors
for i=1:size(u,2)
kk=u(:,i);
temp=sqrt(sum(kk.^2));
u(:,i)=u(:,i)./temp;
end
% show eigenfaces
for i=1:size(u,2)
img=reshape(u(:,i),icol,iraw);
img=img';
img=histeq(img,255);
subplot(2,2,i);
imshow(img);
drawnow;
end
%find weights
omega = [];
for h=1:size(dbx,2)
WW=[];
for i=1:size(u,2)
t = u(:,i)';
WeightOfImage = dot(t,dbx(:,h)');
WW = [WW; WeightOfImage];
end
omega = [omega WW];
end
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, ~, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on selection change in popup.
function popup_Callback(hObject, eventdata, handles)
% hObject handle to popup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Set current data to the selected data set.
% Hints: contents = cellstr(get(hObject,'String')) returns popup contents as cell array
% contents{get(hObject,'Value')} returns selected item from popup
% --- Executes during object creation, after setting all properties.
function popup_CreateFcn(hObject, eventdata, handles)
% hObject handle to popup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on key press with focus on popup and none of its controls.
function popup_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to popup (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)

Accepted Answer

Walter Roberson
Walter Roberson on 31 Mar 2013
Your four pushbuttons have in them calls such as
figure(3)
Change that to
figure(handles.output)
to have the graphics that would normally go to figure 1, 2, 3, or 4 go instead to Face_GUI .

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!