source: trunk/src/read_image.m @ 756

Last change on this file since 756 was 610, checked in by sommeria, 12 years ago

various bugs fixed after tests under widows
introduce uigetfile_uvmat for series/status (some problems need to be solved)

File size: 1.6 KB
RevLine 
[497]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
[604]7% ObjectOut: video object (=[] for single images)
[497]8%
9% INPUT:
10% FileName: input file name
[604]11%                 other inputs needed  only for video and multi-image file:
[497]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%-----------------------------------------------------------------------
[610]18if ~exist('FileType','var')
[604]19    FileType='image';
20end
[497]21if ~exist('VideoObject','var')
22    VideoObject=[];
23end
24if ~exist('num','var')
25    num=1;
26end
27ObjectOut=VideoObject;%default
[453]28switch FileType
[493]29         case 'video'
30            if strcmp(class(VideoObject),'VideoReader')
31                A=read(VideoObject,num);
32            else
[497]33                ObjectOut=VideoReader(FileName);
34                A=read(ObjectOut,num);
[493]35            end
36        case 'mmreader'
37            if strcmp(class(VideoObject),'mmreader')
38                A=read(VideoObject,num);
39            else
[497]40                ObjectOut=mmreader(FileName);
41                A=read(ObjectOut,num);
[493]42            end
[453]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.