本文整理汇总了Python中ij.measure.ResultsTable.size方法的典型用法代码示例。如果您正苦于以下问题:Python ResultsTable.size方法的具体用法?Python ResultsTable.size怎么用?Python ResultsTable.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.measure.ResultsTable
的用法示例。
在下文中一共展示了ResultsTable.size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import size [as 别名]
def process(self,imp):
# extract nucleus channel, 8-bit and twice binned
imp.setC(self.nucleusChannel)
ip = imp.getChannelProcessor().duplicate()
ip = ip.convertToByteProcessor()
ip = ip.bin(4)
nucleus = ImagePlus("nucleus_channel", ip)
# threshold image and separate clumped nuclei
IJ.run(nucleus, "Auto Threshold", "method=Otsu white setthreshold show");
IJ.run(nucleus, "Make Binary", "thresholded remaining black");
IJ.run(nucleus, "Watershed", "");
directory = imp.getTitle()
directory = directory.replace(" ", "_")\
.replace(",", "_")\
.replace("#", "_series")\
.replace("...", "")\
.replace(".","_")
directory = os.path.join(self.exportDir, directory)
sliceDirectory = os.path.join(directory, "slices")
print directory
print sliceDirectory
if not os.path.exists(sliceDirectory):
os.makedirs(sliceDirectory)
# Create a table to store the results
table = ResultsTable()
# Create a hidden ROI manager, to store a ROI for each blob or cell
#roim = RoiManager(True)
# remove small particles and border particles
pa = ParticleAnalyzer(\
ParticleAnalyzer.ADD_TO_MANAGER | ParticleAnalyzer.EXCLUDE_EDGE_PARTICLES,\
Measurements.CENTER_OF_MASS,\
table,\
self.minArea, self.maxArea,\
0.0,1.0)
if pa.analyze(nucleus):
print "All ok, number of particles: ", table.size()
else:
print "There was a problem in analyzing", imp, nucleus
table.save(os.path.join(directory, "rt.csv"))
# read the center of mass coordinates
cmx = table.getColumn(0)
cmy = table.getColumn(1)
if self.debug:
imp.show()
i=0
for i in range(0, min(self.nCells,table.size())):
# ROI around the cell
cmx = table.getValue("XM",i)
cmy = table.getValue("YM",i)
x = 4 * cmx - (self.boxSize - 1) / 2
y = 4 * cmy - (self.boxSize - 1) / 2
if (x < self.edge or y < self.edge or x > imp.getWidth() - self.edge or y > imp.getHeight() - self.edge):
continue
roi = Roi(x,y,self.boxSize,self.boxSize)
imp.setRoi(roi, False)
cellStack = ImageStack(self.boxSize, self.boxSize)
for z in range(1, imp.getNSlices() + 1):
imp.setSlice(z)
for c in range(1, imp.getNChannels() + 1):
imp.setC(c)
# copy ROI to stack
imp.copy()
impSlice = imp.getClipboard()
cellStack.addSlice(impSlice.getProcessor())
if self.slices:
sliceTitle = "cell_%s_z%s_c%s" % (str(i).zfill(4), str(z).zfill(3), str(c))
print sliceTitle
IJ.saveAsTiff(impSlice, os.path.join(sliceDirectory, sliceTitle))
impSlice.close()
title = "cell_" + str(i).zfill(4)
cell = ImagePlus(title, cellStack)
# save ROI image
IJ.saveAsTiff(cell, os.path.join(directory, title))
cell.close()
if self.debug:
imp.updateAndDraw()
wait = Wait("particle done")
wait.show()
示例2: ResultsTable
# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import size [as 别名]
### Compute area fraction of oriented regions ###
# Compute area of oriented mask
newMaskImp = ImageJFunctions.wrapUnsignedByte(newMask, "New mask");
newMaskImp.getProcessor().setThreshold(1.0, 1.5, False); # [0.5, 1.0] does not work due to rounding problems
rt = ResultsTable();
analyzer = Analyzer(newMaskImp, Measurements.AREA | Measurements.LIMIT, rt);
analyzer.measure();
# Compute area of overall selection mask
energyMaskImp = ImageJFunctions.wrapUnsignedByte(overallSelectionMask, "Energy mask");
energyMaskImp.getProcessor().setThreshold(1.0, 1.5, False); # [0.5, 1.0] does not work due to rounding problems
rtEnergy = ResultsTable();
analyzerEnergy = Analyzer(energyMaskImp, Measurements.AREA | Measurements.LIMIT, rtEnergy);
analyzerEnergy.measure();
# Print Area% (through SciJava OUTPUT, see L5)
if IJ.debugMode:
print("Coherency area: "+str(rt.getValueAsDouble(rt.getColumnIndex("Area"), rt.size()-1)));
print("Energy area: "+str(rtEnergy.getValueAsDouble(rtEnergy.getColumnIndex("Area"), rtEnergy.size()-1)));
areaCoherency = rt.getValueAsDouble(rt.getColumnIndex("Area"), rt.size()-1);
areaEnergy = rtEnergy.getValueAsDouble(rtEnergy.getColumnIndex("Area"), rtEnergy.size()-1);
areaFraction = str(areaCoherency/areaEnergy*100.0)+"%";
# Close "S-Mask"
if not IJ.debugMode:
maskImp.close();
# Close "Energy"
if not IJ.debugMode and useEnergy:
energyImp.close();