boofcv.alg.feature.dense
Class DescribeDenseHogAlg<Input extends ImageBase,Derivative extends ImageBase>
- java.lang.Object
-
- boofcv.alg.feature.dense.DescribeDenseHogAlg<Input,Derivative>
-
- Direct Known Subclasses:
- DescribeDenseHogAlg_F32, DescribeDenseHogAlg_PLF32, DescribeDenseHogAlg_PLU8, DescribeDenseHogAlg_U8
public abstract class DescribeDenseHogAlg<Input extends ImageBase,Derivative extends ImageBase> extends java.lang.ObjectImplementation of the Histogram of Oriented Gradients (HOG) [1] dense feature descriptor. Several variants are described in the paper. The algorithm used here is the "R-HOG unsigned orientation" variant. The descriptor is computed from a regular grid of cells and an unsigned histogram is computed. Unsigned as in the angle is from 0 to 180 degrees instead of 0 to 360.
This is a (hopefully) faithful implementation to the algorithm described in the paper. The descriptors are computed with the following steps.- Compute image gradient using [-1,0,1] kernel
- Compute histogram for each cell in the image
- Compute descriptor from blocks of cells
- Normalize descriptor using SIFT style L2-Hys normalization
Cell Histogram
The image is broken up into a regular grid of "cells". Every cell is square with a width of N pixels, where N is a user specified parameter. Within each cell a histogram is computed. The number of histogram bins B is specified by the user. The histogram is created by computing the Euclidean norm for each pixel's gradient inside the cell and then using bilinear interpolation to put it into the two neighboring bins which best match its angle.Descriptor Blocks
Square blocks, which are M cells wide, are used to compute each descriptor. The histogram is copied into aTupleDesc_F64in a row-major fashion and a weight is applied. The weight is specified for each cell based on its distance from the block's center. Gaussian weight is used with a standard deviation of 0.5*block_width. Note that blocks do overlap. See paper for details.Descriptor Normalization
First L2-normalization is applied to the descriptor. Then min(0.2,desc[i]) is applied to all elements in the descriptor. After which L2-normalization is applied again.Accessing Results
A list of descriptor and their locations is available. The location refers to the top-left most pixel in the region the descriptor is computed from. These lists are computed in a regular grid with row-major ordering. A request can be made for all descriptors computed from inside a rectangular region.Multi-Band Images
The gradient is computed for each band individually. The band with the largest magnitude at that specific pixel is used as the gradient for the pixel.[1] Dalal, Navneet, and Bill Triggs. "Histograms of oriented gradients for human detection." Computer Vision and Pattern Recognition, 2005. CVPR 2005.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classDescribeDenseHogAlg.Cell
-
Constructor Summary
Constructors Constructor and Description DescribeDenseHogAlg(int orientationBins, int widthCell, int widthBlock, int stepBlock, ImageType<Input> imageType)Configures HOG descriptor computation
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description Derivative_getDerivX()Derivative_getDerivY()float_getPixelDX()float_getPixelDY()abstract voidcomputeDerivative(int pixelIndex)Computes and stores the gradient at the specified pixel.TupleDesc_F64createDescription()DescribeDenseHogAlg.CellgetCell(int row, int col)intgetCellCols()intgetCellRows()FastQueue<TupleDesc_F64>getDescriptions()List of descriptorsvoidgetDescriptorsInRegion(int pixelX0, int pixelY0, int pixelX1, int pixelY1, java.util.List<TupleDesc_F64> output)Convenience function which returns a list of all the descriptors computed inside the specified region in the imageImageType<Input>getImageType()FastQueue<Point2D_I32>getLocations()List of locations for each descriptor.intgetOrientationBins()intgetRegionWidthPixel()Returns the number of pixel's wide the square region is that a descriptor was computed fromintgetStepBlock()intgetWidthBlock()intgetWidthCell()voidprocess()Computes the descriptor across the input imagevoidsetInput(Input input)Specifies input image.voidsetStepBlock(int stepBlock)voidsetWidthCell(int widthCell)
-
-
-
Constructor Detail
-
DescribeDenseHogAlg
public DescribeDenseHogAlg(int orientationBins, int widthCell, int widthBlock, int stepBlock, ImageType<Input> imageType)Configures HOG descriptor computation- Parameters:
orientationBins- Number of bins in a cell's histogram. 9 recommendedwidthCell- Number of pixel's wide a cell is. 8 recommendedwidthBlock- Number of cells's wide a black is. 3 recommendedstepBlock- Number of cells which are skipped between each block
-
-
Method Detail
-
setInput
public void setInput(Input input)
Specifies input image. Gradient is computed immediately- Parameters:
input- input image
-
process
public void process()
Computes the descriptor across the input image
-
getDescriptorsInRegion
public void getDescriptorsInRegion(int pixelX0, int pixelY0, int pixelX1, int pixelY1, java.util.List<TupleDesc_F64> output)Convenience function which returns a list of all the descriptors computed inside the specified region in the image- Parameters:
pixelX0- Pixel coordinate X-axis lower extentpixelY0- Pixel coordinate Y-axis lower extentpixelX1- Pixel coordinate X-axis upper extentpixelY1- Pixel coordinate Y-axis upper extentoutput- List of descriptions
-
computeDerivative
public abstract void computeDerivative(int pixelIndex)
Computes and stores the gradient at the specified pixel. pixelIndex = y*columns + x
-
getLocations
public FastQueue<Point2D_I32> getLocations()
List of locations for each descriptor.
-
getDescriptions
public FastQueue<TupleDesc_F64> getDescriptions()
List of descriptors
-
_getDerivX
public Derivative _getDerivX()
-
_getDerivY
public Derivative _getDerivY()
-
_getPixelDX
public float _getPixelDX()
-
_getPixelDY
public float _getPixelDY()
-
getRegionWidthPixel
public int getRegionWidthPixel()
Returns the number of pixel's wide the square region is that a descriptor was computed from- Returns:
- number of pixels wide
-
setWidthCell
public void setWidthCell(int widthCell)
-
getWidthCell
public int getWidthCell()
-
getWidthBlock
public int getWidthBlock()
-
getStepBlock
public int getStepBlock()
-
getOrientationBins
public int getOrientationBins()
-
getCellRows
public int getCellRows()
-
getCellCols
public int getCellCols()
-
getCell
public DescribeDenseHogAlg.Cell getCell(int row, int col)
-
setStepBlock
public void setStepBlock(int stepBlock)
-
createDescription
public TupleDesc_F64 createDescription()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG