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


Python OpenImageIO类代码示例

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


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

示例1: poor_mans_iinfo

def poor_mans_iinfo (filename) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    print 'Opened "' + filename + '" as a ' + input.format_name()
    sub = 0
    mip = 0
    while True :
        if sub > 0 or mip > 0 :
            print "Subimage", sub, "MIP level", mip, ":"
        print_imagespec (input.spec(), mip=mip)
        mip = mip + 1
        if input.seek_subimage (sub, mip) :
            continue    # proceed to next MIP level
        else :
            sub = sub + 1
            mip = 0
            if input.seek_subimage (sub, mip) :
                continue    # proceed to next subimage
        break  # no more MIP levels or subimages
    input.close ()
    print
开发者ID:Chifoncake,项目名称:oiio,代码行数:25,代码来源:test_imageinput.py

示例2: test_readtile

def test_readtile (filename, sub=0, mip=0, type=oiio.UNKNOWN) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    print 'Opened "' + filename + '" as a ' + input.format_name()
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if spec.tile_width == 0 :
        print "Error: not tiled"
        return
    if type == oiio.UNKNOWN :
        type = spec.format.basetype
    # Randomly read a couple of tiles, print a pixel from within it
    (tx,ty) = (spec.x, spec.y)
    data = input.read_tile (tx+spec.x, ty+spec.y, spec.z, type)
    if data == None :
        print "read returned None"
        return
    (x,y) = (tx+spec.tile_width/2, ty+spec.tile_height/2)
    i = ((y-ty)*spec.tile_width + (x-tx)) * spec.nchannels
    print "@", (x,y), "=", data[i:i+spec.nchannels]
    (tx,ty) = (spec.x+2*spec.tile_width, spec.y+2*spec.tile_height)
    data = input.read_tile (tx+spec.x, ty+spec.y, spec.z, type)
    (x,y) = (tx+spec.tile_width/2, ty+spec.tile_height/2)
    i = ((y-ty)*spec.tile_width + (x-tx)) * spec.nchannels
    print "@", (x,y), "=", data[i:i+spec.nchannels]
    input.close ()
    print
开发者ID:Chifoncake,项目名称:oiio,代码行数:31,代码来源:test_imageinput.py

示例3: test_readscanline

def test_readscanline (filename, sub=0, mip=0, type=oiio.UNKNOWN) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    print 'Opened "' + filename + '" as a ' + input.format_name()
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if spec.tile_width != 0 :
        print "Error: tiled"
        return
    if type == oiio.UNKNOWN :
        type = spec.format.basetype
    for y in range(spec.height) :
        data = input.read_scanline (y+spec.y, spec.z, type)
        if data == None :
            print "read returned None"
            return
        # print the first pixel of the first and last scanline
        if y == 0 or y == (spec.height-1) :
            i = 0 * spec.nchannels
            print "@", (spec.x,y+spec.y), "=", data[i:i+spec.nchannels]
    input.close ()
    print
开发者ID:Chifoncake,项目名称:oiio,代码行数:26,代码来源:test_imageinput.py

示例4: test_readtile

