from a2 import morph, segment import numpy as np import imageIO as io me = io.imread("classMorph_43.png") next = io.imread("classMorph_44.png") segmentsBefore = np.array( [ segment(65, 120, 83, 119), segment(113, 121, 132, 121), segment(60, 106, 85, 100), segment(110, 104, 137, 108), segment(55, 93, 86, 65), segment(121, 71, 146, 95), segment(87, 168, 113, 166), ] ) segmentsAfter = np.array( [ segment(68, 114, 92, 114), segment(116, 114, 134, 114), segment(67, 99, 90, 100), segment(115, 102, 135, 100), segment(62, 79, 92, 63), segment(124, 63, 139, 87), segment(83, 154, 118, 156), ] ) results = morph(me, next, segmentsBefore, segmentsAfter, 13) for i, im in enumerate(results):
def test_5_warp(self): segmentsBefore=np.array([a2.segment(89, 130, 106, 125), a2.segment(150, 125, 164, 129), a2.segment(98, 199, 132, 202)]) segmentsAfter=np.array([a2.segment(42, 109, 106, 108), a2.segment(131, 106, 179, 104), a2.segment(44, 180, 140, 180)]) io.imwrite(a2.warp(io.imread("fredo2.png"), segmentsBefore, segmentsAfter), "warp.png")
def test_6_morph(self): segmentsBefore = np.array([a2.segment(87,131,109,129), a2.segment(142,126,165,129)]) segmentsAfter = np.array([a2.segment(81,112,107,107), a2.segment(140,102,163,101)]) images = a2.morph(io.imread('fredo2.png'), io.imread('werewolf.png'), segmentsBefore, segmentsAfter, 7) for img in images: io.imwriteSeq(img)
def test_4_warp1(self): io.imwrite(a2.warpBy1(io.imread('bear.png'), a2.segment(0,0,10,0), a2.segment(10,10,30,15)), 'warp1.png')