本文整理汇总了Python中ij.plugin.frame.RoiManager.getName方法的典型用法代码示例。如果您正苦于以下问题:Python RoiManager.getName方法的具体用法?Python RoiManager.getName怎么用?Python RoiManager.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.plugin.frame.RoiManager
的用法示例。
在下文中一共展示了RoiManager.getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __displayCells
# 需要导入模块: from ij.plugin.frame import RoiManager [as 别名]
# 或者: from ij.plugin.frame.RoiManager import getName [as 别名]
def __displayCells(self, nameimage, methodeleon=False):
"""
Displays all the ROIs of the cells with different colors
"""
# we define a list of colors that will be used.
colors = []
ncells= len(self.__dict[nameimage])
if ncells > 0 :
step=200/ncells
if step<1 : step=1
for i in range(ncells) :
r = random.randrange(5,205,step)
g = random.randrange(10,210,step)
b = random.randrange(30,230,step)
#r = int(0+i*step)
#g = random.randrange(10, 190, 30)
#b = int(250-i*step)
colors.append(Color(r, g, b))
else : colors=[Color.blue, Color.green, Color.magenta, Color.orange, Color.yellow]
tempcolors=list(colors)
# we try to have random and different colors for each cell.
for cellname in self.__dict[nameimage].keys() :
if len(tempcolors)>0 :
self.__dict[nameimage][cellname].setColor(tempcolors.pop(0))
else :
tempcolors=list(colors)
self.__dict[nameimage][cellname].setColor(tempcolors.pop(0))
self.__SaveCells(nameimage)
rm = RoiManager.getInstance()
if (rm==None): rm = RoiManager()
rm.runCommand("reset")
# if the user wants to save files, .zip for the ROIs are saved.
#if self.__optionSave == True :
#os.mkdir(self.__pathdir+"ROIs/", mode=0777)
os.makedirs(self.__pathdir+"ROIs/", mode=0777)
tempimp = IJ.createImage("tempimp", "8-bit Black", self.__dictImages[nameimage].getWidth(), self.__dictImages[nameimage].getHeight(), 1)
tempimp.show()
for cellname in self.__dict[nameimage].keys() :
for numslice in range(self.__dictImages[nameimage].getImageStackSize()) :
r = self.__dict[nameimage][cellname].getRoi(numslice)
try :
name=r.getName()
except AttributeError : continue
else :
s = "%04i" % (numslice+1)
#name=s+"-"+name.split("-", 1)[1]
name=s+"-cell"+name.split("cell")[1]
r.setName(name)
try :
rm.addRoi(r)
rname=rm.getName(rm.getCount()-1)
#rm.select(self.__dictImages[nameimage], rm.getCount()-1)
rm.select(tempimp, rm.getCount()-1)
rm.runCommand("Rename", name)
except TypeError : continue
#if isinstance(self.__dict[nameimage][cellname].getRoi(numslice),Roi) == True :
# s = "%04i" % (numslice)
# #rm.add(self.__dictImages[nameimage], self.__dict[nameimage][cellname].getRoi(numslice) , numslice)
# name=self.__dict[nameimage][cellname].getRoi(numslice).getName()
# name=s+name
# self.__dict[nameimage][cellname].getRoi(numslice).setName(name)
# rm.addRoi(self.__dict[nameimage][cellname].getRoi(numslice))
rm.runCommand("Save", self.__pathdir+"ROIs/"+cellname+".zip")
rm.runCommand("reset")
tempimp.close()