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


Python ImagePlus.setSlice方法代码示例

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


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

示例1: __fmaxfinder

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setSlice [as 别名]
	def __fmaxfinder(self) :
		#stack = self.__impRes.getStack()
		self.__impD.killRoi()
		self.__impF.killRoi()
		stack = self.__impF.getStack()
		n_slices = stack.getSize()
		#newstack=ImageStack(self.__impRes.getWidth(), self.__impRes.getHeight())
		newstack=ImageStack(self.__impF.getWidth(), self.__impF.getHeight())
		noise = self.__display3.text
		for index in range(1,n_slices+1):
			IJ.selectWindow(self.__impF.getTitle())
			self.__impF.setSlice(index)
			ip = self.__impF.getProcessor()
			mf=MaximumFinder()
			ipmax = mf.findMaxima(ip, int(noise), 0, 0, False, False)
			newstack.addSlice("", ipmax)
			

		newimage=ImagePlus("max points"+self.__name, newstack)
		newimage.show()
		newimage.updateAndDraw()
		
		listip = []
		maxh=self.__impRes.getHeight()

		for roi in self.__cellsrois : 
			straightener = Straightener()
			newimage.setSlice(roi[1])
			newimage.setRoi(roi[0])
			#listip.append(straightener.straighten(newimage, roi[0], int(self.__widthl)))
			listip.append(straightener.straighten(newimage, roi[0], maxh))
		
		ipw=[ ip.getWidth() for ip in listip ]
		iph=[ ip.getHeight() for ip in listip ]
		maxw=max(ipw)
		maxh=max(iph)
		
		if self.__enlarge : resizelist = [ ip.resize(maxw, maxh, True) for ip in listip ]
		
		elif  self.__alignC : 
			resizelist = []
			for ip in listip :
				tempip = ByteProcessor(maxw, maxh)
				tempip.copyBits(ip, 0, 0, Blitter.COPY)
				resizelist.append(tempip)

		else :
			resizelist = []
			for ip in listip :
				tempip = ByteProcessor(maxw, maxh)
				tempip.copyBits(ip, 0, 0, Blitter.COPY)
				resizelist.append(tempip)
				
		ims = ImageStack(maxw, maxh) 	
		
		#for ip in resizelist : ims.addSlice("", ip)
		for i in range(len(resizelist)) : 
			ims.addSlice(self.__labels[i], resizelist[i])
		
		self.__impMax = ImagePlus(self.__name+"-max", ims)
		self.__impMax.show()
		stack = self.__impMax.getStack() # get the stack within the ImagePlus
		n_slices = stack.getSize()
		
		for index in range(1, n_slices+1):
			self.__impMax.killRoi()	
			self.__impMax.setSlice(index)
			roi = self.__listrois[index-1]
			
			if self.__sens[index-1]<0 : 
				self.__impMax.setRoi(roi)
				ip1 = self.__impMax.getProcessor()
				ip1.flipHorizontal()
				self.__impMax.killRoi()
				self.__impMax.updateAndDraw()

			ip = self.__impMax.getProcessor()
			for i in range(ip.getWidth()*ip.getHeight()) :
				if ip.getf(i) > 0 : ip.setf(i, 255)
				#else : ip.setf(i, 0)

		IJ.run(self.__impMax, "8-bit", "")
		IJ.run(self.__impMax, "Options...", "iterations=2 count=1 black edm=Overwrite do=Close stack")
		IJ.run(self.__impMax, "Ultimate Points", "stack")
		
		self.__impMax.updateAndDraw()
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:88,代码来源:Stack_Cells.py

示例2: ImageStack

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setSlice [as 别名]
if theImage.getNSlices() > 1:
	iStack = ImageStack(theImage.getWidth(),theImage.getHeight())
	for sl in range(theImage.getNSlices()):
		sliceIp = ByteProcessor(theImage.getWidth(),theImage.getHeight())
		iStack.addSlice(sliceIp)
	maskImage = ImagePlus("maskImage",iStack)

	## Gets the user-defined ROIs; user can add in any order to image
	sliceList = []
	gd  = NonBlockingGenericDialog("Select freehand ROI, then hit OK when ready to store")
	gd.showDialog()
	while gd.wasOKed():
		roi = theImage.getRoi()
		if roi is not None:
			currSlice = theImage.getCurrentSlice()
			maskImage.setSlice(currSlice)
			currIp = maskImage.getProcessor()
			currIp.setRoi(roi)
			currIp.setColor(255)
			currIp.fill(currIp.getMask())
			sliceList.append(currSlice)
			theImage.setSlice(currSlice+1)
			
		gd  = NonBlockingGenericDialog("Select freehand ROI, then hit OK when ready to store")
		gd.showDialog()

	## Does simple interpolation of the ROIs through the stack
	if len(sliceList)>0:
		sliceList.sort(reverse=True)
		for sl in range(theImage.getNSlices()):
			if (sl+1) < sliceList[-1]:
开发者ID:stalepig,项目名称:deep-mucosal-imaging,代码行数:33,代码来源:Isolate_stack_ROI.py

示例3: StackCells

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setSlice [as 别名]

#.........这里部分代码省略.........

	def __new(self, event): 
		self.__init = True
		self.__n += 1
		self.__name = "stackcells"+str(self.__n)
		self.__display.text = self.__name
		self.__sens[:] = []
		self.__listrois[:] = []
		self.__iplist[:] = []
		self.__cellsrois[:] = []
		self.__labels[:] = []

	def __add(self, event): 
		if ( not self.__init) : 
			IJ.showMessage("", "please start a new stack")
			return
		if ( not self.__initDIA) :
			IJ.showMessage("", "please select an image for DIA")
			return

		if ( not self.__initFLUO) :
			IJ.showMessage("", "please select an image for FLUO")
			return
		
		self.__widthl = self.__display2.getText()
		roi = self.__impD.getRoi()
		
		if roi == None : 
			IJ.showMessage("", "No selection")
			return

		if roi.getType() in [6,7] : 		
			nslice = self.__impD.getCurrentSlice()
			self.__impF.setSlice(nslice)
			self.__impF.setRoi(roi)
		elif roi.getType() in [2,4] :
			nslice = self.__impD.getCurrentSlice()
			self.__impF.setSlice(nslice)
			m=Morph(self.__impF, roi)
			m.setMidParams(10, 2)
			roi=m.MidAxis
			if roi == None :
				self.__display.text = "roi fail"
				if not self.__skip : IJ.showMessage("", "failed roi, please draw it as polyline")
				return				

		#if roi.getType() != 6 : self.__impF.setRoi(roi)
		else : 
			IJ.showMessage("", "This selection is not yet allowed")
			return

		self.__impF.setRoi(roi)
		
		straightener = Straightener()
		new_ip = straightener.straighten(self.__impF, roi, int(self.__widthl))
		
		self.__iplist.append(new_ip)
		self.__labels.append(self.__isF.getShortSliceLabel(nslice))
		
		self.__display.text = self.__name + " cell " + str(len(self.__iplist)) +" width="+str(new_ip.getWidth())+ " height="+ str(new_ip.getHeight())
		roi.setPosition(self.__impD.getCurrentSlice())	

		self.__rm = RoiManager.getInstance()
		if (self.__rm==None): self.__rm = RoiManager()
		
		self.__rm.add(self.__impD, roi, len(self.__iplist))
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:70,代码来源:Stack_Cells.py


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