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


Python RoiManager.getRoisAsArray方法代码示例

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


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

示例1: resetpressed

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
		def resetpressed(event):
			self.__ranges.clear()
			self.__image=IJ.getImage()
			rm = RoiManager.getInstance()
			if (rm==None): rm = RoiManager()
			rm.runCommand("reset")
			self.__image.killRoi()
			IJ.setAutoThreshold(self.__image, "MaxEntropy")
			rt=ResultsTable()
			pa=ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET , Measurements.AREA+Measurements.ELLIPSE+Measurements.MEAN, rt, 0.00, 10000.00, 0.00, 1.00)
			pa.analyze(self.__image)
			self.__roisArray=[]
			self.__roisArray=rm.getRoisAsArray()
			#rm.runCommand("Show All")
			#rm.runCommand("Select All")
			#rm.runCommand("Set Color", "blue")
			
			IJ.resetThreshold(self.__image)
			
			keys=self.__slidersDict.keys()
			for k in keys:
				if k.endswith("min"): 
					self.__slidersDict[k].setValue(0)
					self.__slidersDict[k].repaint()
				else:
					self.__slidersDict[k].setValue(self.__slidersDict[k].getMaximum())
					self.__slidersDict[k].repaint()
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:29,代码来源:RangeRois.py

示例2: measureTumor

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
def measureTumor(original, locations):
	'''Returns the area from the original image with the 
	highest kurtosis which generally corresponds to the most
	in focus image. Also saves an image corresponding to a mask
	of the measurement.'''
	# Prevent ROI manager from appearing
	roiM = RoiManager(True)
	ParticleAnalyzer.setRoiManager(roiM)
	# Locate particles above a minimum size and with a desired circularity
	IJ.run(locations, "Analyze Particles...", "size=" + str(minimumCancerArea) +"-" + str(maxCancerArea) +" circularity=" + str(circularityCutoff) + "-1.00 show=Nothing exclude add stack");
	# Choose ROI with the highest kurtosis
	maxKurtosis = None
	area = None
	selectedROI = None
	for roi in roiM.getRoisAsArray():
		original.setRoi(roi)
		stats = original.getStatistics(Measurements.KURTOSIS, Measurements.AREA)
		currentKurtosis = stats.kurtosis
		if currentKurtosis > maxKurtosis:
			maxKurtosis = stats.kurtosis
			area = stats.area
			selectedROI = roi
	original.killRoi() # Remove the remaining ROI
	roiM.runCommand("Reset")
	return (area, selectedROI)
开发者ID:btweinstein,项目名称:bryan_imagej,代码行数:27,代码来源:getEllipticalArea_.py

示例3: RoiSelection

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
def RoiSelection():
	true=1
	false=0
	IJ.run("Invert", "stack");
	IJ.run("Fill Holes", "stack");
	IJ.run("Create Selection");
	rm = RoiManager()
	rm.runCommand("add")
	rm.runCommand("split")
	#number_selected=rm.getCount()
	IJ.run("Select None");
	rm.runCommand("deselect")
	#rm.select(0)
	#print number_selected
	roi_array=rm.getRoisAsArray()
	max_roi=None
	max_points=-1
	for roi in roi_array:
	  polygon=roi.getPolygon()
	  if polygon is not None:
	    number_of_points = polygon.npoints
	    if max_points < number_of_points:
	      max_points=number_of_points
	      max_roi=roi
	#print max_points
	#sorted_roi_array=sorted(roi_array, key=methodcaller('getLength'), reverse=True)
	#length_array=[]
	#index=0
	#for roi in roi_array:
	#	index=index+1
	#	length_array.append((index,roi.getLength()))
	#sorted_length_array=sorted(length_array, key=itemgetter(0))
	rm.runCommand("Select All")
	rm.runCommand("Delete")
	#for roi in roi_array:
	interpolated_polygon=max_roi.getInterpolatedPolygon(20,True)
	roi_polygon=PolygonRoi(interpolated_polygon,Roi.POLYGON)
	rm.addRoi(roi_polygon)
开发者ID:jmil,项目名称:MPI_Fiji_Scripts,代码行数:40,代码来源:MainProgram.py

示例4: poreDetectionUV

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]

