1 简介
2 部分代码
function varargout = OpenImage(varargin)
% OPENIMAGE MATLAB code for OpenImage.fig
% OPENIMAGE, by itself, creates a new OPENIMAGE or raises the existing
% singleton*.
%
% H = OPENIMAGE returns the handle to a new OPENIMAGE or the handle to
% the existing singleton*.
%
% OPENIMAGE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in OPENIMAGE.M with the given input arguments.
%
% OPENIMAGE('Property','Value',...) creates a new OPENIMAGE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before OpenImage_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to OpenImage_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 OpenImage
% Last Modified by GUIDE v2.5 04-Jul-2016 15:53:58
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @OpenImage_OpeningFcn, ...
'gui_OutputFcn', @OpenImage_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 OpenImage is made visible.
function OpenImage_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 OpenImage (see VARARGIN)
% Choose default command line output for OpenImage
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes OpenImage wait for user response (see UIRESUME)
% uiwait(handles.figure1);
initital_dir=pwd;
FileInformation=load_listbox(initital_dir,handles);
handles.FileInformation=FileInformation;
guidata(handles.figure1,handles);
uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = OpenImage_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)
global Image_I;
% Get default command line output from handles structure
if isstruct(handles)==1
varargout{1} = handles.output;
Image_I.flag = 0;
else %区分是否选择图片
varargout{1} = 0;
Image_I.flag = 1;
end
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
index_selected=get(handles.listbox1,'Value');
filename=handles.FileInformation.sorted_names{index_selected};
handles.FileInformation.filename=[pwd,'\',filename];
handles.FileInformation.names_disp=handles.FileInformation.sorted_names_disp{index_selected};
handles.FileInformation.imsize=handles.FileInformation.imsize_disp{index_selected};
if index_selected<=handles.FileInformation.cnPiont
cd(handles.FileInformation.filename)
FileInformation=load_listbox(pwd,handles);
handles.FileInformation=FileInformation;
handles.FileInformation.IsImage=0;
else
handles.FileInformation.IsImage=1;
end
global Image_I;
Image_I.figure1 = handles.figure1;
Image_I.FileInformation = handles.FileInformation;
guidata(handles.figure1,handles);
uiresume(handles.figure1);
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function FileInformation=load_listbox(dir_path,handles)
cd(dir_path)
dir_struct=dir(dir_path);
[sorted_names1,sorted_index1]=sortrows({dir_struct.name}');
k=max(sorted_index1);
if k==2
sorted_names{1}='.';
sorted_names{2}='..';
sorted_names_disp{1}='.';
sorted_names_disp{2}='..';
imsize_disp{1}='null';
imsize_disp{2}='null';
cnPiont=2;
else
sorted_names{1}='.';
sorted_names{2}='..';
sorted_names_disp{1}='.';
sorted_names_disp{2}='..';
imsize_disp{1}='null';
imsize_disp{2}='null';
cn=2;
%%%%%%%%%%%%%%查找文件夹
for i=1:k
[path,name,ext]=fileparts(sorted_names1{i});
switch ext
case ''
cn=cn+1;
cnarray(cn)=cn;
sorted_names{cn}=name;
sorted_names_disp{cn}=name;
imsize_disp{cn}='null';
end
end
cnPiont=cn;
%%%%%%%%%%%%%%%%%查找图片文件
for i=1:k
[path,name,ext]=fileparts(sorted_names1{i});
switch ext
case {'.bmp','.jpg','.jpeg','.tif','.png','.gif'}
cn=cn+1;
cnarray(cn)=cn;
name=[name,ext];
sorted_names{cn}=name;
temp=imread(name);
[m,n]=size(temp);
m=num2str(m);
n=num2str(n);
imsize=[' ',m,'*',n];
name_disp=[name,imsize];
sorted_names_disp{cn}=name_disp;
imsize_disp{cn}=imsize;
end
end
end
FileInformation.sorted_names=sorted_names;
FileInformation.sorted_names_disp=sorted_names_disp;
FileInformation.imsize_disp=imsize_disp;
FileInformation.cnPiont=cnPiont;
set(handles.listbox1,'String',sorted_names_disp,...
'Value',1);
set(handles.text1,'String',pwd);
3 仿真结果
4 参考文献
[1]袁杰. 基于SIFT的图像配准与拼接技术研究[D]. 南京理工大学.