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


Python Transform.preprocess方法代码示例

本文整理汇总了Python中Transform.preprocess方法的典型用法代码示例。如果您正苦于以下问题:Python Transform.preprocess方法的具体用法?Python Transform.preprocess怎么用?Python Transform.preprocess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transform的用法示例。


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

示例1: child

# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import preprocess [as 别名]
def child(i, step, totalimage, prefs, kind, finalData, monitor, nOutstart):

    Start = i*step;
    End = (i+1)*step;
    if(Start >= totalimage):
        return 0
    if(End > totalimage):
        End = totalimage;

    for iproj in range(Start,End):
        nOut = nOutstart+iproj
        # outfilename = "%s/%s_%s.hdf" % (prefs['out']['filePath'], prefs['projection']['Prefix'], Transform.paddingZero(nOut, int(prefs['out']['numberDigit'])))
        dataArray = []

        for i in prefs['series']:
            i = i -1
            filename = "%s/%s%s.%s" % ( prefs['filePath'], prefs[kind]['Prefix'][0], Transform.paddingZero(int(prefs[kind]['Num'][i][iproj]), prefs['numberDigit'] ), prefs[kind]['extension'] )
            im = Image.open(filename)
            imarray = np.array(im)
            dataArray.append(0)
            dataArray[i] = imarray[(prefs['ROIy'][i][0]-1):prefs['ROIy'][i][-1] , (prefs['ROIx'][i][0]-1):prefs['ROIx'][i][-1]] # corp the array
            # if prefs['slits']['shouldCorr']: #comment out for this momoent, if need corr, need to initialize in the initialize script
            # dataAve[iavg] = slitposcorr(dataAve[iavg], prefs, j, kind, iavg)
            dataArray[i], _, _, aveint = Transform.preprocess(dataArray[i], prefs, i)
            if prefs['vis']['intMonitor']:
                monitor[iproj][i]=array('d', [aveint, prefs[kind]['Num'][i][iproj], nOut])

        dataResutArray, sminx, smaxx = Transform.stitching(dataArray, prefs)
        finalData[iproj] = dataResutArray

    return 1
开发者ID:kyueaes,项目名称:tomoPre,代码行数:33,代码来源:projTransform.py

示例2: child

# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import preprocess [as 别名]
def child(i, procs, step, totalimage, prefs, kind, j, dataAve, monitor, nOut):

    Start = i*step;
    End = (i+1)*step;
    if(Start >= totalimage):
        return 0
    if(End > totalimage):
        End = totalimage;

    for iavg in range(Start, End ):
        filename = "%s/%s%s.%s" % ( prefs['filePath'], prefs[kind]['Prefix'][0], Transform.paddingZero(int(prefs[kind]['Num'][j][iavg]), prefs['numberDigit'] ), prefs[kind]['extension'] )
        im = Image.open(filename)
        imarray = np.array(im)
        dataAve[iavg] = imarray[(prefs['ROIy'][j][0]-1):prefs['ROIy'][j][-1] , (prefs['ROIx'][j][0]-1):prefs['ROIx'][j][-1]] # corp the array
        # if prefs['slits']['shouldCorr']: #comment out for this momoent, if need corr, need to initialize in the initialize script
        # dataAve[iavg] = slitposcorr(dataAve[iavg], prefs, j, kind, iavg)
        # print iavg
        if prefs['vis']['intMonitor']:
            _, _, _, aveint = Transform.preprocess(dataAve[iavg], prefs, j)
            monitor[iavg][j] = array('d', [aveint, prefs[kind]['Num'][j][iavg], nOut])

    return 1
开发者ID:kyueaes,项目名称:tomoPre,代码行数:24,代码来源:avgTransform.py

示例3: projTransform

# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import preprocess [as 别名]
def projTransform(prefs, nOutstart, sType, kind, fileID, moncnt):

    prefs = Transform.stitching_calcbefore(prefs)

    maxx = 0; minx = sys.maxint
    sArrayX = 0; sArrayY = 0

    iproj = 0
    dataArray = []
    for i in prefs['series']:
        i = i -1
        filename = "%s/%s%s.%s" % ( prefs['filePath'], prefs[kind]['Prefix'][0], Transform.paddingZero(int(prefs[kind]['Num'][i][iproj]), prefs['numberDigit'] ), prefs[kind]['extension'] )
        # filename = "b_image.tif" # this tif image is for testing purpose
        im = Image.open(filename)
        imarray = np.array(im)
        dataArray.append(0)
        dataArray[i] = imarray[(prefs['ROIy'][i][0]-1):prefs['ROIy'][i][-1] , (prefs['ROIx'][i][0]-1):prefs['ROIx'][i][-1]] # corp the array
        # if prefs['slits']['shouldCorr']: #comment out for this momoent, if need corr, need to initialize in the initialize script
        # dataAve[iavg] = slitposcorr(dataAve[iavg], prefs, j, kind, iavg)
        dataArray[i], _, _, aveint = Transform.preprocess(dataArray[i], prefs, i)
    dataResutArray, sminx, smaxx = Transform.stitching(dataArray, prefs)


    totalimage = len(prefs[kind]['Num'][0])
    # totalimage = 2
    step = 100
    workjob = []
    procs = totalimage/step + 1


    # finalData = np.zeros(shape=( len(prefs[kind]['Num'][0]), dataResutArray.shape[0], dataResutArray.shape[1] ))

    sharedArray = Array(ctypes.c_double, len(prefs[kind]['Num'][0])*dataResutArray.shape[0]*dataResutArray.shape[1], lock=False)
    sharedNpArray = np.frombuffer(sharedArray, dtype=ctypes.c_double)
    finalData = sharedNpArray.reshape(len(prefs[kind]['Num'][0]), dataResutArray.shape[0], dataResutArray.shape[1])

    sharedMonitor = Array(ctypes.c_double, totalimage*len(prefs['series'])*3, lock=False)
    sharedNpMonitor = np.frombuffer(sharedMonitor, dtype=ctypes.c_double)
    monitor = sharedNpMonitor.reshape(totalimage, len(prefs['series']), 3)

    for i in range(0, procs):
        process = Process(target=child, args = (i, step, totalimage, prefs, kind, finalData, monitor, nOutstart))
        workjob.append(process)

    for j in workjob:
        j.start()

    for j in workjob:
        j.join()

    # for iproj in range(0,len(prefs[kind]['Num'][0])):
    #     nOut = nOutstart+iproj
    #     # outfilename = "%s/%s_%s.hdf" % (prefs['out']['filePath'], prefs['projection']['Prefix'], Transform.paddingZero(nOut, int(prefs['out']['numberDigit'])))
    #     dataArray = []
    #
    #     for i in prefs['series']:
    #         i = i -1
    #         filename = "%s/%s%s.%s" % ( prefs['filePath'], prefs[kind]['Prefix'][0], Transform.paddingZero(int(prefs[kind]['Num'][i][iproj]), prefs['numberDigit'] ), prefs[kind]['extension'] )
    #         # filename = "b_image.tif" # this tif image is for testing purpose
    #         im = Image.open(filename)
    #         imarray = np.array(im)
    #         dataArray.append(0)
    #         dataArray[i] = imarray[(prefs['ROIy'][i][0]-1):prefs['ROIy'][i][-1] , (prefs['ROIx'][i][0]-1):prefs['ROIx'][i][-1]] # corp the array
    #         # if prefs['slits']['shouldCorr']: #comment out for this momoent, if need corr, need to initialize in the initialize script
    #         # dataAve[iavg] = slitposcorr(dataAve[iavg], prefs, j, kind, iavg)
    #         dataArray[i], _, _, aveint = Transform.preprocess(dataArray[i], prefs, i)
    #         if prefs['vis']['intMonitor']:
    #             monitor.append(array('d', [aveint, prefs[kind]['Num'][i][iproj], nOut]))
    #
    #     dataResutArray, sminx, smaxx = Transform.stitching(dataArray, prefs)
    #
    #     if iproj == 0:
    #         finalData = np.zeros(shape=( len(prefs[kind]['Num'][0]), dataResutArray.shape[0], dataResutArray.shape[1] ))
    #
    #     finalData[iproj] = dataResutArray




        # d = array('i', finalData)
    # minx = min(minx, sminx)
    # maxx = max(maxx, smaxx)
    #
    # sArrayX = max(sArrayX, dataResutArray.shape[1])
    # sArrayY = max(sArrayY, dataResutArray.shape[0])

        # write the data array to the file


    prefs = Transform.stitching_calcafter(prefs, minx, maxx, sArrayX, sArrayY)

    moncnt = moncnt + len(prefs[kind]['Num'][0])
    nOutarg = nOutstart+len(prefs[kind]['Num'][0])

    return prefs, nOutarg, monitor, moncnt, finalData


# prefs = dict()
# prefs = Stitching_InitConv_TIFFtoHDF4_single.initPyPref(prefs)
# fileID = '/local/kyue/test/txt'
#.........这里部分代码省略.........
开发者ID:kyueaes,项目名称:tomoPre,代码行数:103,代码来源:projTransform.py

示例4: avgTransform

# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import preprocess [as 别名]
def avgTransform(prefs, nOut, sType, kind, fileID, moncnt):
    # monitor=[]

    nOut = nOut + 1;
    # outfilename = "%s/%s_%s.hdf" % (prefs['out']['filePath'], prefs['projection']['Prefix'], Transform.paddingZero(nOut, int(prefs['out']['numberDigit'])))

    dataArray = []
    subROIx = []
    subROIy = []

    # print type(prefs['cropROIx'][0])
    prefs = Transform.stitching_calcbefore(prefs)

    maxx = 0; minx = sys.maxint

    # if isinstance(prefs['series'], float):
    #     j = int (prefs['series'] - 1) #euqal to prefs.series
    #     subROIx.append(0)
    #     subROIy.append(0)
    #     dataAve = np.zeros(shape=( len(prefs[kind]['Num'][j]), len(prefs['ROIy'][j]), len(prefs['ROIx'][j]) ))
    #
    #     for iavg in range(0, len(prefs[kind]['Num'][j]) ):
    #         filename = "%s/%s%s.%s" % ( prefs['filePath'], prefs[kind]['Prefix'], paddingZero(prefs[kind]['Num'][j][iavg], prefs['numberDigit'] ), prefs[kind]['extension'] )
    #         im = Image.open(filename)
    #         imarray = np.array(im)
    #         dataAve[iavg] = imarray[int(prefs['ROIy'][j][0])-1: int(prefs['ROIy'][j][-1]) , int(prefs['ROIx'][j][0])-1 : int(prefs['ROIx'][j][0][-1])  ]
    #
    #         # if prefs['slits']['shouldCorr']:
    #             # dataAve[iavg] = slitposcorr(dataAve[iavg], prefs, j, kind, iavg)
    #
    #         if prefs['vis']['intMonitor']:
    #             _, _, _, aveint = preprocess(dataAve[iavg], prefs, j, im)
    #             monitor.append(array('d', [aveint, prefs[kind]['Num'][j][iavg]]))
    #
    #     dataArray.append(dataAve.mean(0))
    #
    #     dataArray[j], subROIx[j], subROIy[j], _ = preprocess(dataArray[j], prefs, j)

        # dataArray, minx, maxx = stitching(dataArray, prefs)

    # if isinstance(prefs['series'], array):


    for j in prefs['series']:
        j = j -1
        # dataAve = np.zeros(shape=( len(prefs[kind]['Num'][j]), len(prefs['ROIy'][j]), len(prefs['ROIx'][j])  ))

        sharedArray = Array(ctypes.c_double, len(prefs[kind]['Num'][j])*len(prefs['ROIy'][j])*len(prefs['ROIx'][j]), lock=False)
        sharedNpArray = np.frombuffer(sharedArray, dtype=ctypes.c_double)
        dataAve = sharedNpArray.reshape(len(prefs[kind]['Num'][j]), len(prefs['ROIy'][j]), len(prefs['ROIx'][j]))

        totalimage = len(prefs[kind]['Num'][j])

        # sharedMonitor = Array(ctypes.c_double, totalimage*3, lock=False)
        # sharedNpMonitor = np.frombuffer(sharedMonitor, dtype=ctypes.c_double)
        # monitor = sharedNpMonitor.reshape(totalimage, 3)

        sharedMonitor = Array(ctypes.c_double, totalimage*len(prefs['series'])*3, lock=False)
        sharedNpMonitor = np.frombuffer(sharedMonitor, dtype=ctypes.c_double)
        monitor = sharedNpMonitor.reshape(totalimage, len(prefs['series']), 3)

        step = 1
        workjob = []


        procs = totalimage/step + 1

        if step == 0:
            step =1

        for i in range(0, procs):
            process = Process(target=child, args = (i,procs, step, totalimage, prefs, kind, j, dataAve, monitor, nOut))
            workjob.append(process)

        for pIndex in workjob:
            pIndex.start()

        for pIndex in workjob:
            pIndex.join()

        dataArray.append(dataAve.mean(0).astype(int))
        subROIx.append(0)
        subROIy.append(0)
        dataArray[j], subROIx[j], subROIy[j], _ = Transform.preprocess(dataArray[j], prefs, j)

    dataResultArray, minx, maxx = Transform.stitching(dataArray, prefs)
    # print dataArray
    prefs = Transform.stitching_calcafter(prefs, minx, maxx, dataResultArray.shape[1], dataResultArray.shape[0])

    moncnt = moncnt + len(prefs[kind]['Num'][0])
    # print prefs['out']['xposInBBox'][0]

    #write dataArray to the file

    return prefs, nOut, monitor, moncnt, dataResultArray
开发者ID:kyueaes,项目名称:tomoPre,代码行数:97,代码来源:avgTransform.py


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