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


Python misc.toimage函数代码示例

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


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

示例1: retrieve

    def retrieve(self, request, pano_id=None, heading=0):
        target_heading = get_int_value(
            request, 'heading', default=heading, upper=360, strategy='modulo')

        target_width = get_int_value(
            request, 'width', default=750,
            lower=1, upper=1600, strategy='cutoff')

        target_fov = get_int_value(
            request, 'fov', default=80, upper=120, strategy='cutoff')

        target_width, target_fov = self._max_fov_per_width(target_width, target_fov)

        target_horizon = get_float_value(
            request, 'horizon', default=0.3, lower=0.0, upper=1.0)
        target_aspect = get_float_value(
            request, 'aspect', default=1.5, lower=1.0)

        pano = get_object_or_404(Panoramas, pano_id=pano_id)
        thumb = Thumbnail(pano)
        thumb_img = thumb.get_image(target_width=target_width,
                                    target_fov=target_fov,
                                    target_horizon=target_horizon,
                                    target_heading=target_heading,
                                    target_aspect=target_aspect)

        response = HttpResponse(content_type="image/jpeg")
        misc.toimage(thumb_img).save(response, "JPEG")
        return response
开发者ID:DatapuntAmsterdam,项目名称:panorama,代码行数:29,代码来源:view_imgs.py

示例2: _data_images

   def _data_images():
       """ Make images with linear scaling, sqrt scaling, log scaling.
       This might take a little bit of time. """
       mag, phase = np.abs(self.rs_data), np.angle(self.rs_data)
       mag *= self.blocker
       
       # resize, then save the color and scale permutations of first_frame.
       linr = mag
       sqrt = np.sqrt(mag)
       logd = np.log((mag-mag.min())/mag.max()*1000+1)
 
       self.rs_image_linr = io.complex_hsv_image(linr)
       self.rs_image_sqrt = io.complex_hsv_image(sqrt*np.exp(1j*phase))
       self.rs_image_log = io.complex_hsv_image(logd*np.exp(1j*phase))
       
       imgs = {'logd':smp.toimage(self.rs_image_log),
               'sqrt':smp.toimage(self.rs_image_sqrt),
               'linr':smp.toimage(self.rs_image_linr)}
       
       base = './static/imaging/images/ifth_session%s_id%s_%s_%s.%s'
       for key, val in imgs.items():
           val.save(base%(self.session_id, self.data_id,
                          self.blocker_power, key, 'png'))
           val.save(base%(self.session_id, self.data_id,
                          self.blocker_power, key, 'jpg'))
开发者ID:dhparks,项目名称:speckle_server,代码行数:25,代码来源:imaging_backend.py

示例3: print_map

    def print_map(self):
        ocmap = []
        for line in self.occupancy_map:
            ocmap.append([cell[0] for cell in line])

        npmap = np.array(ocmap)
        toimage(npmap, cmin=0.0, cmax=1.0).save('occupancy_map.jpeg')
开发者ID:renvieir,项目名称:roboticappgi,代码行数:7,代码来源:occupancy_grids.py

示例4: detect_blur

def detect_blur(f):
  print "Processing %s" % f
  im = Image.open("images/orig_"+f+".jpeg") 
  im = im.convert('F')
  im = array(im)

  im = filters.laplace(im)
  laplacien_im = im
  toimage(im).save(out_dir+"/laplacien_"+f+".png", "png")
  im = morphology.white_tophat(im, (3,3))
  tophat_im = im
  toimage(im).save(out_dir+"/tophat_"+f+".png", "png")
  
  im = filters.percentile_filter(im, 30, 1)

  toimage(im).save(out_dir+"/final_"+f+".png", "png")
  
  subprocess.call("/usr/local/bin/convert %s/final_%s.png %s/ppm_final_%s.ppm" % (out_dir, f, out_dir,f), shell=True)
  
  subprocess.call("./segment/segment 0.8 100 100 %s/ppm_final_%s.ppm %s/segment_%s.ppm" % (out_dir, f, out_dir,f), shell=True)
  
  im_seg = Image.open("%s/segment_%s.ppm" % (out_dir, f))
  im_seg = array(im_seg)
  
  print "laplacien"
  
  laplacian_mask = build_mask(im_seg, laplacien_im)
  toimage(laplacian_mask).save(out_dir+"/laplacian_mask_"+f+".png", "png")
  
  print "tophat"
  
  tophat_mask = build_mask(im_seg, tophat_im, 10)
  toimage(tophat_mask).save(out_dir+"/tophat_mask_"+f+".png", "png")
开发者ID:nt,项目名称:blur,代码行数:33,代码来源:blur_detection.py

