当前位置: 首页>>代码示例>>Python>>正文


Python pylab.imread函数代码示例

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


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

示例1: main

def main():
    img = img_as_float(imread("HJoceanSmall.png"))
    img_seam_v = img_as_float(imread("HJoceanSmall.png"))
    img_transformed_v = img_as_float(imread("HJoceanSmall.png"))
    iterations = 20
    img_seam_v, img_transformed_v = seam_carve(iterations, img_seam_v, img_transformed_v)

    figure()

    subplot(221)
    imshow(img)
    title("1. Original")

    subplot(222)
    imshow(img_seam_v)
    title("2. Seam carved vertical")

    # Transposed Image

    img_seam_hv = img_transformed_v.transpose(1, 0, 2)
    img_transformed_hv = img_transformed_v.transpose(1, 0, 2)
    iterations = 20

    img_seam_hv, img_transformed_hv = seam_carve(iterations, img_seam_hv, img_transformed_hv)

    subplot(223)
    imshow(img_seam_hv.transpose(1, 0, 2))
    title("3. Seam carved horizontal")

    subplot(224)
    imshow(img_transformed_hv.transpose(1, 0, 2))
    title("4. Transformed Image")

    show()
开发者ID:srikiranpanchavati,项目名称:DataStructures,代码行数:34,代码来源:seamcarver.py

示例2: find_movement

def find_movement():
    # img = imread('shot1.jpg')
    # img2 = imread('shot2.jpg')
    img = imread("frame0.jpg")
    img2 = imread("frame2.jpg")
    img1 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
    img1 = img_as_float(img1)
    img2 = img_as_float(img2)
    # print img1
    h1, w1 = img1.shape
    h2, w2 = img2.shape

    img3 = zeros((h1, w1))

    for x in range(0, h1 - 1):
        for y in range(0, w1 - 1):
            if abs(img1[x, y] - img2[x, y]) > 0.01:
                # print img1[x, y], " ", img2[x, y]
                img3[x, y] = 1

    figure()
    # subplot(1, 2, 1), imshow(img)
    # subplot(1, 2, 2), \
    imshow(img3)
    show()
开发者ID:bks2009,项目名称:ImageDeepLearning,代码行数:26,代码来源:Subtraction.py

示例3: AnalyseNSS

    def AnalyseNSS(self):
        if self.Mode=="Manual":
            files=QFileDialog(self)
            files.setWindowTitle('Non-Synchronised Segment Stripes')
            self.CurrentImages=files.getOpenFileNames(self,caption='Non-Synchronised Segment Stripes')

        SSSDlg1=SSSDlg.SSSWidget(self)
        SSSDlg1.Img1=DCMReader.ReadDCMFile(str(self.CurrentImages[0]))
        SSSDlg1.SSS1.axes.imshow(SSSDlg1.Img1,cmap='gray')

        SSSDlg1.Img2=DCMReader.ReadDCMFile(str(self.CurrentImages[1]))
        SSSDlg1.SSS2.axes.imshow(SSSDlg1.Img2,cmap='gray')

        SSSDlg1.Img3=DCMReader.ReadDCMFile(str(self.CurrentImages[2]))
        SSSDlg1.SSS3.axes.imshow(SSSDlg1.Img3,cmap='gray')

        SSSDlg1.Img4=DCMReader.ReadDCMFile(str(self.CurrentImages[3]))
        SSSDlg1.SSS4.axes.imshow(SSSDlg1.Img4,cmap='gray')

        SSSDlg1.ImgCombi=SSSDlg1.Img1+SSSDlg1.Img2+SSSDlg1.Img3+SSSDlg1.Img4
        SSSDlg1.SSSCombi.axes.imshow(SSSDlg1.ImgCombi,cmap='gray')

        EPIDType=np.shape(SSSDlg1.Img1)

        pl.imsave('NSS.jpg',SSSDlg1.ImgCombi)
        Img1=pl.imread('NSS.jpg')
        if EPIDType[0]==384:
            Img2=pl.imread('NSSOrgRefas500.jpg')
        else:
            Img2=pl.imread('NSSOrgRef.jpg')
        self.MSENSS=np.round(self.mse(Img1,Img2))

        if self.Mode=="Manual":
            SSSDlg1.exec_()
开发者ID:Jothy,项目名称:RTQA,代码行数:34,代码来源:Start.py

示例4: computeImageDifferences

def computeImageDifferences(numPictures):
  first = rgb2gray(pl.imread("reference/0.png"))
  others = []
  for num in xrange(1, numPictures + 1):
    others.append(rgb2gray(pl.imread("reference/%d.png" % num)))
    print num
  result = np.array(others) - first
  #pickle.dump(result, open("computeImageDifference.pickle", "w"))
  return result
开发者ID:mrauen,项目名称:physics15c-speckle,代码行数:9,代码来源:images.py

示例5: computePhaseFirstThree

