reference
labkit.image.readFiles
Read image files into path/name/image records.
Syntax
records = labkit.image.readFiles(paths)
records = labkit.image.readFiles(paths, opts)Description
Reads one or more image files in the supplied order and returns a uniform record for each file. The default path validates source extensions and file existence, converts data with labkit.image.im2double, expands grayscale to RGB, discards channels after the first three, and clamps values to [0,1]. Set Normalize to false when the exact class and channel layout returned by imread must be preserved.
progressFcn is called immediately before and after every imread. If a read, conversion, or callback fails, the error propagates and no partial records array is returned.
Inputs
paths- Character vector, string array, cell array, or empty value accepted by
labkit.image.normalizePaths. opts- Optional scalar struct containing the fields listed below.
Options
Normalize- Logical scalar controlling conversion to clamped RGB double. The default is true.
AllowEmpty- Logical scalar controlling whether an empty path collection returns an empty record column. The default is true.
ValidateExtensions- Logical scalar controlling validation with assertSupportedPaths. The default is true.
RequireExisting- Logical scalar controlling the explicit file-existence check before imread. The default is true. imread can still fail when this option is false.
progressFcn- Function handle or []. The callback receives a scalar structure before and after each read. The default is [].
Outputs
records- N-by-1 structure array with path, name, and image fields. path and name are strings; image contains the normalized or raw image matrix.
Progress Fields
stage- "beforeRead" or "afterRead".
index- 1-based index of the current path.
count- Total number of paths.
path- Current path as a string scalar.
name- Filename and extension from
labkit.image.displayName.
Errors
labkit:image:InvalidOptions- opts or one of its fields is invalid.
labkit:image:NoPaths- paths is empty while AllowEmpty is false.
labkit:image:UnsupportedImageFile- An extension is unsupported while ValidateExtensions is true.
labkit:image:ImageFileNotFound- A file is missing while RequireExisting is true.
Typical Call
opts = struct('Normalize', true, 'progressFcn', @updateProgress);
records = labkit.image.readFiles(selectedPaths, opts);Related APIs
labkit.image.normalizePaths— Normalize image file path inputs to a string column.labkit.image.assertSupportedPaths— Throw when any path has an unsupported image extension.labkit.image.writeFile— Write one image file, creating the parent folder when needed.labkit.image.adjustBrightnessContrast— Apply simple brightness and contrast adjustment.labkit.image.adjustHueSaturation— Apply HSV hue and saturation adjustment.labkit.image.displayName— Return a short image-file display name.labkit.image.ensureRgb— Return image data with exactly three color channels.labkit.image.fileDialogFilter— Return a file-chooser-compatible image filter.
Source
This page is generated from the MATLAB help text in +labkit/+image/readFiles.m.