{"id":13738258,"url":"https://github.com/vdevmcitylp/local-descriptors-for-image-classification","last_synced_at":"2025-05-08T16:33:02.885Z","repository":{"id":183209093,"uuid":"114394960","full_name":"vdevmcitylp/local-descriptors-for-image-classification","owner":"vdevmcitylp","description":"Local Descriptors","archived":false,"fork":false,"pushed_at":"2021-05-19T14:11:25.000Z","size":30,"stargazers_count":22,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-15T07:34:03.750Z","etag":null,"topics":["descriptors","image-processing","local-binary-patterns","local-ternary-patterns"],"latest_commit_sha":null,"homepage":"https://vdevmcitylp.github.io/local-descriptors-for-image-classification/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vdevmcitylp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-12-15T17:20:33.000Z","updated_at":"2024-02-09T12:44:32.000Z","dependencies_parsed_at":"2023-07-23T12:39:08.546Z","dependency_job_id":null,"html_url":"https://github.com/vdevmcitylp/local-descriptors-for-image-classification","commit_stats":null,"previous_names":["vdevmcitylp/local-descriptors-for-image-classification"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdevmcitylp%2Flocal-descriptors-for-image-classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdevmcitylp%2Flocal-descriptors-for-image-classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdevmcitylp%2Flocal-descriptors-for-image-classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdevmcitylp%2Flocal-descriptors-for-image-classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vdevmcitylp","download_url":"https://codeload.github.com/vdevmcitylp/local-descriptors-for-image-classification/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253105412,"owners_count":21855019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["descriptors","image-processing","local-binary-patterns","local-ternary-patterns"],"created_at":"2024-08-03T03:02:16.220Z","updated_at":"2025-05-08T16:33:02.624Z","avatar_url":"https://github.com/vdevmcitylp.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# local-descriptors-for-image-classification\n\nUPDATE: My paper has been accepted! Check it out [here](https://www.igi-global.com/article/center-symmetric-local-descriptors-for-image-classification/217023).\n\nEach file implements one of the variants of the [Local Binary Pattern (LBP)](http://jultika.oulu.fi/files/isbn9514270762.pdf).\n\n1. [Center Symmetric LBP](http://www.ee.oulu.fi/mvg/files/pdf/pdf_750.pdf)\n2. [Center Symmetric Local Derivative Pattern](https://ieeexplore.ieee.org/document/6011859/) \n3. Center Symmetric Local Derivative Mapped Pattern\n4. [Center Symmetric Local Mapped Pattern](https://dl.acm.org/citation.cfm?id=2554895)\n5. [Center Symmetric Local Ternary Pattern](https://www.computer.org/csdl/proceedings/cvpr/2010/6984/00/05540195-abs.html)\n6. [Extended Center Symmetric Local Binary Pattern](https://hal.archives-ouvertes.fr/hal-01227955/document)\n7. Extended Center Symmetric Local Mapped Pattern\n8. [Extended Center Symmetric Local Ternary Pattern](https://link.springer.com/chapter/10.1007/978-3-642-23321-0_56)\n\n\n## Setup\n\n### Environment \n```\n- Python 3.7.6\n- Ubuntu 16.04\n```\n\nPreferably, create a new environment using [virtualenv](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/).\n\n### Requirements\n\nAfter activating the virtual environment, run the following command to install dependencies.\n\n```\npip install -r requirements.txt\n```\n\n### Datset Setup\n\nDownload the CIFAR-10 dataset from [here]() and extract in the `dataset` directory.\n\nFor CIFAR-10, run this command to convert the images to grayscale.\n\n```\npython data_helper.py\n```\n\nThis is a helper function for loading, preprocessing and saving the preprocessed images to disk for the CIFAR-10 dataset\n\nPlease write your own function for a custom dataset which,\n- Converts images to grayscale (you can use OpenCV functions)\n- Saves the converted images to disk\n\n\u003chr\u003e\n\nAll the files in ```operators/``` have the same underlying structure with the only difference being in the algorithm being implemented.\nAll algorithms are trained and tested on the CIFAR-10 dataset.\n\n## To compute features\n\n    python main.py --operator cslbp --img_height 32 --img_width 32\n\nThe above command will compute CS-LBP features, check the `operator` argument for more choices.\n\n## Brief Explanation\n\n### Converting to Grayscale\n\nThese local descriptors require the input to be in grayscale.\n\n    grayscaleImg = (imRed*0.3 + imGreen*0.59 + imBlue*0.11).astype(int)\n\n### The Algorithm\n\nFirst, I pad the image with zeros before running the algorithm. \n\n    img = np.concatenate((img, zeroVertical), axis=1)\n    img = np.concatenate((zeroVertical, img), axis=1)\n    img = np.concatenate((zeroHorizontal, img), axis=0)\n    img = np.concatenate((img, zeroHorizontal), axis=0)\n\nThe function then goes on to implement the respective algorithm (CS-LBP in this case). \n\n    pattern_img = np.zeros((img_height + 1, img_width + 1))\n        \n        for x in range(1, img_height + 1):\n            for y in range(1, img_width + 1):\n                \n                s1 = threshold(img[x-1, y-1] - img[x+1, y+1])\n                s2 = threshold(img[x-1, y] - img[x+1, y])*2 \n                s3 = threshold(img[x-1, y+1] - img[x+1, y-1])*4 \n                s4 = threshold(img[x, y+1] - img[x, y-1])*8\n\n                s = s1 + s2 + s3 + s4\n\n                pattern_img[x, y] = s\n\nWe then compute the histogram of the resultant image to get the feature vector.\n\n    histogram = np.histogram(pattern_img, bins = np.arange(17))[0]\n\n### Classification\n\n    python classification.py --operator cslbp\n\nI'm using the [XGBoost](https://xgboost.readthedocs.io/en/latest/) Classifier for classification.\n\n    model = XGBClassifier(n_estimators=800)\n    model.fit(X_train, y_train)\n\nYou have to play with *n_estimators* to get the best accuracy.\n\nAnd that's about it! Feel free to open an issue if required.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdevmcitylp%2Flocal-descriptors-for-image-classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvdevmcitylp%2Flocal-descriptors-for-image-classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdevmcitylp%2Flocal-descriptors-for-image-classification/lists"}