Texture Classification

Objective: Use the texture classifier to distinguish between sand, seed, and stone and then add an additional texture to the classification (your choice). The script uses a Local Binary Pattern (LBP) to create the features and a Support Vector Machine for training and testing.
Local Binary Pattern
A Local Binary Patterns (LBP) is a visual descriptor for classification in computer vision by analyzing the local pixels around a point. LBP is an effective feature for texture classification.

A threshold is set to create a zero or one for each location. The one and zero combinations create a binary pattern that is translated into a decimal. A rotation-invariant transform is performed to create 36 unique patterns.

Train and Test Classifier

Images of sand, seed, and stone are available in training (training-set) and test (test-set) folders from the GitHub archive.
The archive includes two source files step1_LBP.py and step2_SVM.py to analyze the images for the LBP and perform the classification with the SVM. Alternatively, run the exercise with one of the following Jupyter Notebooks.
Verify that the following confusion matrix results are obtained when running the scripts. Tip: The accuracy with Linear SVC may be improved; try the nonlinear SVC or other classifiers.

Select a new material such as fabric, grass, wood. Add this texture to add to the training and testing. Create a new folder with 5 new photos in the test-set and training-set folders. Re-run the programs to determine the new confusion matrix with the added texture. Comment on the accuracy with the new texture.
Another way to detect materials is through Convolutional Neural Networks (CNNs) that use Deep Learning to classify textures and materials. See Soil Classification
References
- Ahonen, T., Hadid, A., Pietikäinen, M., Face recognition with local binary patterns. European conference on computer vision. Springer, Berlin, Heidelberg, 2004.
- Ojala, T., Pietikäinen, M., Maenpaa, T., Multiresolution gray-scale and rotation invariant texture classification with local binary patterns. IEEE Transactions on pattern analysis and machine intelligence 24.7 (2002): 971-987.
- Kylberg, G., Texture Dataset v. 1.0, Centre for Image Analysis, Swedish University of Agricultural Sciences and Uppsala University, External report (Blue series) No. 35. Dataset
- Scikit Image, Local Binary Pattern for texture classification, Accessed Online: 2 Feb 2022. Source Code
Solutions
Thanks to DJ Lee, BYU ECE Professor, for the computer vision material and for sharing research and industrial experience with the class.

Generative AI Learning
Use these prompts to test your understanding after completing the exercise. Direct the AI — the predictions come before the reveal.
Tip: Your 5 photos are a tiny dataset, so protocol dominates: same distance, same lighting, same focus as the provided images — otherwise the classifier learns your camera settings, not the texture. That is a miniature of the dataset-shift problem in every deployed vision system.
What to Turn In
Submit a short report (PDF, 1-2 pages) that curates your results into a demonstration of what you learned. You may use Generative AI to help write the report, but you must supply the correct matrices, photos, and reasoning. Answer these questions:
- Include the baseline 3-class confusion matrix (verified against the provided one) and your 4-class confusion matrix after adding the new material.
- Which classes lost accuracy when the fourth was added, and does the pattern match the LBP-based reasoning from the prediction prompt? State who predicted better, you or the AI.
- Describe your photo protocol (distance, lighting, background) and one way a protocol difference could fake either good or bad results.
- From the quiz prompt: one question you missed and the corrected answer.