matlab-recognize-text

Build OCR pipelines in MATLAB to extract text from images and documents.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-recognize-text
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-recognize-text
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/image-processing-and-computer-vision/matlab-recognize-text
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-recognize-text

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Extracting text from images in MATLAB often fails due to poor preprocessing, wrong detection methods, or misconfigured ocr() parameters, producing garbage output and wasted trial-and-error cycles. This Skill provides a structured diagnose-preprocess-detect-recognize-validate workflow that routes each image type to the correct pipeline.

Core Features & Use Cases

  • Guided OCR Pipeline: Diagnose the image visually, then apply the prescribed preprocessing route (binarization, deskewing, local contrast subtraction, SAM segmentation) before calling ocr().
  • Text Detection Methods: Choose between detectTextCRAFT for natural scenes, MSER for documents, manual ROI for fixed layouts, and imsegsam for text on textured backgrounds.
  • Validation and Logging: Compute CER/WER with evaluateOCR against ground truth, then save a re-runnable pipeline script and decision log.
  • Use Case: Read stamped serial numbers from metal parts, extract text from scanned receipts, read seven-segment meter displays, or digitize multi-language documents.

Quick Start

Ask your AI agent to extract the text from an image file using MATLAB OCR, and it will diagnose the image, build the pipeline, and save the results.

Frequently Asked Questions about matlab-recognize-text

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract text from an image in MATLAB?

Use the ocr() function from Computer Vision Toolbox on a preprocessed image. Binarize with imbinarize, fix polarity with imcomplement if needed, then call ocr(BW) and read results.Text for the recognized string.

What is the best text detection method for OCR in natural scenes?

detectTextCRAFT is the recommended method for scene text like signs and product labels because it handles complex backgrounds better than MSER. It requires the Text Detection Using Deep Learning support package.

Does MATLAB OCR support languages other than English?

Yes, ocr() supports over 64 languages via the OCR Language Data support package, specified with the Model parameter such as Model="japanese" or Model="french". A quantized -fast variant exists for each language.

Why does MATLAB OCR return garbage or empty results?

Common causes are inverted polarity (light text on dark background), skew greater than 10 degrees, missing preprocessing, or text under 20 pixels tall. Fix polarity with imcomplement, deskew with imrotate, and upscale small text with imresize.

Can MATLAB OCR read handwriting or CAPTCHAs?

No, the ocr() engine is trained on printed characters and cannot parse cursive handwriting, artistic calligraphy, or CAPTCHAs. For handwriting you need a dedicated HTR model; for custom printed fonts you can train a model with trainOCR.

How do I train a custom OCR model in MATLAB?

Label text regions in the Image Labeler app, extract datastores with ocrTrainingData, configure ocrTrainingOptions, then call trainOCR to fine-tune from a base language model. You need at least 50 labeled images and should validate with evaluateOCR.