def plot_rgb(image, name, label=None, label_color='w', label_size='large'):
"""
This will plot the r,g,b channels of an *image* of shape (N,M,3) or
(N,M,4). *name* is the prefix of the file name, which will be supplemented
with "_rgb.png." *label*, *label_color* and *label_size* may also be
specified.
"""
import pylab
Nvec = image.shape[0]
image[np.isnan(image)] = 0.0
if image.shape[2] >= 4:
image = image[:,:,:3]
pylab.clf()
pylab.gcf().set_dpi(100)
pylab.gcf().set_size_inches((Nvec/100.0, Nvec/100.0))
pylab.gcf().subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0, wspace=0.0, hspace=0.0)
pylab.imshow(image, interpolation='nearest')
if label is not None:
pylab.text(20, 20, label, color = label_color, size=label_size)
pylab.savefig("%s_rgb.png" % name)
pylab.clf()
评论列表
文章目录