# Building Image Classifier not using Deep Learning

Image classifier can be easily built by using deep learning especially Convolutional Neural Network (CNN). However, you can simply implement image classifier using traditional classifiers. In this post, I introduce how to build image classifier not using Deep Learning. I will not use mathematical formula. Please try to understand the overview intuitively.

# Video

# Feature extraction

Feature extraction part refers to CNN. The important concepts are **window** and **stride**. Let us denote horizontal window as wx, verticalwindow as wy, horizontal stride as sx, and vertical stride as sy.

Suppose you have a image like this:

Next, consider a rectangle (called window) whose width is wx and height is wy like this:

We put the window starting at left-top of the image like this:

Then we move the window based on the stride to right-bottom like this:

At each position of window, vectorize the pixels, consider the vector as an example (the number of columns are fixed), vertically stack the vectors, and then an image is converted to a matrix. Note that the number of columns of the resulting matrix does not depend on the size of images. By this procedure, Images are converted to a matrix and a vector like this:

# Training

You can train any traditional classifiers (e.g. XGBoost and RandomForest) with X and y above.

# Prediction

The prediction to an image is conducted by voting. First, converting the image to matrix by the procedure above. Second, predict the labels of the examples using trained classifier. Finally, determine the label of the image by majority voting. The figure below shows the procedure:

# Conclusion

In this post, I introduce the way to build image classifier not using Deep Learning. Efficient sampling way for classification will accelerate the prediction speed. This is my future work.

—

Thanks for reading!

The implemented image-classifier is here:

The video implementing image-classifier is here:

This post is linked to my Youtube channel:https://www.youtube.com/channel/UC-SHOllZQsQFCsbL3BvP1rA

The content might be updated in the future.