Last change
on this file since 35 was
19,
checked in by gostiaux, 15 years ago
|
the private files have been moved down to the root folder
|
File size:
985 bytes
|
Line | |
---|
1 | %'read_image': reads an image from a single file or a movie file
|
---|
2 | function [A,error]=read_image(filename,NomType,num);
|
---|
3 | %read images in different formats.
|
---|
4 | A=[]; %default
|
---|
5 | error=0; %default
|
---|
6 | if ~exist(filename,'file')
|
---|
7 | error='input file not found in read_image'
|
---|
8 | return
|
---|
9 | end
|
---|
10 | testframe=0;
|
---|
11 | if ~exist('NomType','var')
|
---|
12 | NomType=[];
|
---|
13 | end
|
---|
14 | if ~exist('num','var')
|
---|
15 | num=1;
|
---|
16 | end
|
---|
17 | [pth,fl,ext]=fileparts(filename);
|
---|
18 | if isequal(lower(ext),'.avi')
|
---|
19 | mov=aviread(filename,num);
|
---|
20 | A=frame2im(mov(1));
|
---|
21 | elseif isequal(lower(ext),'.vol')
|
---|
22 | A=imread(filename);
|
---|
23 | else
|
---|
24 | form=imformats(ext([2:end]));
|
---|
25 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
26 | if isequal(NomType,'*');
|
---|
27 | A=imread(filename,num);
|
---|
28 | else
|
---|
29 | A=imread(filename);
|
---|
30 | end
|
---|
31 | else
|
---|
32 | error=['ERROR in read_image: file extension not recognized by matlab as image'];
|
---|
33 | return
|
---|
34 | end
|
---|
35 | end
|
---|
36 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.