3

I am trying to implement a procedure similar to that of MatLab whereby HOG features are extracted from an image and then plotted over either the original image, or simply standalone to estimate the shape/template of the image (see here, and below). HOG feature extraction can be easily done in R via the OpenImageR's HOG() function, but I cannot figure out a way to recreate the plot in R. Preferably, there would be a way to overlay the features extracted onto an image via ggplot and raster.

HOG features overlaid on image

HOG features overlaid on image

HOG features plotted by itself HOG features plotted by itself

EDIT

Here is a minimal example from R and OpenImageR

library(OpenImageR)
path = system.file("tmp_images", "1.png", package = "OpenImageR")
image = rgb_2gray(readImage(path))
image=image*255 # Convert to gray values
hog = HOG(image, cells = 9, orientations = 4)

Essentially, I load an image and extract the HOG features by slicing the 32x32 image 4 (4*4) times, and collecting 4 orientations per slice block resulting in a long unidimensional vector of 64 values (4*4 slices * 4 orientations). The trouble I am having is moving from HOG features to visualization like in the examples provided.

DrPineapple
  • 321
  • 1
  • 4
  • 13
  • 1
    how far have you gotten with `OpenImageR`'s `HOG` function? – MichaelChirico Feb 28 '17 at 05:40
  • 1
    It would be easier to help you if you provided a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Include the code you've already written (such as the code to run `HOG()`). – MrFlick Feb 28 '17 at 05:42
  • I've edited my question to provide some addition information, and a reproducible example. – DrPineapple Mar 01 '17 at 20:04
  • 2
    @DrPineapple, the HOG function ports a C++ function which does not support plotting of the HOG features. However, if you have access to python from your operating system then you can use the [reticulate](https://github.com/rstudio/reticulate) package to plot the HOG features as I described in one of my [blog posts](http://mlampros.github.io/2017/04/13/fuzzywuzzyR_package/). – lampros Nov 16 '17 at 21:05

0 Answers0