Visual Inspection

Conduct automated visual inspections for defect detection in industrial applications

Visual inspection is the image-based inspection of parts where a camera scans the part under test for both failures and quality defects. Automated inspection and defect detection are critical for high-throughput quality control in production systems. Visual inspection systems with high-resolution cameras efficiently detect microscale or even nanoscale defects that are difficult for human eyes to pick up. Hence, they are widely adopted in many industries for detection of flaws on manufactured surfaces such as metallic rails, semiconductor wafers, and contact lenses.

Visual inspection for defect detection in semiconductor manufacturing.

With MATLAB®, you can develop visual inspection systems. It supports image acquisition, algorithm development, and deployment. Interactive and easy-to-use apps in MATLAB help users explore, iterate, and automate algorithms to improve productivity. These capabilities find use in many industrial applications.

For example, automotive part manufacturer Musashi Seimitsu Industry’s manually operated visual inspection system inspected about 1.3 million parts per month. Using MATLAB to develop deep learning–based approaches to detect and localize different types of anomalies, it built an automated visual inspection system for inspecting bevel gears. The updated approach is expected to considerably reduce the company’s workload as well as its costs.

Musashi Seimitsu Industry’s visual inspection system for automotive parts.

Similarly, Airbus built a robust visual inspection artificial intelligence (AI) model for automatically detecting any defects in multiple aircraft components to ensure its airplanes have no defect before entering service. Using the MATLAB environment simplified the process of interactively prototyping and testing for defects in a short amount of time.

Detecting multiple defects in elements of the aircraft with automated visual inspection.

The defect detection process can be broken down into three main stages: data preparation, AI modeling, and deployment.

End-to-end defect detection workflow in MATLAB.

Data Preparation

Data comes from multiple sources and is usually unstructured and noisy, making data preparation and management difficult and time-consuming. Preprocessing images in the dataset will result in higher accuracy in detecting anomalies. MATLAB has several apps to support various preprocessing techniques. For example, the Registration Estimator app lets you explore various algorithms to register misaligned images, making it easier for AI models to detect defects.

Registration Estimator app aligning a pair of images of hex bolts in different orientations.

MATLAB provides automation capabilities to accelerate the labeling process. For example, the Image and Video Labeler app can apply custom semantic segmentation or object detection algorithms to label regions or objects in an image or video frames. For datasets other than images, MATLAB provides the Audio Labeler and Signal Labeler apps for labeling audio and signal datasets, respectively.

AI Modeling

AI techniques are widely used for classification and prediction as part of defect detection. Within the MATLAB environment, you have direct access to common algorithms used for classification and prediction, from regression, to deep networks, to clustering.

When applying deep learning for classification tasks, there are two approaches. One approach is to build and train a deep network from scratch. The other is to adjust and fine-tune a pretrained neural network, also known as transfer learning. Both approaches are easy to implement in MATLAB.

Convolutional neural network (CNN) from scratch (top) vs. CNN from transfer learning (bottom).

MATLAB provides the Deep Network Designer app, which lets you build, visualize, edit, and train deep learning networks. You can also analyze the network to ensure that the network architecture is defined correctly and detect problems before training.

In MATLAB, you can import networks and network architectures from TensorFlow™-Keras, from Caffe, and from and to the ONNX™ model format. You can use these pretrained networks and edit them for transfer learning.


Deep learning models must be incorporated into a larger system to be useful. MATLAB offers a code generation framework that allows models developed in MATLAB to be deployed anywhere, without having to rewrite the original model. This gives you the ability to test and deploy the model within an entire system.

MATLAB enables you to deploy your deep learning networks to various embedded hardware platforms, such as NVIDIA® GPUs, Intel® and ARM® CPUs, and Xilinx® and Intel SoCs and FPGAs. With the help of MathWorks tools, you can explore and target embedded hardware easily.

Deployment of deep learning networks from MATLAB to various embedded hardware platforms.

See also: MATLAB for image processing and computer vision, Deep Learning Toolbox, pattern recognition