Skip to content

Commit dda908c

Browse files
mkcorgrlee77
andcommitted
Refactor display helper function
Co-authored-by: Gregory R. Lee <[email protected]>
1 parent 8aa2d2a commit dda908c

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

doc/examples/applications/plot_3d_image_processing.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,15 @@ def show_plane(ax, plane, cmap="gray", title=None):
108108

109109
#####################################################################
110110
# As hinted before, a three-dimensional image can be viewed as a series of
111-
# two-dimensional planes. Let us write a helper function, `display`, to
112-
# display 30 planes of our data. By default, every other plane is displayed.
111+
# two-dimensional planes. Let us write a helper function, `display`, to create
112+
# a montage of several planes. By default, every other plane is displayed.
113113

114114

115-
def display(im3d, cmap="gray", step=2):
116-
_, axes = plt.subplots(nrows=5, ncols=6, figsize=(16, 14))
117-
118-
vmin = im3d.min()
119-
vmax = im3d.max()
120-
121-
for ax, image in zip(axes.flatten(), im3d[::step]):
122-
ax.imshow(image, cmap=cmap, vmin=vmin, vmax=vmax)
123-
ax.set_xticks([])
124-
ax.set_yticks([])
115+
def display(im3d, cmap='gray', step=2):
116+
data_montage = util.montage(im3d[::step], padding_width=4, fill=np.nan)
117+
_, ax = plt.subplots(figsize=(16, 14))
118+
ax.imshow(data_montage, cmap=cmap)
119+
ax.set_axis_off()
125120

126121

127122
display(data)

0 commit comments

Comments
 (0)