當前位置: 首頁>>代碼示例>>Python>>正文


Python pylab.imshow方法代碼示例

本文整理匯總了Python中pylab.imshow方法的典型用法代碼示例。如果您正苦於以下問題:Python pylab.imshow方法的具體用法?Python pylab.imshow怎麽用?Python pylab.imshow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pylab的用法示例。


在下文中一共展示了pylab.imshow方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def generate(self, filename, show=True):
        '''Generate a sample sequence, plot the resulting piano-roll and save
        it as a MIDI file.
        filename : string
            A MIDI file will be created at this location.
        show : boolean
            If True, a piano-roll of the generated sequence will be shown.'''

        piano_roll = self.generate_function()
        midiwrite(filename, piano_roll, self.r, self.dt)
        if show:
            extent = (0, self.dt * len(piano_roll)) + self.r
            pylab.figure()
            pylab.imshow(piano_roll.T, origin='lower', aspect='auto',
                         interpolation='nearest', cmap=pylab.cm.gray_r,
                         extent=extent)
            pylab.xlabel('time (s)')
            pylab.ylabel('MIDI note number')
            pylab.title('generated piano-roll') 
開發者ID:feynmanliang,項目名稱:bachbot,代碼行數:21,代碼來源:rnnrbm.py

示例2: _plot_background

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def _plot_background(self, bgimage):
        import pylab as pl
        # Show the portion of the image behind this facade
        left, right = self.facade_left, self.facade_right
        top, bottom = 0, self.mega_facade.rectified.shape[0]
        if bgimage is not None:
            pl.imshow(bgimage[top:bottom, left:right], extent=(left, right, bottom, top))
        else:
            # Fit the facade in the plot
            y0, y1 = pl.ylim()
            x0, x1 = pl.xlim()
            x0 = min(x0, left)
            x1 = max(x1, right)
            y0 = min(y0, top)
            y1 = max(y1, bottom)
            pl.xlim(x0, x1)
            pl.ylim(y1, y0) 
開發者ID:jfemiani,項目名稱:facade-segmentation,代碼行數:19,代碼來源:megafacade.py

示例3: plot

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def plot(self):
        """ Plot the layer data (for debugging)
        :return: The current figure
        """
        import pylab as pl
        aspect = self.nrows / float(self.ncols)
        figure_width = 6 #inches

        rows = max(1, int(np.sqrt(self.nlayers)))
        cols = int(np.ceil(self.nlayers/rows))
        # noinspection PyUnresolvedReferences
        pallette = {i:rgb for (i, rgb) in enumerate(pl.cm.jet(np.linspace(0, 1, 4), bytes=True))}
        f, a = pl.subplots(rows, cols)
        f.set_size_inches(6 * cols, 6 * rows)
        a = a.flatten()
        for i, label in enumerate(self.label_names):
            pl.sca(a[i])
            pl.title(label)
            pl.imshow(self.color_data)
            pl.imshow(colorize(self.label_data[:, :, i], pallette), alpha=0.5)
            # axis('off')
        return f 
開發者ID:jfemiani,項目名稱:facade-segmentation,代碼行數:24,代碼來源:import_labelme.py

示例4: plot

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def plot(self, overlay_alpha=0.5):
        import pylab as pl
        rows = int(sqrt(self.layers()))
        cols = int(ceil(self.layers()/rows))

        for i in range(rows*cols):
            pl.subplot(rows, cols, i+1)
            pl.axis('off')
            if i >= self.layers():
                continue
            pl.title('{}({})'.format(self.labels[i], i))
            pl.imshow(self.image)
            pl.imshow(colorize(self.features[i].argmax(0),
                               colors=np.array([[0,     0, 255],
                                                [0,   255, 255],
                                                [255, 255, 0],
                                                [255, 0,   0]])),
                      alpha=overlay_alpha) 
開發者ID:jfemiani,項目名稱:facade-segmentation,代碼行數:20,代碼來源:model.py

示例5: _extract_lines

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def _extract_lines(img, edges=None, mask=None, min_line_length=20, max_line_gap=3):
    global __i__
    __i__ += 1

    if edges is None:
        edges = canny(rgb2grey(img))
    if mask is not None:
        edges = edges & mask

    # figure()
    # subplot(131)
    # imshow(img)
    # subplot(132)
    #vimshow(edges)
    # subplot(133)
    # if mask is not None:
    #     imshow(mask, cmap=cm.gray)
    # savefig('/home/shared/Projects/Facades/src/data/for-labelme/debug/foo/{:06}.jpg'.format(__i__))

    lines = np.array(probabilistic_hough_line(edges, line_length=min_line_length, line_gap=max_line_gap))

    return lines 
開發者ID:jfemiani,項目名稱:facade-segmentation,代碼行數:24,代碼來源:rectify.py

示例6: plot_rectified

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def plot_rectified(self):
        import pylab
        pylab.title('rectified')
        pylab.imshow(self.rectified)

        for line in self.vlines:
            p0, p1 = line
            p0 = self.inv_transform(p0)
            p1 = self.inv_transform(p1)
            pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='green')

        for line in self.hlines:
            p0, p1 = line
            p0 = self.inv_transform(p0)
            p1 = self.inv_transform(p1)
            pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='red')

        pylab.axis('image');
        pylab.grid(c='yellow', lw=1)
        pylab.plt.yticks(np.arange(0, self.l, 100.0));
        pylab.xlim(0, self.w)
        pylab.ylim(self.l, 0) 
開發者ID:jfemiani,項目名稱:facade-segmentation,代碼行數:24,代碼來源:rectify.py

示例7: compute_ffmc2d

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def compute_ffmc2d(X):
    """Computes the 2D-Fourier Magnitude Coefficients."""
    # 2d-fft
    fft2 = scipy.fftpack.fft2(X)

    # Magnitude
    fft2m = magnitude(fft2)

    # FFTshift and flatten
    fftshift = scipy.fftpack.fftshift(fft2m).flatten()

    #cmap = plt.cm.get_cmap('hot')
    #plt.imshow(np.log1p(scipy.fftpack.fftshift(fft2m)).T, interpolation="nearest",
    #    aspect="auto", cmap=cmap)
    #plt.show()

    # Take out redundant components
    return fftshift[:fftshift.shape[0] // 2 + 1] 
開發者ID:urinieto,項目名稱:msaf,代碼行數:20,代碼來源:utils_2dfmc.py

示例8: on_epoch_end

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def on_epoch_end(self, epoch, logs={}):
        self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch)))
        self.show_edit_distance(256)
        word_batch = next(self.text_img_gen)[0]
        res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words])
        if word_batch['the_input'][0].shape[0] < 256:
            cols = 2
        else:
            cols = 1
        for i in range(self.num_display_words):
            pylab.subplot(self.num_display_words // cols, cols, i + 1)
            if K.image_data_format() == 'channels_first':
                the_input = word_batch['the_input'][i, 0, :, :]
            else:
                the_input = word_batch['the_input'][i, :, :, 0]
            pylab.imshow(the_input.T, cmap='Greys_r')
            pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i]))
        fig = pylab.gcf()
        fig.set_size_inches(10, 13)
        pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch)))
        pylab.close() 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:23,代碼來源:image_ocr.py

示例9: plot_confusion_matrix

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def plot_confusion_matrix(self, matrix, labels):
        if not self.to_save and not self.to_show:
            return

        pylab.figure()
        pylab.imshow(matrix, interpolation='nearest', cmap=pylab.cm.jet)
        pylab.title("Confusion Matrix")

        for i, vi in enumerate(matrix):
            for j, vj in enumerate(vi):
                pylab.annotate("%.1f" % vj, xy=(j, i), horizontalalignment='center', verticalalignment='center', fontsize=9)

        pylab.colorbar()

        classes = np.arange(len(labels))
        pylab.xticks(classes, labels)
        pylab.yticks(classes, labels)

        pylab.ylabel('Expected label')
        pylab.xlabel('Predicted label') 
