VideoReaderLoader¶
- class io.loaders.VideoReaderLoader¶
Bases:
io.loaders.BaseImageLoaderVIDEOREADERLOADER - Loader for video formats using VideoReader, based on.
io.loaders.BaseImageLoader base class
- Constructor Summary
- VideoReaderLoader(options)¶
VIDEOREADERLOADER - Constructor for VideoReaderLoader class.
- Syntax:
loader = io.loaders.VideoReaderLoader(options)- Input Arguments:
options - (optional) struct with fields:
waitbar- [logical] show or not the waitbar; default:falsemibPath- [char] path to MIB directorycustomSections- [logical] load custom sections only; default:falsecustomSectionsSettings- [struct] custom section parametersimgStretch- [logical] stretch uint32 images to uint16; default:falsesilentMode- [logical] do not ask user questions; default:falseverbose- [logical] show timing information; default:falseFont- [struct] font settings for dialogsParentFigure- handle of the main MIB window (parent for uiprogressdlg)
- Output Arguments:
obj - instance of the VideoReaderLoader class
Example 1 - create loader with options:
options.waitbar = true; options.mibPath = 'c:\\mib'; loader = io.loaders.VideoReaderLoader(options);
- Method Summary
- loadImages(files, imginfo, options)¶
LOADIMAGES - Load image data for video files.
- Syntax:
[img, imginfo] = obj.loadImages(files, imginfo, options)
This method loads actual video frames using VideoReader. It supports frame range selection, custom region loading, and dimension mismatch handling with background filling.
- Input Arguments:
files - structure array from loadMetadata with file information:
filename- [char] full filenameobjecttype- [char] type of the image loader'movie'extension- [char] file extension with dot -'.avi'height- [numeric] image heightwidth- [numeric] image widthcolor- [numeric] number of color channelsnoLayers- [numeric] number of video framestime- [numeric] number of time framesimgClass- [char] image class,'uint8','uint16','uint32'xMin,xMax,yMin,yMax- [numeric] region coordinates (optional)zMin,zMax- [numeric] frame range (optional)xyStep- [numeric] XY step for binning (optional)backgroundColor- [numeric] background color value (optional)
imginfo - dictionary from loadMetadata with image metadata
options - (optional) struct with fields:
waitbar- [logical] show or not the waitbar; default:trueimgStretch- [logical] stretch uint32 to uint16; default:truesilentMode- [logical] do not ask user questions; default:false
- Output Arguments:
img - loaded image dataset [1:height, 1:width, 1:depth, 1:color, 1:time]
imginfo - updated dictionary with final metadata containing fields:
Height- final image heightWidth- final image widthDepth- final number of framesTime- number of time pointsColorType- color type
Example 1 - load images from video file:
loader = io.loaders.VideoReaderLoader(); options.waitbar = true; [imginfo, files] = loader.loadMetadata({'video.avi'}, options); [img, imginfo] = loader.loadImages(files, imginfo, options); fprintf('Loaded video size: %s\n', mat2str(size(img)));
- loadMetadata(filenames, options)¶
LOADMETADATA - Load metadata for video files.
- Syntax:
[imginfo, files] = obj.loadMetadata(filenames, options)
This method extracts video metadata using VideoReader for standard video formats. It handles frame count detection, frame dimensions, and frame rate extraction.
- Input Arguments:
filenames - cell array with filenames of video files
options - (optional) struct with fields:
waitbar- [logical] show or not the waitbar; default:falsecustomSections- [logical] load part of the dataset; default:falsecustomSectionsSettings- [struct] custom section settings -xMin- [numeric] min X coordinate -xMax- [numeric] max X coordinate -yMin- [numeric] min Y coordinate -yMax- [numeric] max Y coordinate -zMin- [numeric] min Z coordinate (frame) -zMax- [numeric] max Z coordinate (frame) -xyStep- [numeric] XY binning stepmibPath- [char] path to MIB directoryParentFigure- handle to the parent window to show progress dialogFont- [struct] font settings for dialogs
- Output Arguments:
imginfo - dictionary with image metadata containing fields:
Height- image height in pixelsWidth- image width in pixelsColors- number of color channelsDepth- number of framesTime- number of time pointsimgClass- image class (uint8,uint16, etc.)ColorType-'grayscale','truecolor', or'indexed'ImageDescription- description with BoundingBox infoFrameRate- frames per secondDuration- video duration in secondspixSize- struct with pixel sizes:.x,.y,.z,.t,.units,.tunitsother format-specific metadata fields
files - structure array with file information for each file
filename- [char] full filenameobjecttype- [char] type of the image loader'movie'extension- [char] file extension, including the leading dotheight- [numeric] image heightwidth- [numeric] image widthcolor- [numeric] number of color channelsnoLayers- [numeric] number of video framestime- [numeric] number of time pointsimgClass- [char] image class,'uint8','uint16','uint32'xMin,xMax,yMin,yMax- [numeric] region coordinatesxyStep- [numeric] XY step for binning
Example 1 - load metadata from video files:
loader = io.loaders.VideoReaderLoader(); options.waitbar = true; filenames = {'video1.avi', 'video2.mp4'}; [imginfo, files] = loader.loadMetadata(filenames, options); fprintf('Video size: %d x %d x %d frames\n', imginfo{"Width"}, imginfo{"Height"}, imginfo{"Depth"});