forked from HuimingJia/face_recognition_matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openfile.m
executable file
·36 lines (35 loc) · 1.35 KB
/
openfile.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [image] = openfile( )
%OPENFILE 此处显示有关此函数的摘要
% 此处显示详细说明
%
% 输出参数:
% image:用户所读入图片
global image_show;
%===================================================================
%===================================================================
%%%%%%%%%%%%%%%%%%%%
%资源管理器中读取任何格式的文件,默认文件名为‘myFace.jpg’
%%%%%%%%%%%%%%%%%%%%%
[f,p]=uigetfile('*.*','选择图像文件','myFace.jpg');
if f
try
image=imread(strcat(p,f));
catch
%%%%%%%%%%%%%%%%%%%%
%如果imread读入函数报错,则报错提示该文件不可被读入
%%%%%%%%%%%%%%%%%%%%%
errordlg('file can not be readed','Error','replace');
end
else
%%%%%%%%%%%%%%%%%%%%
%如果用户没有选择文件,则提示选择不可以为空,等待用户重新点击openfile按钮
%%%%%%%%%%%%%%%%%%%%%
errordlg('choice can not be empty','Error','replace');
end
%=================================================================
%=================================================================
%%%%%%%%%%%%%%%%%%%%
%打印图片至image_show
%%%%%%%%%%%%%%%%%%%%%
imshow(image,'parent',image_show);
end