from inception.image.matte.bordermatte import *

if __name__ == '__main__':
    from inception.image.image import Image
    #image = Image.from_filepath("../../../../test/images/buff_small.png")#traditional-buffets-and-sideboards.jpg")
    image = Image.from_filepath("../../../../test/images/traditional-buffets-and-sideboards.jpg")
    image = Image.from_filepath("../../../../test/images/cookiejar.jpg")
    #image = Image.from_filepath("../../../../test/images/buff_small.png")

    import time
    t1 = time.time()
    print("Starting")
    result = alphamatte(image.data)


    t2 = time.time()
    print("Done (in %2.2f seconds)!" % (t2-t1))
    filename = image.filename
    
    image.to_rgba()
    image[..., 3] = result
    
    """
    image = image[...,0]
    image = Image(image)
    image.to_rgb()
    image[..., 0] = result
    image[..., 1] = result
    image[..., 2] = result
    """
    
Example #2
0
from inception.image.shadow.shadow import *

if __name__ == '__main__':
    import os
    from inception.image.image import Image
    from inception.image.matte.bordermatte import alphamatte
    from inception.image.operation.merge import MergeOperation
    from inception.image.operation.scale import ScaleOperation
    from PIL import Image as PILImage

    image = Image.from_filepath("../../../../test/images/traditional-buffets-and-sideboards.jpg")
    bg = Image.from_filepath("../../../../test/images/vanishing.jpg")
    
    result = alphamatte(image.data)
    
    filename = image.filename
    image.to_rgba()
    image[..., 3] = result
    image = ScaleOperation(image, image.width/3.0).run()

    offset = 20, 200
    
    pickle_path = bg.filename.rsplit('.', 1)[0] + '.scene.pkl'
    #pickle_path = bg.filename.rsplit('/',1)[0] + '/definitive.vanishing.pkl'
    import cPickle
    if (os.path.exists(pickle_path)):
        with open(pickle_path, 'r') as f:
            sd = cPickle.load(f)
        print("Detected vanishing points (x,y,z): %s" % sd.get_vanishing_points())
        print("Focal length: %s" % sd.focal_length)
        print(sd.vpestimator.vanishing_points)
from inception.image.matte.simplematte import *

if __name__ == '__main__':
    from inception.image.image import Image
    image = Image.from_filepath("../../../../test/images/buff_small.png")#traditional-buffets-and-sideboards.jpg")
    image = Image.from_filepath("../../../../test/images/traditional-buffets-and-sideboards.jpg")
    
    import time
    t1 = time.time()
    print("Starting")
    result = alphamatte(image.data)

    t2 = time.time()
    print("Done (in %2.2f seconds)!" % (t2-t1))
    image.to_rgba()
    image[..., 3] = result
    from PIL import Image as PILImage
    green = Image.from_any(PILImage.new('RGBA', (image.shape[1], image.shape[0]), color=(0,255,0,255)))
    from inception.image.operation.merge import MergeOperation
    mop = MergeOperation([green, image]).run()
    mop.save(image.filename.rsplit('.',1)[0] + '_greencomp.png')
    Image.from_any(result).save(image.filename.rsplit('.',1)[0] + '_matte.png')
 print("DONE")
 """
 from inception.image.image import Image
 from inception.image.operation import merge
 import os, glob
 testdir = os.path.abspath(os.path.dirname(__file__) + '/../../../../test/images/statadjust')
 #mattes = glob.glob(testdir + "/brigh*_small_matte.jpg")
 mattes = glob.glob(testdir + "/ice_stand_small_matte.jpg")
 #mattes.extend(glob.glob(testdir + "/col*_small_matte.jpg"))
 mattes.extend(glob.glob(testdir + "/dance_small_matte.jpg"))
 backgrounds = [a.rsplit("_matte.jpg",1)[0] + ".jpg" for a in mattes]
 
 foregroundImages = []
 backgroundImages = []
 for i, matte in enumerate(mattes):
     backgroundImages.append(Image.from_filepath(backgrounds[i]))
     matteImage = Image.from_filepath(matte)
     foregroundImage = backgroundImages[-1].clone()
     foregroundImage.to_rgba()
     foregroundImage[..., 3] = linear_to_srgb(getluminance(srgb_to_linear(matteImage.data)))
     foregroundImages.append(foregroundImage)
     foregroundImage.filename = matteImage.filename
 
 # test the images
 for i in range(len(backgroundImages)):
     bg = backgroundImages[i]
     fg = i + 1 if (i < len(backgroundImages) - 1) else 0
     fg = foregroundImages[fg]
     
     print("-------- Running on %s over %s ----------" % (os.path.basename(fg.filename), os.path.basename(bg.filename)))
     results = statadjust(fg.data, bg.data, intermediary_results=True)