Skip to content

Commit ae340df

Browse files
DOC make_montage(): More descriptive error if make_montage() is called with blank image
1 parent 4e590ac commit ae340df

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

surfer/viz.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def make_montage(filename, fnames, orientation='h', colorbar=None,
8686
# sum the RGB dimension so we do not miss G or B-only pieces
8787
gray = np.sum(np.array(im), axis=-1)
8888
gray[gray == gray[0, 0]] = 0 # hack for find_objects that wants 0
89+
if np.all(gray == 0):
90+
raise ValueError("Empty image (all pixels have the same color).")
8991
labels, n_labels = ndimage.label(gray.astype(np.float))
9092
slices = ndimage.find_objects(labels, n_labels) # slice roi
9193
if colorbar is not None and ix in colorbar:

0 commit comments

Comments
 (0)