Switched to memory view syntax.

This commit is contained in:
Korijn van Golen
2015-06-15 15:41:18 +02:00
parent aedf63f1f7
commit ecdf71d14d
+7 -9
View File
@@ -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
@@ -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
@@ -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