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


Python ImageStack.getProcessor方法代码示例

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


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

示例1: RoiManager

# 需要导入模块: from ij import ImageStack [as 别名]
# 或者: from ij.ImageStack import getProcessor [as 别名]
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)
开发者ID:singingstars,项目名称:lab-program,代码行数:31,代码来源:roi.to.mask_.py

示例2: run

# 需要导入模块: from ij import ImageStack [as 别名]
# 或者: from ij.ImageStack import getProcessor [as 别名]
def run():
	""" Loads an image stack which contains both reference and target images for the registration
		Scales the images to have their largest side equal to longSide
		Registration is performed:
			- translation (brute force optimization)
			- rotation (brute force optimization)
			- sift registration
			- bunwarpj registration
		Calculation of the errors by different methods """

	# load the input stack as an ImagePlus
	imp = IJ.openImage(filePath.getAbsolutePath())
	stack = imp.getStack()
	sizeZ = imp.getStackSize()

	LAND_MARKS = 0

	# Copy the reference and target slice
	refId = 1
	ref = stack.getProcessor(refId).duplicate()

	if (Scale == 1):
		[ref, s] = scaleLongSide(ref, longSide)

	sizeZ = min(sizeZ, maxSlice)
	stackReg = ImageStack(ref.getWidth(), ref.getHeight())
	stackReg.addSlice(ref)
# = stack.duplicate()
	for i in range(2, sizeZ+1):
		targetId = i
		target = stack.getProcessor(targetId).duplicate()

		# Scale the slices: scale the reference slice using the longSide parameter, and use the same scale for the target slice.
		if (Scale == 1):
			target = scale(target, s)
			#ImagePlus('Ref',ref).show()
			#ImagePlus('Target',target).show()
	
		if (Reg == 1):
	
			if (translationReg == 1):
				target = translation(ref, target)
	
			if (rotationReg == 1):
				[rot, target] = rotationSingle(ref,target,rotationStep)
	
			if (siftReg == 1):
				[roiRef, roiTarget] = siftSingle(ref, target)
				impTarget = ImagePlus('Target',target)
				impTarget.setRoi(roiTarget)
				#impTarget.show()
				impRef = ImagePlus('Ref',ref)
				impRef.setRoi(roiRef)
				#impRef.show()
				LAND_MARKS = 1

			if (bunwarpjReg == 1):
				target = bunwarpjSingle(impRef, impTarget, LAND_MARKS, 'direct_transfo_' + str(i) + '.txt', 'inverse_transfo_' + str(i) + '.txt')
				impTarget = ImagePlus('unwarpj_target', target)
				#impTarget.show()
				fileName = 'target_id' + str(targetId) + '.tif'
				IJ.saveAs(impTarget, "Tiff", os.path.join(saveDir.getAbsolutePath(), fileName))

			#stackReg.setProcessor(target.convertToShortProcessor(), i)
			stackReg.addSlice(target)

	if (calculateError == 1):
		eCorrelation = zeros(sizeZ, 'f')
		eMSE = zeros(sizeZ, 'f')
		eMSE_ROI = zeros(sizeZ, 'f')
		eRMSE = zeros(sizeZ, 'f')
		eNRMSE = zeros(sizeZ, 'f')
		eCVRMSE = zeros(sizeZ, 'f')
		for i in range(1, sizeZ+1):
			ip = stackReg.getProcessor(i).duplicate()
			#ImagePlus('test',ip).show()
			eCorrelation[i-1], eMSE[i-1], eMSE_ROI[i-1], eRMSE[i-1], eNRMSE[i-1], eCVRMSE[i-1] = measureError(ref,ip)
		errorFileName = 'error.txt'
		errorFilePath = os.path.join(saveDir.getAbsolutePath(), errorFileName)
		writeCSV( errorFilePath, [eCorrelation,eMSE, eMSE_ROI, eRMSE,eNRMSE,eCVRMSE], ["Correlation","MSE","MSE_ROI","RMSE","N_RMSE","CV_RMSE"] )
开发者ID:mbarbie1,项目名称:fiji-registration-plugins,代码行数:82,代码来源:registration_v5.py

示例3: IP

# 需要导入模块: from ij import ImageStack [as 别名]
# 或者: from ij.ImageStack import getProcessor [as 别名]
	#ipMIP = newMIPImp.getProcessor()
	#EDM().toEDM( ipMIP.convertToByte(True) )
	#imgMIP = IP( "MIP", ipMIP )
	#imgMIP.show()
	#break

	print 'Converting to 8 bit...'
	stack = newImp.getStack()
	for s in range( 0, slices ):
		ip = stack.getProcessor(s+1)
		label = stack.getSliceLabel(s+1)
		ip.resetMinAndMax()
		newStack.addSlice( label, ip.convertToByte(True) )
		IJ.showProgress(s+1, slices)

	print 'Applying ultimate erosion...'
	EDMStack = IMGS( imp.getWidth(), imp.getHeight() )
	for s in range( 0, slices ):
		ip = newStack.getProcessor(s+1)
		EDM().toEDM( ip )
		#EDM().run( ip )
		EDMStack.addSlice( label, ip )
		IJ.showProgress(s+1, slices)

	imp.setStack( EDMStack )
	imp.show()
	
	#fs = FileSaver( imp )
	#print "Saving to", outputPath
	#fs.saveAsTiff( outputPath )
	
开发者ID:AlexisMaizel,项目名称:Virtual_Lateral_Roots,代码行数:32,代码来源:ultimateErosion.py


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