[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 | % |
---|
| 16 | function [A,ObjectOut]=read_image(FileName,FileType,VideoObject,num) |
---|
| 17 | %----------------------------------------------------------------------- |
---|
[610] | 18 | if ~exist('FileType','var') |
---|
[604] | 19 | FileType='image'; |
---|
| 20 | end |
---|
[497] | 21 | if ~exist('VideoObject','var') |
---|
| 22 | VideoObject=[]; |
---|
| 23 | end |
---|
| 24 | if ~exist('num','var') |
---|
| 25 | num=1; |
---|
| 26 | end |
---|
| 27 | ObjectOut=VideoObject;%default |
---|
[453] | 28 | switch 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); |
---|
| 47 | end |
---|