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


Python ImagePlus.updateAndDraw方法代码示例

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


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

示例1: Color

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import updateAndDraw [as 别名]
zscale = calib.pixelDepth
cred = Color(255, 0, 0)
cblue = Color(0, 0, 255)
xoffset = imp.getWidth()
yoffset = imp.getHeight()
for d in data:
   frame = int(d[1])
   if frame < out.getStack().getSize():
      x1 = int(round(float(d[2]) / xscale))
      y1 = int(round(float(d[3]) / yscale))
      z1 = int(round(float(d[4]) / zscale))
      x2 = int(round(float(d[5]) / xscale))
      y2 = int(round(float(d[6]) / yscale))
      z2 = int(round(float(d[7]) / zscale))
      direction = float(d[8])
      if PLOT_ONLY_IN_FRAME1:
         ip = out.getStack().getProcessor(1)
      else:
         ip = out.getStack().getProcessor(frame+1)      
      if direction <= 0:
         ip.setColor(Color(255, 100, 100))
      else:
         ip.setColor(Color(100, 100, 255))
      ip.setLineWidth(2)
      ip.drawLine(x1, y1, x2, y2)
      ip.drawLine(x1, yoffset+ z1, x2, yoffset+z2)
      ip.drawLine(xoffset+z1, y1, xoffset+z2, y2)
out.updateAndDraw()
# plot 
out.show()
开发者ID:cmci,项目名称:ijmacros,代码行数:32,代码来源:3dextractor.py

示例2: print

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import updateAndDraw [as 别名]
    # This permits file names to contains periods other than for the extension
    strName = strName.rsplit('.', 1)[:-1][0]
    print(strName)
    orig.setTitle(strName)
    cal = orig.getCalibration()
    u = cal.getUnit()
    pw = cal.pixelWidth
    if(u == scaUm):
        pw = cal.pixelWidth
        ph = cal.pixelHeight
        pw *= 1000.0
        ph *= 1000.0
        str1 = "channels=1 slices=1 frames=1 unit=nm "
        str2 = "pixel_width=%.5f pixel_height=%.5f voxel_depth=%.5f" % (pw, ph, pw) 
        IJ.run(orig,"Properties...", str1+str2)
        orig.updateAndDraw()
    if bVerbose:
        print(pw)
        
    if (pw <= 3):
        barW = 10.  # bar width, nm
    else:
        barW =  100.

    strBar = "width=%g height=%g font=%g color=%s location=[%s] bold" % (barW, barH, barF, barC, barL)
    # a hack to get the scale bars to work reliably
    foo = orig.duplicate()
    if (bSetGrayLevels == True):
        IJ.setMinAndMax(foo, gLo, gHi)    
    IJ.run(foo, "RGB Color", "")
    IJ.run(foo, "Add Scale Bar", strBar)
开发者ID:jrminter,项目名称:OSImageAnalysis,代码行数:33,代码来源:makePngFromCalibTifWithNmSb.py

