source: trunk/src/read_image.m @ 837

Last change on this file since 837 was 823, checked in by sommeria, 10 years ago

various

File size: 2.4 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_info.m
13% VideoObject: video object (for faster reading if availlable)
14% num: frame index for movies or multimage types
15
16%=======================================================================
17% Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
18%   http://www.legi.grenoble-inp.fr
19%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
20%
21%     This file is part of the toolbox UVMAT.
22%
23%     UVMAT is free software; you can redistribute it and/or modify
24%     it under the terms of the GNU General Public License as published
25%     by the Free Software Foundation; either version 2 of the license,
26%     or (at your option) any later version.
27%
28%     UVMAT is distributed in the hope that it will be useful,
29%     but WITHOUT ANY WARRANTY; without even the implied warranty of
30%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31%     GNU General Public License (see LICENSE.txt) for more details.
32%=======================================================================
33
34function [A,ObjectOut]=read_image(FileName,FileType,VideoObject,num)
35%-----------------------------------------------------------------------
36if ~exist('FileType','var')
37    FileType='image';
38end
39if ~exist('VideoObject','var')
40    VideoObject=[];
41end
42if ~exist('num','var')
43    num=1;
44end
45A=[];
46ObjectOut=VideoObject;%default
47switch FileType
48         case 'video'
49            if strcmp(class(VideoObject),'VideoReader')
50                A=read(VideoObject,num);
51            else
52                ObjectOut=VideoReader(FileName);
53                A=read(ObjectOut,num);
54            end
55        case 'mmreader'
56            if strcmp(class(VideoObject),'mmreader')
57                A=read(VideoObject,num);
58            else
59                ObjectOut=mmreader(FileName);
60                A=read(ObjectOut,num);
61            end
62    case 'multimage'
63        A=imread(FileName,num);
64    case 'image'   
65        A=imread(FileName);
66end
Note: See TracBrowser for help on using the repository browser.