Exemplo n.º 1
0
def Patch(X, pw, ph):
    Xt = []
    for x in X: 
        w, h = x.shape[:2]
        i = py_rng.randint(0, w-pw)
        j = py_rng.randint(0, h-ph)
        Xt.append(x[i:i+pw, j:j+pw])
    return Xt
Exemplo n.º 2
0
def patch(x, ph, pw=None):
    if pw is None:
        pw = ph
    h, w = x.shape[:2]
    j = py_rng.randint(0, h-ph)
    i = py_rng.randint(0, w-pw)
    x = x[j:j+ph, i:i+pw]
    return x
Exemplo n.º 3
0
def patch(x, ph, pw=None):
    if pw is None:
        pw = ph
    h, w = x.shape[:2]
    j = py_rng.randint(0, (h - ph))
    i = py_rng.randint(0, (w - pw))
    x = x[j:(j + ph), i:(i + pw)]
    return x
Exemplo n.º 4
0
def patch(x, ph, pw=None):
    if pw is None:
        pw = ph
    h, w = x.shape[:2]
    j = py_rng.randint(0, h - ph)
    i = py_rng.randint(0, w - pw)
    x = x[j:j + ph, i:i + pw]
    return x
Exemplo n.º 5
0
def ColorShift(X, p=1/3., scale=20):
    Xt = []
    for x in X:
        x = x.astype(np.int16)
        x[:, :, 0] += (py_rng.random() < p)*py_rng.randint(-scale, scale)
        x[:, :, 1] += (py_rng.random() < p)*py_rng.randint(-scale, scale)
        x[:, :, 2] += (py_rng.random() < p)*py_rng.randint(-scale, scale)
        x = np.clip(x, 0, 255).astype(np.uint8)
        Xt.append(x)
    return Xt
Exemplo n.º 6
0
def SeqPatch(X, p_size):
    Xt = []
    for x in X:
        l = len(x)
        n = int(p_size*l)
        i = py_rng.randint(0, l-n)
        Xt.append(x[i:i+n])
    return Xt
Exemplo n.º 7
0
def Rot90(X):
    Xt = []
    for x in X:
        x = np.rot90(x, py_rng.randint(0, 3))
        Xt.append(x)
    return Xt