All Projects → vdevmcitylp → local-descriptors-for-image-classification

vdevmcitylp / local-descriptors-for-image-classification

Licence: other
Local Descriptors

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to local-descriptors-for-image-classification

GeobitNonrigidDescriptor ICCV 2019
C++ implementation of the nonrigid descriptor Geobit presented at ICCV 2019 "GEOBIT: A Geodesic-Based Binary Descriptor Invariant to Non-Rigid Deformations for RGB-D Images"
Stars: ✭ 11 (-50%)
Mutual labels:  descriptors
fastDesp-corrProp
Fast Descriptors and Correspondence Propagation for Robust Global Point Cloud Registration
Stars: ✭ 16 (-27.27%)
Mutual labels:  descriptors
face-authentication
Face-authentication system enterely written on C++ with OpenCV and Qt third party library. Face-antispoofing procedure is included.
Stars: ✭ 49 (+122.73%)
Mutual labels:  local-binary-patterns
lcd
[AAAI'20] LCD: Learned Cross-Domain Descriptors for 2D-3D Matching
Stars: ✭ 93 (+322.73%)
Mutual labels:  descriptors
bidd-molmap
MolMap: An Efficient Convolutional Neural Network Based Molecular Deep Learning Tool
Stars: ✭ 102 (+363.64%)
Mutual labels:  descriptors
node-dvbtee
MPEG2 transport stream parser for Node.js with support for television broadcast PSIP tables and descriptors
Stars: ✭ 24 (+9.09%)
Mutual labels:  descriptors
PyVGGFace
VGG-Face CNN descriptor in PyTorch.
Stars: ✭ 21 (-4.55%)
Mutual labels:  descriptors
whales descriptors
python code for calculating the WHALES (Weighted Holistic Atom Localization and Entity Shape) molecular descriptors
Stars: ✭ 24 (+9.09%)
Mutual labels:  descriptors
efficient-descriptors
🚀🚀 Revisiting Binary Local Image Description for Resource Limited Devices
Stars: ✭ 76 (+245.45%)
Mutual labels:  descriptors
lbph
Local Binary Patterns Histograms (LBPH) implementation in Go
Stars: ✭ 50 (+127.27%)
Mutual labels:  local-binary-patterns

local-descriptors-for-image-classification

UPDATE: My paper has been accepted! Check it out here.

Each file implements one of the variants of the Local Binary Pattern (LBP).

  1. Center Symmetric LBP
  2. Center Symmetric Local Derivative Pattern
  3. Center Symmetric Local Derivative Mapped Pattern
  4. Center Symmetric Local Mapped Pattern
  5. Center Symmetric Local Ternary Pattern
  6. Extended Center Symmetric Local Binary Pattern
  7. Extended Center Symmetric Local Mapped Pattern
  8. Extended Center Symmetric Local Ternary Pattern

Setup

Environment

- Python 3.7.6
- Ubuntu 16.04

Preferably, create a new environment using virtualenv.

Requirements

After activating the virtual environment, run the following command to install dependencies.

pip install -r requirements.txt

Datset Setup

Download the CIFAR-10 dataset from here and extract in the dataset directory.

For CIFAR-10, run this command to convert the images to grayscale.

python data_helper.py

This is a helper function for loading, preprocessing and saving the preprocessed images to disk for the CIFAR-10 dataset

Please write your own function for a custom dataset which,

  • Converts images to grayscale (you can use OpenCV functions)
  • Saves the converted images to disk

All the files in operators/ have the same underlying structure with the only difference being in the algorithm being implemented. All algorithms are trained and tested on the CIFAR-10 dataset.

To compute features

python main.py --operator cslbp --img_height 32 --img_width 32

The above command will compute CS-LBP features, check the operator argument for more choices.

Brief Explanation

Converting to Grayscale

These local descriptors require the input to be in grayscale.

grayscaleImg = (imRed*0.3 + imGreen*0.59 + imBlue*0.11).astype(int)

The Algorithm

First, I pad the image with zeros before running the algorithm.

img = np.concatenate((img, zeroVertical), axis=1)
img = np.concatenate((zeroVertical, img), axis=1)
img = np.concatenate((zeroHorizontal, img), axis=0)
img = np.concatenate((img, zeroHorizontal), axis=0)

The function then goes on to implement the respective algorithm (CS-LBP in this case).

pattern_img = np.zeros((img_height + 1, img_width + 1))
    
    for x in range(1, img_height + 1):
        for y in range(1, img_width + 1):
            
            s1 = threshold(img[x-1, y-1] - img[x+1, y+1])
            s2 = threshold(img[x-1, y] - img[x+1, y])*2 
            s3 = threshold(img[x-1, y+1] - img[x+1, y-1])*4 
            s4 = threshold(img[x, y+1] - img[x, y-1])*8

            s = s1 + s2 + s3 + s4

            pattern_img[x, y] = s

We then compute the histogram of the resultant image to get the feature vector.

histogram = np.histogram(pattern_img, bins = np.arange(17))[0]

Classification

python classification.py --operator cslbp

I'm using the XGBoost Classifier for classification.

model = XGBClassifier(n_estimators=800)
model.fit(X_train, y_train)

You have to play with n_estimators to get the best accuracy.

And that's about it! Feel free to open an issue if required.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].