Exemple #1
0
    def test_spline(self):
        try:
            spl = coord_path.spline(((0, 0), (3, 5)))
            spl.next()
        except ValueError:
            pass
        else:
            raise Exception("ValueError expected, got (%s)" % spl.next())

        spl = coord_path.spline(((0, 0), (3, 5), (1, 1)))
        coords = [c for c in spl]
        assert (len(coords) > 10)
        assert_array_almost_equal(coords[0], (0, 0))
        assert_array_almost_equal(coords[-1], (1, 1))
Exemple #2
0
    def test_spline(self):
        try:
            spl = coord_path.spline(((0, 0), (3, 5)))
            spl.next()
        except ValueError:
            pass
        else:
            raise Exception("ValueError expected, got (%s)" % spl.next())

        spl = coord_path.spline(((0, 0), (3, 5), (1, 1)))
        coords = [c for c in spl]
        assert(len(coords) > 10)
        assert_array_almost_equal(coords[0], (0, 0))
        assert_array_almost_equal(coords[-1], (1, 1))
Exemple #3
0
    img[p[:, 0], p[:, 1]] = np.array(col) * 255


def add_line(img, c0, c1, col=[1., 0, 0]):
    p = cp.build(cp.line(c0, c1))
    add_path(img, p, col)


img = supreme.io.imread(os.path.join(data_path, 'toystory/toystory000.png'))
shape = np.array(img.shape[:2]) - 1
height, width = shape
centre = shape / 2.
add_line(img, (0, 0), centre)
add_line(img, centre, (0, width), [0., 1, 0])
add_line(img, centre, (height, width), [.9, .6, .6])
add_line(img, centre, (height, 0), [.4, .7, .8])
add_path(img, cp.build(cp.circle(centre, 50)), [0.9, 0.9, 0])

add_path(img, cp.build(cp.spline(
    ((0, 0), (height, 80), (140, 200), (150, 80)))), [0.9, 0.9, 0.9])

add_path(
    img,
    cp.build(
        cp.spline(((0, 0), (height / 2., 0), (height / 2., width),
                   (height, width)))), [0.6, 0.7, 0.9])

plt.imshow(img, interpolation='nearest')
plt.title('Trajectories of several coordinate paths')
plt.show()
Exemple #4
0
import supreme.io
from supreme.geometry import coord_path as cp
from supreme.config import data_path

def add_path(img,p,col=[1.,0,0]):
    img[p[:,0],p[:,1]] = np.array(col)*255

def add_line(img,c0,c1,col=[1.,0,0]):
    p = cp.build(cp.line(c0,c1))
    add_path(img,p,col)

img = supreme.io.imread(os.path.join(data_path, 'toystory/toystory000.png'))
shape = np.array(img.shape[:2])-1
height,width = shape
centre = shape/2.
add_line(img,(0,0),centre)
add_line(img,centre,(0,width),[0.,1,0])
add_line(img,centre,(height,width),[.9,.6,.6])
add_line(img,centre,(height,0),[.4,.7,.8])
add_path(img,cp.build(cp.circle(centre,50)),[0.9,0.9,0])

add_path(img,cp.build(cp.spline(((0,0),(height,80),(140,200),(150,80)))),
         [0.9,0.9,0.9])

add_path(img,cp.build(cp.spline(((0,0),(height/2.,0),(height/2.,width),(height,width)))),
         [0.6,0.7,0.9])

plt.imshow(img,interpolation='nearest')
plt.title('Trajectories of several coordinate paths')
plt.show()