#
A New Method of Histogram Computation for Efficient Implementation of the HOG Algorithm^{ †}

^{1}

^{2}

^{*}

^{†}

## Abstract

**:**

## 1. Introduction

## 2. Related Work

## 3. Classical HOG Algorithm and Preliminary Simplifications

#### 3.1. Classical HOG Algorithm

- Computation of x and y gradients for each image pixel;
- Based on the gradients, computation of gradient magnitude and angle (using the arctangent) for each image pixel;
- For each cell of a specified dimension (CellSize), allocate the gradient magnitude in a predefined bin (from a total of NBins) depending on the gradient angle. For example, if NBins = 9, each bin will span over 20 degrees: [0, 20), [20, 40), …, [160, 180]. In general (for all angles which are not exactly in the center of a bin (e.g., 10, 30, etc.)), in the classical approach, the magnitude of the gradients is allocated proportionally to the respective bin and the adjacent one. For instance, a gradient with an angle of 25 degrees, which is closer to the center of Bin 2, will have 75% of its magnitude allocated to Bin 2 and 25% to Bin 1;
- In this way, for each cell is obtained a histogram of oriented gradients, with NBins, and the magnitude of each bin is calculated by adding the interpolated gradient magnitudes of all corresponding pixels;
- Several cells can be grouped together within a block (of BlockSize dimension) and the magnitudes of all histograms are normalized within this block. The normalized values become part of the final algorithm output. All possible combinations of blocks (of given BlockSize) are considered, including overlapping ones.

#### 3.2. Preliminary HOG Simplifications

## 4. New Histogram Computation Method

#### 4.1. Replacing the Arctangent with Slope

#### 4.1.1. Case of y and x Strictly Positive (Angles in the First Quadrant)

#### 4.1.2. General Case (Angles in All Four Quadrants)

- -
- angles within [90°, 180°], if y > 0, x < 0,
- -
- negative angles within [0°, −180°], for y < 0.

#### 4.2. New HOG Computation Method

## 5. Results

#### 5.1. Tests for Replacing the Arctangent with Slope

#### 5.2. Tests for the New HOG Computation Method

#### 5.3. Tests for Different Classifiers

## 6. Discussions

## 7. Conclusions

## Acknowledgments

## Author Contributions

## Conflicts of Interest

## References