def computePhaseFirstThree(folder):
    import math
    #transformation = np.vectorize(math.sqrt)
    #transformation = np.vectorize(lambda x: x ** 2)
    transformation = np.vectorize(lambda x: x)  # identity
    im1 = transformation(rgb2gray(pl.imread("%s/0.png" % folder)))
    im2 = transformation(rgb2gray(pl.imread("%s/1.png" % folder)))
    im3 = transformation(rgb2gray(pl.imread("%s/2.png" % folder)))

    result = images.computePhase(im1, im2, im3)
    pickle.dump(result, open("%s.pickle" % folder, "w"))
开发者ID:mrauen,项目名称:physics15c-speckle,代码行数:11,代码来源:test.py

示例6: load_img

def load_img(path  = 'data/rjp_small.png', gray=True):
  try:
    x = pylab.imread(path)
  except:
    x = pylab.imread('../' + path)
  if len(x.shape) > 2 and gray:
    x =  x[:, :, 2]
  if len(x.shape) > 2 and x.shape[2] == 4:
    x = x[:,:,:3]
  if x.max() > 1: 
    x = x.astype('float') / 257.0
  return x
开发者ID:Tillsten,项目名称:parakeet,代码行数:12,代码来源:test_morphology.py

示例7: load

 def load(self, uri):
     filename = self.get(uri)
     if isimg(filename):
         obj = pylab.imread(filename)
     elif ishdf5(filename):
         f = h5py.File(filename, 'r')
         obj = f[self.key(filename)].value  # FIXME: lazy evaluation?              
     else:
         try:
             obj = pylab.imread(filename)
         except:
             raise CacheError('[bobo.cache][ERROR]: unsupported object type for loading key "%s" ' % self.key(uri))
     return obj
开发者ID:jethrotan,项目名称:bobo,代码行数:13,代码来源:cache.py

示例8: test_file_image

def test_file_image(fname):
  ext = os.path.splitext(fname)[-1][len(os.path.extsep):]
  kwargs = to_dict_params(fname)

  # Creates the image in memory
  mem = BytesIO()
  fractal_data = call_kw(generate_fractal, kwargs)
  imsave(mem, fractal_data, cmap=kwargs["cmap"], format=ext)
  mem.seek(0) # Return stream position back for reading

  # Comparison pixel-by-pixel
  img_file = imread("images/" + fname)
  img_mem = imread(mem, format=ext)
  assert img_file.tolist() == img_mem.tolist()
开发者ID:danilobellini,项目名称:fractals,代码行数:14,代码来源:test_fractal.py

示例9: load_descs

def load_descs(config, i, norm=1, old_desc=False, invert_mask=False, use_masks2=0):
    fname = config.desc_filename(i)
    mask_name = config.mask_filename(i)
    mask      = pylab.imread(mask_name)
    descs     = load_ndesc_pc(fname, norm=norm, old_desc=old_desc)
    if use_masks2==0:
        descs     = [l for l in descs if bool(mask[l.v,l.u])!=bool(invert_mask)]
    elif use_masks2==1:
        mask2 = pylab.imread(config.mask2_filename(i))
        descs = [l for l in descs if bool(mask2[l.v,l.u])]
    elif use_masks2==2:
        mask2 = pylab.imread(config.mask2_filename(i))
        descs = [l for l in descs if not(mask2[l.v,l.u].astype('bool')) and mask[l.v,l.u].astype('bool')]
    return descs
开发者ID:jypuigbo,项目名称:robocup-code,代码行数:14,代码来源:learn_codebook.py

示例10: myimread

def myimread(imgname,flip=False,resize=None):
    """
        read an image
    """
    img=None
    if imgname.split(".")[-1]=="png":
        img=pylab.imread(imgname)
    else:
        img=numpy.ascontiguousarray(pylab.imread(imgname)[::-1])
    if flip:
        img=numpy.ascontiguousarray(img[:,::-1,:])        
    if resize!=None:
        from scipy.misc import imresize
        img=imresize(img,resize)
    return img
开发者ID:ChrisYang,项目名称:CRFdet,代码行数:15,代码来源:util2.py

示例11: test_with_file

def test_with_file(fn):
    im = pylab.imread(fn)
    if im.ndim > 2:
        im = numpy.mean(im[:, :, :3], 2)
    pylab.imsave("intermediate.png", im, vmin=0, vmax=1., cmap=pylab.cm.gray)
    r = test_inline(im)
    return r
开发者ID:braingram,项目名称:eyetracker,代码行数:7,代码来源:radial.py

示例12: __init__

    def __init__(self, path, waveaxis=None, regions=None, start=None, end=None):
        """ SpectrumImage(path[, waveaxis[, regions]]) initializes a new
        spectrum image from the specified image path.

        Upon initialization, the image is read in to a numpy ndarray, this
        method currently assumes that 2 of the three color channels are
        redundant and eliminates them. At the time of initialization, the
        wavelength axis (0 - columns, 1 - rows) may be specified as well
        as a tuple of lists representing regions in the form [min, max].
        """
        self.image = pylab.imread(path)
        self.image = self.image[:,:,0]
        self.start = start
        self.end = end
        self.regions = []
        if waveaxis is 0 or waveaxis is 1:
            self.waveaxis = waveaxis
            for region in regions:
                bounds = self._validateregion([region['min'], region['max']])
                try:
                    self.regions.append({'min': bounds[0], 'max': bounds[1],
                                         'group': region['group']})
                except TypeError:
                    pass
        elif waveaxis is not None:
            raise ValueError('If the wavelength axis is specified it must',  
                             'be 0 or 1.')
