source: trunk/src/read_image.m @ 35

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
2function [A,error]=read_image(filename,NomType,num);
3 %read  images in different formats.
4A=[]; %default
5error=0; %default
6if ~exist(filename,'file')
7    error='input file not found in read_image'
8    return
9end
10testframe=0;
11if ~exist('NomType','var')
12    NomType=[];
13end
14if ~exist('num','var')
15    num=1;
16end
17[pth,fl,ext]=fileparts(filename);
18if isequal(lower(ext),'.avi')
19    mov=aviread(filename,num);
20    A=frame2im(mov(1));
21elseif isequal(lower(ext),'.vol')
22     A=imread(filename);
23else
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
35end
36 
Note: See TracBrowser for help on using the repository browser.