Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/image-processing-and-computer-vision/matlab-recognize-text

matlab-recognize-text

Verified

Build OCR pipelines in MATLAB using the ocr() function. Use this skill when the user wants to read text from images, documents, signs, meters, displays, license plates, gauges, receipts, or seven-segment displays. Covers image preprocessing, text detection (CRAFT, MSER), ROI-based recognition, multi-language OCR, and custom model training. Use when: OCR, text recognition, extract text from image, character recognition, document scanning, meter reading, gauge reading, receipt scanning, digitize text from photo.

reference/batch-pipeline.md

View on GitHub
# Batch Pipeline for Multiple Images

When the user has several representative images from their application and wants a reusable pipeline, build a function that processes any image from that domain. Develop the pipeline on 2-3 sample images, then generalize.

## Pipeline Function Template

```matlab
function results = ocrPipeline(imagePath, opts)
% ocrPipeline  OCR pipeline tuned for [application domain]
%   results = ocrPipeline(imagePath) reads text from the image.
%   results = ocrPipeline(imagePath, CharacterSet="0-9") constrains output.
arguments
    imagePath (1,1) string
    opts.CharacterSet (1,1) string = ""
    opts.LayoutAnalysis (1,1) string = "word"
end

I = imread(imagePath);
Igray = im2gray(I);

% Preprocessing tuned for this application
BW = imbinarize(Igray);
if mean(BW(:)) > 0.5
    BW = imcomplement(BW);  % Fix polarity
end
if size(I,1) < 50
    Igray = imresize(Igray, 4, "bicubic");
    BW = imbinarize(Igray);
end

% Recognition
ocrArgs = {"LayoutAnalysis", opts.LayoutAnalysis};
if opts.CharacterSet ~= ""
    ocrArgs = [ocrArgs, {"CharacterSet", opts.CharacterSet}];
end
results = ocr(BW, ocrArgs{:});
end
```

## Workflow for Building a Batch Pipeline

1. Run the full diagnostic workflow (Steps 1-5) on 2-3 representative images
2. Identify which preprocessing steps are common across all images
3. Wrap those steps into a function with `arguments` block for configurability
4. Test on all sample images — verify consistent results
5. Save as a `.m` file the user can call in a loop or with `imageDatastore`

## Processing All Images in a Folder

```matlab
% Process all images in a folder
imds = imageDatastore("path/to/images");
allText = strings(numel(imds.Files), 1);
for i = 1:numel(imds.Files)
    results = ocrPipeline(imds.Files{i}, CharacterSet="0123456789");
    allText(i) = strtrim(results.Text);
end
```

## Tips

- Start with the hardest image in the set — if your pipeline handles the worst case, it handles the rest
- Use `CharacterSet` to constrain output if all images contain the same character domain (e.g., serial numbers = digits + uppercase letters)
- Add early exit: if `ocr()` returns high confidence on raw grayscale, skip heavy preprocessing
- Log per-image confidence so the user can spot which images need manual review


----
Copyright 2026 The MathWorks, Inc.
----
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 319kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall