• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pylab.imshow函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.pylab.imshow函数的典型用法代码示例。如果您正苦于以下问题:Python imshow函数的具体用法?Python imshow怎么用?Python imshow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了imshow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: zsview

def zsview(im, cmap=pl.cm.gray, figsize=(8,5), contours=False, ccolor='r'):
    z1, z2 = zscale(im)
    pl.figure(figsize=figsize)
    pl.imshow(im, vmin=z1, vmax=z2, origin='lower', cmap=cmap, interpolation='none')
    if contours:
        pl.contour(im, levels=[z2], origin='lower', colors=ccolor)
    pl.tight_layout()
开发者ID:cenko,项目名称:RATIR-GSFC,代码行数:7,代码来源:astro_functs.py


示例2: viz_docwordfreq_sidebyside

def viz_docwordfreq_sidebyside(P1, P2, title1='', title2='', 
                                vmax=None, aspect=None, block=False):
  from matplotlib import pylab
  pylab.figure()

  if vmax is None:
    vmax = 1.0
    P1limit = np.percentile(P1.flatten(), 97)
    if P2 is not None:
      P2limit = np.percentile(P2.flatten(), 97)
    else:
      P2limit = P1limit
    while vmax > P1limit and vmax > P2limit:
      vmax = 0.8 * vmax

  if aspect is None:
    aspect = float(P1.shape[1])/P1.shape[0]
  pylab.subplot(1, 2, 1)
  pylab.imshow(P1, aspect=aspect, interpolation='nearest', vmin=0, vmax=vmax)
  if len(title1) > 0:
    pylab.title(title1)
  if P2 is not None:
    pylab.subplot(1, 2, 2)
    pylab.imshow(P2, aspect=aspect, interpolation='nearest', vmin=0, vmax=vmax)
    if len(title2) > 0:
      pylab.title(title2)
  pylab.show(block=block)
开发者ID:agile-innovations,项目名称:refinery,代码行数:27,代码来源:BirthMoveTopicModel.py


示例3: plot_confusion_matrix

def plot_confusion_matrix(cm, title='', cmap=plt.cm.Blues):
    #print cm
    #display vehicle, idle, walking accuracy respectively
    #display overall accuracy
    print type(cm)
   # plt.figure(index
    plt.imshow(cm, interpolation='nearest', cmap=cmap)
    #plt.figure("")
    plt.title("Confusion Matrix")
    plt.colorbar()
    tick_marks = [0,1,2]
    target_name = ["driving","idling","walking"]


    plt.xticks(tick_marks,target_name,rotation=45)

    plt.yticks(tick_marks,target_name,rotation=45)
    print len(cm[0])

    for i in range(0,3):
        for j in range(0,3):
         plt.text(i,j,str(cm[i,j]))
    plt.tight_layout()
    plt.ylabel("Actual Value")
    plt.xlabel("Predicted Outcome")
开发者ID:sb1989,项目名称:fyp,代码行数:25,代码来源:KNNClassifierAccuracy.py


示例4: test_likelihood_evaluator3

def test_likelihood_evaluator3():
    
    tr = template.TemplateRenderCircleBorder()
    tr.set_params(14, 6, 4)

    t1 = tr.render(0, np.pi/2)
    img = np.zeros((240, 320), dtype=np.uint8)

    env = util.Environmentz((1.5, 2.0), (240, 320))
    
    le2 = likelihood.LikelihoodEvaluator3(env, tr)

    img[(120-t1.shape[0]/2):(120+t1.shape[0]/2), 
        (160-t1.shape[1]/2):(160+t1.shape[1]/2)] += t1 *255
    pylab.subplot(1, 2, 1)
    pylab.imshow(img, interpolation='nearest', cmap=pylab.cm.gray)

    state = np.zeros(1, dtype=util.DTYPE_STATE)

    xvals = np.linspace(0, 2.,  100)
    yvals = np.linspace(0, 1.5, 100)
    res = np.zeros((len(yvals), len(xvals)), dtype=np.float32)
    for yi, y in enumerate(yvals):
        for xi, x in enumerate(xvals):
            state[0]['x'] = x
            state[0]['y'] = y
            state[0]['theta'] = np.pi / 2. 
            res[yi, xi] =     le2.score_state(state, img)
    pylab.subplot(1, 2, 2)
    pylab.imshow(res)
    pylab.colorbar()
    pylab.show()
开发者ID:ericmjonas,项目名称:franktrack,代码行数:32,代码来源:test_likelihood.py


示例5: show_filters

def show_filters(weights,nweights,d1, d2, nrows, ncols, scale):
    """
    Plots the rows of NumPy 2D array ``weights`` as ``d1`` by ``d2`` images.

    The images are layed out in a ``nrows`` by ``ncols`` grid.

    Option ``scale`` sets the maximum absolute value of elements in ``weights``
    that will be plotted (larger values will be clamped to ``scale``, with the
    right sign).
    """
    perm = range(nweights)
    #random.shuffle(perm)
    image = -scale*numpy.ones((nrows*(d1+1)-1,ncols*(d2+1)-1),dtype=float)
    for i in range(nrows):
        for j in range(ncols):
            image[(i*d1+i):((i+1)*d1+i),(j*d2+j):((j+1)*d2+j)] = -1*weights[perm[i*ncols + j]].reshape(d1,d2)

    for i in range(nrows*(d1+1)-1):
        for j in range(ncols*(d2+1)-1):
            a = image[i,j]
            if a > scale:
                image[i,j] = scale
            if a < -scale:
                image[i,j] = -scale

    bordered_image = scale * numpy.ones((nrows*(d1+1)+1,ncols*(d2+1)+1),dtype=float)

    bordered_image[1:nrows*(d1+1),1:ncols*(d2+1)] = image

    imshow(bordered_image,cmap = cm.Greys,interpolation='nearest')
    xticks([])
    yticks([])
开发者ID:goelhardik,项目名称:projects,代码行数:32,代码来源:visualize.py


示例6: showimg

 def showimg(self, img):
     from matplotlib import pylab as pl
     pixels = img.shape[0] / 3
     size = int(sqrt(pixels))
     img = img.reshape((3,size,size)).swapaxes(0,2).swapaxes(0,1)
     pl.imshow(img, interpolation='nearest')
     pl.show()
开发者ID:hunse,项目名称:cuda-convnet2,代码行数:7,代码来源:convdata.py


示例7: static_view

    def static_view(self, m=0, n=1, NS=100):
        """=============================================================
	   Grafica Estatica (m,n) Modo normal:
	    
	    Realiza un grafico de densidad del modo de oscilación (m,n)
	    de la membrana circular en el tiempo t=0

	    ARGUMENTOS:
	      *Numero cuantico angular				m
	      *Numero cuantico radial				n
	      *Resolucion del grid (100 por defecto)		NS
	============================================================="""
        # Grid
        XM = np.linspace(-1 * self.R, 1 * self.R, NS)
        YM = np.linspace(1 * self.R, -1 * self.R, NS)
        # ---------------------------------------------------------------
        Z = np.zeros((NS, NS))
        for i in xrange(0, NS):
            for j in xrange(0, NS):
                xd = XM[i]
                yd = YM[j]
                rd = (xd ** 2 + yd ** 2) ** 0.5
                thd = np.arctan(yd / xd)
                if xd < 0:
                    thd = np.pi + thd
                if rd < self.R:
                    Z[j, i] = self.f(rd, thd, 0, m, n)
                # ---------------------------------------------------------------
        Z[0, 0] = -1
        Z[1, 0] = 1
        plt.xlabel("X (-R,R)")
        plt.ylabel("Y (-R,R)")
        plt.title("Circular Membrane: (%d,%d) mode" % (m, n))
        plt.imshow(Z)
        plt.show()
开发者ID:sbustamante,项目名称:Computacional-OscilacionesOndas,代码行数:35,代码来源:demo3_01.py


示例8: plot_valid

def plot_valid(b, s):
  from dials.array_family import flex

  b = [0.1, 0.2, 0.3, 0.4, 0.5]
  s = [0.1, 0.3, 0.5, 0.3, 0.1]


  v1 = flex.bool(flex.grid(100, 100))
  v2 = flex.bool(flex.grid(100, 100))
  v3 = flex.bool(flex.grid(100, 100))
  r = [float(ss) / float(bb) for ss, bb in zip(s, b)]

  for BB in range(0, 100):
    for SS in range(0, 100):
      B = -5.0 + BB / 10.0
      S = -5.0 + SS / 10.0
      V1 = True
      V2 = True
      V3 = True
      for i in range(len(b)):
        if B*b[i]+S*s[i] <= 0:
          V1 = False
          break
      for i in range(len(b)):
        if B*b[i] <= -S*s[i]:
          V2 = False
          break

      v1[BB,SS] = V1
      v2[BB,SS] = V2

  from matplotlib import pylab
  pylab.imshow(v1.as_numpy_array())
  pylab.show()
  exit(0)
开发者ID:dials,项目名称:dials_scratch,代码行数:35,代码来源:test.py


示例9: locate

def locate(data, plot=False, rectangle=False, total_pooling=16):
    #    data = cv2.cvtColor(cv2.imread("test1.jpg"), cv2.COLOR_BGR2RGB)

    heatmap = 1 - \
        heatmodel.predict(data.reshape(
            1, data.shape[0], data.shape[1], data.shape[2]))

    if plot:
        plt.imshow(heatmap[0, :, :, 0])
        plt.title("Heatmap")
        plt.show()
        plt.imshow(heatmap[0, :, :, 0] > 0.99, cmap="gray")
        plt.title("Car Area")
        plt.show()

    if rectangle:
        xx, yy = np.meshgrid(
            np.arange(heatmap.shape[2]), np.arange(heatmap.shape[1]))
        x = (xx[heatmap[0, :, :, 0] > 0.99])
        y = (yy[heatmap[0, :, :, 0] > 0.99])

        for i, j in zip(x, y):
            cv2.rectangle(data, (i * total_pooling, j * total_pooling),
                          (i * total_pooling + 48, j * total_pooling + 48), 1)

    return heatmap, data
开发者ID:Peichao,项目名称:Constrained_NMF,代码行数:26,代码来源:evaluate_net_cifar_edge_cutter.py


示例10: display_data

def display_data(x, **kwargs):
  plt.set_cmap('gray')
  nrows, ncols = x.shape
  example_width = int(kwargs.get('example_width', round(math.sqrt(ncols))))
  example_height = int(ncols / example_width)
  display_rows = int(math.floor(math.sqrt(nrows)))
  display_cols = int(math.ceil(nrows/display_rows))
  pad = 1
  display_array = -np.ones( (pad + display_rows *(example_height + pad),
                            pad + display_cols * (example_width + pad)) );
  curr_ex = 0;
  for j in range(0, display_rows):
    for i in range(0, display_cols):
      if (curr_ex >= nrows):
        break;
      max_val = np.max(np.abs(x[curr_ex, :]))
      x_splice_start = pad + j*(example_height + pad)
      y_splice_start = pad + i*(example_width + pad)
      display_array[x_splice_start:(x_splice_start+example_height),
                    y_splice_start:(y_splice_start+example_width)] = \
                    np.reshape(x[curr_ex,:], (example_height, example_width)) / max_val
      curr_ex += 1
    if (curr_ex >= nrows):
      break
  plt.imshow(display_array)
  plt.show()
开发者ID:CharlesTwitchell,项目名称:basic_machine_learning,代码行数:26,代码来源:ex7_pca.py


示例11: plot_prob_for_zero

def plot_prob_for_zero(c, b, s):
  from math import log, exp, factorial
  from dials.array_family import flex
  L = flex.double(flex.grid(100, 100))
  MASK = flex.bool(flex.grid(100, 100))
  c = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
  b = [bb / sum(b) for bb in b]
  s = [ss / sum(s) for ss in s]
  for BB in range(0, 100):
    for SS in range(0, 100):
      B = 0 + BB / 10000.0
      S = 0 + SS / 40.0
      LL = 0
      for i in range(len(b)):
        if B*b[i] + S*s[i] <= 0:
          MASK[BB, SS] = True
          LL = -999999
          break
        else:
          LL += c[i]*log(B*b[i]+S*s[i]) - log(factorial(c[i])) - B*b[i] - S*s[i]

      L[BB, SS] = LL
  index = flex.max_index(L)
  i = index % 100
  j = index // 100
  B = 0 + j / 10000.0
  S = 0 + i / 40.0
  print flex.max(L), B, S
  from matplotlib import pylab
  import numpy
  im = numpy.ma.masked_array(flex.exp(L).as_numpy_array(), mask=MASK.as_numpy_array())
  pylab.imshow(im)
  pylab.show()
  exit(0)
开发者ID:dials,项目名称:dials_scratch,代码行数:34,代码来源:test.py


示例12: reconstructContactMap

def reconstructContactMap(map, datavec):
    """ Plots a given vector as a contact map

    Parameters
    ----------
    map : np.ndarray 2D
        The map from a MetricData object
    datavec : np.ndarray
        The data we want to plot in a 2D map
    """
    map = np.array(map, dtype=int)
    atomidx = np.unique(map.flatten()).astype(int)
    mask = np.zeros(max(atomidx)+1, dtype=int)
    mask[atomidx] = range(len(atomidx))

    # Create a new map which maps from vector indexes to matrix indexes
    newmap = np.zeros(np.shape(map), dtype=int)
    newmap[:, 0] = mask[map[:, 0]]
    newmap[:, 1] = mask[map[:, 1]]

    contactmap = np.zeros((len(atomidx), len(atomidx)))
    for i in range(len(datavec)):
        contactmap[newmap[i, 0], newmap[i, 1]] = datavec[i]
        contactmap[newmap[i, 1], newmap[i, 0]] = datavec[i]

    from matplotlib import pylab as plt
    plt.imshow(contactmap, interpolation='nearest', aspect='equal')
    plt.colorbar()
    #plt.axis('off')
    #plt.tick_params(axis='x', which='both', bottom='off', top='off', labelbottom='off')
    #plt.tick_params(axis='y', which='both', left='off', right='off', labelleft='off')
    plt.show()
开发者ID:PabloHN,项目名称:htmd,代码行数:32,代码来源:model.py


示例13: PlotMtxError

def PlotMtxError(Corr_w):
    max_val = 1
    min_val = -0.1

    AvCorr = np.sum(Corr_w, axis=0)
    dCorr = Corr_w - AvCorr
    errCorr = np.log10(np.sqrt(np.einsum("i...,i...", dCorr, dCorr)) / np.absolute(AvCorr) / np.sqrt(Corr_w.shape[0]))
    # print errCorr.shape
    # print errCorr

    plt.rcParams.update({"font.size": 6, "font.weight": "bold"})
    for i in xrange(errCorr.shape[0]):
        plt.subplot(2, 7, i + 1)
        plt.title("SITE " + str(i + 1) + ":: \nHistogram of errors in corr. mtx.")
        plt.hist(errCorr[0, :, :].flatten(), 256, range=(min_val, max_val))
        plt.xlabel("log_10(sigma)")
        plt.ylabel("Count")

        plt.subplot(2, 7, i + 7 + 1)
        plt.imshow(errCorr[0, :, :], vmin=min_val, vmax=max_val)
        cbar = plt.colorbar(shrink=0.25, aspect=40)
        cbar.set_label("log_10(sigma)")
        plt.set_cmap("gist_yarg")
        plt.title("SITE " + str(i + 1) + ":: \nError in corr. matx. values")
        plt.xlabel("Site i")
        plt.ylabel("Site j")
    plt.show()
开发者ID:jhaberstroh,项目名称:cGromCorrFMO,代码行数:27,代码来源:f3AnalyzeCorrError.py


示例14: func

 def func(im):
     plt.figure()
     plt.title(ti)
     if type(im) == list:
         im = np.zeros(max_shape)
     plt.imshow(im,cmap=cmap,vmin=a_min,vmax=a_max)
     plt.axis('off')
开发者ID:jahuth,项目名称:litus,代码行数:7,代码来源:__init__.py


示例15: prob_grid

def prob_grid():
    im_store=grocery_store_im()
    im=im_store.copy()
    shape=im.shape
    plt.imshow(im)
    print shape
    nx=shape[0]
    ny=shape[1]
    print nx*ny
    x=np.array([np.arange(nx) for i in xrange(ny)]).flatten()
    y=np.array([np.repeat(i,nx) for i in xrange(ny)]).flatten()

    imflat=[]
    for plane in range(3):
        f=(im[0:,0:,plane]).flatten()
        print f.shape
        imflat.append(f)

    xc=nx/2.0
    yc=ny/2.0
    rad=100.0
    mask=np.sqrt((x-xc)**2 + (y-yc)**2 ) < rad
    #return mask, x,y,imflat

    imflat_g=imflat[0]
    imflat_g[mask]=0.5
    imflat_g.shape=(nx,ny)

    im[0:,0:,0]=imflat_g
    plt.imshow(im)
开发者ID:dave31415,项目名称:beacons,代码行数:30,代码来源:smoothing.py


示例16: part2

def part2(w):
    f = plt.figure()
    for i in range(16):
        f.add_subplot(4,4,i+1)
        plt.axis('off')
        plt.imshow(np.reshape(normalize(w[1:,i]), (20,20)), cmap = matplotlib.cm.Greys_r)
    plt.savefig('3.png')
开发者ID:renhzhang2,项目名称:EECS-545-Machine-Learning,代码行数:7,代码来源:Q2.py


示例17: plotMatrix

def plotMatrix(data):
    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    ax.set_aspect('equal')
    plt.imshow(data, interpolation='nearest', cmap=plt.cm.ocean)
    plt.colorbar()
    plt.show()
开发者ID:wande001,项目名称:netCDFtoGrads,代码行数:7,代码来源:plotMatrix.py


示例18: search

def search():
	#extract the query from the searchbox
	search_term = searchbox.get()
	print "searched for: "+search_term
	
	search_term = search_term.replace(' ','%20')
	url = ('https://ajax.googleapis.com/ajax/services/search/images?' + 'v=1.0&q='+search_term+'&userip=MyIP')

	request = urllib2.Request(url, None, {'Referer': search_term})
	response = urllib2.urlopen(request)
	
	# Process the JSON string.
	results = simplejson.load(response)
	data = results['responseData']
	img_url=data['results'][0]['unescapedUrl']
	
	#update the url in the url text box
	url_disp.set(img_url)
	
	#check and print the filename of the image
	file_name= img_url.split("/")[-1]
	print "the file name of the image is: " +file_name

	img_data = urllib2.urlopen(img_url).read()
	output = open('dl_img.jpg','wb')
	output.write(img_data)
	output.close()

	#update the displayed image to the image download
	root.image = mpimg.imread('dl_img.jpg')
	plt.imshow(root.image)
	canvas.show()
	root.update()
开发者ID:ericwayman,项目名称:python-seminar,代码行数:33,代码来源:img_gui.py


示例19: apply_butterworth_filter

 def apply_butterworth_filter(self):
     """
     Apply Butterworth low pass filter.
     The code is derived from Paragraph 4.8.2, 
     Butterworth Lowpass Filters, 
     "Digital image Processing (3rd edition)" by R.C. Gonzalez.
     """
     max_ksize = max(self.img.shape[0], self.img.shape[1])
     self.dft4img = self.get_dft(self.img, showdft=True)
     cv2.imshow(self.test_winname, self.img)
     cv2.imshow(self.ctrl_panel_winname, np.zeros((100, 600), np.uint8))
     cv2.createTrackbar(
         "stopband**2", self.ctrl_panel_winname, 3, (max_ksize - 1) / 2, self.update_butterworth_win)
     self.update_butterworth_win()
     print "Reducing high frequency noise, Press a to accept"
     while True:
         ch = cv2.waitKey()
         if ch == 27:
             break
         if ch == 97:
             self.img = self.tmp
             plt.imshow(self.img)
             plt.show()
             break
     cv2.destroyAllWindows()
开发者ID:thundertrick,项目名称:imageNoiseAnalyst,代码行数:25,代码来源:image_noise_analyst.py


示例20: plotscalefactors

    def plotscalefactors(self):
        '''
        Plots the distribution of scalefactors between consecutive images.
        This is to check manually that the hdr image assembly is done correctly.
        '''
        import matplotlib.pylab as plt

        print('Scalefactors for HDR-assembling are', self.scalefactors)
        print('Standard deviations for Scalefactors are', self.scalefactorsstd)

        # Plots the scalefactordistribution and scalefactors for each pixelvalue
        self.scaleforpix = range(len(self.raw))
        for n in range(len(self.raw) - 1):
            A = self.getimgquotient(n)
            B = self._getrealimg(n + 1)
            fig = plt.figure()
            plt.xlabel('x [pixel]')
            plt.ylabel('y [pixel]')
            fig.set_size_inches(10, 10)
            plt.imshow(A)
            plt.clim([0.95 * A[np.isfinite(A)].min(), 1.05 * A[np.isfinite(A)].max()])
            plt.colorbar()
            fig = plt.figure()
            linplotdata = np.array([B[np.isfinite(B)].flatten(), A[np.isfinite(B)].flatten()])
            plt.plot(linplotdata[0, :], linplotdata[1, :], 'ro')
开发者ID:skuschel,项目名称:IPread,代码行数:25,代码来源:ipread.py



注:本文中的matplotlib.pylab.imshow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pylab.ioff函数代码示例发布时间:2022-05-27
下一篇:
Python pylab.hold函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap