reference
Image API
labkit.image.* provides GUI-free image file IO, conversion, preview sizing, and common enhancement operations. App-specific registration, measurement, ROI, matching, and export workflows build on these functions.
labkit.image.version() returns image-library version and compatibility information used by App definition.m requirement declarations.
Common Calls
filter = labkit.image.fileDialogFilter("IncludeAll", true);
paths = labkit.image.normalizePaths(rawPaths);
records = labkit.image.readFiles(paths);
source = labkit.image.im2double(records(1).image);
preview = labkit.image.ensureRgb(source);
preview = min(max(preview, 0), 1);
luma = labkit.image.rgb2gray(preview);
[preview, scale] = labkit.image.resizeToFit(preview, "MaxHeight", 1500);
[preview, budget] = labkit.image.previewBudget(preview, "MaxPixels", 1.2e6);
blurred = labkit.image.meanFilter2(preview(:, :, 1), 7);
enhanced = labkit.image.adjustBrightnessContrast(preview, 10, 20);
enhanced = labkit.image.localContrast(enhanced, 50, 3);
enhanced = labkit.image.sharpen(enhanced, 30, 1.5);
enhanced = labkit.image.grayWorldWhiteBalance(enhanced, 80, 0);
labkit.image.writeFile(enhanced, outputPath);
Normalization Helpers
labkit.image.im2double follows the MATLAB im2double call contract for supported numeric image classes, including the optional "indexed" mode.
labkit.image.rgb2gray follows the MATLAB rgb2gray call contract for RGB images and colormaps while using the documented Rec.601 luma transform.
labkit.image.ensureRgb changes channel shape only. It expands grayscale data to three channels or drops channels after RGB without changing class or sample values. Callers that need display-ready RGB data explicitly compose im2double, ensureRgb, and [0, 1] clamping as shown above.
Provided Operations
The module provides:
- supported source-image extension lists and file-dialog filters
- path normalization and display names
imread/imwritewrappers that normalize app-facing edge behavior- MATLAB-compatible image conversion, explicit RGB shaping, preview-size fitting, and edge-normalized mean filtering
- display-pixel budget helpers for responsive previews while preserving a documented integer coordinate scale
- generic image enhancement primitives such as brightness/contrast, HSV hue/saturation, gray-world white balance, local contrast, and sharpening
Applications add:
- which filters or processing steps appear in the app UI
- parameter labels, defaults, validation ranges, and step history semantics
- reference matching, protected background/ROI behavior, scientific formulas, crop geometry, focus stacking, curvature, and DIC processing
- export manifests, result columns, filenames, failed-row policy, alerts, and log text
Use labkit.image.readFiles when an app needs generic source-image records. Apps may copy the returned path, name, and image fields into their own item structures. Specialized formats and result structures remain documented by the app that uses them.
Reference Contract
The generated Image API pages linked from the public API index document exact syntax, inputs, outputs, implemented options and defaults, legal values, failure behavior, examples, and related functions. In particular, resizeToFit accepts only the documented "bilinear" and "nearest" methods and rejects any other method instead of silently selecting an interpolation policy.
Functions And API
Open a function for exact MATLAB syntax, arguments, outputs, behavior, and source.
| Function | Purpose |
|---|---|
labkit.image.adjustBrightnessContrast | Apply simple brightness and contrast adjustment. |
labkit.image.ensureRgb | Return image data with exactly three color channels. |
labkit.image.fileDialogFilter | Return a file-chooser-compatible image filter. |
labkit.image.grayWorldWhiteBalance | Apply generic gray-world white balance. |
labkit.image.im2double | Convert image data to double using MATLAB's im2double contract. |
labkit.image.localContrast | Enhance local value-channel contrast with a mean-filter mask. |
labkit.image.meanFilter2 | Apply normalized 2-D mean filtering with edge correction. |
labkit.image.normalizePaths | Normalize image file path inputs to a string column. |
labkit.image.previewBudget | Downsample image data to fit a display pixel budget. |
labkit.image.readFiles | Read image files into path/name/image records. |
labkit.image.resizeToFit | Resize an image to fit within maximum row/column limits. |
labkit.image.rgb2gray | Convert RGB data using MATLAB's rgb2gray call contract. |
labkit.image.sharpen | Apply generic unsharp-mask sharpening. |
labkit.image.version | Return the LabKit image facade contract version. |
labkit.image.writeFile | Write one image file, creating the parent folder when needed. |
Change history
- 2026-07-17 - Public API help is complete, discoverable, and behavior checkeddocs | compatible
- 2026-07-16 - Public library help contracts and reference validationdocs | compatible
- 2026-07-13 - MATLAB-compatible image conversion APIrefactor | breaking
- 2026-07-13 - Base-MATLAB image compatibilityfeat | compatible
- 2026-07-01 - Image app workflow improvementsfeat | compatible
- 2026-06-30 - Shared image facadefeat | compatible