- Ilas, M.E. New Histogram Computation Adapted for FPGA Implementation of HOG Algorithm—For Car Detection Applications. In Proceedings of the 9th Computer Science & Electronic Engineering Conference (CEEC), Colchester, UK, 27–29 September 2017. [Google Scholar]
- Luettel, T.; Himmelshach, M.; Wuensche, H.-J. Autonomous Ground Vehicles—Concepts and a path to the future. Proc. IEEE
**2012**, 1831–1839. [Google Scholar] [CrossRef] - Lozano-Perez, T. Autonomous Robot Vehicles; Cox, I.J., Wilfong, G.T., Eds.; Springer Science & Business Media: Berlin, Germany, 2012. [Google Scholar]
- Rouff, C.; Hinchey, M. Experience from the DARPA Urban Challenge; Springer: London, UK, 2012; ISBN 978-0-85729771-6. [Google Scholar]
- Frazzoli, E.; Munther, D.A.; Feron, E. Real-time motion planning for agile autonomous vehicles. J. Guid. Control Dyn.
**2012**, 25, 116–129. [Google Scholar] [CrossRef] - Ilas, C. Electronic sensing technologies for autonomous ground vehicles: A review. In Proceedings of the 8th International Symposium on Advanced Topics in Electrical Engineering (ATEE), Bucharest, Romania, 23–25 May 2013; pp. 1–6. [Google Scholar]
- Ilas, C. Perception in Autonomous Ground Vehicles—A Review. In Proceedings of the ECAI Conference, Pitesti, Romania, 27–29 June 2013; pp. 1–6. [Google Scholar]
- Ilas, C.; Mocanu, I.; Ilas, M. Advances in Environment Sensing and Perception Technologies and Algorithms for Autonomous Ground Vehicles. In Autonomous Vehicles; Bizon, N., Dascalescu, L., Tabatabaei, N.M., Eds.; Nova Science Inc.: New York, NY, USA, 2014; Chapter 4; pp. 113–146. ISBN 971-1-63321-326-5. [Google Scholar]
- Lin, B.Z.; Chien-Chou, L. Pedestrian detection by fusing 3D points and color images. In Proceedings of the IEEE/ACIS 15th International Conference on Computer and Information Science (ICIS), Okayama, Japan, 26–29 June 2016; pp. 1–5. [Google Scholar]
- Sivaraman, S.; Trivedi, M.M. Looking at vehicles on the road: A survey of vision-based vehicle detection, tracking, and behavior analysis. IEEE Trans. Intell. Transp. Syst.
**2013**, 14, 1773–1795. [Google Scholar] [CrossRef] - Ma, X.; Walid Najjar, A.; Roy-Chowdhury, A.K. Evaluation and acceleration of high-throughput fixed-point object detection on FPGAs. IEEE Trans. Circ. Syst. Video Technol.
**2015**, 25, 1051–1062. [Google Scholar] - Tasson, D.; Montagnini, A.; Marzotto, R.; Farenzena, M.; Cristani, M. FPGA-based pedestrian detection under strong distortions. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), Boston, MA, USA, 7–12 June 2015; pp. 65–70. [Google Scholar]
- Ilas, M.E. Parameter Selection for Efficient HOG-based car detection. In Proceedings of the IEEE 26th International Symposium on Industrial Electronics (ISIE), Edinburgh, UK, 19–21 June 2017. [Google Scholar]
- Ilas, M.E. HOG Algorithm Simplification and Its Impact on FPGA Implementation—With Applications in Car Detection. Proceedings of 9th IEEE Conference on Electronics, Computers and Artificial Intelligence, Targoviste, Romania, 29 June–1 July 2017. [Google Scholar]
- Dalal, N.; Triggs, B. Histograms of oriented gradients for human detection. In Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition, San Diego, CA, USA, 20–25 June 2005; Volume 1. [Google Scholar]
- Lee, SH.; Bang, K.H.; Jung, K. An efficient selection of HOG feature for SVM classification of vehicle. In Proceedings of the IEEE International Symposium on Consumer Electronics (ISCE), Madrid, Spain, 24–26 June 2015; pp. 1–2. [Google Scholar]
- Li, X.; Guo, X. A HOG feature and SVM based method for forward vehicle detection with single camera. In Proceedings of the 5th International Conference on Intelligent Human-Machine Systems and Cybernetics (IHMSC), Hangzhou, China, 26–27 August 2013; Volume 1, pp. 263–266. [Google Scholar]
- Hsiao, P.Y.; Lin, S.Y.; Huang, S.S. An FPGA based human detection system with embedded platform. Microelectron. Eng.
**2015**, 138, 42–46. [Google Scholar] [CrossRef] - Benenson, R.; Mathias, C.; Timofte, R.; Van Gool, L. Pedestrian detection at 100 frames per second. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Providence, RI, USA, 16–21 June 2012; pp. 2903–2910. [Google Scholar]
- Hsiao, P.Y.; Lin, S.Y.; Chen, C.Y. A Real-Time FPGA Based Human Detector. In Proceedings of the International Symposium on Computer, Consumer and Control (IS3C), Xi’an, China, 4–6 July 2016; pp. 1014–1017. [Google Scholar]
- Hemmati, M.; Biglari-Abhari, M.; Berber, S.; Niar, S. HOG feature extractor hardware accelerator for real-time pedestrian detection. In Proceedings of the 17th Euromicro Conference on Digital System Design (DSD), Verona, Italy, 27–29 August 2014; pp. 543–550. [Google Scholar]
- Kim, J.; Baek, J.; Kim, E. A Novel On-Road Vehicle Detection Method Using π-HOG. IEEE Trans. Intell. Transp. Syst.
**2015**, 16, 3414–3429. [Google Scholar] [CrossRef] - Mizuno, K.; Terachi, Y.; Takagi, K.; Izumi, S.; Kawaguchi, H.; Yoshimoto, M. Architectural study of HOG feature extraction processor for real-time object detection. In Proceedings of the 2012 IEEE Workshop on Signal Processing Systems (SiPS), Quebec City, QC, Canada, 17–19 October 2012; pp. 197–202. [Google Scholar]
- Mizuno, K.; Terachi, Y.; Takagi, K.; Izumi, S.; Kawaguchi, H.; Yoshimoto, M. A sub-100 mw dual-core HOG accelerator VLSI for parallel feature extraction processing for HDTV resolution video. IEICE Trans. Electron.
**2013**, 96, 433–443. [Google Scholar] [CrossRef] - Bauer, S.; Köhler, S.; Doll, K.; Brunsmann, U. FPGA-GPU architecture for kernel SVM pedestrian detection. In Proceedings of the 2010 IEEE Computer Society Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), San Francisco, CA, USA, 13–18 June 2010; pp. 61–68. [Google Scholar]
- Bauer, S.; Brunsmann, U.; Schlotterbeck-Macht, S. FPGA implementation of a HOG-based pedestrian recognition system. In Proceedings of the MPC-Workshop, Karlsruhe, Germany, 6 May 2009; pp. 49–58. [Google Scholar]
- Hahnle, M.; Saxen, F.; Hisung, M.; Brunsmann, U.; Doll, K. FPGA-based real-time pedestrian detection on high-resolution images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), Portland, OR, USA, 23–28 June 2013; pp. 629–635. [Google Scholar]
- Chen, P.Y.; Huang, C.C.; Lien, C.Y.; Tsai, Y.H. An efficient hardware implementation of HOG feature extraction for human detection. IEEE Trans. Intell. Transp. Syst.
**2014**, 15, 656–662. [Google Scholar] [CrossRef] - Wang, J.F.; Choy, C.S.; Chao, T.L.; Kit, K.C.; Pun, K.P.; Ouyang, W.L.; Wang, X.G. HOG arithmetic for speedy hardware realization. In Proceedings of the 2014 IEEE Asia Pacific Conference on Circuits and Systems (APCCAS), Ishigaki, Japan, 17–20 November 2014; pp. 61–64. [Google Scholar]
- Rajan, S.; Wang, S.; Inkol, R.; Joyal, A. Efficient approximations for the arctangent function. IEEE Signal Process. Mag.
**2006**, 23, 108–111. [Google Scholar] [CrossRef] - Static Images. Available online: https://drive.google.com/drive/folders/0B7EEW4NFU3YdTUpsRXBNSm1JNEE?usp=sharing (accessed on 28 February 2018).
- Krause, J.; Stark, M.; Deng, J.; Li, F. 3D object representations for fine-grained categorization. Proceedings of IEEE International Conference on Computer Vision Workshops, Sydney, Australia, 2–8 December 2013; pp. 554–561. [Google Scholar]
- Opelt, A.; Pinz, A.; Fussenegger, M.; Auer, P. Generic object recognition with boosting. IEEE Trans. Pattern Anal. Mach. Intell.
**2006**, 28, 416–431. [Google Scholar] [CrossRef] [PubMed] - Carbonetto, P.; Dorkó, G.; Schmid, C.; Kück, H.; De Freitas, N. Learning to recognize objects with little supervision. Int. J. Comp. Vis.
**2008**, 77, 219–237. [Google Scholar] [CrossRef]

