本文整理汇总了Python中Transform.stitching_calcafter方法的典型用法代码示例。如果您正苦于以下问题:Python Transform.stitching_calcafter方法的具体用法?Python Transform.stitching_calcafter怎么用?Python Transform.stitching_calcafter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.stitching_calcafter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: projTransform
# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import stitching_calcafter [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'
#.........这里部分代码省略.........
示例2: avgTransform
# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import stitching_calcafter [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