ImreadLoader¶
- class io.loaders.ImreadLoader¶
Bases:
io.loaders.BaseImageLoaderIMREADLOADER - Loader for standard MATLAB image formats using imread, based on.
io.loaders.BaseImageLoader base class
This loader handles standard image formats that can be read using MATLAB’s built-in imread function (TIF, TIFF, PNG, JPEG, BMP, GIF, etc.). It supports multi-page TIF files, pyramidal TIF images, custom region loading, and pixel size extraction from metadata.
- Constructor Summary
- ImreadLoader(options)¶
IMREADLOADER - Constructor for ImreadLoader class.
- Syntax:
loader = io.loaders.ImreadLoader(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 ImreadLoader class
Example 1 - create loader with options:
options.waitbar = true; options.mibPath = 'c:\mib'; loader = io.loaders.ImreadLoader(options);
- Method Summary
- loadImages(files, imginfo, options)¶
LOADIMAGES - Load image data for standard image files.
- Syntax:
[img, imginfo] = obj.loadImages(files, imginfo, options)
This method loads actual image data using imread for standard MATLAB image formats. It supports multi-page TIF files, pyramidal images, custom region loading (PixelRegion), GIF conversion, 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'imread'extension- [char] file extension with dot (e.g.,'.jpg')height- [numeric] image heightwidth- [numeric] image widthcolor- [numeric] number of color channelsnoLayers- [numeric] number of image layers/framestime- [numeric] number of image framesimgClass- [char] image class ('uint8','uint16','uint32')level- [numeric] pyramid level (optional)xMin,xMax,yMin,yMax- [numeric] region coordinates (optional)zMin,zMax- [numeric] slice 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 [height, width, depth, color, time]
imginfo - updated dictionary with final metadata:
Height- final image heightWidth- final image widthDepth- final number of slicesTime- number of time pointsColorType- color typeColorTable- colormap for indexed images (optional)
Example 1 - load images from standard image file:
loader = io.loaders.ImreadLoader(); options.waitbar = true; [imginfo, files] = loader.loadMetadata({'image.tif'}, options); [img, imginfo] = loader.loadImages(files, imginfo, options); fprintf('Loaded image size: %s\n', mat2str(size(img)));
- loadMetadata(filenames, options)¶
LOADMETADATA - Load metadata for standard image files.
- Syntax:
[imginfo, files] = obj.loadMetadata(filenames, options)
This method extracts image metadata using imfinfo for standard MATLAB-readable image formats. It handles pyramidal TIF detection, pixel size extraction from various formats (Amira, Zeiss, Fibics), and custom section parameters.
- Input Arguments:
filenames - cell array with filenames of images
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 settingsxMin- [numeric] min X coordinatexMax- [numeric] max X coordinateyMin- [numeric] min Y coordinateyMax- [numeric] max Y coordinatezMin- [numeric] min Z coordinate (slice)zMax- [numeric] max Z coordinate (slice)xyStep- [numeric] XY binning stepmibPath- [char] path to MIB directoryParentFigure- handle to the parent window for progress dialogFont- [struct] font settings for dialogsBioFormatsIndices- [numeric] level index for pyramidal TIF
- Output Arguments:
imginfo - dictionary with image metadata containing fields:
Height- image height in pixelsWidth- image width in pixelsColors- number of color channelsDepth- number of z-slicesTime- number of time pointsimgClass- image class (uint8,uint16, etc.)ColorType-'grayscale','truecolor', or'indexed'ImageDescription- description with BoundingBox infoother format-specific metadata fields
files - structure array with file information for each file:
filename- [char] full filenameobjecttype- [char] type of the image loader'imread'extension- [char] file extension, including the leading dotheight- [numeric] image heightwidth- [numeric] image widthcolor- [numeric] number of color channelsnoLayers- [numeric] number of image framestime- [numeric] number of time pointsimgClass- [char] image class ('uint8','uint16','uint32','single')level- [numeric] pyramid level (for pyramidal TIF)levelMagScale- [numeric] magnification scale factorxMin,xMax,yMin,yMax- [numeric] region coordinatesxyStep- [numeric] XY step for binning
Example 1 - load metadata from standard image files:
loader = io.loaders.ImreadLoader(); options.waitbar = true; filenames = {'image1.tif', 'image2.tif'}; [imginfo, files] = loader.loadMetadata(filenames, options); fprintf('Image size: %d x %d x %d\n', imginfo{"Width"}, imginfo{"Height"}, imginfo{"Depth"});