**Figure 1.**Gradient conversion to two quadrants: (

**a**) classical histogram of oriented gradients (HOG) approach: gradients OA’ and OB’ are converted to OA and OB, respectively, and represented by the angles which are in the 0–180° interval; (

**b**) new computation method: gradients OA’ and OB’ are converted to OA and OB, respectively, and represented by the slopes s1 and s2 which are in the [−90, 90] interval.

**Figure 2.**Histogram of gradients: (

**a**) Computed using the arctangent function. Each bin has a 20° span. Bin 1 starts with 0°. Bin 5 contains angles within [80°, 100°]. (

**b**) Computed using the limited slope function. Each bin has a span of 20. Bin 1 starts with −90. Bin 5 contains slopes around 0.

**Figure 4.**Precision–recall curves for car classification using the original HOG (solid line, thinner) and the HOG using gradient slope for bin allocation (dotted line, thicker) (

**a**) for Training Set 1, Test Set 1; (

**b**) for Training Set 2, Test Set 2.

**Figure 5.**Histogram of gradients computed using the limited slope function, for the same cell as the one presented in Figure 2, but after applying the filtering of gradient components, with a threshold of 10 (

**a**). In (

**b**) the original histogram shown in Figure 2b is repeated here, to facilitate comparison.

**Table 1.**Different slope values and the corresponding values of arctangent and ls function, together with the resulting allocation bins.

