Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
0
    def __init__(self, T, shm=False, extraSpaceFactor=1.5, calcDistances=True):
        self.Nverts = len(T.x)
        if shm:
            from PYME.shmarray import shmarray
            self.edgeArray = shmarray.zeros(int(extraSpaceFactor*self.Nverts), dtype)
        else:
            self.edgeArray = numpy.zeros(int(extraSpaceFactor*self.Nverts), dtype)

        #record how many vertices there are
        self.edgeArray[-1]['numIncidentEdges'] = self.Nverts

        #say where we can start adding extra rows
        self.edgeArray[-1]['nextRecordIndex'] = self.Nverts + 1

        addEdges(self.edgeArray, T.edge_db)

        if calcDistances:
            self.calcDistances((T.x, T.y))
Esempio n. 6
0
    def __init__(self, T, shm=False, extraSpaceFactor=1.5, calcDistances=True):
        self.Nverts = len(T.x)
        if shm:
            from PYME.shmarray import shmarray
            self.edgeArray = shmarray.zeros(
                int(extraSpaceFactor * self.Nverts), dtype)
        else:
            self.edgeArray = numpy.zeros(int(extraSpaceFactor * self.Nverts),
                                         dtype)

        #record how many vertices there are
        self.edgeArray[-1]['numIncidentEdges'] = self.Nverts

        #say where we can start adding extra rows
        self.edgeArray[-1]['nextRecordIndex'] = self.Nverts + 1

        addEdges(self.edgeArray, T.edge_db)

        if calcDistances:
            self.calcDistances((T.x, T.y))