示例5: rgbtiffstojpg

def rgbtiffstojpg(files, path, name):
    '''
    files: a list of files ordered as follow. 0: Blue Band 1: Green Band 2: Red Band
    path: the path to look for the tiff files and to save the jpg
    '''
    import scipy.misc as sm
    import gdal
    import numpy as np
    b2_link = gdal.Open(path+"/tiff/"+files[0])
    b3_link = gdal.Open(path+"/tiff/"+files[1])
    b4_link = gdal.Open(path+"/tiff/"+files[2])

    # call the norm function on each band as array converted to float
    def norm(band):
        band_min, band_max = band.min(), band.max()
        return ((band - band_min) / (band_max - band_min))

    b2 = norm(b2_link.ReadAsArray().astype(np.float))
    b3 = norm(b3_link.ReadAsArray().astype(np.float))
    b4 = norm(b4_link.ReadAsArray().astype(np.float))

    # Create RGB
    rgb = np.dstack((b4, b3, b2))
    del b2, b3, b4
    sm.toimage(rgb, cmin=np.percentile(rgb,2), cmax=np.percentile(rgb,98)).save(path+'/images/'+name)
开发者ID:WFP-VAM,项目名称:HRM_NN_Training,代码行数:25,代码来源:SentinelExp.py

示例6: arrayVisualizeS1

 def arrayVisualizeS1(self): # Used to plot all of the arrays
     for a,n in zip(self.S1.arrays,range(12)): # Plots all of the S1 arrays
         array = a.arr
         ph = np.empty(array.shape)
         for i in range(array.shape[0]):
             for j in range(array.shape[1]):
                 ph[i,j]= array[i,j].output
                 img = toimage(ph)
         plt.subplot(5,3,n+1)
         plt.imshow(img)
         plt.title('S1_{0}'.format(n+1))
     ph = np.empty(self.C0.arrays[0].arr.shape)
     for i in range(self.C0.arrays[0].arr.shape[0]): # Plots the input array
             for j in range(self.C0.arrays[0].arr.shape[1]):
                 ph[i,j]= self.C0.arrays[0].arr[i,j].output
                 img = toimage(ph)
     plt.subplot(5,3,13)
     for i in range(self.V0.arrays[0].arr.shape[0]): # Plots the inhibitory array
         for j in range(self.V0.arrays[0].arr.shape[1]):
             ph[i,j]= self.V0.arrays[0].arr[i,j].output
             img = toimage(ph)
     plt.subplot(5,3,13)
     plt.imshow(img)
     # plt.subplot(5,3,13)
     plt.title('C0')
     plt.tight_layout()
     plt.draw()
开发者ID:DmitriyLeybel,项目名称:Neural_Networks,代码行数:27,代码来源:Neocognitron.py

示例7: pairdump

def pairdump():
    "可视化模型列"
    from layerbase import DrawPatch
    import cPickle
    sparsedirect = cPickle.load(file('sparselinked','rb'))
    drec = sparsedirect.components_.reshape((-1,1,70-25,90-0))
    misc.toimage(DrawPatch(drec)).save('dictpair.jpg')
开发者ID:wzc11,项目名称:glasses-removal,代码行数:7,代码来源:model2.py

示例8: overlay_predictions

def overlay_predictions(image, im_softmax,image_shape, threshold, channel, seg_color=(0,255,0,172)):
    """creates a overlay using pixels with p(class) > threshold"""

    segmentation = np.expand_dims(im_softmax[:,:,channel] > threshold, 2)
    mask = segmentation * np.reshape(np.array(seg_color), (1,1,-1))
    mask = misc.toimage(mask, mode="RGBA")
    street_im = misc.toimage(image)
    street_im.paste(mask, box=None, mask=mask)
    return street_im
开发者ID:gangadhara691,项目名称:RoboND-DeepLearning-Project,代码行数:9,代码来源:visualization.py

示例9: test_jpg

def test_jpg(w, img):
    prev_i = 100
    for i in range(prev_i, 0, -5):
        print i,
        misc.toimage(img).save("out.jpg", quality = i)
        if w.extract(misc.imread("out.jpg")) is None:
            return prev_i
        prev_i = i
    return "unbound"
开发者ID:KWMalik,项目名称:tau,代码行数:9,代码来源:all3.py

示例10: test_jpg

def test_jpg(w, img):
    prev_i = 100
    for i in range(prev_i, 0, -5):
        misc.toimage(img).save("out.jpg", quality = i)
        try:
            w.extract(misc.imread("out.jpg"))
        except ReedSolomonError:
            return prev_i
        prev_i = i
    return 5
