Home > . > read_image.m

read_image

PURPOSE ^

'read_image': reads an image from a single file or a movie file

SYNOPSIS ^

function [A,error]=read_image(filename,NomType,num);

DESCRIPTION ^

'read_image': reads an image from a single file or a movie file
read  images in different formats.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %'read_image': reads an image from a single file or a movie file
0002 function [A,error]=read_image(filename,NomType,num);
0003  %read  images in different formats.
0004 A=[]; %default
0005 error=0; %default
0006 if ~exist(filename,'file')
0007     error='input file not found in read_image'
0008     return
0009 end
0010 testframe=0;
0011 if ~exist('NomType','var')
0012     NomType=[];
0013 end
0014 if ~exist('num','var')
0015     num=1;
0016 end
0017 [pth,fl,ext]=fileparts(filename);
0018 if isequal(lower(ext),'.avi')
0019     mov=aviread(filename,num);
0020     A=frame2im(mov(1));
0021 elseif isequal(lower(ext),'.vol')
0022      A=imread(filename);
0023 else
0024      form=imformats(ext([2:end]));
0025      if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
0026          if isequal(NomType,'*');
0027             A=imread(filename,num);
0028          else 
0029            A=imread(filename);  
0030          end
0031      else
0032          error=['ERROR in read_image: file extension not recognized by matlab as image'];
0033          return
0034      end
0035 end
0036

Generated on Fri 13-Nov-2009 11:17:03 by m2html © 2003