開發者ID:tonybeltramelli,項目名稱:Deep-Spying,代碼行數:22,代碼來源:View.py

示例10: plotFields

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def plotFields(layer,fieldShape=None,channel=None,figOffset=1,cmap=None,padding=0.01):
	# Receptive Fields Summary
	try:
		W = layer.W
	except:
		W = layer
	wp = W.eval().transpose();
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		fields = np.reshape(wp,list(wp.shape[0:-1])+fieldShape)	
	else:			# Convolutional layer already has shape
		features, channels, iy, ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	perRow = int(math.floor(math.sqrt(fields.shape[0])))
	perColumn = int(math.ceil(fields.shape[0]/float(perRow)))

	fig = mpl.figure(figOffset); mpl.clf()
	
	# Using image grid
	from mpl_toolkits.axes_grid1 import ImageGrid
	grid = ImageGrid(fig,111,nrows_ncols=(perRow,perColumn),axes_pad=padding,cbar_mode='single')
	for i in range(0,np.shape(fields)[0]):
		im = grid[i].imshow(fields[i],cmap=cmap); 

	grid.cbar_axes[0].colorbar(im)
	mpl.title('%s Receptive Fields' % layer.name)
	
	# old way
	# fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	# tiled = []
	# for i in range(0,perColumn*perRow,perColumn):
	# 	tiled.append(np.hstack(fields2[i:i+perColumn]))
	# 
	# tiled = np.vstack(tiled)
	# mpl.figure(figOffset); mpl.clf(); mpl.imshow(tiled,cmap=cmap); mpl.title('%s Receptive Fields' % layer.name); mpl.colorbar();
	mpl.figure(figOffset+1); mpl.clf(); mpl.imshow(np.sum(np.abs(fields),0),cmap=cmap); mpl.title('%s Total Absolute Input Dependency' % layer.name); mpl.colorbar() 
開發者ID:robb-brown,項目名稱:IntroToDeepLearning,代碼行數:41,代碼來源:TensorFlowInterface.py

示例11: plotOutput

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def plotOutput(layer,feed_dict,fieldShape=None,channel=None,figOffset=1,cmap=None):
	# Output summary
	try:
		W = layer.output
	except:
		W = layer
	wp = W.eval(feed_dict=feed_dict);
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		temp = np.zeros(np.product(fieldShape)); temp[0:np.shape(wp.ravel())[0]] = wp.ravel()
		fields = np.reshape(temp,[1]+fieldShape)
	else:			# Convolutional layer already has shape
		wp = np.rollaxis(wp,3,0)
		features, channels, iy,ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	perRow = int(math.floor(math.sqrt(fields.shape[0])))
	perColumn = int(math.ceil(fields.shape[0]/float(perRow)))
	fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	tiled = []
	for i in range(0,perColumn*perRow,perColumn):
		tiled.append(np.hstack(fields2[i:i+perColumn]))

	tiled = np.vstack(tiled)
	if figOffset is not None:
		mpl.figure(figOffset); mpl.clf(); 

	mpl.imshow(tiled,cmap=cmap); mpl.title('%s Output' % layer.name); mpl.colorbar(); 
開發者ID:robb-brown,項目名稱:IntroToDeepLearning,代碼行數:32,代碼來源:TensorFlowInterface.py