#.........这里部分代码省略.........
	else:
		impthresholdedred=SpotDetection2(redPlus)
	
	# threshold the spots from the brightness channel
	if (fast==False):
		thresholded=SpotDetectionGray(brightness, data, display, ops, "triangle")
		impthresholded=ImageJFunctions.wrap(thresholded, "wrapped")
	else:
		impthresholded=SpotDetection2(brightnessPlus)
		
	# or the thresholding results from red and brightness channel
	impthresholded = ic.run("OR create", impthresholded, impthresholdedred);
	
	roim=RoiManager(True)
	
	# convert to mask
	Prefs.blackBackground = True
	IJ.run(impthresholded, "Convert to Mask", "")
	
	def isRed(imp, roi):
		stats = imp.getStatistics()
	
		if (stats.mean>detectionParameters.porphyrinRedPercentage): return True
		else: return False
	
	def notRed(imp, roi):
		stats = imp.getStatistics()
	
		if (stats.mean>detectionParameters.porphyrinRedPercentage): return False
		else: return True


	roiClone=inputRoi.clone()
	roiClone.setLocation(0,0)
	Utility.clearOutsideRoi(impthresholded, roiClone)

	impthresholded.show()
	
	countParticles(impthresholded, roim, detectionParameters.porphyrinMinSize, detectionParameters.porphyrinMaxSize, \
		detectionParameters.porphyrinMinCircularity, detectionParameters.porphyrinMaxCircularity)
	
	uvPoreList=[]
	for roi in roim.getRoisAsArray():
		uvPoreList.append(roi.clone())

	
	#allList=uvPoreList+closedPoresList+openPoresList
	
	# count particles that are porphyrins (red)
	porphyrinList=CountParticles.filterParticlesWithFunction(redMask, uvPoreList, isRed)
	# count particles that are visible on uv but not porphyrins
	sebumList=CountParticles.filterParticlesWithFunction(redMask, uvPoreList, notRed)

	
	# for each roi add the offset such that the roi is positioned in the correct location for the 
	# original image
	[roi.setLocation(roi.getXBase()+x1, roi.getYBase()+y1) for roi in uvPoreList]
	
	# draw the ROIs on to the image
	inputImp.getProcessor().setColor(Color.green)
	IJ.run(inputImp, "Line Width...", "line=3");
	inputImp.getProcessor().draw(inputRoi)
	IJ.run(inputImp, "Line Width...", "line=1");
	[CountParticles.drawParticleOnImage(inputImp, roi, Color.magenta) for roi in porphyrinList]
	[CountParticles.drawParticleOnImage(inputImp, roi, Color.green) for roi in sebumList]	
	inputImp.updateAndDraw()

	# calculate stats for the UV visible particles
	detectionParameters.setCalibration(APlus)
	statsDictUV=CountParticles.calculateParticleStatsUV(APlus, BPlus, redMask, roim.getRoisAsArray())
	
	totalUVPoreArea=0
	for area in statsDictUV['Areas']:
		totalUVPoreArea=totalUVPoreArea+area
	averageUVPoreArea=totalUVPoreArea/len(statsDictUV['Areas'])

	poreDiameter=0
	for diameter in statsDictUV['Diameters']:
		poreDiameter=poreDiameter+diameter
	poreDiameter=poreDiameter/len(statsDictUV['Diameters'])

	redTotal=0
	for red in statsDictUV['redPercentage']:
		redTotal=redTotal+red
	redAverage=redTotal/len(statsDictUV['redPercentage'])

	statslist=[len(porphyrinList), 100*redAverage];
	statsheader=[Messages.Porphyrins,  Messages.PercentageRedPixels]

	print("Roi Area: "+str(inputRoiArea))
	print("Total Pore Area: "+str(totalUVPoreArea))
	print("Average Pore Area: "+str(averageUVPoreArea))
	print str(len(uvPoreList))+" "+str(len(porphyrinList))+" "+str(len(sebumList))+" "+str(100*totalUVPoreArea/inputRoiArea)+" "+str(100*redAverage)
	print "cp min circularity"+str(detectionParameters.closedPoresMinCircularity)+":"+str(detectionParameters.closedPoresMinSize)

	# close the thresholded image
	impthresholded.changes=False
	impthresholded.close()
	
	return uvPoreList, statslist, statsheader
开发者ID:bnorthan,项目名称:TrueNorthImageJScripts,代码行数:104,代码来源:PoreDetectionUV.py

