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


Python Texture.create_from_source_transfer_target方法代碼示例

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


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

示例1: texture_transfer

# 需要導入模塊: from texture import Texture [as 別名]
# 或者: from texture.Texture import create_from_source_transfer_target [as 別名]
def texture_transfer(args):
    print "Texture Transfer Starting..."
    source_texture = Texture()
    source_texture.load_texture(args.source_texture)
    target_image = Texture()
    target_image.load_texture(args.target_image)
    
    source_corr_texture = Texture()
    target_corr_texture = Texture()
    if args.corr_map_type == 0:
        source_corr_texture.load_texture(args.source_texture, gray=True)
        target_corr_texture.load_texture(args.target_image, gray=True)
    elif args.corr_map_type == 1:
        source_corr_texture.load_texture(args.source_texture,
                                         gray=True, blur=True)
        
        target_corr_texture.load_texture(args.target_image,
                                         gray=True, blur=True)
    patch_width = args.patch_width
    patch_height = args.patch_height

    new_t_height, new_t_width, dim = target_image.pixels.shape

    texture = Texture()
    texture.init_empty_texture(new_t_height, new_t_width, dim) 
    for step in range(args.iterations):
        if args.iterations == 1:
            alpha = .1
        else:
            alpha = .8 * step / (args.iterations-1) + .1
        patches, source_patch_cmap = \
            source_texture.create_patches(patch_height,
                                          patch_width,
                                          overlap=args.overlap_percent,
                                          cmap=source_corr_texture)
    
        texture = \
            Texture.create_from_source_transfer_target(patches,
                                                       source_patch_cmap,
                                                       target_corr_texture,
                                                       texture,
                                                       alpha)

        patch_width = int(patch_width * (1-args.patch_len_reduction))
        patch_height = int(patch_height * (1-args.patch_len_reduction))
        if patch_width == 0 or patch_height == 0:
            print "patch width or height reduced to 0, stopping iterations"
            break 
    texture.save_texture(args.output_file)
    
    return 
開發者ID:azgo14,項目名稱:CS283,代碼行數:53,代碼來源:texture_transfer.py


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