mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-12 12:30:16 +08:00
Updated docstrings.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import numpy as np
|
||||
from scipy import sqrt, pi, arctan2, cos, sin
|
||||
from scipy.ndimage import uniform_filter
|
||||
from .._shared.utils import assert_nD
|
||||
from . import _hoghistogram
|
||||
@@ -63,7 +62,7 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8),
|
||||
assert_nD(image, 2)
|
||||
|
||||
if normalise:
|
||||
image = sqrt(image)
|
||||
image = np.sqrt(image)
|
||||
|
||||
"""
|
||||
The second stage computes first order image gradients. These capture
|
||||
@@ -104,8 +103,8 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8),
|
||||
cell are used to vote into the orientation histogram.
|
||||
"""
|
||||
|
||||
magnitude = sqrt(gx ** 2 + gy ** 2)
|
||||
orientation = arctan2(gy, gx) * (180 / pi) % 180
|
||||
magnitude = np.hypot(gx, gy)
|
||||
orientation = np.arctan2(gy, gx) * (180 / np.pi) % 180
|
||||
|
||||
sy, sx = image.shape
|
||||
cx, cy = pixels_per_cell
|
||||
@@ -132,8 +131,8 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8),
|
||||
for y in range(n_cellsy):
|
||||
for o in range(orientations):
|
||||
centre = tuple([y * cy + cy // 2, x * cx + cx // 2])
|
||||
dx = radius * cos(float(o) / orientations * np.pi)
|
||||
dy = radius * sin(float(o) / orientations * np.pi)
|
||||
dx = radius * np.cos(float(o) / orientations * np.pi)
|
||||
dy = radius * np.sin(float(o) / orientations * np.pi)
|
||||
rr, cc = draw.line(int(centre[0] - dx),
|
||||
int(centre[1] + dy),
|
||||
int(centre[0] + dx),
|
||||
@@ -164,7 +163,7 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8),
|
||||
for y in range(n_blocksy):
|
||||
block = orientation_histogram[y:y + by, x:x + bx, :]
|
||||
eps = 1e-5
|
||||
normalised_blocks[y, x, :] = block / sqrt(block.sum() ** 2 + eps)
|
||||
normalised_blocks[y, x, :] = block / np.sqrt(block.sum() ** 2 + eps)
|
||||
|
||||
"""
|
||||
The final step collects the HOG descriptors from all blocks of a dense
|
||||
|
||||
@@ -15,25 +15,25 @@ cdef float CellHog(np.ndarray[np.float64_t, ndim=2] magnitude,
|
||||
Parameters
|
||||
----------
|
||||
magnitude : ndarray
|
||||
Coordinate to be clipped.
|
||||
The gradient magnitudes of the pixels.
|
||||
orientation : ndarray
|
||||
The lower bound.
|
||||
Lookup table for orientations.
|
||||
ori1 : float
|
||||
The higher bound.
|
||||
Orientation range start.
|
||||
ori2 : float
|
||||
The higher bound.
|
||||
Orientation range end.
|
||||
cx : int
|
||||
The higher bound.
|
||||
Pixels per cell (x).
|
||||
cy : int
|
||||
The higher bound.
|
||||
Pixels per cell (y).
|
||||
xi : int
|
||||
The higher bound.
|
||||
Block index (x).
|
||||
yi : int
|
||||
The higher bound.
|
||||
Block index (y).
|
||||
sx : int
|
||||
The higher bound.
|
||||
Image size (x).
|
||||
sy : int
|
||||
The higher bound.
|
||||
Image size (y).
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -58,35 +58,35 @@ cdef float CellHog(np.ndarray[np.float64_t, ndim=2] magnitude,
|
||||
|
||||
def HogHistograms(np.ndarray[np.float64_t, ndim=2] gx,
|
||||
np.ndarray[np.float64_t, ndim=2] gy,
|
||||
int cx, int cy, #Pixels per cell
|
||||
int sx, int sy, #Image size
|
||||
int cx, int cy,
|
||||
int sx, int sy,
|
||||
int n_cellsx, int n_cellsy,
|
||||
int visualise, int orientations,
|
||||
np.ndarray[np.float64_t, ndim=3] orientation_histogram):
|
||||
"""HogHistograms
|
||||
"""Extract Histogram of Oriented Gradients (HOG) for a given image.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
gx : ndarray
|
||||
Coordinate to be clipped.
|
||||
First order image gradients (x).
|
||||
gy : ndarray
|
||||
The lower bound.
|
||||
First order image gradients (y).
|
||||
cx : int
|
||||
The higher bound.
|
||||
Pixels per cell (x).
|
||||
cy : int
|
||||
The higher bound.
|
||||
Pixels per cell (y).
|
||||
sx : int
|
||||
The higher bound.
|
||||
Image size (x).
|
||||
sy : int
|
||||
The higher bound.
|
||||
Image size (y).
|
||||
n_cellsx : int
|
||||
The higher bound.
|
||||
Number of cells (x).
|
||||
n_cellsy : int
|
||||
The higher bound.
|
||||
Number of cells (y).
|
||||
visualise : int
|
||||
The higher bound.
|
||||
Also return an image of the HOG.
|
||||
orientations : int
|
||||
The higher bound.
|
||||
Number of orientation bins.
|
||||
orientation_histogram : ndarray
|
||||
The histogram to fill.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user