示例5: __calRois

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
	def __calRois(self, imp, indice) :									
		"""
		Returns the ROIs of a slice given (identified with its n°) in a stack
		"""
		##imp=self.__dictImages[nameimages]							 		# IL FAUT RÉCUPÉRER L'IMAGE DU STACK !!!!!
		#if self.__batch : imp.hide()
		#else : imp.show()
		#imp.hide()
		imp.show()
		if self.__batch : imp.hide()
		imp.setSlice(indice)
		imp.killRoi()
		ip = imp.getProcessor()

		bs=BackgroundSubtracter() 

		#if str(self.__subback) == "0" or str(self.__subback) == "1" : self.__subback = bool(int(self.__subback))
		#if self.__subback == True : IJ.run(imp, "Subtract Background...", "rolling="+str(self.__radius)+" light")
		if self.__subback == True : bs.rollingBallBackground(ip, self.__radius, False, True, False, True, False)

		if self.__runmacro :
			imp.show()
			imp.setSlice(indice)
			imp.updateAndDraw()
			IJ.runMacroFile(self.__macropath, imp.getTitle())
		
		
			
		imp.updateAndDraw()
		
		#if str(self.__manthresh) == "0" or str(self.__manthresh) == "1" : self.__manthresh = bool(int(self.__manthresh))
		
		#if self.__manthresh : IJ.setThreshold(imp, self.__minthr, self.__maxthr)
		if self.__manthresh : 
			ip.setThreshold(self.__minthr, self.__maxthr, ImageProcessor.RED_LUT)
		else : self.__setThreshold(imp, indice)
		
		rt=ResultsTable()
		pa1=ParticleAnalyzer(ParticleAnalyzer.SHOW_MASKS+ParticleAnalyzer.EXCLUDE_EDGE_PARTICLES , Measurements.AREA, rt, self.__minArea, self.__maxArea, self.__minCirc, self.__maxCirc)
		pa1.setHideOutputImage(True) 
		pa1.analyze(imp)
		
		masks=pa1.getOutputImage()
		masks.getProcessor().erode()
		masks.getProcessor().dilate()
		masks.getProcessor().invertLut()
		masks.getProcessor().threshold(1)
		
		rm = RoiManager.getInstance()
		if (rm==None): rm = RoiManager()
		rm.runCommand("reset")
		#rm.hide()
		
		pa2=ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET+ParticleAnalyzer.EXCLUDE_EDGE_PARTICLES , Measurements.AREA, rt, self.__minArea, self.__maxArea, self.__minCirc, self.__maxCirc) 
		pa2.analyze(masks)
		masks.close()
		
		temparray=rm.getRoisAsArray()
		for r in temparray :
			tempnameroi=r.getName()
			r.setPosition(indice)
			r.setName(str(indice)+"-"+tempnameroi)
			r.setStrokeWidth(1) 
		
		if len(self.__params) > 0 :
			for k in self.__params:
				#if k[0]=="Area": self.__minArea, self.__maxArea = str(k[1]), str(k[2])
				if k[0]=="Area": self.__minArea, self.__maxArea = k[1], k[2]
			for k in self.__params:
				#if k[0]=="Circ": self.__minCirc, self.__maxCirc = str(k[1]), str(k[2])
				if (k[0]=="Circ") and k[3] : self.__minCirc, self.__maxCirc = k[1], k[2]
				else : self.__minCirc, self.__maxCirc = 0, 1
			self.__rr.setRoisarray(temparray, imp)
			self.__rr.setRange(indice, self.__params)
			return self.__rr.includeRois
		else : return temparray
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:78,代码来源:BacteriaTracking.py

示例6: RoiManager

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
	preview.show()
	rm = RoiManager()
	dialog = WaitForUserDialog("Action required", "Please select regions of interest in this image. Click OK when done.")
	dialog.show()
	rm.close()
	splitter = ChannelSplitter()
	imp1 = ImagePlus("CH1", splitter.getChannel(image, imageA))
	imp2 = ImagePlus("CH2", splitter.getChannel(image, imageB))
	title = image.getTitle()
	title = title[:title.rfind('.')]
	image.close()
	preview.close()
	ch1 = ImagePlusAdapter.wrap(imp1)
	ch2 = ImagePlusAdapter.wrap(imp2)

	for roi in rm.getRoisAsArray():
		container = createContainer(roi, ch1, ch2)
		img1 = container.getSourceImage1()
		img2 = container.getSourceImage2()
		mask = container.getMask()
		
		thr1, thrimp1 = calculateThreshold(imp1, roi, methods[0])
		thr2, thrimp2 = calculateThreshold(imp2, roi, methods[1])
		
		cursor = TwinCursor(img1.randomAccess(), img2.randomAccess(), Views.iterable(mask).localizingCursor())
		rtype = img1.randomAccess().get().createVariable()
		raw = manders.calculateMandersCorrelation(cursor, rtype)
		rthr1 = rtype.copy()
		rthr2 = rtype.copy()
		rthr1.set(thr1)
		rthr2.set(thr2)
开发者ID:rejsmont,项目名称:FijiScripts,代码行数:33,代码来源:mcoloc.py

示例7: CellsSelection

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]

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

	def __show(self, event):
		IJ.run("Show Overlay", "")

	def __hide(self, event):
		IJ.run("Hide Overlay", "")

	def __showall(self, event) :
		self.__rm.runCommand("Associate", "false")
		self.__rm.runCommand("Show All")

	def __showone(self, event) : 
		self.__rm.runCommand("Associate", "true")
		self.__rm.runCommand("Show All")

	def __reset(self, event) : 
		self.__rm.runCommand("reset")
		
	def __boxaction(self, event):
		self.__setDisplay(str(event.getSource().text)+" is "+str(event.getSource().isSelected()))
		
		if event.getSource().isSelected() :  #print self.__dictFiles[event.getSource().text][1]
			#self.__rm.runCommand("reset")
			
			self.__rm.runCommand("Open", self.__dictFiles[event.getSource().text][1])
		
		
		
	def __setDisplay(self, val=""): 
		self.__display.text = str(val)

	def __split(self, event) : 
		sel = self.getSelected()
		if len(sel) != 1 : 
			IJ.showMessage("only one cell should be selected !")
			return
		else : 
			cellname = sel[0]
			rois = self.__rm.getRoisAsArray()
			self.__rm.runCommand("reset")
			n = int(IJ.getNumber("slice to split ?", 1))
			for i in range(n) : 
				self.__rm.addRoi(rois[i])
			#print self.__path+cellname+"-a.zip"
			self.__rm.runCommand("Save", self.__path+cellname+"-a.zip")
			self.__rm.runCommand("reset")
			for i in range(n, len(rois)) : 
				self.__rm.addRoi(rois[i])
			self.__rm.runCommand("Save", self.__path+cellname+"-b.zip")
			self.__rm.runCommand("reset")

		root = self.__path.rsplit(os.path.sep, 2)[0]+os.path.sep
		
		if not path.exists(root+"Cells"+os.path.sep) :os.makedirs(root+"Cells"+os.path.sep, mode=0777)

		fichiertemp = open(root+"Cells"+os.path.sep+cellname+"-a.cell","w")
		fichiertemp.write("NAMECELL="+cellname+"-a\n")
		fichiertemp.write("PATHCELL="+root+"Cells"+os.path.sep+cellname+"-a.cell\n")
		fichiertemp.write("PATHROIS="+root+"ROIs"+os.path.sep+cellname+"-a.zip\n")
		fichiertemp.write("NSLICES="+str(len(rois))+"\n")
		fichiertemp.write("SLICEINIT="+str(1)+"\n")
		fichiertemp.write("SLICEEND="+str(n)+"\n")
		r = random.randrange(5,205,1)
		g = random.randrange(10,210,1)
		b = random.randrange(30,230,1)
		fichiertemp.write("COLOR="+str(r)+";"+str(g)+";"+str(b)+"\n")
		fichiertemp.close()

		fichiertemp = open(root+"Cells"+os.path.sep+cellname+"-b.cell","w")
		fichiertemp.write("NAMECELL="+cellname+"-b\n")
		fichiertemp.write("PATHCELL="+root+"Cells"+os.path.sep+cellname+"-b.cell\n")
		fichiertemp.write("PATHROIS="+root+"ROIs"+os.path.sep+cellname+"-b.zip\n")
		fichiertemp.write("NSLICES="+str(len(rois))+"\n")
		fichiertemp.write("SLICEINIT="+str(n+1)+"\n")
		fichiertemp.write("SLICEEND="+str(len(rois))+"\n")
		r = random.randrange(5,205,1)
		g = random.randrange(10,210,1)
		b = random.randrange(30,230,1)
		fichiertemp.write("COLOR="+str(r)+";"+str(g)+";"+str(b)+"\n")
		fichiertemp.close()

		
	def getSelected(self) :
		#selected=[self.__cells[i] for i in range(len(self.__cells)) if self.__boxes[i].isSelected()]
		selected=[b.getText() for b in self.__boxes if b.isSelected()]
		return selected

	def setSelected(self, selected) :
		for b in self.__boxes : b.setSelected(False)
		#for s in selected : print str(s)
		for c in self.__cells : 
			#print str(c)
			if c in selected :
				self.__dictBox[c][1].setSelected(True)

	def resetok(self): 
		self.oked = False

	def setLabel(self, text):
		self.__label.setText(text)
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:104,代码来源:CellsSelection.py

示例8: ResultsTable

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
from ij.plugin.frame import RoiManager
from ij.plugin.filter import ParticleAnalyzer
from ij import IJ

# get active image
imp=IJ.getImage()