开发者ID:l3enny,项目名称:rovib,代码行数:27,代码来源:spectrum.py

示例13: extract_features

def extract_features(image_path_list):
  feature_list = []
  for image_path in image_path_list:
    features = []
    image_array = imread(image_path)
# Note: Looping through multiple filters for edge detection drastically slows
# Down the feature extraction while only marginally improving performance, thus
# it is left out for the HW submission
#     for ax in [0,1]:
#       for pct in [.01, .02]:
    emat = featureExtractor.getEdgeMatrix(image_array, sigpercent=.01, \
                                          axis=0)
    features.append( featureExtractor.getEdgePercent(image_array, emat) )
    features.append( featureExtractor.getNumMeridialEdges(emat) )
    features.append( featureExtractor.getNumEquatorialEdges(emat) )
    features.append( featureExtractor.getSize(image_array) )
    features.append( featureExtractor.getCentralRatio(image_array) )
    features.append( featureExtractor.getCentralRatio(emat) )
    features.append( featureExtractor.getMeanColorVal(image_array, 0) )
    features.append( featureExtractor.getMeanColorVal(image_array, 1) )
    features.append( featureExtractor.getMeanColorVal(image_array, 2) )
    features.append( featureExtractor.getVariance( image_array, 0 ) )
    features.append( featureExtractor.getVariance( image_array, 1 ) )
    features.append( featureExtractor.getVariance( image_array, 2 ) )
    xr, yr = featureExtractor.getCOM(image_array, 0)
    features.append(xr)
    features.append(yr)
    xg, yg = featureExtractor.getCOM(image_array, 1)
    features.append(xg)
    features.append(yg)
    xb, yb = featureExtractor.getCOM(image_array, 2)
    features.append(xb)
    features.append(yb)
    feature_list.append([image_path, features])
  return feature_list
开发者ID:rossbar,项目名称:AY250-HW,代码行数:35,代码来源:parallelFeatures.py

示例14: read_tiff

def read_tiff(fname,res_x,res_y,pix_x,pix_y,ext_x,ext_y):
	# get array numbers
	img=pl.imread(fname)
	if len(img.shape)==2:
		img_arraynum=1
	else:
		img_arraynum=img.shape[2]
	#collapse accordingly
	if img_arraynum == 4:
		imgmat=numpy.multiply(img[:,:,0]+img[:,:,1]+img[:,:,2],img[:,:,3])
	elif img_arraynum == 1:
		imgmat = img
	else:
		print "Image has %d arrays, unhandled." % img_arraynum
		exit(0)

	### convert data to float64
	imgmat = numpy.array(imgmat,dtype=numpy.float64)

	### image parameters
	pix_x = imgmat.shape[1]
	pix_y = imgmat.shape[0]
	ext_x = pix_x * res_x
	ext_y = pix_y * res_y

	### convert to linear
	imgmat = convert2lin(imgmat,latitude,sensitivity)

	### return final image
	return imgmat,res_x,res_y,pix_x,pix_y,ext_x,ext_y
开发者ID:sellitforcache,项目名称:plateplot,代码行数:30,代码来源:plotPlate.py

示例15: main

def main():
    s = 2.0
    img = imread('cameraman.png')

    # Create all the images with each a differen order of convolution
    img1 = gD(img, s, 0, 0)
    img2 = gD(img, s, 1, 0)
    img3 = gD(img, s, 0, 1)
    img4 = gD(img, s, 2, 0)
    img5 = gD(img, s, 0, 2)
    img6 = gD(img, s, 1, 1)

    fig = plt.figure()
    ax1 = fig.add_subplot(2, 3, 1)
    ax1.set_title("Fzero")
    ax1.imshow(img1, cmap=cm.gray)
    ax2 = fig.add_subplot(2, 3, 2)
    ax2.set_title("Fx")
    ax2.imshow(img2, cmap=cm.gray)
    ax3 = fig.add_subplot(2, 3, 3)
    ax3.set_title("Fy")
    ax3.imshow(img3, cmap=cm.gray)
    ax4 = fig.add_subplot(2, 3, 4)
    ax4.set_title("Fxx")
    ax4.imshow(img4, cmap=cm.gray)
    ax5 = fig.add_subplot(2, 3, 5)
    ax5.set_title("Fyy")
    ax5.imshow(img5, cmap=cm.gray)
    ax6 = fig.add_subplot(2, 3, 6)
    ax6.set_title("Fxy")
    ax6.imshow(img6, cmap=cm.gray)
    show()
开发者ID:latencie,项目名称:Beeldbewerken,代码行数:32,代码来源:exercise_4.py


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