示例#1
0
def plot_trans_ts(json_data, kernel, bias, use_padding, stride):

    dff = pd.read_json(json_data, orient='values').to_numpy().flatten()
    original_length = dff.shape[0]
    kernel = np.array(json.loads(kernel)['dila_kernel'])
    bias = float(bias)
    stride = int(stride)
    if use_padding:
        # add padding
        padlen = len(kernel) // 2
        ts = np.zeros(len(dff) + 2 * padlen)
        ts[padlen:(padlen + len(dff))] = dff
        dff = ts

    transformed = utls.apply_kernel(dff, kernel, bias, stride)
    layout = {
        'title': {
            'text': 'Transformed time series'
        },
        'xaxis': {
            'range': [0, original_length]
        }
    }
    ppv = utls.ppv(transformed)
    max_value = np.max(transformed)
    min_value = np.min(transformed)
    return go.Figure(
        data=[go.Scatter(y=transformed)], layout=layout
    ), f"ppv = {ppv:.2f}", f"min = {min_value:.2f}", f"max = {max_value:.2f}"
示例#2
0
def gabor(im, W, angles):
    (x, y) = im.size
    im_load = im.load()

    freqs = frequency.freq(im, W, angles)
    print "computing local ridge frequency done"

    gauss = utils.gauss_kernel(3)
    utils.apply_kernel(freqs, gauss)

    for i in range(1, x / W - 1):
        for j in range(1, y / W - 1):
            kernel = gabor_kernel(W, angles[i][j], freqs[i][j])
            for k in range(0, W):
                for l in range(0, W):
                    im_load[i * W + k, j * W + l] = utils.apply_kernel_at(
                        lambda x, y: im_load[x, y], kernel, i * W + k,
                        j * W + l)

    return im
示例#3
0
def gabor(im, W, angles):
    (x, y) = im.size
    im_load = im.load()

    freqs = frequency.freq(im, W, angles)
    print "computing local ridge frequency done"

    gauss = utils.gauss_kernel(3)
    utils.apply_kernel(freqs, gauss)

    for i in range(1, x / W - 1):
        for j in range(1, y / W - 1):
            kernel = gabor_kernel(W, angles[i][j], freqs[i][j])
            for k in range(0, W):
                for l in range(0, W):
                    im_load[i * W + k, j * W + l] = utils.apply_kernel_at(
                        lambda x, y: im_load[x, y],
                        kernel,
                        i * W + k,
                        j * W + l)

    return im