HOG_python
Histogram of Gradients in Python from scratch
import sys
from skimage import color, data
import matplotlib.pyplot as plt
from hogpylib.hog import HistogramOfGradients
def main(args=None):
from skimage.feature import hog
PIXELS_PER_CELL = (8, 8)
CELLS_PER_BLOCK = (2, 2)
NUMBER_OF_BINS = ORIENTATIONS = 9 # NUMBER_OF_BINS
VISUALISE = True
orig_img = color.rgb2gray(data.astronaut())
# orig_img = color.rgb2gray(skimage.io.imread("../data/people.jpg"))
custom_hog = HistogramOfGradients(pixels_per_cell=PIXELS_PER_CELL,
cells_per_block=CELLS_PER_BLOCK,
num_of_bins=NUMBER_OF_BINS,
visualise=VISUALISE)
hog_features, hog_image = custom_hog.compute_features(orig_img)
hog_features_check, hog_image_scikit = hog(orig_img,
orientations=ORIENTATIONS,
pixels_per_cell=PIXELS_PER_CELL,
cells_per_block=CELLS_PER_BLOCK,
block_norm='L2',
visualize=VISUALISE)
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(12, 4))
ax1.axis('off')
ax2.axis('off')
ax3.axis('off')
ax1.imshow(orig_img, cmap=plt.get_cmap('gray'))
ax1.set_title('Input Image')
ax2.imshow(hog_image, cmap=plt.get_cmap('gray'))
ax2.set_title('Custom HOG')
ax3.imshow(hog_image_scikit, cmap=plt.get_cmap('gray'))
ax3.set_title('Scikit HOG')
plt.show()
if __name__ == "__main__":
sys.exit(main())
Result
References
[1] http://lear.inrialpes.fr/people/triggs/pubs/Dalal-cvpr05.pdf
Metadata
Release files for hogpylib 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hogpylib-1.0.2.tar.gz | 1.4 MB | Without provenance | Details for hogpylib-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hogpylib-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for hogpylib-1.0.2-py3-none-any.whl |
Total release size: 2.8 MB
Release files / hogpylib-1.0.2.tar.gz
| Download URL | hogpylib-1.0.2.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2cdf784fa44e9d76a6f30c2d20a5f7f26cb94d87cb0963244e7d8fb8f7b5a05d
|
|
BLAKE2b-256 checksum How to use checksums |
8edb44ddae918202811907b4ecfe6e25a5941ec56b8041a6be8083466073bc87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / hogpylib-1.0.2-py3-none-any.whl
| Download URL | hogpylib-1.0.2-py3-none-any.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09eaef6e513c7460e3d85603697e24512dd1d90ba055b894431594ea96dca2a0
|
|
BLAKE2b-256 checksum How to use checksums |
e926d07ee79b77868f3fc15d050c40541220f825769e76d4b22f461a43f3d5ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for hogpylib 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.