y/x Ratio [-] | Atan(y, x) [rad] | ls(y, x) [-] | Atan(y, x) [deg] | ls × 180/π [-] | Atan Bin | ls Bin |
---|---|---|---|---|---|---|

0.33 | 0.32 | 0.33 | 18.43 | 19.09 | 1 | 1 |

0.5 | 0.46 | 0.5 | 26.56 | 28.64 | 2 | 2 |

1 | 0.78 | 1 | 45 | 57.3 | 3 | 3 |

1.57 | 1.00 | 1.57 | 57.52 | 90 | 3 | 5 |

2 | 1.1 | 1.57 | 63.43 | 90 | 4 | 5 |

3 | 1.25 | 1.57 | 71.56 | 90 | 4 | 5 |

4 | 1.32 | 1.57 | 75.96 | 90 | 4 | 5 |

7 | 1.43 | 1.57 | 81.86 | 90 | 5 | 5 |

10 | 1.47 | 1.57 | 84.28 | 90 | 5 | 5 |

**Table 2.**Precision and recall values for classification using the original HOG and the algorithm using gradient slope for bin allocation.

Data Sets | Original HOG (Arctangent Based) | New Algorithm (Slope Based) | |||||
---|---|---|---|---|---|---|---|

Training | Test | Precision | Recall | AUC | Precision | Recall | AUC |

Set 1 | Set 1 | 0.99 | 0.65 | 0.927 | 0.98 | 0.62 | 0.921 |

Set 2 | Set 2 | 0.99 | 0.84 | 0.982 | 0.99 | 0.83 | 0.980 |

Set 1 | Set 2 | 1 | 0.68 | 0.968 | 1 | 0.70 | 0.969 |

Set 2 | Set 1 | 0.91 | 0.33 | 0.795 | 0.92 | 0.32 | 0.832 |

**Table 3.**Precision and recall values for classification using the algorithm using gradient slope for bin allocation, with and without gradient filtering.

Data Sets | New Algorithm (Slope Based, No Filtering) | New Algorithm (Slope Based, with Filtering) | |||||
---|---|---|---|---|---|---|---|

Training | Test | Precision | Recall | AUC | Precision | Recall | AUC |

Set 1 | Set 1 | 0.98 | 0.62 | 0.921 | 1 | 0.69 | 0.919 |

Set 2 | Set 2 | 0.99 | 0.83 | 0.980 | 1 | 0.83 | 0.972 |

Set 1 | Set 2 | 1 | 0.70 | 0.969 | 1 | 0.65 | 0.949 |

Set 2 | Set 1 | 0.92 | 0.32 | 0.832 | 0.97 | 0.42 | 0.881 |

**Table 4.**Precision and recall values for classification using the original and the new HOG computation method.

Data Sets | Original Histogram Computation Method | New Histogram Computation Method | |||||
---|---|---|---|---|---|---|---|

Training | Test | Precision | Recall | AUC | Precision | Recall | AUC |

Set 1 | Set 1 | 0.99 | 0.65 | 0.927 | 0.98 | 0.62 | 0.922 |

Set 2 | Set 2 | 0.99 | 0.84 | 0.982 | 0.99 | 0.83 | 0.980 |

Set 1 | Set 2 | 1 | 0.68 | 0.969 | 1 | 0.68 | 0.966 |