示例12: plotFields

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def plotFields(layer,fieldShape=None,channel=None,maxFields=25,figName='ReceptiveFields',cmap=None,padding=0.01):
	# Receptive Fields Summary
	W = layer.W
	wp = W.eval().transpose();
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		fields = np.reshape(wp,list(wp.shape[0:-1])+fieldShape)
	else:			# Convolutional layer already has shape
		features, channels, iy, ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	fieldsN = min(fields.shape[0],maxFields)
	perRow = int(math.floor(math.sqrt(fieldsN)))
	perColumn = int(math.ceil(fieldsN/float(perRow)))

	fig = mpl.figure(figName); mpl.clf()

	# Using image grid
	from mpl_toolkits.axes_grid1 import ImageGrid
	grid = ImageGrid(fig,111,nrows_ncols=(perRow,perColumn),axes_pad=padding,cbar_mode='single')
	for i in range(0,fieldsN):
		im = grid[i].imshow(fields[i],cmap=cmap);

	grid.cbar_axes[0].colorbar(im)
	mpl.title('%s Receptive Fields' % layer.name)

	# old way
	# fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	# tiled = []
	# for i in range(0,perColumn*perRow,perColumn):
	# 	tiled.append(np.hstack(fields2[i:i+perColumn]))
	#
	# tiled = np.vstack(tiled)
	# mpl.figure(figOffset); mpl.clf(); mpl.imshow(tiled,cmap=cmap); mpl.title('%s Receptive Fields' % layer.name); mpl.colorbar();
	mpl.figure(figName+' Total'); mpl.clf(); mpl.imshow(np.sum(np.abs(fields),0),cmap=cmap); mpl.title('%s Total Absolute Input Dependency' % layer.name); mpl.colorbar() 
開發者ID:robb-brown,項目名稱:IntroToDeepLearning,代碼行數:39,代碼來源:TensorFlowInterface.py

示例13: plotOutput

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def plotOutput(layer,feed_dict,fieldShape=None,channel=None,figOffset=1,cmap=None):
	# Output summary
	W = layer.output
	wp = W.eval(feed_dict=feed_dict);
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		temp = np.zeros(np.product(fieldShape)); temp[0:np.shape(wp.ravel())[0]] = wp.ravel()
		fields = np.reshape(temp,[1]+fieldShape)
	else:			# Convolutional layer already has shape
		wp = np.rollaxis(wp,3,0)
		features, channels, iy,ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	perRow = int(math.floor(math.sqrt(fields.shape[0])))
	perColumn = int(math.ceil(fields.shape[0]/float(perRow)))
	fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	tiled = []
	for i in range(0,perColumn*perRow,perColumn):
		tiled.append(np.hstack(fields2[i:i+perColumn]))

	tiled = np.vstack(tiled)
	if figOffset is not None:
		mpl.figure(figOffset); mpl.clf();

	mpl.imshow(tiled,cmap=cmap); mpl.title('%s Output' % layer.name); mpl.colorbar(); 
開發者ID:robb-brown,項目名稱:IntroToDeepLearning,代碼行數:29,代碼來源:TensorFlowInterface.py

示例14: explorer

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def explorer():
    for c in range(0, len(captchas), 77):
        e = del_line(captchas[c])
        pl.figure(c)
        for i, p in enumerate(split_pic(e)):
            pl.subplot(221+i)
            char = e[:, p[0]:p[1]]
            y1, y2 = split_y(char)
            pl.imshow(regularize(char[y1:y2, :]), cmap=pl.cm.Greys)
        pl.show()
        if raw_input() == 'q':
            pl.close('all')
            break 
開發者ID:leonhx,項目名稱:njucaptcha,代碼行數:15,代碼來源:preprocess.py

示例15: plotMagnitudeSpectrogram

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import imshow [as 別名]
def plotMagnitudeSpectrogram(self, rate, sample, framesz, hop):
        """
            Calculates and plots the magnitude spectrum of a given sound wave.
        """

        X = self.STFT(sample, rate, framesz, hop)

        # Plot the magnitude spectrogram.
        pylab.figure('Magnitude spectrogram')
        pylab.imshow(scipy.absolute(X.T), origin='lower', aspect='auto',
                     interpolation='nearest')
        pylab.xlabel('Time')
        pylab.ylabel('Frequency')
        pylab.show() 
開發者ID:Agerrr,項目名稱:Automated_Music_Transcription,代碼行數:16,代碼來源:first_peaks_method.py


注:本文中的pylab.imshow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。