source: trunk/src/read_image.m @ 604

Last change on this file since 604 was 604, checked in by sommeria, 8 years ago

bugs corrected in series, ima_levels cleaned as exemple

File size: 1.6 KB
Line 
1%'read_image': read images or video objects
2%----------------------------------------------------------------------
3% function [A,ObjectOut]=read_image(FileName,FileType,VideoObject,num)
4%
5% OUTPUT:
6% A(npy,npx,rgb): matrix of integers (iunt8 or uint16) representing the image, with sizes npy, npx, and possibly color component rgb=1:3
7% ObjectOut: video object (=[] for single images)
8%
9% INPUT:
10% FileName: input file name
11%                 other inputs needed  only for video and multi-image file:
12% FileType: input file type, as determined by the function get_file_type.m
13% VideoObject: video object (for faster reading if availlable)
14% num: frame index for movies or multimage types
15%
16function [A,ObjectOut]=read_image(FileName,FileType,VideoObject,num)
17%-----------------------------------------------------------------------
18if ~exist(FileType,'var')
19    FileType='image';
20end
21if ~exist('VideoObject','var')
22    VideoObject=[];
23end
24if ~exist('num','var')
25    num=1;
26end
27ObjectOut=VideoObject;%default
28switch FileType
29         case 'video'
30            if strcmp(class(VideoObject),'VideoReader')
31                A=read(VideoObject,num);
32            else
33                ObjectOut=VideoReader(FileName);
34                A=read(ObjectOut,num);
35            end
36        case 'mmreader'
37            if strcmp(class(VideoObject),'mmreader')
38                A=read(VideoObject,num);
39            else
40                ObjectOut=mmreader(FileName);
41                A=read(ObjectOut,num);
42            end
43    case 'multimage'
44        A=imread(FileName,num);
45    case 'image'   
46        A=imread(FileName);
47end
Note: See TracBrowser for help on using the repository browser.