Skip to content

Commit

Permalink
Switched to memory view syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
Korijn committed Jun 15, 2015
1 parent aedf63f commit ecdf71d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions skimage/feature/_hoghistogram.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import numpy as np
cimport numpy as cnp

# cnp.float64_t[:, :] magnitude
cdef float CellHog(cnp.ndarray[cnp.float64_t, ndim=2] magnitude,
cnp.ndarray[cnp.float64_t, ndim=2] orientation,
cdef float CellHog(cnp.float64_t[:, :] magnitude,
cnp.float64_t[:, :] orientation,
float ori1, float ori2,
int cx, int cy, int xi, int yi, int sx, int sy):
"""CellHog
Expand Down Expand Up @@ -56,13 +55,13 @@ cdef float CellHog(cnp.ndarray[cnp.float64_t, ndim=2] magnitude,

return total

def HogHistograms(cnp.ndarray[cnp.float64_t, ndim=2] gx,
cnp.ndarray[cnp.float64_t, ndim=2] gy,
def HogHistograms(cnp.float64_t[:, :] gx,
cnp.float64_t[:, :] gy,
int cx, int cy,
int sx, int sy,
int n_cellsx, int n_cellsy,
int visualise, int orientations,
cnp.ndarray[cnp.float64_t, ndim=3] orientation_histogram):
cnp.float64_t[:, :, :] orientation_histogram):
"""Extract Histogram of Oriented Gradients (HOG) for a given image.
Parameters
Expand Down Expand Up @@ -91,9 +90,8 @@ def HogHistograms(cnp.ndarray[cnp.float64_t, ndim=2] gx,
The histogram to fill.
"""

cdef cnp.ndarray[cnp.float64_t, ndim=2] magnitude = np.hypot(gx, gy)
cdef cnp.ndarray[cnp.float64_t, ndim=2] orientation = (
np.arctan2(gy, gx) * (180 / np.pi) % 180)
cdef cnp.float64_t[:, :] magnitude = np.hypot(gx, gy)
cdef cnp.float64_t[:, :] orientation = np.arctan2(gy, gx) * (180 / np.pi) % 180
cdef int i, x, y, o, yi, xi, cy1, cy2, cx1, cx2
cdef float ori1, ori2

Expand Down

0 comments on commit ecdf71d

Please sign in to comment.