本文整理汇总了Python中ij.ImageStack.setProcessor方法的典型用法代码示例。如果您正苦于以下问题:Python ImageStack.setProcessor方法的具体用法?Python ImageStack.setProcessor怎么用?Python ImageStack.setProcessor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.ImageStack
的用法示例。
在下文中一共展示了ImageStack.setProcessor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RoiManager
# 需要导入模块: from ij import ImageStack [as 别名]
# 或者: from ij.ImageStack import setProcessor [as 别名]
refpath = os.path.join(refdir, reffn)
refImp = IJ.openImage(refpath)
width = refImp.width
height = refImp.height
roim = RoiManager()
roim.runCommand("open", roipath)
roiArray = roim.getRoisAsArray()
nRoi = len(roiArray)
roim.close()
bwStack = ImageStack(width, height, nRoi)
for i in xrange(1, nRoi+1):
bwStack.setProcessor(FloatProcessor(width, height, zeros('f', width * height), None), i)
for i in xrange(1, nRoi+1):
roi = roiArray[i-1]
fp = bwStack.getProcessor(i)
fp.setValue(1.0)
fp.fill(roi)
roiImp = ImagePlus("roi", bwStack)
outfn = "roi_" + os.path.splitext(roifn)[0] + ".tif"
outpath = os.path.join(roidir, outfn)
if os.path.exists(outpath):
print "Skipped, already exists: ", outfn
else:
IJ.saveAsTiff(roiImp, outpath)
示例2: regBf
# 需要导入模块: from ij import ImageStack [as 别名]
# 或者: from ij.ImageStack import setProcessor [as 别名]
#.........这里部分代码省略.........
refImp = ImagePlus("ref", stack.getProcessor(imp.getStackIndex(refC, refZ, refT)))
refWin.setImage(refImp)
tr = TurboReg_()
for t in xrange(1, nFrames+1):
IJ.showProgress(t-1, nFrames)
# print "t ", t
# do TurboReg on reference channel
toRegId = imp.getStackIndex(refC, refZ, t)
toRegImp = ImagePlus("toReg", stack.getProcessor(toRegId))
toRegWin.setImage(toRegImp)
regArg = "-align " +\
"-window " + toRegImp.getTitle() + " " +\
"0 0 " + str(width - 1) + " " + str(height - 1) + " " +\
"-window " + refImp.getTitle() + " " +\
"0 0 " + str(width - 1) + " " + str(height - 1) + " " +\
"-rigidBody " +\
str(width / 2) + " " + str(height / 2) + " " +\
str(width / 2) + " " + str(height / 2) + " " +\
"0 " + str(height / 2) + " " +\
"0 " + str(height / 2) + " " +\
str(width - 1) + " " + str(height / 2) + " " +\
str(width - 1) + " " + str(height / 2) + " " +\
"-hideOutput"
tr = TurboReg_()
tr.run(regArg)
registeredImp = tr.getTransformedImage()
sourcePoints = tr.getSourcePoints()
targetPoints = tr.getTargetPoints()
registeredStack.setProcessor(registeredImp.getProcessor(), toRegId)
# toRegImp.flush()
# apply transformation on other channels
for c in xrange(1, nChannels+1):
# print "c ", c
if c == refC:
continue
toTransformId = imp.getStackIndex(c, 1, t)
toTransformImp = ImagePlus("toTransform", stack.getProcessor(toTransformId))
toTransformWin.setImage(toTransformImp)
transformArg = "-transform " +\
"-window " + toTransformImp.getTitle() + " " +\
str(width) + " " + str(height) + " " +\
"-rigidBody " +\
str(sourcePoints[0][0]) + " " +\
str(sourcePoints[0][1]) + " " +\
str(targetPoints[0][0]) + " " +\
str(targetPoints[0][1]) + " " +\
str(sourcePoints[1][0]) + " " +\
str(sourcePoints[1][1]) + " " +\
str(targetPoints[1][0]) + " " +\
str(targetPoints[1][1]) + " " +\
str(sourcePoints[2][0]) + " " +\
str(sourcePoints[2][1]) + " " +\
str(targetPoints[2][0]) + " " +\
str(targetPoints[2][1]) + " " +\
"-hideOutput"
tr = TurboReg_()
tr.run(transformArg)
registeredStack.setProcessor(tr.getTransformedImage().getProcessor(), toTransformId)
# toTransformImp.flush()
sourcePoints = None
targetPoints = None
IJ.showProgress(t, nFrames)
IJ.showStatus("Frames registered: " + str(t) + "/" + str(nFrames))
refWin.close()
toRegWin.close()
toTransformWin.close()
imp2 = ImagePlus("reg_"+imp.getTitle(), registeredStack)
imp2.setCalibration(imp.getCalibration().copy())
imp2.setDimensions(nChannels, nSlices, nFrames)
# print "type ", imp.getType()
# print "type ", imp2.getType()
# print nChannels, " ", nSlices, " ", nFrames
# print registeredStack.getSize()
for key in imp.getProperties().stringPropertyNames():
imp2.setProperty(key, imp.getProperty(key))
# comp = CompositeImage(imp2, CompositeImage.COLOR)
# comp.show()
# imp2 = imp.clone()
# imp2.setStack(registeredStack)
# imp2.setTitle("reg"+imp.getTitle())
# imp2.show()
# imp.show()
return imp2