VideoReaderLoader

class io.loaders.VideoReaderLoader

Bases: io.loaders.BaseImageLoader

VIDEOREADERLOADER - 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: false

    • mibPath - [char] path to MIB directory

    • customSections - [logical] load custom sections only; default: false

    • customSectionsSettings - [struct] custom section parameters

    • imgStretch - [logical] stretch uint32 images to uint16; default: false

    • silentMode - [logical] do not ask user questions; default: false

    • verbose - [logical] show timing information; default: false

    • Font - [struct] font settings for dialogs

    • ParentFigure - 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 filename

    • objecttype - [char] type of the image loader 'movie'

    • extension - [char] file extension with dot - '.avi'

    • height - [numeric] image height

    • width - [numeric] image width

    • color - [numeric] number of color channels

    • noLayers - [numeric] number of video frames

    • time - [numeric] number of time frames

    • imgClass - [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: true

    • imgStretch - [logical] stretch uint32 to uint16; default: true

    • silentMode - [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 height

    • Width - final image width

    • Depth - final number of frames

    • Time - number of time points

    • ColorType - 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: false

    • customSections - [logical] load part of the dataset; default: false

    • customSectionsSettings - [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 step

    • mibPath - [char] path to MIB directory

    • ParentFigure - handle to the parent window to show progress dialog

    • Font - [struct] font settings for dialogs

Output Arguments:
  • imginfo - dictionary with image metadata containing fields:

    • Height - image height in pixels

    • Width - image width in pixels

    • Colors - number of color channels

    • Depth - number of frames

    • Time - number of time points

    • imgClass - image class (uint8, uint16, etc.)

    • ColorType - 'grayscale', 'truecolor', or 'indexed'

    • ImageDescription - description with BoundingBox info

    • FrameRate - frames per second

    • Duration - video duration in seconds

    • pixSize - struct with pixel sizes: .x, .y, .z, .t, .units, .tunits

    • other format-specific metadata fields

  • files - structure array with file information for each file

    • filename - [char] full filename

    • objecttype - [char] type of the image loader 'movie'

    • extension - [char] file extension, including the leading dot

    • height - [numeric] image height

    • width - [numeric] image width

    • color - [numeric] number of color channels

    • noLayers - [numeric] number of video frames

    • time - [numeric] number of time points

    • imgClass - [char] image class, 'uint8', 'uint16', 'uint32'

    • xMin, xMax, yMin, yMax - [numeric] region coordinates

    • xyStep - [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"});