示例3: __midline

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import updateAndDraw [as 别名]
	def __midline(self):
		debug=False
		#print "line 251", self.__boolML
		if self.__boolML :
			ordpoints=self.__midLine[:]
			npoints=len(ordpoints)
			xpoints=[point[0] for point in ordpoints]
			ypoints=[point[1] for point in ordpoints]
			polyOrd=PolygonRoi(xpoints, ypoints, npoints, PolygonRoi.POLYLINE)
			return polyOrd

		#if self.getMaxF()<15 : return None
			#self.__FeretAxis()
			#return self.__line

		self.__boolML=True
		self.__image.killRoi()
		self.__image.setRoi(self.__contour)
		boundRect=self.__contour.getBounds()
		boundRoi=Roi(boundRect)
		xori=boundRect.x
		yori=boundRect.y
		wori=boundRect.width
		hori=boundRect.height
		ip2 = ByteProcessor(self.__image.getWidth(), self.__image.getHeight())
		ip2.setColor(255)
		ip2.setRoi(self.__contour)
		ip2.fill(self.__contour)
		skmp=ImagePlus("ip2", ip2)
		skmp.setRoi(xori-1,yori-1,wori+1,hori+1)
		ip3=ip2.crop()
		skmp3=ImagePlus("ip3", ip3)
		skmp3.killRoi()
		#-------------------------------------------------------------
		if debug : 
			skmp3.show()
			IJ.showMessage("imp3 l287")
		#-------------------------------------------------------------
		IJ.run(skmp3, "Skeletonize (2D/3D)", "")
		#IJ.run(skmp3, "Skeletonize", "")
		#-------------------------------------------------------------
		if debug : 
			skmp3.show()
			IJ.showMessage("imp3 l294")
		#-------------------------------------------------------------
		IJ.run(skmp3, "BinaryConnectivity ", "white")
		ip3.setThreshold(3,4, ImageProcessor.BLACK_AND_WHITE_LUT)
		IJ.run(skmp3, "Convert to Mask", "")
		#-------------------------------------------------------------
		if debug : 
			skmp3.show()
			IJ.showMessage("imp3 l302")
		#-------------------------------------------------------------
		#IJ.run(skmp3, "Skeletonize", "")
		#-------------------------------------------------------------
		if debug : 
			skmp3.updateAndDraw() 
			skmp3.show()
			IJ.showMessage("imp3 l308")
		#-------------------------------------------------------------
		rawPoints=[]
		w=ip3.getWidth()
		h=ip3.getHeight()
		
		rawPoints=[(x+xori,y+yori,self.__sommeVals(x,y,ip3)) for x in range(w) for y in range(h) if ip3.getPixel(x,y)==255]
		tempbouts=[val for val in rawPoints if val[2]==2]

		if len(tempbouts)!=2 : return None
		# test
		#if len(tempbouts)!=2 :
		#	
		#	IJ.run(skmp3, "BinaryConnectivity ", "white")
		#	ip3.setThreshold(3,3, ImageProcessor.BLACK_AND_WHITE_LUT)
		#	IJ.run(skmp3, "Convert to Mask", "")
		#	#-------------------------------------------------------------
		#	if debug==debug : 
		#		skmp3.updateAndDraw() 
		#		skmp3.show()
		#		IJ.showMessage("if test l 328")
		##-------------------------------------------------------------
		#	rawPoints=[(x+xori,y+yori,self.__sommeVals(x,y,ip3)) for x in range(w) for y in range(h) if ip3.getPixel(x,y)==255]
		#	tempbouts=[val for val in rawPoints if val[2]==2]
			
		ip3.setRoi(boundRect)
		if rawPoints==[]: return None
		npoints=len(rawPoints)
		xpoints=[point[0] for point in rawPoints]
		ypoints=[point[1] for point in rawPoints]
		valpoints=[point[2] for point in rawPoints]
		
		bouts={}
		
		if tempbouts==[]: return None
		
		if tempbouts[0][1]>tempbouts[1][1]:
			bouts["A"]=tempbouts[0]
			bouts["B"]=tempbouts[1]
		else:
			bouts["A"]=tempbouts[1]
			bouts["B"]=tempbouts[0]
#.........这里部分代码省略.........
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:103,代码来源:MorphoBact.py

示例4: makeMask

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import updateAndDraw [as 别名]
	def makeMask(self):
		"""
		This function makes the mask. The steps are (1) Minimum Filter - makes a darker boundary around beads (2) Autothresholding using the Huang algorithm - has some fuzzy logic and seems to work (3) Analyze particles with a size between 500-50000 and 
		circularity between 0.4 to 1.0; The mask generated is sometimes black on beads and white around. Then I need to invert the LUTs
		"""
	
		ipOriginal = self.stack.getProcessor(self.DIC_index)
		ip = ipOriginal.duplicate()
		imgUpdate = ImagePlus("New",ip)
		imgUpdate.setProcessor("Mask",ip)
		
		img0 = ImagePlus("Before",ipOriginal)
		img0.show()
		
		# Minimum filter
		RankFilters().rank(ip,2,RankFilters.MIN)
		img1 = ImagePlus("Filter",ip)
		# Autothreshold - Huang algorithm
		hist = ip.getHistogram()
		lowTH = Auto_Threshold.Huang(hist)
		ip.setThreshold(0,lowTH, ImageProcessor.BLACK_AND_WHITE_LUT)
		img3 = ImagePlus("Thresholded",ip)
		img3.show()

		# Making a binary mask
		IJ.run(img3,"Convert to Mask","")
		
		if self._dialog("Invert Mask ??") is True: IJ.run("Invert LUT")
		img3.updateAndDraw()
		
		# The true mask after Particle Analysis; Creates a mask image around the particles
		IJ.run(img3,"Analyze Particles...", "size=500-50000 circularity=0.40-1.00 show=Masks")
		img1.close()
		#img3.close()

		# Editing the masks (filling holes and dilating it twice)
		imgActive = IJ.getImage()
		IJ.run(imgActive,"Convert to Mask","")
		IJ.run(imgActive,"Fill Holes","")
		for i in range(8): IJ.run(imgActive,"Dilate","")
		ipActive = imgActive.getProcessor().convertToFloat()
		
		# Saving the mask
		maskFname = self.sourceDir + "\\" + self.title + '_mask'
		IJ.saveAs(imgActive, "PNG", maskFname)
				
		# Confirming that the image is masked and the histogram is correct
		#IJ.run(imgActive, "Histogram", "")
		
		#stats = ipActive.getStatistics()
		pixels = ipActive.getPixels()
		self.maskPixels = [pix/255 for pix in pixels]
		self.areaMask = self.maskPixels.count(1)

		# Checking if the image is fine. If not, returns option to skip
		ImageCalculator().calculate("zero create", img0, imgActive)

		skip = False
		if self._dialog("Skip Image ??") is True: skip = True

		IJ.run("Close All")
		return self.maskPixels, skip
