Beispiel #1
0
def pipeline(param_a,param_b,param_c,param_d,param_e):

    loadCSV = False

    createFolders()

    # BEGIN
    # MIXING + PROVING + KNEADING + 2ND PROVING
    # SIMULATED: BUBBLING + INTERSECTION + DEFORM
    ##############################

    print "Bubbling..."
    t = time.clock()

    # field #(Nx,Ny,Nz)
    # density #(Nx,Ny,Nz)
    field,density = proving.proving(param_a,param_b,param_c,param_d,param_e,N,Nz)
    #import poisson3D
    #field = poisson3D.main()
    print "Bubbling Time: ", time.clock()-t


    
    # INTERSECTION

    # input geometry
    print "Loading..."
    t = time.clock()
    # geom #(256,256,256)
    geom = np.array(load_obj('otherbread.binvox')).astype(np.uint8)
    print "Loading Time: ", time.clock()-t

    print "Intersecting..."
    t = time.clock()


    # field #(Nx,Ny,Nz)
    # dfield #(256,256,256)
    # geom #(Nx,Ny,Nz)
    # crust #(256,256,256)
    field,dfield,geom,crust,density = cloadobj.intersect(field, geom,density,N,Nz)
    print "Intersect Time: ", time.clock()-t
    saveField(2*orientate(density.astype(np.uint8),N,Nz),"density","density.png")

    # END
    # MIXING + PROVING + KNEADING + 2ND PROVING
    ##############################

    # 3D BAKING WITH CRUST FORMATION
    print "Baking..."
    t = time.clock()

    # baking effect parameter
    k = 5.0

    #saveField(fieldf,"accumulated","bread.png")

    if(accumulatedBaking):

        bake = True
        if(bake):
            temperatures = bk.getTemperaturesArray(20)

            t2 = time.clock()
            # deform bubbles with temperature
            print "cbake.."
            saveField(255*orientate(field,N,Nz),"accumulated/pre","bread.png")

            print "Max, min: ", np.max(density), np.min(density)
            # bakedField #(Nx,Ny,Nz)
            # geomD      #(Nx,Ny,Nz)
            bakedField,geomD,dfieldDeformed = cbake.bake(255*field,dfield,255*geom,density,temperatures,N,Nz,k)
            field = orientate(bakedField,N,Nz)
            saveField(field,"postbaking","postbaking.png")
            #exit()
            
            print "Crumb..."
            crumbD = np.array(dfieldDeformed>thresh).astype(np.uint8)
            print "New Crust..."
            crust = geomD/255-crumbD

            crust = ndimage.filters.gaussian_filter(255*(orientate(resize(crust,N,Nz),N,Nz)),1)
            saveField(crust,"accumulated","crust.png")

            # geomD      #(Nx,Ny,Nz)
            print "New geomD..."
            geomD = orientate(resize(geomD,N,Nz),N,Nz)

            saveField(geomD,"accumulated","postbakingGeom.png")


            print "Specific field..."
            field = np.array(1.0*field*((cloadobj.orientatef(cloadobj.resizef(dfieldDeformed,N,Nz),N,Nz) > thresh/8.0))).astype(np.uint8)

        else:
            field = cloadobj.orientate(255*field,N,Nz)
        #saveField(field,"accumulated","finalbread.png")


        print "Baking time: ", time.clock()-t
        # loadtexOcclusion
        print "Computing ambient Occlusion..."
        arr=cprint.cprint2(0,Nz,N,field,15)
        saveField(arr,"accumulated","aocclusion.png")
        

        print "Resizing crust and Exporting Field to OGRE: warpedC.field "
        printFile(crust ,"Ogre/output/media/fields/warpedC.field")
        print "Exporting Field to OGRE: warpedO.field "
        printFile(arr,'Ogre/output/media/fields/warpedO.field')
        print "Exporting Field to OGRE: warped.field "
        printFile(field,'Ogre/output/media/fields/warped.field')


    else:
        temperatures = bk.getTemperatures()
        sphere = struct(20)
        for w in xrange(1,180):
            t2 = time.clock()
            diff = temperatures[w]-temperatures[w-1]
            # deform bubbles with temperature
            # geom = scipy.ndimage.binary_closing(fieldf,structure=sphere).astype(np.uint8)
            fieldf = cbake.bake(fieldf,geom,diff,N,Nz,k)
            print w, "Time: ", time.clock()-t2
            saveField(fieldf,"warp2","warped.png")
    print "Baking Time: ", time.clock()-t
Beispiel #2
0
import numpy as np
import Image
import random
import cprint, time
import sys 

I = Image.open(sys.argv[1])
dim = I.size[0]
Nz = I.size[1]/I.size[0]
arr = np.array(I).reshape((Nz,dim,dim))
N = dim

p = 0

maxNeigh = 15.0
c = 15#int(N*(0.9/100.0))
#print c

arr=cprint.cprint2(p,Nz,N,arr,c)

cprint.cprint(p,Nz,N,arr)