-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
executable file
·28 lines (21 loc) · 805 Bytes
/
Copy pathutils.py
File metadata and controls
executable file
·28 lines (21 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import tempfile
from IPython.core import display
from matplotlib import pyplot as plt
from skimage.io import imread, imsave
from skimage import img_as_float, img_as_ubyte
def _show_arr(arr):
with tempfile.NamedTemporaryFile(suffix='.png') as tf:
imsave(tf.name,arr)
return display.Image(filename=tf.name)
def show_image(arr):
return _show_arr(img_as_ubyte(img_as_float(arr)))
def show_mask(arr):
return _show_arr((arr>0)*255)
def show_channels(rgb):
fig, (ax1, ax2, ax3) = plt.subplots(ncols=3, figsize=(15, 5), sharex=True, sharey=True)
ax1.imshow(rgb[:,:,0],cmap='gray')
ax1.set_adjustable('box-forced')
ax2.imshow(rgb[:,:,1],cmap='gray')
ax2.set_adjustable('box-forced')
ax3.imshow(rgb[:,:,2],cmap='gray')
ax3.set_adjustable('box-forced')