开发者ID:jagannath,项目名称:imageAnalysis,代码行数:64,代码来源:maskingBeads_autothreshold_v1_fiji.py

示例5: __fmaxfinder

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import updateAndDraw [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

示例6: StackCells

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

#.........这里部分代码省略.........
		zp.setMethod(ZProjector.AVG_METHOD)
		zp.doProjection() 
		imp = zp.getProjection()
		imp.show()
		if self.__fire : IJ.run(imp, "Fire", "")

	def __fmosa(self) :
		mm = MontageMaker()
		imp = mm.makeMontage2(self.__impRes, 1, self.__impRes.getStackSize(), 1, 1, self.__impRes.getStackSize(), 1, 0, False)
		imp.setTitle("MONTAGE"+self.__name)
		imp.show()
		if self.__fire : IJ.run(imp, "Fire", "")

	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)
				
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:69,代码来源:Stack_Cells.py

示例7: while

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import updateAndDraw [as 别名]
		while (doSameSlice):
			accept_waiter = NonBlockingGenericDialog("Thresholding...")
			accept_waiter.addNumericField("Threshold:",t_line,0)
			accept_waiter.setCancelLabel("Apply new threshold")
			accept_waiter.setOKLabel("Accept threshold")
			accept_waiter.showDialog()
			if (accept_waiter.wasCanceled()):
				newip.reset()
				newip.snapshot()
				t_line = accept_waiter.getNextNumber()
#				if (t_line > 10):
#					t_line = t_line - 5
#				else:
#					t_line = 5
				newip.setThreshold(0,t_line,ImageProcessor.BLACK_AND_WHITE_LUT)
				newImage.updateAndDraw()
			else:
				doSameSlice = False
				for i in range(newImage.getWidth()):
					for j in range(newImage.getHeight()):
						if (newip.getPixel(i,j) > newip.getMaxThreshold()):
							newip.putPixel(i,j,254)
						else:
							newip.putPixel(i,j,0)
				newnewip = newip.duplicate()
				newStack.addSlice(newnewip)
				newImage.close()

	castImage = ImagePlus("cast",newStack)
	castImage.show()
			
开发者ID:stalepig,项目名称:deep-mucosal-imaging,代码行数:32,代码来源:Set_cast_by_threshold.py

示例8: ConvertPixCopy

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import updateAndDraw [as 别名]
ops.convert(bgs32, imgBgs, ConvertPixCopy() )

log = ops.convolve(ops.create( dimensions2D, FloatType()), bgs32, kernel)
display.createDisplay("log", data.create(ImgPlus(log)))

otsu=ops.run("threshold", ops.create( dimensions2D, BitType()), imgBgs, Otsu())
display.createDisplay("thresholded", data.create(ImgPlus(otsu)))
'''

#Utility.clearOutsideRoi(imp, clone)
IJ.run(imp, "Auto Local Threshold", "method=MidGrey radius=15 parameter_1=0 parameter_2=0 white");
IJ.run(imp, "Fill Holes", "");
IJ.run(imp, "Close-", "");
IJ.run(imp, "Watershed", "");

iplus.updateAndDraw()

# create a hidden roi manager
roim = RoiManager(True)
	
# count the particles
countParticles(iplus, roim, 10, 200, 0.5, 1.0)

[truecolor1.getProcessor().draw(roi) for roi in roim.getRoisAsArray()]
truecolor1.updateAndDraw()
	
#Prefs.blackBackground = False;
#IJ.run("Make Binary", "");

#IJ.run("LoG 3D");
开发者ID:bnorthan,项目名称:TrueNorthImageJScripts,代码行数:32,代码来源:SpotDetection_truecolor.py


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