From 54d1f96f95c96ba4f6ad78cc5630d50365db3db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Ma=CC=81rquez=20Neila?= Date: Mon, 10 Jun 2013 06:24:20 +0200 Subject: [PATCH] Reduced gifs. --- morphsnakes.py | 15 ++++++--------- tests.py | 8 ++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/morphsnakes.py b/morphsnakes.py index ff60118..136cf39 100644 --- a/morphsnakes.py +++ b/morphsnakes.py @@ -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. @@ -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) diff --git a/tests.py b/tests.py index 7721f9e..79bd7e0 100644 --- a/tests.py +++ b/tests.py @@ -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. @@ -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. @@ -64,7 +64,7 @@ def test_lakes(): if __name__ == '__main__': print """""" - #test_nodule() - #test_starfish() + test_nodule() + test_starfish() test_lakes() ppl.show()