https://github.com/ycc789741ycc/hog-bgr-with-visualization
HOG feature descriptor, the kind of feature transform before we put our image into SVM. This repository also provides hog visualization both before and after doing block normalization.
https://github.com/ycc789741ycc/hog-bgr-with-visualization
computer-vision hog-features hog-features-extraction numpy opencv python
Last synced: 2 months ago
JSON representation
HOG feature descriptor, the kind of feature transform before we put our image into SVM. This repository also provides hog visualization both before and after doing block normalization.
- Host: GitHub
- URL: https://github.com/ycc789741ycc/hog-bgr-with-visualization
- Owner: ycc789741ycc
- License: other
- Created: 2021-08-30T06:32:22.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-08-30T11:04:40.000Z (over 3 years ago)
- Last Synced: 2025-03-20T15:03:39.590Z (2 months ago)
- Topics: computer-vision, hog-features, hog-features-extraction, numpy, opencv, python
- Language: Python
- Homepage:
- Size: 2.33 MB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HOG-BGR-with-visualization
HOG feature descriptor, a kind of feature transform before we put our image into SVM or NN.
In this API, I split hog feature into BGR channel respectively, it's a little different from hog in skimage, but this API still support grayscale image.
This API divides orients of gradient into 9 bins and each bin represent 0 20 40 60 ... 160.
Furthermore, due to hog's performance has some relationship with tuning parameters, so this repository provides hog visualization both before and after doing block normalization.
## Environment
Python>=3.9.1
numpy>=1.20.0
opencv-python>=4.5.1.48## Installation
```
pip install hogBGR
```## Demo
Original Picture![]()
```
import cv2
from hogBGR import HOG
from hogBGR import HOGvisualized
from hogBGR import util
```### HOG
> Let's create a 16x16 (pixels) cell, 2x2 (cells) block hog image.
```
img = cv2.imread(r'hogBGR/example/rose.png')
cell_hogfeature = HOG.Cell_HOG(img,cell_size=(16,16))
hog = HOG.BlockNorm_HOG(cell_hogfeature,block_size=(2,2))
```
or
```
img = cv2.imread(r'hogBGR/example/rose.png')
hog = HOG.HOGfeature(img,cell_size=(16,16),block_size=(2,2),flatten=False)
```
> Take a visualization
```
res = HOGvisualized.visualize_HOG(hog[:,:,:,0,0,:],15)
cv2.imshow("HOG feature with block normaliztion",res)
```
or
```
util.BlockNormaliztionHOG_Show(img,one_cell=True)
```
> Below shows hog image in each cell of blocks. (First method would only show first cell of blocks)![]()
### HOG without block normalization
> Let's create a 16x16 (pixels) cell hog image.
```
img = cv2.imread(r'hogBGR/example/rose.png')
cell_hogfeature = HOG.Cell_HOG(img,cell_size=(16,16))
```
> Take a visualization
```
res = HOGvisualized.visualize_HOG(cell_hogfeature,15)
cv2.imshow("part1 - HOG feature without block normaliztion",res)
```
or
```
util.NonBlockNormaliztionHOG_Show(img)
```
> Below shows hog image before block normalization![]()
### Gray scale input image is also supported
Orginal Picture![]()
Visualization![]()
### Simplified visualization
> You can try the result with yourself if you want a faster visualization.
```
res = HOGvisualized.Fast_visualize_HOG(hogfeature,7)
```