Set 2 | Set 1 | 0.91 | 0.33 | 0.795 | 0.93 | 0.33 | 0.833 |

**Table 5.**Precision and recall values for classification using the original and the new HOG computation method, with filtering.

Data Sets | Original Histogram Computation Method | New Histogram Computation Method, with Filtering | |||||
---|---|---|---|---|---|---|---|

Training | Test | Precision | Recall | AUC | Precision | Recall | AUC |

Set 1 | Set 1 | 0.99 | 0.65 | 0.927 | 1 | 0.69 | 0.919 |

Set 2 | Set 2 | 0.99 | 0.84 | 0.982 | 1 | 0.81 | 0.972 |

Set 1 | Set 2 | 1 | 0.68 | 0.969 | 1 | 0.63 | 0.949 |

Set 2 | Set 1 | 0.91 | 0.33 | 0.795 | 0.97 | 0.42 | 0.881 |

**Table 6.**Absolute and relative number of slice lookup tables (LUTs) and registers for the simplified versions of HOG, versus the original one.

Implemented Algorithm | Slice LUTs Abs. Value | Slice LUTs Relative Value | Slice Registers Abs. Value | Slice Registers Relative Value |
---|---|---|---|---|

Original HOG (with arctangent, bin interpolation, and 20 degree bins) | 42,917 | 100% | 27,808 | 100% |

HOG with 16 degree bins (with arctangent, bin interpolation, and 16 degree bins) | 40,239 | 93.76% | 23,052 | 82.90% |

Simplified HOG (with arctangent, no bin interpolation, 16 degree bins) | 15,150 | 35.30% | 17,002 | 61.14% |

New histogram computation, with slope, no interpolation, and bins of 16 units | 11,075 | 25.81% | 10,928 | 39.30% |

**Table 7.**Relative number of slice LUTs and registers for the simplified versions of HOG, versus the original one.

Implemented Algorithm | Slice LUTs |
---|---|

Original HOG (with arctangent, bin interpolation, and 20 degree bins) | - |

HOG with 16 degree bins (with arctangent, bin interpolation, and 16 degree bins) | 0% |

Simplified HOG (with arctangent, no bin interpolation, 16 degree bins) | −1 to +1% ^{1} |

New histogram computation, with slope, no interpolation, and bins of 16 units | −3 to −1% |

New histogram computation, with slope, no interpolation, and bins of 16 units, with filtering, on similar training and test data | −3 to +4% ^{1} |

^{1}Recall may actually be increased.

**Table 8.**Precision and recall values for classification using the original and the new HOG computation method, using a linear SVM classifier.

Data Sets | Original Histogram Computation Method | New Histogram Computation Method | |||||
---|---|---|---|---|---|---|---|

Training | Test | Precision | Recall | AUC | Precision | Recall | AUC |

Set 1 | Set 1 | 0.95 | 0.68 | 0.889 | 0.97 | 0.64 | 0.898 |

Set 2 | Set 2 | 0.97 | 0.81 | 0.950 | 0.95 | 0.81 | 0.940 |

Set 1 | Set 2 | 1 | 0.51 | 0.870 | 0.97 | 0.52 | 0.880 |

Set 2 | Set 1 | 0.89 | 0.30 | 0.741 | 0.92 | 0.36 | 0.800 |

© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Ilas, M.-E.; Ilas, C. A New Method of Histogram Computation for Efficient Implementation of the HOG Algorithm. *Computers* **2018**, *7*, 18.
https://doi.org/10.3390/computers7010018

**AMA Style**

Ilas M-E, Ilas C. A New Method of Histogram Computation for Efficient Implementation of the HOG Algorithm. *Computers*. 2018; 7(1):18.
https://doi.org/10.3390/computers7010018

**Chicago/Turabian Style**

Ilas, Mariana-Eugenia, and Constantin Ilas. 2018. "A New Method of Histogram Computation for Efficient Implementation of the HOG Algorithm" *Computers* 7, no. 1: 18.
https://doi.org/10.3390/computers7010018