Skip to content

Commit

Permalink
Reduced gifs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmneila committed Jun 10, 2013
1 parent cd4c7e5 commit 54d1f96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
15 changes: 6 additions & 9 deletions morphsnakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,15 @@ def evolve_visual(msnake, levelset=None, num_iters=20, background=None):
# Prepare the visual environment.
fig = ppl.gcf()
fig.clf()
ax1 = fig.add_subplot(1,1,1)
ax1 = fig.add_subplot(1,2,1)
if background is None:
ax1.imshow(msnake.data, cmap=ppl.cm.gray)
else:
ax1.imshow(background, cmap=ppl.cm.gray)
ax1.contour(msnake.levelset, [0.5], colors='r')

#ax2 = fig.add_subplot(1,2,2)
#ax_u = ax2.imshow(msnake.levelset)
ppl.axis('off')
ax2 = fig.add_subplot(1,2,2)
ax_u = ax2.imshow(msnake.levelset)
ppl.pause(0.001)

# Iterate.
Expand All @@ -334,11 +333,9 @@ def evolve_visual(msnake, levelset=None, num_iters=20, background=None):
msnake.step()

# Update figure.
del ax1.collections[:]
ax1.contour(msnake.levelset, [0.5], colors='k', linewidths=5)
ax1.contour(msnake.levelset, [0.5], colors='r', linewidths=2)
ppl.savefig("gifs/lakes%03d.png"%i, bbox_inches='tight')
#ax_u.set_data(msnake.levelset)
del ax1.collections[0]
ax1.contour(msnake.levelset, [0.5], colors='r')
ax_u.set_data(msnake.levelset)
fig.canvas.draw()
#ppl.pause(0.001)

Expand Down
8 changes: 4 additions & 4 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_nodule():

# Visual evolution.
ppl.figure()
morphsnakes.evolve_visual(mgac, num_iters=50, background=img)
morphsnakes.evolve_visual(mgac, num_iters=45, background=img)

def test_starfish():
# Load the image.
Expand All @@ -45,7 +45,7 @@ def test_starfish():

# Visual evolution.
ppl.figure()
morphsnakes.evolve_visual(mgac, num_iters=120, background=imgcolor)
morphsnakes.evolve_visual(mgac, num_iters=110, background=imgcolor)

def test_lakes():
# Load the image.
Expand All @@ -64,7 +64,7 @@ def test_lakes():

if __name__ == '__main__':
print """"""
#test_nodule()
#test_starfish()
test_nodule()
test_starfish()
test_lakes()
ppl.show()

0 comments on commit 54d1f96

Please sign in to comment.