def test_readtile (filename, sub=0, mip=0, type=oiio.UNKNOWN) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print ('Could not open "' + filename + '"')
        print ("\tError: ", oiio.geterror())
        print ()
        return
    print ('Opened "' + filename + '" as a ' + input.format_name())
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if spec.tile_width == 0 :
        print ("Error: not tiled")
        return
    if type == oiio.UNKNOWN :
        type = spec.format.basetype
    # Randomly read a couple of tiles, print a pixel from within it
    (tx,ty) = (spec.x, spec.y)
    data = input.read_tile (tx+spec.x, ty+spec.y, spec.z, type)
    if data is None :
        print ("read returned None")
        return
    (x,y) = (tx+spec.tile_width//2, ty+spec.tile_height//2)
    print ("@", (x,y), "=", data[y,x])
    (tx,ty) = (spec.x+2*spec.tile_width, spec.y+2*spec.tile_height)
    data = input.read_tile (tx+spec.x, ty+spec.y, spec.z, type)
    print ("@", (x,y), "=", data[y,x])
    input.close ()
    print ()
开发者ID:AtomicFiction,项目名称:oiio,代码行数:28,代码来源:test_imageinput.py

示例5: oiioSupportsRaw

def oiioSupportsRaw():
    '''
    Check to see if raw files can be loaded natively
    '''
    # Check to see if the raw plugin has been loaded
    format_list = oiio.get_string_attribute( "format_list" ).split(',')
    raw_plugin_present = 'raw' in format_list

    # Check to see if version is above when raw reading was fixed
    # Update this version number to reflect when the functionality is fixed
    version_great_enough = oiio.VERSION >= 10707

    return (raw_plugin_present and version_great_enough)
开发者ID:hpd,项目名称:general,代码行数:13,代码来源:mkhdr.py

示例6: test_readimage

def test_readimage (filename, sub=0, mip=0, type=oiio.UNKNOWN,
                    method="image", nchannels=0,
                    print_pixels = True, keep_unknown=False) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print ('Could not open "' + filename + '"')
        print ("\tError: ", oiio.geterror())
        print ()
        return
    print ('Opened "' + filename + '" as a ' + input.format_name())
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if nchannels == 0 or method == "image" :
        nchannels = spec.nchannels
    if str(type) == "unknown" and not keep_unknown :
        type = spec.format.basetype
    if method == "image" :
        data = input.read_image (type)
    elif method == "scanlines" :
        data = input.read_scanlines (spec.y, spec.y+spec.height, spec.z,
                                     0, nchannels, type)
    elif method == "tiles" :
        data = input.read_tiles (spec.x, spec.x+spec.width,
                                 spec.y, spec.y+spec.height,
                                 spec.z, spec.z+spec.depth,
                                 0, nchannels, type)
    else :
        print ("Unknown method:", method)
        return
    if data is None :
        print ("read returned None")
        return
    if print_pixels :
        # print the first, last, and middle pixel values
        (x,y) = (spec.x, spec.y)
        print ("@", (x,y), "=", data[y,x])
        (x,y) = (spec.x+spec.width-1, spec.y+spec.height-1)
        print ("@", (x,y), "=", data[y,x])
        (x,y) = (spec.x+spec.width//2, spec.y+spec.height//2)
        print ("@", (x,y), "=", data[y,x])
    else :
        print ("Read array typecode", data.dtype, " [", data.size, "]")
    # Test the spec and spec_dimensions methods
    spec = input.spec_dimensions (0, 0)
    if len(spec.extra_attribs) > 0 :
        print ("wrong spec_dimensions(s,m) metadata items: ", len(spec.extra_attribs))
    spec = input.spec (0, 0)
    if len(spec.extra_attribs) == 0 :
        print ("wrong spec(s,m) metadata items: ", len(spec.extra_attribs))
    input.close ()
    print ()
开发者ID:AtomicFiction,项目名称:oiio,代码行数:51,代码来源:test_imageinput.py

示例7: test_readimage

def test_readimage (filename, sub=0, mip=0, type=oiio.UNKNOWN,
                    method="image", nchannels=0,
                    print_pixels = True, keep_unknown=False) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    print 'Opened "' + filename + '" as a ' + input.format_name()
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if nchannels == 0 or method == "image" :
        nchannels = spec.nchannels
    if type == oiio.UNKNOWN and not keep_unknown :
        type = spec.format.basetype
    if method == "image" :
        data = input.read_image (type)
    elif method == "scanlines" :
        data = input.read_scanlines (spec.y, spec.y+spec.height, spec.z,
                                     0, nchannels, type)
    elif method == "tiles" :
        data = input.read_tiles (spec.x, spec.x+spec.width,
                                 spec.y, spec.y+spec.height,
                                 spec.z, spec.z+spec.depth,
                                 0, nchannels, type)
    else :
        print "Unknown method:", method
        return
    if data == None :
        print "read returned None"
        return
    if print_pixels :
        # print the first, last, and middle pixel values
        (x,y) = (spec.x, spec.y)
        i = ((y-spec.y)*spec.width + (x-spec.x)) * nchannels
        print "@", (x,y), "=", data[i:i+nchannels]
        (x,y) = (spec.x+spec.width-1, spec.y+spec.height-1)
        i = ((y-spec.y)*spec.width + (x-spec.x)) * nchannels
        print "@", (x,y), "=", data[i:i+nchannels]
        (x,y) = (spec.x+spec.width/2, spec.y+spec.height/2)
        i = ((y-spec.y)*spec.width + (x-spec.x)) * nchannels
        print "@", (x,y), "=", data[i:i+nchannels]
    else :
        print "Read array typecode", data.typecode, " [", len(data), "]"
    input.close ()
    print
开发者ID:ElaraFX,项目名称:oiio,代码行数:47,代码来源:test_imageinput.py

示例8: copy_image

def copy_image (in_filename, out_filename, method="image") :
    input = oiio.ImageInput.open (in_filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    spec = input.spec ()
    output = oiio.ImageOutput.create (out_filename)
    if not output :
        print "Could not create ImageOutput for", out_filename
        return
    ok = output.open (out_filename, spec, oiio.Create)
    if not ok :
        print "Could not open", out_filename
        return
    ok = copy_subimage (input, output, method)
    input.close ()
    output.close ()
    if ok :
        print "Copied", in_filename, "to", out_filename, "as", method
开发者ID:Chifoncake,项目名称:oiio,代码行数:21,代码来源:test_imageoutput.py

示例9: copy_image

def copy_image (in_filename, out_filename, method="image",
                memformat=oiio.TypeFloat, outformat=oiio.TypeUnknown) :
    input = oiio.ImageInput.open (in_filename)
    if not input :
        print ('Could not open "' + filename + '"')
        print ("\tError: ", oiio.geterror())
        print ()
        return
    outspec = input.spec()
    if outformat != oiio.TypeUnknown :
        outspec.format = outformat
    output = oiio.ImageOutput.create (out_filename)
    if not output :
        print ("Could not create ImageOutput for", out_filename)
        return
    ok = output.open (out_filename, outspec)
    if not ok :
        print ("Could not open", out_filename)
        return
    ok = copy_subimage (input, output, method, memformat)
    input.close ()
    output.close ()
    if ok :
        print ("Copied", in_filename, "to", out_filename, "as", method)
开发者ID:StereoD-Development,项目名称:oiio,代码行数:24,代码来源:test_imageoutput.py

示例10: copy_image

def copy_image (in_filename, out_filename, method="image",
                memformat=oiio.FLOAT, outformat=oiio.UNKNOWN) :
    input = oiio.ImageInput.open (in_filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    outspec = input.spec ()
    if (outformat != oiio.UNKNOWN) :
        outspec.format = oiio.TypeDesc(outformat)
    output = oiio.ImageOutput.create (out_filename)
    if not output :
        print "Could not create ImageOutput for", out_filename
        return
    ok = output.open (out_filename, outspec, oiio.Create)
    if not ok :
        print "Could not open", out_filename
        return
    ok = copy_subimage (input, output, method, memformat)
    input.close ()
    output.close ()
    if ok :
        print "Copied", in_filename, "to", out_filename, "as", method
开发者ID:ElaraFX,项目名称:oiio,代码行数:24,代码来源:test_imageoutput.py

示例11: len

    print "getattribute('foo_str') retrieves", s.getattribute("foo_str")
    print "getattribute('foo_vector') retrieves", s.getattribute("foo_vector")
    print "getattribute('foo_matrix') retrieves", s.getattribute("foo_matrix")
    print "getattribute('foo_no') retrieves", s.getattribute("foo_no")
    print

    print "extra_attribs size is", len(s.extra_attribs)
    for i in range(len(s.extra_attribs)) :
        print i, s.extra_attribs[i].name, s.extra_attribs[i].type, s.extra_attribs[i].value
        print s.metadata_val (s.extra_attribs[i], True)
    print

    # test initialization from ROI
    print ("Testing construction from ROI:")
    sroi = oiio.ImageSpec (oiio.ROI(0,640,0,480,0,1,0,3), oiio.FLOAT);
    print_imagespec (sroi)

    # Also test global OIIO functions here
    print "\nTesting global attribute store/retrieve:"
    oiio.attribute ("plugin_searchpath", "perfect")
    print "get_string_attribute plugin_searchpath : ", oiio.get_string_attribute ("plugin_searchpath", "bad")
    print "get_int_attribute plugin_searchpath : ", oiio.get_int_attribute ("plugin_searchpath", 0)
    print "getattribute TypeString plugin_searchpath : ", oiio.getattribute ("plugin_searchpath", oiio.TypeDesc.TypeString)
    print "getattribute TypeFloat plugin_searchpath : ", oiio.getattribute ("plugin_searchpath", oiio.TypeDesc.TypeFloat)
    print "getattribute TypeString blahblah : ", oiio.getattribute ("blahblah", oiio.TypeDesc.TypeString)

    print "Done."
except Exception as detail:
    print "Unknown exception:", detail

开发者ID:MrKepzie,项目名称:oiio,代码行数:29,代码来源:test_imagespec.py

示例12: print

#######################################################
# Create an exr file with deliberately missing tiles

tilesize = 64
res = 256
tile = np.ones((tilesize,tilesize,3), dtype='float') * 0.75

spec = oiio.ImageSpec(res, res, 3, "half")
spec.tile_width = tilesize
spec.tile_height = tilesize
spec.attribute('openexr:lineOrder', 'randomY')

out = oiio.ImageOutput.create ('partial.exr')
if not out :
    print ('Could not create ImageOutput: ', oiio.geterror())
ok = out.open ('partial.exr', spec)
if not ok :
    print ('Could not open file: ', out.geterror())
count = 0
for y in range(0,res,tilesize) :
    for x in range(0,res,tilesize) :
        # Skip every 7th tile
        if (count % 7) > 1 :
            ok = out.write_tile (x, y, 0, tile)
            if not ok :
                print ('Could not write tile y={} x={}: {}'.format(y, x, out.geterror()))
        count += 1

out.close()
开发者ID:AtomicFiction,项目名称:oiio,代码行数:29,代码来源:makepartialexr.py

示例13: print

    print ("r == r2 (expect yes): ", (r == r2))
    print ("r != r2 (expect no): ", (r != r2))
    print ("r == r3 (expect no): ", (r == r3))
    print ("r != r3 (expect yes): ", (r != r3))
    print ("")

    print ("r contains (10,10) (expect yes): ", r.contains(10,10))
    print ("r contains (1000,10) (expect no): ", r.contains(1000,10))
    print ("r contains roi(10,20,10,20,0,1,0,1) (expect yes): ", r.contains(oiio.ROI(10,20,10,20,0,1,0,1)))
    print ("r contains roi(1010,1020,10,20,0,1,0,1) (expect no): ", r.contains(oiio.ROI(1010,1020,10,20,0,1,0,1)))

    A = oiio.ROI (0, 10, 0, 8, 0, 1, 0, 4)
    B = oiio.ROI (5, 15, -1, 10, 0, 1, 0, 4)
    print ("A =", A)
    print ("B =", B)
    print ("ROI.union(A,B) =", oiio.union(A,B))
    print ("ROI.intersection(A,B) =", oiio.intersection(A,B))
    print ("")

    spec = oiio.ImageSpec(640, 480, 3, oiio.UINT8)
    print ("Spec's roi is", oiio.get_roi(spec))
    oiio.set_roi (spec, oiio.ROI(3, 5, 7, 9))
    oiio.set_roi_full (spec, oiio.ROI(13, 15, 17, 19))
    print ("After set, roi is", oiio.get_roi(spec))
    print ("After set, roi_full is", oiio.get_roi_full(spec))

    print ("")

    print ("Done.")
except Exception as detail:
    print ("Unknown exception:", detail)
开发者ID:AtomicFiction,项目名称:oiio,代码行数:31,代码来源:test_roi.py


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