image_fhog {image.dlib}R Documentation

HOG (Histogram Of Gradients) feature extraction

Description

Gets the histogram of oriented gradients (HOG) feature descriptor https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients of an image. More information on the calculation, see the reference paper or the dlib reference http://dlib.net/dlib/image_transforms/fhog_abstract.h.html

Usage

image_fhog(
  x,
  cell_size = 8L,
  filter_rows_padding = 1L,
  filter_cols_padding = 1L
)

Arguments

x

a 3-dimensional array of integer pixel values where the first dimension is RGB, 2nd the width of the image and the 3rd the height of the image. See the example.

cell_size

integer. HOG groups pixels in cells, based on which a histogram of the gradiens is computed. Give the cell size. Defaults to 8.

filter_rows_padding

integer indicating how many extra rows and columns of zero padding along the borders to add, for more efficient convolution code

filter_cols_padding

integer indicating how many extra rows and columns of zero padding along the borders to add, for more efficient convolution code

Value

a list with HOG features of the pixels mapped into HOG space. It contains:

References

Object Detection with Discriminatively Trained Part Based Models by P. Felzenszwalb, R. Girshick, D. McAllester, D. Ramanan IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 32, No. 9, Sep. 2010

Examples

library(magick)
f <- system.file("extdata", "cruise_boat.png", package = "image.dlib")
x <- image_read(f)
x
feats <- image_data(x, channels = "rgb")
feats <- as.integer(feats, transpose = FALSE)
feats <- image_fhog(feats, cell_size = 8)
str(feats)

## FHOG feature vector of pixel at HOG space position 1, 1
feats$fhog[1, 1, ]
## FHOG feature vector of pixel at HOG space position 4 (height), 7 (width)
feats$fhog[4, 7, ]

[Package image.dlib version 0.1.1 Index]