Ejemplo n.º 1
0
    def rendJitTriang(x,y,n,jsig, mcp, imageBounds, pixelSize):
        sizeX = int((imageBounds.x1 - imageBounds.x0)/pixelSize)
        sizeY = int((imageBounds.y1 - imageBounds.y0)/pixelSize)

        im = shmarray.zeros((sizeX, sizeY))

        x = shmarray.create_copy(x)
        y = shmarray.create_copy(y)
        if type(jsig) == numpy.ndarray:
            jsig = shmarray.create_copy(jsig)


        nCPUs = multiprocessing.cpu_count()

        tasks = (n/nCPUs)*numpy.ones(nCPUs, 'i')
        tasks[:(n%nCPUs)] += 1

        processes = [multiprocessing.Process(target = rendJitTri, args=(im, x, y, jsig, mcp, imageBounds, pixelSize, nIt)) for nIt in tasks]

        for p in processes:
            p.start()

        for p in processes:
            p.join()

        return im/n
Ejemplo n.º 2
0
    def rendJitTriang2(x,y,n,jsig, mcp, imageBounds, pixelSize):
        #import threading
        sizeX = int((imageBounds.x1 - imageBounds.x0)/pixelSize)
        sizeY = int((imageBounds.y1 - imageBounds.y0)/pixelSize)

        im = shmarray.zeros((sizeX, sizeY))
        im1 = shmarray.zeros((sizeX, sizeY))

        x = shmarray.create_copy(x)
        y = shmarray.create_copy(y)
        if type(jsig) == numpy.ndarray:
            jsig = shmarray.create_copy(jsig)

        #pool = multiprocessing.Pool()

        #Ts = pool.map(gJitTriang, range(n))

        nCPUs = multiprocessing.cpu_count()

        tasks = (n/nCPUs)*numpy.ones(nCPUs, 'i')
        tasks[:(n%nCPUs)] += 1

        processes = [multiprocessing.Process(target = rendJitTri2, args=(im, im1, x, y, jsig, mcp, imageBounds, pixelSize, nIt)) for nIt in tasks]

        for p in processes:
            p.start()

        for p in processes:
            p.join()

        imn =  im/(im1 + 1) #n
        print imn.min(), imn.max()
        return imn
Ejemplo n.º 3
0
    def rendJitTet(x,y,z,n,jsig, jsigz, mcp, imageBounds, pixelSize, zb,sliceSize=100):
        #import gen3DTriangs

        sizeX = (imageBounds.x1 - imageBounds.x0)/pixelSize
        sizeY = (imageBounds.y1 - imageBounds.y0)/pixelSize

        x = (x - imageBounds.x0)/pixelSize
        y = (y - imageBounds.y0)/pixelSize

        jsig = jsig/pixelSize
        jsigz = jsigz/sliceSize

        z = (z - zb[0])/sliceSize

        sizeZ  = floor((zb[1] + sliceSize - zb[0])/sliceSize)

        #im = numpy.zeros((sizeX, sizeY, sizeZ), order='F')

        im = shmarray.zeros((sizeX, sizeY, sizeZ), order='F')

        x = shmarray.create_copy(x)
        y = shmarray.create_copy(y)
        z = shmarray.create_copy(z)

        if type(jsig) == numpy.ndarray:
            jsig = shmarray.create_copy(jsig)

        if type(jsigz) == numpy.ndarray:
            jsigz = shmarray.create_copy(jsigz)

        #pool = multiprocessing.Pool()

        #Ts = pool.map(gJitTriang, range(n))

        nCPUs = multiprocessing.cpu_count()

        tasks = (n/nCPUs)*numpy.ones(nCPUs, 'i')
        tasks[:(n%nCPUs)] += 1

        processes = [multiprocessing.Process(target = rendJTet, args=(im, y, x,z, jsig, jsigz, mcp, nIt)) for nIt in tasks]

        for p in processes:
            p.start()

        for p in processes:
            p.join()

        return im/n