---
title: Decision Trees Applied to Image Classification
url: https://www.dataloco.com/en/decision-trees-applied-to-image-classification
published: 2026-09-14T07:10:51+00:00
language: en
section: Data
source: https://machinelearningmastery.com/seeing-images-through-the-eyes-of-decision-trees/
publisher: Dataloco
---

# Decision Trees Applied to Image Classification

A tutorial illustrates using decision tree-based models for classifying images by extracting structured features from raw image data. The discussion focuses on converting pixel-level information into higher-level descriptors such as color histograms and edge counts, enabling decision trees to handle unstructured data effectively.

The tutorial utilizes the CIFAR-10 dataset, which contains low-resolution color images, each defined by three RGB values. The dataset is already divided into training and test sets, with output labels corresponding to ten different classes. The core function of the tutorial, named extract_features(), is designed to extract relevant features from images, particularly focusing on color histograms and edge strength.

Each color histogram is computed with 8 bins, ensuring adequate information density. Edge detection is achieved using two functions from the skimage library, rgb2gray and sobel, which help in identifying edges in grayscale images. The process is applied to all images in the dataset, resulting in 25 extracted features that summarize image properties.

Despite the extraction process, the decision tree classifier performs poorly on these features, which is considered typical. Reducing a 32×32 color image to just 25 features oversimplifies the data, leading to challenges in distinguishing between similar classes. The tutorial emphasizes understanding the limitations of feature extraction for decision trees rather than achieving high accuracy.

An attempt to improve classification accuracy using a random forest classifier yielded slight enhancements, though significant challenges remained. The tutorial encourages further exploration by applying the concepts to simpler datasets such as MNIST or fashion MNIST.

To enhance feature extraction, the tutorial suggests incorporating more complex features, such as HOG (Histogram of Oriented Gradients), which captures additional characteristics like shape and texture. This approach increases the number of features to 193, leading to better performance in classifying multiple classes, though significant work is still needed to improve overall accuracy.
