Code Generation For Image Classification
Code Generation For Image Classification
This example shows how to generate C code from a MATLAB function that classifies
images of digits using a trained classification model. This example demonstrates an
alternative workflow to Digit Classification Using HOG Features (Computer Vision
Toolbox)
INTRODUCTION
Because raw pixel intensities vary widely, you should normalize their values before
training a classification model. Rescale the pixel intensities so that they range in the
interval [0,1]. That is, suppose pij is pixel intensity j within image i. For image i, rescale all
of its pixel intensities using this formula:
ˆpij=pij−minj(pij)maxj(pij)−minj(pij).
RESHAPE DATA
For code generation, the predictor data for training must be in a table of numeric variables
or a numeric matrix.
Reshape the data to a matrix such that predictor variables (pixel intensities) correspond to
columns, and images (observations) to rows.
OUTPUT
Extract Features
HOG, or Histogram of Oriented Gradients, is a feature descriptor that is often used to extract
features from image data.
The HOG descriptor focuses on the structure or the shape of an object.
It counts the occurrences of gradient orientation in localized portions of an image.
Prior to training and testing a classifier, a pre-processing step is applied to remove noise
artifacts introduced while collecting the image samples. This provides better feature vectors
for training the classifier.
Prior to training and testing a classifier, a pre-processing step is applied to remove noise
artifacts introduced while collecting the image samples. This provides better feature
vectors for training the classifier.
Train and Optimize Classification Model
Linear SVM models are often applied to image data sets for classification.
However, SVM are binary classifiers, and there are 10 possible classes in the data set.
ANU COLLEGE OF ENGINEERING AND
TECHNOLOGY
Guided