• Stars
    star
    168
  • Rank 217,410 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[UNMAINTAINED] Histogram of Oriented Gradients (HOG) descriptor extractor

hog-descriptor

hog-descriptor extracts a Histogram of Oriented Gradients descriptor from an image (canvas):

var hog = require("hog-descriptor");

var descriptor = hog.extractHOG(canvas);

console.log(descriptor); // [0.455, 0.003, 0.987, ...]

Install

For node.js:

npm install hog-descriptor

API

extractHOG() takes options for the cell size (default is 4 pixels), block size (default is 2 cells), block stride (default is blockSize / 2), number of bins per orientation histogram (default is 6), and block normalization method (one of "L1", "L1-sqrt", and default "L2"):

var options = {
  cellSize: 4,    // length of cell in px
  blockSize: 2,   // length of block in number of cells
  blockStride: 1, // number of cells to slide block window by (block overlap)
  bins: 6,        // bins per histogram
  norm: 'L2'      // block normalization method
}

var descriptor = hog.extractHOG(canvas, options);

Other Goodies

In the process of computing a HOG descriptor, a bunch of other intermediate things have to be computed, like the image gradient, so these steps are also provided as secret goodies on the library:

intensities

Get a 2d array of the pixel intensities (normalized to fall between 0 and 1):

var intensities = hog.intensities(canvas);

The return array is indexed first by row (y direction) then by column (x direction).

gradients

Get a 2d array of the image gradient at each pixel of the canvas with respect to the vertical and horizontal directions using a [-1, 0, 1] filter:

var gradients = hog.gradients(canvas);

Return looks like this:

{
   x: [[0.0084, 0.354] /* , ... */],
   y: [[0.056, 0.7888] /* , ... */]
}

gradientVectors

Get a 2d array of the gradient vectors at each pixel of the canvas:

var vectors = hog.gradientVectors(canvas);

Return value is the vector at each pixel with mag and orient for magnitude and orientation (in radians):

[[{ mag: 0.4, orient: -1.52} /*, ... */]]

drawGreyscale

Greyscales a canvas:

hog.drawGreyscale(canvas)

x-gradient

drawGradient

Draws the gradient of the canvas with respect to 'x' or 'y' direction:

hog.drawGradient(canvas, 'x')

x-gradient

hog.drawGradient(canvas, 'y')

y-gradient

drawMagnitude

Draws the magnitude of the gradient vectors over the canvas:

hog.drawMagnitude(canvas)

magnitude

More Repositories

1

brain

Simple feed-forward neural network in JavaScript
JavaScript
8,005
star
2

kittydar

Face detection for cats in JavaScript - demo for TXJS 2012 talk
JavaScript
1,415
star
3

replace

Command line search and replace utility
JavaScript
749
star
4

classifier

Bayesian classifier with Redis backend
JavaScript
626
star
5

clustering

K-means and hierarchical clustering
JavaScript
492
star
6

nomnom

Option parser for node with generated usage and commands
JavaScript
469
star
7

glossary

[UNMAINTAINED] Extract terms and keywords from a piece of text
JavaScript
168
star
8

fxconsole

[UNMAINTAINED] Remote JavaScript console for Firefox
JavaScript
128
star
9

firefox-client

[UNMAINTAINED] Node.js remote debugging client for Firefox
JavaScript
101
star
10

costco

UI for bulk editing CouchDB docs
JavaScript
56
star
11

js-select

[UNMAINTAINED] Traverse and modify objects using JSONSelect selectors
JavaScript
56
star
12

rainbow

Color tools for Firefox
JavaScript
39
star
13

txjs-slides

dzslides deck for my txjs talk
CSS
14
star
14

mac-sounds

Play default OS X sounds from node
JavaScript
10
star
15

bzhome

Bugzilla dashboard
JavaScript
9
star
16

passion-project-slides

Slides for my Passion Projects talk on Machine Learning and JS
JavaScript
7
star
17

detect-indent

CSS
6
star
18

tcm

Mozilla's new testcase manager
JavaScript
5
star
19

searchbugs

Search for Bugzilla bugs by component
JavaScript
5
star
20

celestial-snips-app

Snips voice assistant that answers celestial questions
Python
3
star
21

mini-devtools

mini in-content devtools
JavaScript
3
star
22

test-pages

Testcase websites for devtools
JavaScript
3
star
23

artfulimage

The Artful Image fine printing
3
star
24

devtools-guide

3
star
25

showsearch

Jetpack that shows search terms in Firefox's awesomebar
JavaScript
3
star
26

firefontfamily

A Firebug extension that highlights the rendered font-family
JavaScript
2
star
27

contextfont

Firefox addon to find fonts on websites
JavaScript
2
star
28

bztweaks

mirror of Bugzilla Tweaks Firefox addon (https://bitbucket.org/ehsan/bugzilla-tweaks)
JavaScript
2
star
29

fluent-talk

JavaScript
1
star
30

bugidhelper

Bugzilla bug id linkifier and tooltipifier extension
JavaScript
1
star
31

brooklynjs-slides

Write your own in-content devtools with web APIs
CSS
1
star
32

test-snips-calc

Test Snips Calc Action
Python
1
star
33

harth

harth's no.de code
1
star
34

wwcode

A small website for Women Who Code SF
JavaScript
1
star
35

celestial-jupyter

Jupyter Notebook
1
star
36

test.js

Whatever's in my ~/test.js
JavaScript
1
star