Changing show_slices view to return an image
import scipy as sp
-import matplotlib.pyplot as plt
+# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d.art3d import Poly3DCollection
-def show_planes(planes, overlaid=False):
+def show_planes(im):
r"""
+ Create a quick montage showing a 3D image in all three directions
+
+ Parameters
+ ----------
+ im : ND-array
+ A 3D image of the porous material
+
+ Returns
+ -------
+ image : ND-array
+ A 2D array containing the views. This single image can be viewed using
+ ``matplotlib.pyplot.imshow``.
+
"""
- plt.subplot(1, 3, 1)
- plt.imshow(planes[0])
- plt.subplot(1, 3, 2)
- plt.imshow(planes[1])
- plt.subplot(1, 3, 3)
- plt.imshow(planes[2])
+ if sp.squeeze(im.ndim) < 3:
+ raise Exception('This view is only necessary for 3D images')
+ x, y, z = (sp.array(im.shape)/2).astype(int)
+ im_xy = im[:, :, z]
+ im_xz = im[:, y, :]
+ im_yz = sp.rot90(im[x, :, :])
+
+ new_x = im_xy.shape[0] + im_yz.shape[0] + 10
+
+ new_y = im_xy.shape[1] + im_xz.shape[1] + 10
+
+ new_im = sp.zeros([new_x + 20, new_y + 20], dtype=im.dtype)
+
+ # Add xy image to upper left corner
+ new_im[10:im_xy.shape[0]+10,
+ 10:im_xy.shape[1]+10] = im_xy
+ # Add xz image to lower left coner
+ x_off = im_xy.shape[0]+20
+ y_off = im_xy.shape[1]+20
+ new_im[10:10 + im_xz.shape[0],
+ y_off:y_off + im_xz.shape[1]] = im_xz
+ new_im[x_off:x_off + im_yz.shape[0],
+ 10:10 + im_yz.shape[1]] = im_yz
+
+ return new_im
def sem(im, direction='X'):
