import numpy as np from skimage.feature import hog im = np.random.normal(0, 1.0, (126, 126)) hf = hog(im, orientations=9, pixels_per_cell=(9,9), cells_per_block=(2,2)) print(hf.shape)
My code gives (6084,) , which is correct.
A common feature vector is a set of vector features for each block. For each block (block), features are a set of histograms for all cells (cells) of a given block (block).
- The number of elements (orientations) in the histogram of each cell: 9.
- The number of cells in the block (with
cells_per_block=(2,2) ): 2 * 2 = 4. - That is, the number of features of one block:
9*2*2=36 .
Now, about the number of blocks. The main thing: the blocks intersect . That is, blocks are obtained by shifting by one cell , not by block size. Thus, the number of blocks, for example, horizontally: всего_ячеек - размер_блока_в_ячейках + 1 . The total number of blocks: (126/9) - 2 + 1 = 13 .
As a result, the total number of features num_blocks количество_блоков * количество_фич_на_блок : 13 * 13 *36 = 6084
The nature of the appearance of the number of features 17424 = 2*2*2*2*3*3*11*11 for the image of this size (126, 126) I do not really understand. An image of the size (207, 207) with other constant parameters, gives just such a number of features.
Just in case:
python --version Python 3.6.2 :: Anaconda custom (64-bit) python -c "import skimage; print(skimage.__version__)" 0.13.0