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.

"Quiz me with 4 questions, one at a time, on texture classification: what a local binary pattern encodes at each pixel and why the rotation-invariant form matters for photos taken at arbitrary angles, why texture features can separate materials that color histograms cannot, what the support vector machine's margin means for these 36-bin LBP feature vectors, and what should happen to the existing confusion matrix when a fourth class is added — which cells can get worse and why. Grade my answers and list my misconceptions."
"I am about to add a fourth texture class ({your material: fabric, grass, wood, ...}) to a working sand/seed/stone LBP + SVM classifier, with 5 new training and 5 new test photos. BEFORE I retrain: predict which existing class my new material will be confused with most and why, in terms of LBP pattern statistics (fine vs coarse texture, regularity). Commit to a specific prediction. Then I will show you the new confusion matrix — score your own prediction against it and explain any miss."

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:

  1. Include the baseline 3-class confusion matrix (verified against the provided one) and your 4-class confusion matrix after adding the new material.
  2. 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.
  3. Describe your photo protocol (distance, lighting, background) and one way a protocol difference could fake either good or bad results.
  4. From the quiz prompt: one question you missed and the corrected answer.

Course on GitHub

Exams

Data Engineering

Agentic Engineering

Classification

Supervised Learning

Unsupervised Learning

Regression

Time-Series

Computer Vision

Applications

3D Print 📈📊
Automotive Data 📈📊
Auto Efficiency 📈📊👁️
Battery Life⏱️📈
Bit Classification 👁️📊
Facial Recognition 👁️📊
Glass Type⏱️📈
Hand Tracking 👁️
OT Cybersecurity ⏱️📊
Batteries 📊
Polymers 📈
Road Detection 👁️📊
Safety 👁️
Soils 👁️📊
Sonar 📊
Texture 👁️📊
Wind Power ⏱️📈
📈=Regression
📊=Classification
⏱️=Time Series
👁️=Computer Vision
🎧=Audio

TCLab Project

Related Courses

Admin