开发者ID:KWMalik,项目名称:tau,代码行数:10,代码来源:all.py

示例11: showtransform

def showtransform():
    "显示神经网络转换结果"
    trans = np.load('transform.npy')[:,0]
    glassmodel = np.load('glassline.npy').astype('f').reshape((-1,45,90))
    glassmodel /= np.max(glassmodel)
    trans = np.insert(trans,2,glassmodel,axis=1)
    p = trans[:,0].reshape((trans.shape[0],-1))
    trans[:,0] -= ((p.max(axis=1)+p.mean(axis=1))*0.5).reshape((-1,1,1))
    trans[:,0] = np.where(trans[:,0]>0, trans[:,0],0)
    from layerbase import DrawPatch
    misc.toimage(DrawPatch(trans,False,'bgy')).save('nntrans.png')
开发者ID:wzc11,项目名称:glasses-removal,代码行数:11,代码来源:nn_process.py

示例12: reshapeAndPrint

def reshapeAndPrint( components, fold ):
    '''Takes in the vector encoding of each of the nmf components
    and plots them to file'''
    imHeight = 192
    imWidth = 168
    nComp = np.shape(components)[0]
    for comp in range(nComp):
        image = np.reshape(components[comp,:],(imHeight,imWidth),order='C')
        savestring = './Results/images/nComp' + str(nComp) + \
            '_comp' + str(comp) + '_fold' + str(fold) + '.jpg'
        misc.toimage(image, cmin=0.0, cmax=...).save(savestring)
开发者ID:potachen,项目名称:COS424_Project,代码行数:11,代码来源:main_oldPrintVersion.py

示例13: png_buffer

def png_buffer(array):
    """Convert an array to PNG, handling transparency in an
    at-least-partially-sane manner."""
    assert array.ndim == 2

    im = toimage(array)
    alpha = toimage(array != 0)
    im.putalpha(alpha)

    # Return format is a buffer of PNG-encoded data
    fp = BytesIO()
    im.save(fp, format='png')

    return fp.getbuffer()
开发者ID:ANU-Linked-Earth-Data,项目名称:resampler,代码行数:14,代码来源:resampler.py

示例14: main

def main():
    image = bayer("itau02.png")
    template = bayer("keyboard.png")

    correlation = correlate(image, template)
    c_max = max(correlation)
    c_min = min(correlation)

    signal = (correlation - c_min) * 255 / (c_max - c_min)
    toimage(signal).save("signal.png")

    winner = where(correlation == c_max, 255, 0)
    toimage(winner).save("winner.png")
    print searchmax(winner)
开发者ID:xperroni,项目名称:Skeye,代码行数:14,代码来源:demo_correlate.py

示例15: get_phase

def get_phase(args):
    
    filename = args[0]
    path = args[1]
    path_raw = args[2]
    path_images = args[3]
    mask = args[4]
    coord = args[5]

    file_in = os.path.join(path,filename)
    file_raw = os.path.join(path_raw,'raw_'+filename)
    image_phase = os.path.join(path_images,'wrapped'+filename[4:11]+'bmp')
    binary_phase = os.path.join(path_raw,'wrapped'+filename[4:11]+'dat')
    mod_arr = os.path.join(path_raw,'mod'+filename[4:11]+'dat')
    mod_image = os.path.join(path_images,'mod'+filename[4:11]+'bmp')
    qual_arr = os.path.join(path_raw,'qual'+filename[4:11]+'dat')
    qual_image = os.path.join(path_images,'qual'+filename[4:11]+'bmp')
    # Open meas file and grab dataset
    try:
        f = File(file_in, 'r')
    except:
        print 'Corrupt h5 file: '+filename+' ignoring'
        return
    sub = f.get(r'measurement0/frames/frame_full/data')
    data = np.array(sub[coord[0]-1:coord[1]+1,coord[2]-1:coord[3]+1],'f')
    f.close()

    # Get phase
    phase, modulation, intensity = calc_phase(data)
    # Apply mask
    phase[~mask] = 0
    intensity[~mask] = 0
    modulation[~mask] = 0
    #phase = phase[coord[0]:coord[1],coord[2]:coord[3]]
    
    # Save phase
    toimage(phase).save(image_phase)
    phase.tofile(binary_phase)


    ave_mod = np.average(modulation[mask])
    ave_int = np.average(intensity[mask])
    '''
    if ave_mod < 0.6:
        print filename+' low mod:', ave_mod
    else:
        sys.stdout.write('.')
    '''
    return "%s,%f,%f\n" % (filename, ave_int, ave_mod)
开发者ID:rockman507,项目名称:tfi_py,代码行数:49,代码来源:wrapped_phase.py


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