def main():
    parser = argparse.ArgumentParser(description="Splinart generator")
    parser.add_argument('-f',
                        '--filename',
                        type=str,
                        help="filename where the output is stored",
                        default='output.png')
    parser.add_argument('--path',
                        type=str,
                        help="path where to store the results",
                        default='.')
    parser.add_argument('-s',
                        '--shape',
                        type=str,
                        help='apply spline on this shape',
                        default='circle',
                        choices=['circle', 'line'])
    parser.add_argument('--show',
                        help='show the result using matplotlib',
                        action='store_true')
    args = parser.parse_args()

    img_size, channels = 1000, 4
    img = np.ones((img_size, img_size, channels), dtype=np.float32)

    if args.shape == 'circle':
        circle(img)
    else:
        line(img)

    if args.show:
        spl.show_img(img)
    else:
        spl.save_img(img, args.path, args.filename)
Пример #2
0
def test_case(tmpdir, load_json):

    datadir, js = load_json
    np.random.seed(js["seed"])

    img_size, channels = 1000, 4
    img = np.ones((img_size, img_size, channels), dtype=np.float32)

    theta, path = spl.circle(js["center"], js["radius"])

    def xs_func():
        nsamples = 500
        return (np.random.random() + 2 * np.pi * np.linspace(0, 1, nsamples))%(2*np.pi)

    spl.update_img(img, path, xs_func, nrep=js["nrep"], x=theta)

    spl.save_img(img, tmpdir.dirname, 'output.png')

    assert filecmp.cmp(tmpdir.dirname + '/output.png', datadir + "/" + js["output"]) 
Пример #3
0
lo, up = .2, .8
path = []
color_lines = []
npoints = 20
for iy, y in enumerate(np.linspace(lo, up, 10)):
    npoints += 5
    path.append(spl.line(lo, up, y, npoints))
    color = np.random.random(4) * .3
    color[-1] = 1.
    color_lines.append(color)


def xs_func():
    nsamples = 500
    return .001 * np.random.random() + np.linspace(lo + .02, up - .02,
                                                   nsamples)


for i in range(len(path)):
    img1 = np.ones_like(img)
    spl.update_img(img1,
                   path[i],
                   xs_func,
                   nrep=1000,
                   periodic=False,
                   color=color_lines[i])
    mask = img1 < 1.
    img[mask] += img1[mask]

spl.save_img(img, "./output", "lines.png")
Пример #4
0
RADIUS = .3
NREP = 4000

np.random.seed(SEED)
img_size, channels = 1000, 4
img = np.ones((img_size, img_size, channels), dtype=np.float32)

theta, path = spl.circle(CENTER, RADIUS)


def xs_func():
    nsamples = 500
    return (np.random.random() +
            2 * np.pi * np.linspace(0, 1, nsamples)) % (2 * np.pi)


spl.update_img(img, path, xs_func, nrep=NREP, x=theta)

spl.save_img(img, '.', 'circle.png')

js = json.dumps(
    {
        "circle": {
            "seed": SEED,
            "center": CENTER,
            "radius": RADIUS,
            "nrep": NREP,
            "output": "./circle.png"
        }
    },
    indent=4)
Пример #5
0
for i in range(nb_circles):
    radius = .1 + np.random.random() * .1
    center = .2 + np.random.random(2) * .6
    theta, path = spl.circle(center, radius, npoints=75)
    theta_circles.append(theta)
    path_circles.append(path)
    color = np.random.random(4) * .3
    color[-1] = 1.
    color_circles.append(color)


def xs_func():
    nsamples = 500
    return (np.random.random() +
            2 * np.pi * np.linspace(0, 1, nsamples)) % (2 * np.pi)


for i in range(nb_circles):
    img1 = np.ones_like(img)
    spl.update_img(img1,
                   path_circles[i],
                   xs_func,
                   nrep=1000,
                   scale_value=.00005,
                   x=theta_circles[i],
                   color=color_circles[i])
    mask = img1 < 1.
    img[mask] += img1[mask]

spl.save_img(img, './output', 'circles.png')
Пример #6
0
import numpy as np
from six.moves import range
import splinart as spl

np.random.seed(42)
img_size, channels = 1000, 4
img = np.ones((img_size, img_size, channels), dtype=np.float32)

theta, path = spl.circle([.5, .5], .3, npoints=40)


def xs_func():
    nsamples = 500
    return (np.random.random() +
            2 * np.pi * np.linspace(0, 1, nsamples)) % (2 * np.pi)


spl.update_img(img, path, xs_func, nrep=4000, x=theta, scale_value=.00005)

spl.save_img(img, 'output', 'circle.png')
Пример #7
0
import numpy as np
from six.moves import range
import splinart as spl

img_size, channels = 1000, 4
img = np.ones((img_size, img_size, channels), dtype=np.float32)


def xs_func():
    nsamples = 500
    return .001 * np.random.random() + np.linspace(lo + .1, up - .1, nsamples)


lo, up = .2, .8
path = spl.line(lo, up, .5)

spl.update_img(img, path, xs_func, nrep=1000, periodic=False)

spl.save_img(img, "output", "line.png")