app
Batch Image Crop
Batch Image Crop defines one crop task per image, previews rotation and edge-continuous padding, and exports repeatable same-size crops in pixel or physical-scale mode.
Requirements And Launch
labkit_BatchImageCrop_app
Inputs
Use Add images or folder to load supported image files. A folder selection loads supported files from that folder. Each list row stores its own crop center, rotation, padding, and optional scale calibration. Duplicate image creates another task for the same source so multiple ROIs can be exported without loading duplicate files.
Basic Workflow
- Load images and select a task.
- Set crop width and height or switch to physical mode.
- Drag the highlighted crop center/ROI in the preview or enter center X/Y.
- Set rotation and padding.
- Calibrate physical scale when required.
- Duplicate tasks for additional ROIs.
- Choose format and output folder, then export.
The preview rectangle remains draggable and resizable. Editing the ROI updates the selected task immediately; switching tasks restores that task's geometry. Marker and ROI refreshes preserve axes zoom.
Pixel Mode
Default crop dimensions are 1024 by 1024 pixels. Rotation defaults to 0 degrees and padding to 0%. Center controls use source-image coordinates. When crop geometry crosses the rotated image boundary, edge-continuous padding supplies pixels so every exported crop retains the requested dimensions.
Physical Mode And Scale
Physical mode specifies width and height in the selected unit (default um). Each source image requires a valid pixels-per-unit calibration. Measure a known reference line, enter its physical length, and verify the displayed pixels/unit. targetPixelsPerUnit=0 selects an automatic common output scale; a positive value requests an explicit scale.
The max-upsample warning defaults to 15%. It warns when a task would require substantial interpolation; it does not silently change the requested physical geometry. Crop and calibration units are converted explicitly.
Scale Bar
The scale-bar length defaults to 100 selected units, at Bottom right, in Black. Measure the reference first, then place the bar. The bar is an export overlay; its placement does not change crop geometry or scale calculations.
Outputs
Exports support PNG, TIFF, and JPEG. Each task produces one image at the planned output dimensions. The crop manifest records source, task identity, center, rotation, padding, source/output scale, requested physical geometry, format, and output filename. A second LabKit result JSON records project-wide parameters and identifies each output file.
Project And Recovery
Saved projects preserve one independent task per list row, so duplicated tasks can resolve to the same image while retaining separate crop geometry and calibration. Crop dimensions, physical-scale settings, output format, output folder, and scale-bar choices are also saved. Image pixels and preview caches are reconstructed from the sources after load rather than embedded in the project.
Older projects are upgraded on open while preserving each task's center, rotation, padding, and calibration. If a source moved, the standard relinking flow asks for its new location.
Use Without The GUI
calibration = labkit.app.interaction.scaleCalibration(20, 10, "um");
items = struct("scaleCalibration", calibration);
physicalOptions = struct( ...
"physicalWidth", 5, "physicalHeight", 3, ...
"scaleUnit", "um", "targetPixelsPerUnit", 4);
plan = batch_crop.cropGeometry.scalePlan(items, physicalOptions);
imageData = reshape(uint8(1:100), 10, 10);
cropOptions = struct("centerXY", [5 5]);
cropped = batch_crop.cropGeometry.cropScaledImage( ...
imageData, cropOptions, plan);
For pixel-domain work use batch_crop.cropGeometry.cropImage. Open the linked API pages for exact plan fields, interpolation, and padding behavior.
Function Reference
The generated crop-geometry pages document pixel coordinates, rounding, padding, scaling plans, per-image option fields, defaults, output metadata, failure behavior, and related APIs. Start with cropScaledImage when reproducing a physical-scale export outside the GUI.
Errors And Limitations
- Physical export requires a finite positive calibration for every task.
- Large upsampling cannot restore information absent from the source.
- Rotation and scale resampling can soften high-frequency detail.
- JPEG is lossy; use PNG or TIFF for quantitative downstream image analysis.
Related Topics
Functions And API
Open a function for exact MATLAB syntax, arguments, outputs, behavior, and source.
| Function | Purpose |
|---|---|
batch_crop.cropGeometry.cropImage | Rotate and crop an image at a fixed pixel size. |
batch_crop.cropGeometry.cropScaledImage | Crop one calibrated image to a common physical output scale. |
batch_crop.cropGeometry.scalePlan | Plan equal-size physical crops across calibrated images. |
Change history
- 2026-07-20 - App actions require explanatory hover helpfeat | compatible
- 2026-07-19 - App SDK explicit contract replaces the retired UI runtimerefactor | breaking
- 2026-07-17 - Public API help is complete, discoverable, and behavior checkeddocs | compatible
- 2026-07-17 - Explicit layout action contractrefactor | compatible
- 2026-07-16 - Image App project validation ownershiprefactor | compatible
- 2026-07-16 - Runtime-owned session defaults across App familiesrefactor | compatible
- 2026-07-16 - Batch Crop assigns state to workflow capabilitiesrefactor | compatible
- 2026-07-16 - Image Apps stop creating invalid placeholder outputsfix | compatible
- 2026-07-16 - UI 7 public runtime boundaryrefactor | breaking
- 2026-07-15 - Runtime V2 lifecycle ownership across the app fleetrefactor | breaking
- 2026-07-13 - MATLAB-compatible image conversion APIrefactor | breaking
- 2026-07-07 - Debug workflows, launcher tools, and changelog governancefeat | compatible
- 2026-07-06 - UI 5 facade redesign, app migration, and plot refreshrefactor | breaking
- 2026-07-03 - CSC export and viewport policyfeat | compatible
- 2026-07-03 - UI groups migrationrefactor | compatible
- 2026-07-03 - App file-selection and electrochem control fixesfix | compatible
- 2026-07-03 - Declarative app runtimerefactor | compatible
- 2026-07-02 - Profiling and validation speedupsci | compatible
- 2026-07-01 - Debug sample packsfeat | compatible
- 2026-07-01 - Image app workflow improvementsfeat | compatible
- 2026-06-30 - Shared image facadefeat | compatible
- 2026-06-30 - Migration helper cleanuprefactor | compatible
- 2026-06-30 - App alerts through UI facadefeat | compatible
- 2026-06-30 - Close guards and caught-exception diagnosticsfeat | compatible
- 2026-06-30 - Output folder promptsfeat | compatible
- 2026-06-29 - Tool-panel hosts and image app fixesfix | compatible
- 2026-06-28 - App diagnostics and hardened UI workflowsfeat | compatible
- 2026-06-28 - Batch Crop file workflow feedbackfeat | compatible
- 2026-06-24 - File-panel migrationrefactor | breaking
- 2026-06-23 - Version metadata baselinefeat | compatible