@@ -0,0 +1,2153 @@
+import numpy as np%0Afrom scipy.stats import entropy, skew, kurtosis%0Afrom skimage.feature import canny%0A%0Adef ComputeGradientFeatures(I, Coords, Diff=%5B%5D, C=%5B%5D):%0A    %22%22%22%0A    Calculates gradient features from an intensity image.%0A%0A    Parameters%0A    ----------%0A    I : array_like%0A        A M x N intensity image.%0A    Coords : array_like%0A        A T x 2 coordinate list of a region.%0A    Diff : array_like%0A        A M x N gradient difference. Default value = %5B%5D.%0A    C : array_like%0A        A M x N canny filtered mask. Default value = %5B%5D.%0A%0A    Returns%0A    -------%0A    MeanGradMag : float%0A        Mean of gradient data.%0A    StdGradMag : float%0A        Standard deviation of gradient data.%0A    EntropyGradMag : float%0A        Entroy of gradient data.%0A    EnergyGradMag : float%0A        Energy of gradient data.%0A    SkewnessGradMag : float%0A        Skewness of gradient data. Value is 0 when all values are equal.%0A    KurtosisGradMag : float%0A        Kurtosis of gradient data. Value is -3 when all values are equal.%0A    SumCanny : float%0A        Sum of canny filtered gradient data.%0A    MeanCanny : float%0A        Mean of canny filtered gradient data.%0A%0A    References%0A    ----------%0A    .. %5B1%5D Daniel Zwillinger and Stephen Kokoska. %22CRC standard probability%0A    and statistics tables and formulae,%22 Crc Press, 1999.%0A    %22%22%22%0A%0A    if not len(Diff):%0A        Gx, Gy = np.gradient(I)%0A        Diff = np.sqrt(Gx**2 + Gy**2)%0A%0A    if not len(C):%0A        C = canny(I)%0A%0A    pixOfInterest = Diff%5BCoords%5B:, 0%5D, Coords%5B:, 1%5D%5D%0A    # compute gradient features%0A    MeanGradMag = np.mean(pixOfInterest)%0A    StdGradMag = np.std(pixOfInterest)%0A    EntropyGradMag = entropy(pixOfInterest)%0A    hist, bins = np.histogram(pixOfInterest, bins=np.arange(256))%0A    prob = hist/np.sum(hist, dtype=np.float32)%0A    EnergyGradMag = np.sum(np.power(prob, 2))%0A    SkewnessGradMag = skew(pixOfInterest)%0A    KurtosisGradMag = kurtosis(pixOfInterest)%0A    bw_canny = C%5BCoords%5B:, 0%5D, Coords%5B:, 1%5D%5D%0A    SumCanny = np.sum(bw_canny)%0A    MeanCanny = SumCanny / len(pixOfInterest)%0A%0A    return MeanGradMag, StdGradMag, EntropyGradMag, EnergyGradMag, %5C%0A        SkewnessGradMag, KurtosisGradMag, SumCanny, MeanCanny%0A

Add ComputeGradientFeatures.py