[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: |
---|
[784] | 12 | % FileType: input file type, as determined by the function get_file_info.m |
---|
[497] | 13 | % VideoObject: video object (for faster reading if availlable) |
---|
| 14 | % num: frame index for movies or multimage types |
---|
[809] | 15 | |
---|
| 16 | %======================================================================= |
---|
[1126] | 17 | % Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
[809] | 18 | % http://www.legi.grenoble-inp.fr |
---|
[1127] | 19 | % Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr |
---|
[497] | 20 | % |
---|
[809] | 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 | |
---|
[497] | 34 | function [A,ObjectOut]=read_image(FileName,FileType,VideoObject,num) |
---|
| 35 | %----------------------------------------------------------------------- |
---|
[610] | 36 | if ~exist('FileType','var') |
---|
[604] | 37 | FileType='image'; |
---|
| 38 | end |
---|
[1122] | 39 | if isempty(FileType) |
---|
| 40 | FileType='image'; |
---|
| 41 | end |
---|
[497] | 42 | if ~exist('VideoObject','var') |
---|
| 43 | VideoObject=[]; |
---|
| 44 | end |
---|
| 45 | if ~exist('num','var') |
---|
| 46 | num=1; |
---|
| 47 | end |
---|
[1033] | 48 | if isempty(num) |
---|
| 49 | num=1; |
---|
| 50 | end |
---|
[823] | 51 | A=[]; |
---|
[497] | 52 | ObjectOut=VideoObject;%default |
---|
[453] | 53 | switch FileType |
---|
[979] | 54 | case 'video' |
---|
| 55 | if strcmp(class(VideoObject),'VideoReader') |
---|
| 56 | A=read(VideoObject,num); |
---|
| 57 | else |
---|
| 58 | ObjectOut=VideoReader(FileName); |
---|
| 59 | A=read(ObjectOut,num); |
---|
| 60 | end |
---|
| 61 | case 'mmreader' |
---|
| 62 | if strcmp(class(VideoObject),'mmreader') |
---|
| 63 | A=read(VideoObject,num); |
---|
| 64 | else |
---|
| 65 | ObjectOut=mmreader(FileName); |
---|
| 66 | A=read(ObjectOut,num); |
---|
| 67 | end |
---|
| 68 | case 'cine_phantom' |
---|
| 69 | A = read_cine_phantom(FileName,num ); |
---|
[453] | 70 | case 'multimage' |
---|
| 71 | A=imread(FileName,num); |
---|
[979] | 72 | case 'image' |
---|
[453] | 73 | A=imread(FileName); |
---|
[1007] | 74 | case 'image_DaVis' |
---|
| 75 | Input=readimx(FileName); |
---|
[1033] | 76 | if numel(Input.Frames)==1 |
---|
| 77 | A=Input.Frames{1}.Components{1}.Planes{1}'; |
---|
| 78 | else |
---|
[1007] | 79 | A=Input.Frames{num}.Components{1}.Planes{1}'; |
---|
[1033] | 80 | end |
---|
[453] | 81 | end |
---|