HOG_apply: calculate the HOG (Histogram of oriented gradients) for a...

View source: R/hog_features_rscript.R

HOG_applyR Documentation

calculate the HOG (Histogram of oriented gradients) for a matrix, array or a folder of images

Description

calculate the HOG (Histogram of oriented gradients) for a matrix, array or a folder of images

Usage

HOG_apply(
  object,
  cells = 3,
  orientations = 6,
  rows = NULL,
  columns = NULL,
  threads = 1
)

Arguments

object

a matrix, a data frame, a 3-dimensional array (where the third dimension is equal to 3) or a path to a folder of files (images)

cells

the number of divisions ( cells )

orientations

number of orientation bins

rows

a value specifying the number of rows of each image-row of the matrix (required if object is a matrix)

columns

a value specifying the number of columns of each image-row of the matrix (required if object is a matrix)

threads

the number of parallel cores to use

Details

This function takes as input either a matrix, a data frame, a 3-dimensional array (where the third dimension is equal to 3) or a character path to a folder of files (images). It returns the HOG-descriptors (histogram of oriented gradients) for each row (if matrix or data frame), for each array-slice (if array) or for each file (if path to a folder of images).

Value

If the input is a matrix, data frame or array it returns a matrix of the hog descriptors. If the input is a path to a folder it returns a list of length 2, the 1st sublist is a vector with the names of the image files (the order of the files in the vector corresponds to the order of the rows of the output matrix), the 2nd sublist is the matrix of the hog descriptors.

Examples


## Not run: 

MATR = matrix(runif(75), ncol = 25, nrow = 5)

res = HOG_apply(MATR, cells = 3, orientations = 5, rows = 5, columns = 5, threads = 1)


ARRAY = array(5, dim = c(10, 10, 3))

res = HOG_apply(ARRAY, cells = 3, orientations = 6, threads = 1)


FOLDER_path = paste0(system.file("tmp_images", "same_type", package = "OpenImageR"), '/')

res = HOG_apply(FOLDER_path, cells = 3, orientations = 6, threads = 1)

## End(Not run)

OpenImageR documentation built on July 9, 2023, 5:43 p.m.