Texture image classification with Python and MATLAB
Image source: http://www.nada.kth.se/cvap/databases/kth-tips/download.html (use link 'greyscale PNG Images' - 23MB)
Textures Images used: Aluminium Foil, Corduroy, and Orange Peel.
Train set: 120 images (40 images from each class)
Test set: 120 images (40 images from each class)
Features (extracted using Matlab):
- Gray-level co-occurrence matrix (GLCM): Energy and Entropy.
- Fast Fourier Transform (FFT): Mean and Variances.
Classification method:
- K-nearest neighbor
- Gaussian Naïve-bayes
Evaluation: classification accuracy
Extracting Features with Matlab
- Download texture image dataset
- Collect in one folder, rename images3.
- Run .m file
- Save dataku.mat file (don't worry! dataku.mat file is provided here). To know more about the detail, I am preparing to upload the MATLAB code later.
Number of features: 4:
- attribute 1: Entropy of GLCM
- attribute 2: Energy of GLCM
- attribute 3: Mean of FFT
- attribute 4: Variance of FFT
Classifying the images
KNN
python imageclassification3_knn.py
Note: You can change line 14 to switch the features of GLCM, FFT, or all features.
GNB
python imageclassification4_gnb.py
Note: You can change line 14 to switch the features of GLCM, FFT, or all features.
KNN with GLCM, FFT
GNB with GLCM, FFT
KNN with GLCM + FFT and GNB with GLCM + FFT