What we’ll cover
- Fundamentals of image processing: image representation, common preprocessing steps (resizing, normalization, color-space conversion), and filters (blurring, sharpening, edge detection) used to prepare images for analysis.
- Optical Character Recognition (OCR): extracting readable and structured text from images using Read/OCR APIs and Form Recognizer for structured documents.
- Object and face detection: identifying objects and people using pre-trained models (Computer Vision, Custom Vision for domain-specific classifiers, and Face API for verification and detection).
- Image enhancement and manipulation: techniques for adjusting brightness, contrast, sharpness, denoising, and geometric transforms to improve visual quality or prepare inputs for downstream models.
- Integration patterns: calling image-processing APIs from applications (REST APIs and language SDKs such as Python, C#, and JavaScript), handling results, and designing scalable pipelines for batch and real-time scenarios.
Learning outcomes
After completing this lesson, you will be able to:- Explain core image preprocessing techniques and why they matter for analysis models.
- Use OCR to extract plain text and structured information from images and documents.
- Detect and localize objects and faces in images, and choose between general-purpose and custom models.
- Apply basic image-enhancement operations to improve data quality for models or improve user-facing images.
- Integrate Azure image-processing APIs into applications and select appropriate service endpoints and SDKs for your scenario.
Recommended prerequisites: familiarity with basic programming (Python, C#, or JavaScript), basic concepts of machine learning, and access to an Azure subscription to experiment with Cognitive Services.
Module structure and flow
-
Image representation & preprocessing
- Pixel formats, color spaces (RGB, BGR, grayscale), and when to convert.
- Resizing strategies (preserve aspect ratio, padding vs. cropping).
- Normalization and mean/std scaling for ML models.
- Basic filters: Gaussian blur, median filter, unsharp masking, Sobel/Laplacian edge detection.
-
Optical Character Recognition (OCR)
- When to use generic Read/OCR APIs vs. Form Recognizer for structured forms.
- Preprocessing tips to improve OCR accuracy: deskewing, denoising, binarization, and contrast adjustment.
- Extracting and post-processing text for downstream use.
-
Object & face detection
- Trade-offs between pre-trained models and Custom Vision (accuracy vs. training cost).
- Face detection, face landmarks, and verification concepts with Face API.
- Bounding box formats and coordinate conventions.
-
Image enhancement & manipulation
- Adjustments for brightness/contrast/sharpness and techniques for denoising.
- Geometric transforms (rotate, scale, crop) and format conversion for web and model inputs.
-
Integration & scaling
- Calling REST APIs vs. using SDKs (Python/C#/JavaScript) and handling async operations for long-running tasks.
- Batch processing patterns, streaming pipelines, and serverless integration options.
Quick reference: common preprocessing patterns
- Resize while preserving aspect ratio:
- Compute scale factor and resize the longer side to a target, then pad/crop.
- Normalize pixel values:
- Scale to [0, 1] or standardize using mean/std depending on the model.
- Convert color spaces:
- Many OpenCV functions use BGR; convert to RGB when using most ML frameworks.
- Remove noise:
- Use median blur for salt-and-pepper noise, Gaussian blur for general smoothing.
- Edge detection:
- Apply Sobel or Canny to extract edges for tasks like contour detection.
Choosing the right Azure service
Useful links:
Integration patterns and recommendations
- For small-scale or prototyping projects, use the SDK for your language (Python/C#/JavaScript) for convenience.
- For high-throughput pipelines, call REST APIs directly from distributed workers or serverless functions; use batch transforms and message queues.
- For document-heavy solutions, combine Form Recognizer with pre- and post-processing steps to normalize and validate extracted fields.
- For improving OCR or detection accuracy, apply preprocessing (deskew, enhance contrast, denoise) before sending images to the service.
- Upload image or provide URL to the Read API.
- Receive an operation/location URL with an operation ID.
- Poll the operation endpoint until the status is
succeeded. - Retrieve structured results and map to your data model.
Recommended next steps in the module
- Start with image preprocessing exercises: resize, normalize, and apply filters using your preferred language.
- Run a sample OCR extraction using the Read API and compare results with and without preprocessing.
- Try an object detection task with Custom Vision on a small labeled dataset.
- Build a simple pipeline that ingests images, preprocesses them, calls an Azure vision service, and stores results.
References and further reading
- Kubernetes Basics — if you package as containers
- Azure Cognitive Services documentation
- OpenCV documentation
- Image preprocessing best practices for ML