Lab · 01
Telling animals apart by texture
For a university project, I tested whether a model could tell animals apart by the texture in their photos.
I turned textures into numbers using local binary patterns (LBP) and grey-level co-occurrence matrices (GLCM). I tried four classifiers and used confusion matrices to see which classes they mixed up.
- Project mark
- 82%
- Model accuracy in the project
- About 70%

Try it yourself
Choose a sample photo, or use one of your own, to see what each method picks up and which texture it’s closest to. You can also drop a photo on the frame or paste one.

Closest texture
…
Analysing the sample…
The classifier compares your photo’s LBP histogram with four crops of each of the four animal photos, using k-nearest neighbours. Your photo never leaves your device. Try a jumper, a wooden table or a leopard print.
About the methods
Local binary patterns (LBP)
LBP turns texture into numbers by comparing each pixel with its eight neighbours. In the map above, each colour shows how one pixel compares with those neighbours.
Grey-level co-occurrence matrices (GLCM)
GLCM counts which grey values sit next to each other. The pixel-pair direction sets whether neighbours are paired across or down. In the heat map, lighter squares show grey-value pairs that occur more often.
Classifiers and confusion matrices
I tried naïve Bayes, linear discriminant analysis, k-nearest neighbours and a multilayer perceptron. A confusion matrix showed which animal classes each classifier mixed up.
Photo credits
Zebra by Servali, CC BY 4.0, resized and cropped for display. Giraffe by Bjørn Christian Tørrissen, CC BY-SA 3.0. Leopard by SuperJew, CC BY-SA 3.0, cropped. Tiger by Bas Lammers, CC BY 2.0, cropped.