# set up first ROI manager
table1 = ResultsTable()
roim1=RoiManager()
pa1 = ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER, Measurements.AREA|Measurements.MEAN|Measurements.ELLIPSE, table1, 0, 100, 0, 1)
pa1.setRoiManager(roim1)
pa1.analyze(imp)

# set up second ROI manager
table2 = ResultsTable()
# Pass true to second ROI manager so it will not be seen
roim2=RoiManager(True)
pa2 = ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER, Measurements.AREA|Measurements.MEAN|Measurements.ELLIPSE, table2, 100, 500, 0, 1)
pa2.setRoiManager(roim2)
pa2.analyze(imp)

print "rois from first manager:"
for roi in roim1.getRoisAsArray(): print roi

print 
print "rois from second manager:"
for roi in roim2.getRoisAsArray(): print roi


开发者ID:bnorthan,项目名称:RogueImageJPlugins,代码行数:30,代码来源:TwoROIManagers.py

示例9: poreDetectionUV

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]

#.........这里部分代码省略.........
	# convert to mask
	Prefs.blackBackground = True
	IJ.run(impthresholded, "Convert to Mask", "")
	
	# clear the region outside the roi
	clone=inputRoi.clone()
	clone.setLocation(0,0)
	Utility.clearOutsideRoi(impthresholded, clone)
	
	# create a hidden roi manager
	roim = RoiManager(True)
	
	# count the particlesimp.getProcessor().setColor(Color.green)
	countParticles(impthresholded, roim, detectionParameters.minSize, detectionParameters.maxSize, detectionParameters.minCircularity, detectionParameters.maxCircularity)
	
	# define a function to determine the percentage of pixels that are foreground in a binary image
	# inputs:
	#    imp: binary image, 0=background, 1=foreground
	#    roi: an roi
	def isRed(imp, roi):
		stats = imp.getStatistics()
	
		if (stats.mean>detectionParameters.redPercentage): return True
		else: return False
	
	def notRed(imp, roi):
		stats = imp.getStatistics()
	
		if (stats.mean>detectionParameters.redPercentage): return False
		else: return True

	allList=[]

	for roi in roim.getRoisAsArray():
		allList.append(roi.clone())
	
	# count particles that are red
	redList=CountParticles.filterParticlesWithFunction(redMask, allList, isRed)
	# count particles that are red
	blueList=CountParticles.filterParticlesWithFunction(redMask, allList, notRed)

	print "Total particles: "+str(len(allList))
	print "Filtered particles: "+str(len(redList))

	# for each roi add the offset such that the roi is positioned in the correct location for the 
	# original image
	[roi.setLocation(roi.getXBase()+x1, roi.getYBase()+y1) for roi in allList]
	
	# create an overlay and add the rois
	overlay1=Overlay()
		
	inputRoi.setStrokeColor(Color.green)
	overlay1.add(inputRoi)
	[CountParticles.addParticleToOverlay(roi, overlay1, Color.red) for roi in redList]
	[CountParticles.addParticleToOverlay(roi, overlay1, Color.cyan) for roi in blueList]
	
	def drawAllRoisOnImage(imp, mainRoi, redList, blueList):
		imp.getProcessor().setColor(Color.green)
		IJ.run(imp, "Line Width...", "line=3");
		imp.getProcessor().draw(inputRoi)
		imp.updateAndDraw()
		IJ.run(imp, "Line Width...", "line=1");
		[CountParticles.drawParticleOnImage(imp, roi, Color.magenta) for roi in redList]
		[CountParticles.drawParticleOnImage(imp, roi, Color.green) for roi in blueList]
		imp.updateAndDraw()
	
开发者ID:bnorthan,项目名称:TrueNorthImageJScripts,代码行数:69,代码来源:PoreDetectionUV.py

示例10: open

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
IJ.log("-------start at "+now+"  ------")


#for cell in listfilescells :
f1 = open(rootdir+now+"-R1-MT.txt", "w")
tab="\t"
f1.write("cell"+tab+"maxFrames"+tab+"maxcumul"+tab+"nrevs"+"\n")

for cle in listcellname :
	rm.runCommand("reset")
	#cle = cell.rsplit("/", 1)[1][:-len(".cell")]
	#cles.append(cle)
	rm.runCommand("Open", dictRois[cle])
	rm.runCommand("Show None")
	RawroisArray=rm.getRoisAsArray()
	if len(RawroisArray)< minLife : continue
	roisArray=[RawroisArray[i] for i in range(0,len(RawroisArray), subs)]
	IJ.showStatus(cle)
	IJ.showProgress(listcellname.index(cle), len(listcellname)) 

	dxA=[]
	dyA=[]
	dxB=[]
	dyB=[]
	dA=[]
	dB=[]

	sensA = 1
	sensB = -1
	nrev = 0
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:32,代码来源:Myxo_Track.py

