0% found this document useful (0 votes)
56 views15 pages

Code Generation For Image Classification

This document describes a project to generate C code for image classification. A team trained an error-correcting output codes (ECOC) classification model on digit images to classify them. The model contains binary support vector machine (SVM) learners. The document outlines the steps taken: loading and preprocessing data, extracting HOG features, training and optimizing the ECOC model, saving the model, defining a classification function, and using MATLAB Coder to generate C code for the function. This allows deploying the trained image classifier on devices.

Uploaded by

Jyothi Bitra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views15 pages

Code Generation For Image Classification

This document describes a project to generate C code for image classification. A team trained an error-correcting output codes (ECOC) classification model on digit images to classify them. The model contains binary support vector machine (SVM) learners. The document outlines the steps taken: loading and preprocessing data, extracting HOG features, training and optimizing the ECOC model, saving the model, defining a classification function, and using MATLAB Coder to generate C code for the function. This allows deploying the trained image classifier on devices.

Uploaded by

Jyothi Bitra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

 GUIDED BY:  TEAM MEMBERS:

Prof E.Srinivasa Reddy  B.Naga Sai Jyothi(Y16CS3207)


(M.Tech,Ph.D Head)  P.Bhavani(Y16CS3234)
 V.Sonali(Y16CS3257)
 G.Prudvi(Y16CS3213)
CODE GENERATION FOR IMAGE
CLASSIFICATION
ABSTRACT

 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

 Object classification is an important task in many computer vision applications, including


surveillance, automotive safety, and image retrieval. For example, in an automotive safety
application, you may need to classify nearby objects as pedestrians or vehicles.
 This example shows how to train and optimize a multiclass error-correcting output codes
(ECOC) classification model to classify digits based on pixel intensities in raster images.
The ECOC model contains binary support vector machine (SVM) learners. Then, this
example shows how to generate C code that uses the trained model to classify new images.
The data are synthetic images of warped digits of various fonts, which simulates
handwritten digits.
Assumptions and Limitations :

To generate C code, MATLAB Coder:


 Requires a properly configured compiler.
 Requires supported functions to be in a MATLAB function that you define. Forbids objects
as input arguments of the defined function.
 Forbids objects as input arguments of the defined function.
Concerning the last limitation, consider that:
 Trained classification models are objects
Code Generation for Classification Workflow

Before deploying an image classifier onto a device:


1.Obtain a sufficient amount of labeled images.
2.Decide which features to extract from the images.
3.Train and optimize a classification model.
This step includes choosing an appropriate algorithm and tuning hyperparameters, that is, model parameters not fit during training.
4.Save the model to disk by using saveLearnerForCoder.
5.Define a function for classifying new images.
The function must load the model by using loadLearnerForCoder, and can return labels, such as classification scores.
6.Set up your C compiler.
7.Decide the environment in which to execute the generated code.
8.Generate C code for the function.
Load Data
 Load the digit images data set.
 Images is a 28-by-28-by-3000 array of uint16 intergers.
 Each pair is a raster image of a digit. Each element is a pixel intensity.corresponding lables in the
3000_by_1 numeric vector Y.
OUTPUT
RESCALE DATA

 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

You might also like