Diff of /sitk_show.py [000000] .. [271336]

Switch to side-by-side view

--- a
+++ b/sitk_show.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Thu Oct 13 23:56:36 2016
+
+@author: seeker105
+"""
+import numpy
+import matplotlib.pyplot as plt
+import SimpleITK
+
+def sitk_show(img, title=None, margin=0.05, dpi=40 ):
+    nda = SimpleITK.GetArrayFromImage(img)
+    spacing = img.GetSpacing()
+    figsize = (1 + margin) * nda.shape[0] / dpi, (1 + margin) * nda.shape[1] / dpi
+    extent = (0, nda.shape[1]*spacing[1], nda.shape[0]*spacing[0], 0)
+    fig = plt.figure(figsize=figsize, dpi=dpi)
+    ax = fig.add_axes([margin, margin, 1 - 2*margin, 1 - 2*margin])
+
+    plt.set_cmap("gray")
+    ax.imshow(nda,extent=extent,interpolation=None)
+    
+    if title:
+        plt.title(title)
+    
+    plt.show()
\ No newline at end of file