示例11: StackCells

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]

#.........这里部分代码省略.........
		self.__isD = self.__impD.getImageStack()
		self.__display.text = "DIA="+self.__impD.getTitle()
		self.__initDIA = True

	def __fluo(self, event): 
		IJ.run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel")
		self.__impF = IJ.getImage()
		self.__isF = self.__impF.getImageStack()
		self.__display.text = "FLUO="+self.__impF.getTitle()
		self.__initFLUO = True

	def __addroi(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

		twres = TextWindow("measures-"+self.__name, "label\tname\tsol\tarea\tcirc\tAR\tFeret\taxis\traf\tdMajor\tdFeret\tdArea", "", 300, 450)
		tab="\t"
		
		self.__widthl = self.__display2.getText()
		IJ.selectWindow(self.__impF.getTitle())

		self.__rm = RoiManager.getInstance()
		if (self.__rm==None): self.__rm = RoiManager()

		if self.__impF.getImageStackSize() > 1 :
			roisarray =[(roi, self.__rm.getSliceNumber(roi.getName())) for roi in self.__rm.getRoisAsArray()]
		else : 
			roisarray =[(roi, 1) for roi in self.__rm.getRoisAsArray()]
			
		self.__rm.runCommand("reset")
		#self.__rm.runCommand("Delete")
		IJ.selectWindow(self.__impF.getTitle())

		self.__maxraf=float(self.__display19.text)
		self.__minraf=float(self.__display20.text)

		count=1

		for roielement in roisarray :
			roi = roielement[0]
			pos = roielement[1]
			lab = self.__impF.getImageStack().getShortSliceLabel(pos)

			if lab==None : lab=str(pos)
			
			if self.__conEllipses :
				IJ.selectWindow(self.__impF.getTitle())
				self.__impF.setSlice(pos)
				self.__impF.setRoi(roi)
				self.__rm.runCommand("Add")
				IJ.run(self.__impF,  "Fit Ellipse", "")
				ellipse=self.__impF.getRoi()
				params = ellipse.getParams()
				ferets = ellipse.getFeretValues()
				imp2 = Duplicator().run(self.__impF,pos,pos)
				IJ.run(imp2, "Rotate... ", "angle="+str(ferets[1])+" grid=0 interpolation=Bilinear enlarge slice")
				temproi=Roi((imp2.getWidth()-ferets[0])/2.0,(imp2.getHeight()-ferets[2])/2.0,ferets[0],ferets[2])
				imp2.setRoi(temproi)
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:70,代码来源:Stack_Cells.py

示例12: main

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
def main():

    # Get active dataset
    #img = IJ.getImage()
    display = displayservice.getActiveDisplay()
    active_dataset = imagedisplayservice.getActiveDataset(display)

    if not active_dataset:
        IJ.showMessage('No image opened.')
        return

    # Get image path
    fname = active_dataset.getSource()
    dir_path = os.path.dirname(fname)

    if not fname:
        IJ.showMessage('Source image needs to match a file on the system.')
        return

    # Open ROIs
    rois = RoiManager.getInstance()
    if not rois:
        roi_path = os.path.join(dir_path, "RoiSet.zip")
        if not os.path.isfile(roi_path):
            try:
                roi_path = glob.glob(os.path.join(dir_path, "*.roi"))[0]
            except:
                roi_path = None

        if not roi_path:
            IJ.showMessage('No ROIs. Please use Analyze > Tools > ROI Manager...')
            return

        rois = RoiManager(True)
        rois.reset()
        rois.runCommand("Open", roi_path)

    IJ.log('Image filename is %s' % fname)
    dt = get_dt(active_dataset)

    rois_array = rois.getRoisAsArray()
    for i, roi in enumerate(rois_array):

        crop_id = i + 1
        IJ.log("Croping %i / %i" % (crop_id, len(rois_array)))

        # Get filename and basename of the current cropped image
        crop_basename = "crop%i_%s" % (crop_id, active_dataset.getName())
        crop_basename = os.path.splitext(crop_basename)[0] + ".ome.tif"
        crop_fname = os.path.join(os.path.dirname(fname), crop_basename)

        # Get bounds and crop
        bounds = roi.getBounds()
        dataset = crop(ij, datasetservice, active_dataset,
                       bounds.x, bounds.y, bounds.width,
                       bounds.height, crop_basename)

        # Show cropped image
        ij.ui().show(dataset.getName(), dataset)

        # Save cropped image (ugly hack)
        IJ.log("Saving crop to %s" % crop_fname)

        imp = IJ.getImage()
        bfExporter = LociExporter()
        macroOpts = "save=[" + crop_fname + "]"
        bfExporter.setup(None, imp)
        Macro.setOptions(macroOpts)
        bfExporter.run(None)

        imp.close()

    IJ.log('Done')
开发者ID:pombredanne,项目名称:fiji_tools,代码行数:75,代码来源:Crop_Multi_Roi.py

示例13: segmentation

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
def segmentation(imp, spot_data, channel, diameter_init, ES_tolerance, ES_area_max, ES_ctrl_pts, ES_iteration, repeat_max):
    # Open files
    cal = imp.getCalibration()
    manager = RoiManager.getInstance()
    if manager is None:
        manager = RoiManager()
    # Prepare log files for output
    options = IS.MEDIAN | IS.AREA | IS.MIN_MAX | IS.CENTROID | IS.PERIMETER | IS.ELLIPSE | IS.SKEWNESS
    convergence = []
    Sintensity = []
    for spot in spot_data:
        repeat = 0
        flag = False
        spotID = int(spot[0])
        Xcenter = (float(spot[1]) / cal.pixelWidth)
        Ycenter = (float(spot[2]) / cal.pixelHeight)
        Quality = float(spot[3])
        diameter_init = float(spot[4] / cal.pixelWidth) * 2.0
        while True:
            manager = RoiManager.getInstance()
            if manager is None:
                manager = RoiManager()
            Xcurrent = int(Xcenter - diameter_init / 2.0)
            Ycurrent = int(Ycenter - diameter_init / 2.0)
            Dcurrent1 = int(diameter_init * (1.2 - repeat / 10.0))
            Dcurrent2 = int(diameter_init * (0.8 + repeat / 10.0))
            roi = OvalRoi(Xcurrent, Ycurrent, Dcurrent1, Dcurrent2)
            imp.setPosition(channel)
            imp.setRoi(roi)
            Esnake_options1 = "target_brightness=Bright control_points=" + \
                str(ES_ctrl_pts) + " gaussian_blur=0 "
            Esnake_options2 = "energy_type=Contour alpha=2.0E-5 max_iterations=" + \
                str(ES_iteration) + " immortal=false"
            IJ.run(imp, "E-Snake", Esnake_options1 + Esnake_options2)
            roi_snake = manager.getRoisAsArray()
            roi_ind = len(roi_snake) - 1
            stats = IS.getStatistics(
                imp.getProcessor(), options, imp.getCalibration())
            perimeter = roi_snake[roi_ind].getLength() * cal.pixelWidth
            circularity = 4.0 * 3.1417 * (stats.area / (perimeter * perimeter))
            if stats.area > 17.0 and stats.area < ES_area_max and stats.skewness < -0.01 and circularity > 0.01 and stats.minor > 2.0 and boundaries(Xcenter, Ycenter, stats.xCentroid / cal.pixelWidth, stats.yCentroid / cal.pixelHeight, ES_tolerance):
                Sintensity = stats.median
                convergence.append(True)
                break
            if stats.median > 6000 and stats.area > 17.0 and stats.area < ES_area_max:
                Sintensity = stats.median
                convergence.append(True)
                break
            elif repeat > repeat_max:
                manager.select(imp, roi_ind)
                manager.runCommand(imp, 'Delete')
                roi = OvalRoi(Xcenter + 1.0 - diameter_init / 2.0, Ycenter +
                              1.0 - diameter_init / 2.0, diameter_init, diameter_init)
                imp.setRoi(roi)
                manager.add(imp, roi, spotID)
                roi_snake.append(roi)
                stats = IS.getStatistics(
                    imp.getProcessor(), options, imp.getCalibration())
                Sintensity = stats.median
                convergence.append(False)
                break
            else:
                IJ.log('Area=' + str(stats.area) + '  Skewness=' + str(stats.skewness) +
                       ' circularity=' + str(circularity) + ' Minor=' + str(stats.minor))
                manager.select(imp, roi_ind)
                manager.runCommand(imp, 'Delete')
                repeat += 1
        # End Spot-segmentation
    # End all Spots-segmentation
    manager.runCommand(imp, 'Show All')
    imp.setPosition(channel)
    color = imp.createImagePlus()
    ip = imp.getProcessor().duplicate()
    color.setProcessor("segmentation" + str(channel), ip)
    color.show()
    IJ.selectWindow("segmentation" + str(channel))
    manager.moveRoisToOverlay(color)
    spot_optimal = manager.getRoisAsArray()
    manager.reset()
    for i in xrange(0, len(spot_optimal)):
        spot = spot_optimal[i]
        spot.setStrokeWidth(2)
        if convergence[i]:
            spot.setStrokeColor(Color.GREEN)
        else:
            spot.setStrokeColor(Color.MAGENTA)
        imp.setRoi(spot)
        manager.add(imp, spot, i)
    manager.runCommand(imp, 'Show All')
    imp.setPosition(channel)
开发者ID:jpabbuehl,项目名称:CSC_submission,代码行数:92,代码来源:processing_exemple.py

示例14: BitType

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
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");

#IJ.run("Duplicate...", "title="+"test")
#IJ.run("RGB Stack");
#IJ.run("Convert Stack to Images");
开发者ID:bnorthan,项目名称:TrueNorthImageJScripts,代码行数:33,代码来源:SpotDetection_truecolor.py

示例15: updatepressed

# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getRoisAsArray [as 别名]
		def updatepressed(event):
			self.__image=IJ.getImage()
			rm = RoiManager.getInstance()
			if (rm==None): rm = RoiManager()
			rm.runCommand("reset")
			self.__image.killRoi()
			IJ.run("Threshold...")
			IJ.setAutoThreshold(self.__image, "MaxEntropy")
			
			rt=ResultsTable()
			pa=ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET , Measurements.AREA+Measurements.ELLIPSE+Measurements.MEAN, rt, 0.00, 10000.00, 0.00, 1.00)
			pa.analyze(self.__image)
			self.__roisArray=[]
			self.__roisArray=rm.getRoisAsArray()
			#for i in range(rm.getCount()) : 
			#	rm.select(i)
			#	rm.runCommand("Set Color", "0000FF", 2)
				
			IJ.resetThreshold(self.__image)
			rt.show("tempRT")
			areas=rt.getColumn(ResultsTable.AREA)
			means=rt.getColumn(ResultsTable.MEAN)
			majors=rt.getColumn(ResultsTable.MAJOR)
			minors=rt.getColumn(ResultsTable.MINOR)
			#print 0
			if self.__slidersDict["Area_max"].getMaximum() <  int(max(areas)+1):
			#	print 1
				self.__slidersDict["Area_max"].setMaximum(int(max(areas))+1)
			if self.__slidersDict["Area_min"].getMaximum() < int(max(areas)+1):
			#	print 2
				self.__slidersDict["Area_min"].setMaximum(int(max(areas))+1)
			if self.__slidersDict["Mean_max"].getMaximum() < int(max(means)+1):
			#	print 3
				self.__slidersDict["Mean_max"].setMaximum(int(max(means))+1)
			if self.__slidersDict["Mean_min"].getMaximum() < int(max(means)+1):
			#	print 4
				self.__slidersDict["Mean_min"].setMaximum(int(max(means))+1)
			if self.__slidersDict["Major_max"].getMaximum() < int(max(majors)):
			#	print 5
				self.__slidersDict["Major_max"].setMaximum(int(max(majors))+1)
			if self.__slidersDict["Major_min"].getMaximum() < int(max(majors)+1):
			#	print 6
				self.__slidersDict["Major_min"].setMaximum(int(max(majors))+1)
			if self.__slidersDict["Minor_max"].getMaximum() < int(max(minors)+1):
			#	print 7
				self.__slidersDict["Minor_max"].setMaximum(int(max(minors))+1)
			if self.__slidersDict["Minor_min"].getMaximum() < int(max(minors)+1):
			#	print 8
				self.__slidersDict["Minor_min"].setMaximum(int(max(minors))+1)
			if self.__slidersDict["AR_max"].getMaximum() < int((max(majors)+1)/min(minors)+1):
			#	print 9
				self.__slidersDict["AR_max"].setMaximum(int((max(majors)+1)/(min(minors))))
			if self.__slidersDict["AR_min"].getMaximum() < int((max(majors)+1)/min(minors)):
			#	print 10
				self.__slidersDict["AR_min"].setMaximum(int((max(majors)+1)/(min(minors))))

			#print 11
				
			for sb in self.__slidersDict.values():
				sb.repaint()

			#rm.runCommand("reset")
			#temprois=self.getIncludeRois()
			#IJ.run(self.__image, "Remove Overlay", "")
			#o=Overlay()
			#for roi in temprois:
			#	o.addElement(roi)
			#self.__image.killRoi()
			#self.__image.setOverlay(o)
			self.__image.updateAndDraw()
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:72,代码来源:RangeRois.py


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